|
@@ -3,6 +3,7 @@ package de.tudarmstadt.informatik.hostage.protocol;
|
|
|
import java.io.BufferedInputStream;
|
|
|
import java.io.BufferedOutputStream;
|
|
|
import java.io.IOException;
|
|
|
+import java.net.InetAddress;
|
|
|
import java.net.Socket;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
@@ -26,10 +27,23 @@ public class GHOST implements Protocol {
|
|
|
private BufferedInputStream mirrorInputStream;
|
|
|
|
|
|
private BufferedOutputStream mirrorOutputStream;
|
|
|
+
|
|
|
+ private int currentPort;
|
|
|
+
|
|
|
+ private InetAddress attackerIP;
|
|
|
+
|
|
|
+
|
|
|
+ public void setCurrentPort(int currentPort) {
|
|
|
+ this.currentPort = currentPort;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setAttackerIP(InetAddress attackerIP) {
|
|
|
+ this.attackerIP = attackerIP;
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public int getPort() {
|
|
|
- return 5050; // TODO dynamic port / whats the default!? (1433)
|
|
|
+ return 5050; // TODO whats the default!? (1433)
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -47,7 +61,7 @@ public class GHOST implements Protocol {
|
|
|
List<Packet> responsePackets = new ArrayList<Packet>();
|
|
|
try {
|
|
|
if (mirroredConnection == null) {
|
|
|
- mirroredConnection = new Socket("192.168.178.86", 5050); // FIXME
|
|
|
+ mirroredConnection = new Socket(attackerIP, currentPort);
|
|
|
mirrorInputStream = new BufferedInputStream(
|
|
|
mirroredConnection.getInputStream());
|
|
|
mirrorOutputStream = new BufferedOutputStream(
|
|
@@ -66,24 +80,21 @@ public class GHOST implements Protocol {
|
|
|
|
|
|
int availableBytes;
|
|
|
while ((availableBytes = mirrorInputStream.available()) <= 0) {
|
|
|
- try {
|
|
|
- Thread.sleep(1);
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+ Thread.yield();
|
|
|
}
|
|
|
byte[] mirrorResponse = new byte[availableBytes];
|
|
|
mirrorInputStream.read(mirrorResponse);
|
|
|
responsePackets.add(new Packet(mirrorResponse));
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
+ responsePackets.add(requestPacket);
|
|
|
}
|
|
|
return responsePackets;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public String toString() {
|
|
|
- return "GhostProtocol";
|
|
|
+ return "GHOST";
|
|
|
}
|
|
|
|
|
|
@Override
|