Browse Source

-Added Ghost Protocol: working, but right now for static ip and port,
TBD
-Renamed Protocol.getPort to Protocol.getDefaultPort
-Updated sshlib with src code

Wulf Pfeiffer 10 years ago
parent
commit
5323ed49ef

+ 1 - 1
.classpath

@@ -5,6 +5,6 @@
 	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
 	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
 	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
-	<classpathentry kind="lib" path="libs/sshlib-v1.jar"/>
+	<classpathentry kind="lib" path="libs/sshlib-v1.1.jar"/>
 	<classpathentry kind="output" path="bin/classes"/>
 </classpath>

BIN
libs/sshlib-v1.1.jar


BIN
libs/sshlib-v1.jar


+ 1 - 0
res/values/protocols.xml

@@ -4,6 +4,7 @@
     <string-array name="protocols">
 		<item>ECHO</item>
         <item>FTP</item>
+        <item>GhostProtocol</item>
         <item>HTTP</item>
         <item>HTTPS</item>
         <item>MySQL</item>

+ 1 - 1
src/de/tudarmstadt/informatik/hostage/HoneyHandler.java

@@ -205,7 +205,7 @@ public class HoneyHandler implements Runnable {
 		record.setExternalIP(externalIP);
 		record.setLocalIP(client.getLocalAddress().getHostAddress());
 		record.setLocalHost(client.getLocalAddress().getHostName());
-		record.setLocalPort(protocol.getPort());
+		record.setLocalPort(protocol.getDefaultPort());
 		record.setRemoteIP(client.getInetAddress().getHostAddress());
 		record.setRemoteHost(client.getInetAddress().getHostName());
 		record.setRemotePort(client.getPort());

+ 1 - 1
src/de/tudarmstadt/informatik/hostage/HoneyListener.java

@@ -67,7 +67,7 @@ public class HoneyListener implements Runnable {
 	public HoneyListener(HoneyService service, Protocol protocol) {
 		this.service = service;
 		this.protocol = protocol;
-		port = protocol.getPort();
+		port = protocol.getDefaultPort();
 		conReg = new ConnectionRegister(service);
 	}
 	

+ 1 - 1
src/de/tudarmstadt/informatik/hostage/HoneyService.java

@@ -227,7 +227,7 @@ public class HoneyService extends Service {
 	private int getDefaultPort(String protocolName){
 		for (Protocol protocol : implementedProtocols) {
 			if(protocolName.equals(protocol.toString())){
-				return protocol.getPort();
+				return protocol.getDefaultPort();
 			}
 		}
 		return -1;

+ 1 - 1
src/de/tudarmstadt/informatik/hostage/protocol/ECHO.java

@@ -12,7 +12,7 @@ import de.tudarmstadt.informatik.hostage.wrapper.Packet;
 public class ECHO implements Protocol{
 
 	@Override
-	public int getPort() {
+	public int getDefaultPort() {
 		return 7;
 	}
 

+ 1 - 1
src/de/tudarmstadt/informatik/hostage/protocol/FTP.java

@@ -24,7 +24,7 @@ public class FTP implements Protocol {
 	private STATE state = STATE.NONE;
 	
 	@Override
-	public int getPort() {
+	public int getDefaultPort() {
 		return 21;
 	}
 

+ 85 - 0
src/de/tudarmstadt/informatik/hostage/protocol/GhostProtocol.java

@@ -0,0 +1,85 @@
+package de.tudarmstadt.informatik.hostage.protocol;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.net.Socket;
+import java.util.ArrayList;
+import java.util.List;
+
+import de.tudarmstadt.informatik.hostage.wrapper.Packet;
+
+public class GhostProtocol implements Protocol {
+	
+	private boolean isClosed = false;
+
+	@Override
+	public int getDefaultPort() {
+		return 5050;
+	}
+
+	@Override
+	public TALK_FIRST whoTalksFirst() {
+		return TALK_FIRST.CLIENT;
+	}
+
+	@Override
+	public List<Packet> processMessage(Packet packet) {		
+		List<Packet> response = new ArrayList<Packet>();
+		try {			
+			if(attacker == null) {
+				attacker = new Socket("127.0.0.1", 5050);
+				in = new BufferedInputStream(attacker.getInputStream());
+				out = new BufferedOutputStream(attacker.getOutputStream());
+			}
+			if(attacker.isInputShutdown() || attacker.isOutputShutdown()) {
+				in.close();
+				out.close();
+				attacker.close();
+				isClosed = true;
+			}
+			
+			out.write(packet.getMessage());
+			out.flush();
+			
+			int availableBytes;
+			while((availableBytes = in.available()) <= 0) {
+				try {
+					Thread.sleep(1);
+				} catch (InterruptedException e) {
+					e.printStackTrace();
+				}
+			}
+			byte[] answer =  new byte[availableBytes];
+			in.read(answer);
+			response.add(new Packet(answer));
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		return response;
+	}
+
+	@Override
+	public boolean isClosed() {
+		return isClosed;
+	}
+
+	@Override
+	public boolean isSecure() {
+		return false;
+	}
+
+	@Override
+	public Class<byte[]> getType() {
+		return byte[].class;
+	}
+	
+	@Override
+	public String toString() {
+		return "GhostProtocol";
+	}
+	
+	Socket attacker;
+	BufferedInputStream in;
+	BufferedOutputStream out;
+}

+ 1 - 1
src/de/tudarmstadt/informatik/hostage/protocol/HTTP.java

@@ -19,7 +19,7 @@ import de.tudarmstadt.informatik.hostage.wrapper.Packet;
 public class HTTP implements Protocol {
 	
 	@Override
-	public int getPort() {
+	public int getDefaultPort() {
 		return 80;
 	}
 

+ 1 - 1
src/de/tudarmstadt/informatik/hostage/protocol/HTTPS.java

@@ -14,7 +14,7 @@ import de.tudarmstadt.informatik.hostage.HoneyService;
 public class HTTPS extends HTTP implements SSLProtocol {
 
 	@Override
-	public int getPort() {
+	public int getDefaultPort() {
 		return 443;
 	}
 	

+ 1 - 1
src/de/tudarmstadt/informatik/hostage/protocol/MySQL.java

@@ -73,7 +73,7 @@ public class MySQL implements Protocol {
 	}
 	
 	@Override
-	public int getPort() {
+	public int getDefaultPort() {
 		return 3306;
 	}
 	

+ 3 - 3
src/de/tudarmstadt/informatik/hostage/protocol/Protocol.java

@@ -19,10 +19,10 @@ public interface Protocol {
 	};
 
 	/**
-	 * Returns the port on which the protocol is running.
-	 * @return the port used by the protocol (range: 0-65535)
+	 * Returns the default port on which the protocol is running.
+	 * @return the default port used by the protocol (range: 0-65535)
 	 */
-	int getPort();
+	int getDefaultPort();
 
 	/**
 	 * Returns who starts the communication (server or client)

+ 1 - 1
src/de/tudarmstadt/informatik/hostage/protocol/SIP.java

@@ -7,7 +7,7 @@ import de.tudarmstadt.informatik.hostage.wrapper.Packet;
 public class SIP implements Protocol {
 
 	@Override
-	public int getPort() {
+	public int getDefaultPort() {
 		return 5060;
 	}
 

+ 1 - 1
src/de/tudarmstadt/informatik/hostage/protocol/SMB.java

@@ -33,7 +33,7 @@ public class SMB implements Protocol {
 	private byte[] lastMessage;
 	
 	@Override
-	public int getPort() {
+	public int getDefaultPort() {
 		return 445;
 	}
 

+ 1 - 1
src/de/tudarmstadt/informatik/hostage/protocol/SSH.java

@@ -50,7 +50,7 @@ public class SSH implements Protocol {
 	private boolean useEncryption = false;
 		
 	@Override
-	public int getPort() {
+	public int getDefaultPort() {
 		return 22;
 	}
 

+ 1 - 1
src/de/tudarmstadt/informatik/hostage/protocol/TELNET.java

@@ -24,7 +24,7 @@ public class TELNET implements Protocol {
 	private STATE state = STATE.NONE;
 	
 	@Override
-	public int getPort() {
+	public int getDefaultPort() {
 		return 23;
 	}