Browse Source

deleted unused files

mip-it 10 years ago
parent
commit
b0759f2252

BIN
bin/classes/de/tudarmstadt/informatik/hostage/HoneyHandler.class


BIN
bin/classes/de/tudarmstadt/informatik/hostage/protocol/ECHO.class


BIN
bin/classes/de/tudarmstadt/informatik/hostage/protocol/HTTP$STATE.class


BIN
bin/classes/de/tudarmstadt/informatik/hostage/protocol/HTTPS$STATE.class


BIN
bin/classes/de/tudarmstadt/informatik/hostage/protocol/HTTPS.class


BIN
native/p


+ 0 - 139
native/porthack.c

@@ -1,139 +0,0 @@
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <sys/time.h>
-#include <sys/uio.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-
-#include <android/log.h>
-
-#define  LOG_TAG "hostage: p"
-#define  LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
-#define  LOGW(...) __android_log_print(ANDROID_LOG_WARN,LOG_TAG,__VA_ARGS__)
-#define  LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
-
-#define CONTROLLEN CMSG_LEN(sizeof(int))
-
-char *socket_path = "\0hostage";
-
-int ipc_sock() {
-	int fd;
-	struct sockaddr_un addr;
-
-	if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
-		LOGE("Unable to create local socket: %d", errno);
-		return -1;
-	}
-
-	memset(&addr, 0, sizeof(addr));
-	addr.sun_family = AF_UNIX;
-	strncpy(addr.sun_path, socket_path, sizeof(addr.sun_path) - 1);
-
-	if (connect(fd, (struct sockaddr*) &addr, sizeof(addr)) == -1) {
-		LOGE("Unable to connect local socket: %d", errno);
-		return -1;
-	}
-
-	return fd;
-}
-
-int net_sock(int port) {
-	int fd;
-	struct sockaddr_in addr;
-
-	if ((fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
-		LOGE("Unable to create net socket: %d", errno);
-		return -1;
-	}
-
-	memset(&addr, 0, sizeof(addr));
-	addr.sin_family = AF_INET;
-	addr.sin_addr.s_addr = INADDR_ANY;
-	addr.sin_port = htons(port);
-
-	if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) == -1) {
-		LOGE("Unable to bind net socket: %d", errno);
-		return -1;
-	}
-
-	if (listen(fd, 5) == -1) {
-		LOGE("Unable to listen net socket: %d", errno);
-		return -1;
-	}
-
-	return fd;
-}
-
-int send_fd(int fd, int fd_to_send) {
-	struct iovec iov[1];
-	struct cmsghdr *cmptr;
-	struct msghdr msg;
-	char buf[2] = "FD";
-
-	iov[0].iov_base = buf;
-	iov[0].iov_len = 2;
-
-	cmptr = malloc(CONTROLLEN);
-	cmptr->cmsg_level = SOL_SOCKET;
-	cmptr->cmsg_type = SCM_RIGHTS;
-	cmptr->cmsg_len = CONTROLLEN;
-
-	msg.msg_iov = iov;
-	msg.msg_iovlen = 1;
-	msg.msg_name = NULL;
-	msg.msg_namelen = 0;
-	msg.msg_control = cmptr;
-	msg.msg_controllen = CONTROLLEN;
-	*(int *) CMSG_DATA(cmptr) = fd_to_send;
-
-	if (sendmsg(fd, &msg, 0) == -1) {
-		LOGE("sendmsg failed: %d", errno);
-	}
-
-	return 0;
-}
-
-int main(int argc, char *argv[]) {
-	int port;
-	int ipc_fd, net_fd;
-
-	if (argc < 2) {
-		exit(EXIT_FAILURE);
-	}
-
-	if ((port = atoi(argv[1])) < 1 || (port = atoi(argv[1])) > 65535) {
-		exit(EXIT_FAILURE);
-	}
-
-	if ((ipc_fd = ipc_sock()) == -1) {
-		close(ipc_fd);
-		exit(EXIT_FAILURE);
-	}
-	LOGI("ipc_fd: %d", ipc_fd);
-
-	if ((net_fd = net_sock(port)) == -1) {
-		close(ipc_fd);
-		close(net_fd);
-		exit(EXIT_FAILURE);
-	}
-	LOGI("net_fd: %d", net_fd);
-
-	int status;
-	status = send_fd(ipc_fd, net_fd);
-	LOGI("send_fd: %d", status);
-
-	close(ipc_fd);
-	close(net_fd);
-
-	if (status == -1) {
-		return (EXIT_FAILURE);
-	}
-
-	return EXIT_SUCCESS;
-}

BIN
native/porthack.o


+ 0 - 113
src/de/tudarmstadt/informatik/hostage/HoneyHandler.java

@@ -1,113 +0,0 @@
-package de.tudarmstadt.informatik.hostage;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.net.Socket;
-
-import de.tudarmstadt.informatik.hostage.logging.Logger;
-import de.tudarmstadt.informatik.hostage.logging.Record;
-import de.tudarmstadt.informatik.hostage.logging.Record.TYPE;
-import de.tudarmstadt.informatik.hostage.protocol.Protocol;
-import de.tudarmstadt.informatik.hostage.protocol.Protocol.TALK_FIRST;
-
-public class HoneyHandler implements Runnable {
-
-	private static final int TIMEOUT = 30 * 1000;
-
-	private Protocol protocol;
-	private Socket client;
-	private Thread thread;
-
-	private HoneyListener listener;
-	private Logger log;
-
-	public HoneyHandler(HoneyService service, HoneyListener listener,
-			Protocol protocol, Socket client) {
-		this.listener = listener;
-		this.log = service.getLog();
-		this.protocol = protocol;
-		this.client = client;
-		this.thread = new Thread(this);
-		setSoTimeout(client);
-		thread.start();
-	}
-
-	private void setSoTimeout(Socket client) {
-		try {
-			client.setSoTimeout(TIMEOUT);
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-	}
-
-	@Override
-	public void run() {
-		BufferedReader in;
-		BufferedWriter out;
-		try {
-			in = new BufferedReader(new InputStreamReader(
-					client.getInputStream()));
-			out = new BufferedWriter(new OutputStreamWriter(
-					client.getOutputStream()));
-			talkToClient(in, out);
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		kill();
-	}
-
-	public void kill() {
-		thread.interrupt();
-		try {
-			client.close();
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		listener.refreshHandlers();
-	}
-
-	public boolean isTerminated() {
-		return thread.isInterrupted();
-	}
-
-	private void talkToClient(BufferedReader in, BufferedWriter out)
-			throws IOException {
-		String inputLine;
-		String outputLine;
-
-		if (protocol.whoTalksFirst() == TALK_FIRST.SERVER) {
-			outputLine = "";// protocol.processMessage(null);
-			out.write(outputLine + "\n");
-			out.flush();
-			log.write(createRecord(TYPE.SEND, outputLine));
-		}
-
-		while (!thread.isInterrupted() && (inputLine = in.readLine()) != null) {
-			log.write(createRecord(TYPE.RECEIVE, inputLine));
-			outputLine = "";// protocol.processMessage(inputLine);
-			if (outputLine != null) {
-				out.write(outputLine + "\n");
-				out.flush();
-				log.write(createRecord(TYPE.SEND, outputLine));
-			}
-			if (protocol.isClosed())
-				break;
-		}
-	}
-
-	private Record createRecord(TYPE type, String packet) {
-		Record record = new Record();
-		record.setType(type);
-		record.setTimestamp(System.currentTimeMillis());
-		record.setLocalIP(client.getLocalAddress());
-		record.setLocalPort(protocol.getPort());
-		record.setRemoteIP(client.getInetAddress());
-		record.setRemotePort(client.getPort());
-		record.setPacket(packet);
-		return record;
-	}
-
-}

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

@@ -1,35 +0,0 @@
-package de.tudarmstadt.informatik.hostage.protocol;
-
-public final class ECHO implements Protocol {
-
-	@Override
-	public int getPort() {
-		return 8007;
-	}
-
-	@Override
-	public TALK_FIRST whoTalksFirst() {
-		return TALK_FIRST.CLIENT;
-	}
-
-	@Override
-	public String processMessage(String message) {
-		return message;
-	}
-
-	@Override
-	public boolean isClosed() {
-		return false;
-	}
-
-	@Override
-	public boolean isSecure() {
-		return false;
-	}
-
-	@Override
-	public String toString() {
-		return "ECHO";
-	}
-
-}

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

@@ -1,56 +0,0 @@
-package de.tudarmstadt.informatik.hostage.protocol;
-
-import java.util.regex.Pattern;
-
-public final class HTTPS implements Protocol {
-
-	private static enum STATE {
-		NONE, OPEN, CLOSED
-	};
-
-	private STATE state = STATE.NONE;
-
-	@Override
-	public int getPort() {
-		return 8443;
-	}
-
-	@Override
-	public TALK_FIRST whoTalksFirst() {
-		return TALK_FIRST.SERVER;
-	}
-
-	@Override
-	public String processMessage(String message) {
-		switch (state) {
-		case NONE:
-			state = STATE.OPEN;
-			return "Connection established.";
-		case OPEN:
-			if (Pattern.matches("^QUIT\\s?", message)) {
-				state = STATE.CLOSED;
-				return null;
-			} else {
-				return message;
-			}
-		default:
-			return "Connection closed.";
-		}
-	}
-
-	@Override
-	public boolean isClosed() {
-		return (state == STATE.CLOSED);
-	}
-
-	@Override
-	public boolean isSecure() {
-		return true;
-	}
-
-	@Override
-	public String toString() {
-		return "HTTPS";
-	}
-
-}

+ 0 - 7
src/de/tudarmstadt/informatik/hostage/protocol/transport/Protocol.java

@@ -1,7 +0,0 @@
-package de.tudarmstadt.informatik.hostage.protocol.transport;
-
-public interface Protocol<T> {
-
-	T processMessage(T message);
-
-}

+ 0 - 15
src/de/tudarmstadt/informatik/hostage/protocol/transport/ProtocolImpl.java

@@ -1,15 +0,0 @@
-package de.tudarmstadt.informatik.hostage.protocol.transport;
-
-public class ProtocolImpl implements Protocol<String> {
-
-	public ProtocolImpl() {
-		// TODO Auto-generated constructor stub
-	}
-
-	@Override
-	public String processMessage(String message) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-}

+ 0 - 50
src/de/tudarmstadt/informatik/hostage/system/NativeBridge.java

@@ -1,50 +0,0 @@
-package de.tudarmstadt.informatik.hostage.system;
-
-import java.io.FileDescriptor;
-import java.io.IOException;
-
-import android.net.LocalSocket;
-import android.net.LocalSocketAddress;
-
-public class NativeBridge implements Runnable {
-
-	private final static NativeBridge INSTANCE = new NativeBridge();
-
-	public NativeBridge getInstance() {
-		return INSTANCE;
-	}
-
-	private final static LocalSocket SOCK = new LocalSocket();
-
-	private NativeBridge() {
-		try {
-			SOCK.bind(new LocalSocketAddress("hostage"));
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-	}
-
-	@Override
-	public void run() {
-		try {
-			Process p = Runtime.getRuntime().exec(
-					new String[] { "/data/local/p", "21" });
-			p.waitFor();
-		} catch (IOException e) {
-			e.printStackTrace();
-		} catch (InterruptedException e) {
-			e.printStackTrace();
-		}
-	}
-
-	public static FileDescriptor getFD(int port) {
-		new Thread(INSTANCE).start();
-		try {
-			FileDescriptor[] fds = SOCK.getAncillaryFileDescriptors();
-			return fds[0];
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-		return null;
-	}
-}