Browse Source

changed names

Mihai Plasoianu 10 years ago
parent
commit
0539b87a31

+ 7 - 7
src/de/tudarmstadt/informatik/hostage/HoneyHandler.java → src/de/tudarmstadt/informatik/hostage/Handler.java

@@ -28,12 +28,12 @@ import de.tudarmstadt.informatik.hostage.wrapper.Packet;
  * @author Mihai Plasoianu
  * @author Wulf Pfeiffer
  */
-public class HoneyHandler implements Runnable {
+public class Handler implements Runnable {
 
 	/** Time until the socket throws a time out. The time is in milliseconds. */
 	private int TIMEOUT;
 
-	private HoneyService service;
+	private Hostage service;
 	protected Protocol protocol;
 	private Socket client;
 	protected Thread thread;
@@ -44,7 +44,7 @@ public class HoneyHandler implements Runnable {
 	private String BSSID;
 	private String SSID;
 
-	private HoneyListener listener;
+	private Listener listener;
 
 	/**
 	 * Constructor of the class. Initializes class variables for communication
@@ -59,7 +59,7 @@ public class HoneyHandler implements Runnable {
 	 * @param client
 	 *            A Socket for the communication with a remote client.
 	 */
-	public HoneyHandler(HoneyService service, HoneyListener listener, Protocol protocol, Socket client) {
+	public Handler(Hostage service, Listener listener, Protocol protocol, Socket client) {
 		this.service = service;
 		this.listener = listener;
 		this.protocol = protocol;
@@ -216,16 +216,16 @@ public class HoneyHandler implements Runnable {
 			outputLine = protocol.processMessage(null);
 			writer.write(outputLine);
 			for (Packet o : outputLine) {
-				Logger.log(HoneyService.getContext(), createRecord(TYPE.SEND, o.toString()));
+				Logger.log(Hostage.getContext(), createRecord(TYPE.SEND, o.toString()));
 			}
 		}
 		while (!thread.isInterrupted() && (inputLine = reader.read()) != null) {
 			outputLine = protocol.processMessage(inputLine);
-			Logger.log(HoneyService.getContext(), createRecord(TYPE.RECEIVE, inputLine.toString()));
+			Logger.log(Hostage.getContext(), createRecord(TYPE.RECEIVE, inputLine.toString()));
 			if (outputLine != null) {
 				writer.write(outputLine);
 				for (Packet o : outputLine) {
-					Logger.log(HoneyService.getContext(), createRecord(TYPE.SEND, o.toString()));
+					Logger.log(Hostage.getContext(), createRecord(TYPE.SEND, o.toString()));
 				}
 			}
 			if (protocol.isClosed()) {

+ 19 - 19
src/de/tudarmstadt/informatik/hostage/HoneyService.java → src/de/tudarmstadt/informatik/hostage/Hostage.java

@@ -48,11 +48,11 @@ import de.tudarmstadt.informatik.hostage.ui.MainActivity;
  * @author Lars Pandikow
  * @author Wulf Pfeiffer
  */
-public class HoneyService extends Service {
+public class Hostage extends Service {
 
 	public class LocalBinder extends Binder {
-		public HoneyService getService() {
-			return HoneyService.this;
+		public Hostage getService() {
+			return Hostage.this;
 		}
 	}
 
@@ -99,11 +99,11 @@ public class HoneyService extends Service {
 	 * @return context.
 	 */
 	public static Context getContext() {
-		return HoneyService.context;
+		return Hostage.context;
 	}
 
 	private LinkedList<Protocol> implementedProtocols;
-	private ArrayList<HoneyListener> listeners = new ArrayList<HoneyListener>();
+	private ArrayList<Listener> listeners = new ArrayList<Listener>();
 
 	private NotificationCompat.Builder builder;
 
@@ -132,7 +132,7 @@ public class HoneyService extends Service {
 		}
 	};
 
-	public List<HoneyListener> getListeners() {
+	public List<Listener> getListeners() {
 		return listeners;
 	}
 
@@ -160,7 +160,7 @@ public class HoneyService extends Service {
 	 * @return Number of active connections
 	 */
 	public int getNumberOfActiveConnections(String protocolName, int port) {
-		for (HoneyListener listener : listeners) {
+		for (Listener listener : listeners) {
 			if (listener.getProtocolName().equals(protocolName) && listener.getPort() == port) {
 				return listener.getHandlerCount();
 			}
@@ -174,7 +174,7 @@ public class HoneyService extends Service {
 	 * @return True if there is a running listener, else false.
 	 */
 	public boolean hasRunningListeners() {
-		for (HoneyListener listener : listeners) {
+		for (Listener listener : listeners) {
 			if (listener.isRunning())
 				return true;
 		}
@@ -205,7 +205,7 @@ public class HoneyService extends Service {
 	 * @return True if protocol is running, else false.
 	 */
 	public boolean isRunning(String protocolName, int port) {
-		for (HoneyListener listener : listeners) {
+		for (Listener listener : listeners) {
 			if (listener.getProtocolName().equals(protocolName) && listener.getPort() == port) {
 				return listener.isRunning();
 			}
@@ -224,7 +224,7 @@ public class HoneyService extends Service {
 	public void notifyUI(String sender, String[] values) {
 		createNotification();
 		// Send Notification
-		if (sender.equals(HoneyHandler.class.getName()) && values[0].equals(R.string.broadcast_started)) {
+		if (sender.equals(Handler.class.getName()) && values[0].equals(R.string.broadcast_started)) {
 			attackNotification();
 		}
 		// Inform UI of Preference Change
@@ -243,7 +243,7 @@ public class HoneyService extends Service {
 	@Override
 	public void onCreate() {
 		super.onCreate();
-		HoneyService.context = getApplicationContext();
+		Hostage.context = getApplicationContext();
 		implementedProtocols = getImplementedProtocols();
 		connectionInfo = getSharedPreferences(getString(R.string.connection_info), Context.MODE_PRIVATE);
 		connectionInfoEditor = connectionInfo.edit();
@@ -288,7 +288,7 @@ public class HoneyService extends Service {
 	 *            The port number in which the listener should run.
 	 */
 	public boolean startListener(String protocolName, int port) {
-		for (HoneyListener listener : listeners) {
+		for (Listener listener : listeners) {
 			if (listener.getProtocolName().equals(protocolName) && listener.getPort() == port) {
 				if (!listener.isRunning()) {
 					if (listener.start()) {
@@ -301,7 +301,7 @@ public class HoneyService extends Service {
 
 			}
 		}
-		HoneyListener listener = createListener(protocolName, port);
+		Listener listener = createListener(protocolName, port);
 		if (listener != null) {
 			if (listener.start()) {
 				Toast.makeText(getApplicationContext(), protocolName + " SERVICE STARTED!", Toast.LENGTH_SHORT).show();
@@ -316,7 +316,7 @@ public class HoneyService extends Service {
 	 * Starts all listeners which are not already running.
 	 */
 	public void startListeners() {
-		for (HoneyListener listener : listeners) {
+		for (Listener listener : listeners) {
 			if (!listener.isRunning()) {
 				listener.start();
 			}
@@ -343,7 +343,7 @@ public class HoneyService extends Service {
 	 *            The port number in which the listener is running.
 	 */
 	public void stopListener(String protocolName, int port) {
-		for (HoneyListener listener : listeners) {
+		for (Listener listener : listeners) {
 			if (listener.getProtocolName().equals(protocolName) && listener.getPort() == port) {
 				if (listener.isRunning()) {
 					listener.stop();
@@ -357,7 +357,7 @@ public class HoneyService extends Service {
 	 * Stops all running listeners.
 	 */
 	public void stopListeners() {
-		for (HoneyListener listener : listeners) {
+		for (Listener listener : listeners) {
 			if (listener.isRunning()) {
 				listener.stop();
 			}
@@ -407,10 +407,10 @@ public class HoneyService extends Service {
 	 * @return Returns the created HoneyListener, if creation failed returns
 	 *         null.
 	 */
-	private HoneyListener createListener(String protocolName, int port) {
+	private Listener createListener(String protocolName, int port) {
 		for (Protocol protocol : implementedProtocols) {
 			if (protocolName.equals(protocol.toString())) {
-				HoneyListener listener = new HoneyListener(this, protocol, port);
+				Listener listener = new Listener(this, protocol, port);
 				listeners.add(listener);
 				return listener;
 			}
@@ -427,7 +427,7 @@ public class HoneyService extends Service {
 		boolean bssidSeen = false;
 		boolean listening = false;
 
-		for (HoneyListener listener : listeners) {
+		for (Listener listener : listeners) {
 			if (listener.isRunning())
 				listening = true;
 			if (listener.getHandlerCount() > 0) {

+ 16 - 16
src/de/tudarmstadt/informatik/hostage/HoneyListener.java → src/de/tudarmstadt/informatik/hostage/Listener.java

@@ -17,21 +17,21 @@ import de.tudarmstadt.informatik.hostage.protocol.SSLProtocol;
  * Protocol listener class:<br>
  * Creates a Socket on the port of a given protocol and listens for incoming
  * connections.<br>
- * For each connection creates a Socket and instantiate an {@link HoneyHandler}.
+ * For each connection creates a Socket and instantiate an {@link Handler}.
  * 
  * @author Mihai Plasoianu
  * 
  */
-public class HoneyListener implements Runnable {
+public class Listener implements Runnable {
 
-	private ArrayList<HoneyHandler> handlers = new ArrayList<HoneyHandler>();
+	private ArrayList<Handler> handlers = new ArrayList<Handler>();
 
 	private Protocol protocol;
 
 	private ServerSocket server;
 	private Thread thread;
 	private int port;
-	private HoneyService service;
+	private Hostage service;
 
 	private ConnectionRegister conReg;
 	private boolean running = false;
@@ -44,14 +44,14 @@ public class HoneyListener implements Runnable {
 	 * @param protocol
 	 *            The Protocol on which the listener is running.
 	 */
-	public HoneyListener(HoneyService service, Protocol protocol) {
+	public Listener(Hostage service, Protocol protocol) {
 		this.service = service;
 		this.protocol = protocol;
 		port = protocol.getPort();
 		conReg = new ConnectionRegister(service);
 	}
 
-	public HoneyListener(HoneyService service, Protocol protocol, int port) {
+	public Listener(Hostage service, Protocol protocol, int port) {
 		this.service = service;
 		this.protocol = protocol;
 		this.port = port;
@@ -98,8 +98,8 @@ public class HoneyListener implements Runnable {
 	 * Remove all terminated handlers from its internal ArrayList.
 	 */
 	public void refreshHandlers() {
-		for (Iterator<HoneyHandler> iterator = handlers.iterator(); iterator.hasNext();) {
-			HoneyHandler handler = iterator.next();
+		for (Iterator<Handler> iterator = handlers.iterator(); iterator.hasNext();) {
+			Handler handler = iterator.next();
 			if (handler.isTerminated()) {
 				conReg.closeConnection();
 				iterator.remove();
@@ -112,7 +112,7 @@ public class HoneyListener implements Runnable {
 		while (!thread.isInterrupted()) {
 			addHandler();
 		}
-		for (HoneyHandler handler : handlers) {
+		for (Handler handler : handlers) {
 			handler.kill();
 		}
 	}
@@ -155,7 +155,7 @@ public class HoneyListener implements Runnable {
 
 	/**
 	 * Waits for an incoming connection, accepts it and starts a
-	 * {@link HoneyHandler}
+	 * {@link Handler}
 	 */
 	private void addHandler() {
 		if (conReg.isConnectionFree()) {
@@ -174,7 +174,7 @@ public class HoneyListener implements Runnable {
 	}
 
 	/**
-	 * Creates a new instance of an {@link HoneyHandler}.
+	 * Creates a new instance of an {@link Handler}.
 	 * 
 	 * @param service
 	 *            The background service
@@ -184,15 +184,15 @@ public class HoneyListener implements Runnable {
 	 *            The Protocol the handler will run on
 	 * @param client
 	 *            The Socket the handler uses
-	 * @return A Instance of a {@link HoneyHandler} with the specified
+	 * @return A Instance of a {@link Handler} with the specified
 	 *         parameter.
 	 */
-	private HoneyHandler newInstance(HoneyService service, HoneyListener listener, Protocol protocol, Socket client) {
-		return new HoneyHandler(service, listener, protocol, client);
+	private Handler newInstance(Hostage service, Listener listener, Protocol protocol, Socket client) {
+		return new Handler(service, listener, protocol, client);
 	}
 
 	/**
-	 * Starts a {@link HoneyHandler} with the given socket.
+	 * Starts a {@link Handler} with the given socket.
 	 * 
 	 * @param client
 	 *            The socket with the accepted connection.
@@ -204,7 +204,7 @@ public class HoneyListener implements Runnable {
 
 	/**
 	 * Creates a SSLSocket out of the given socket and starts a
-	 * {@link HoneyHandler}.
+	 * {@link Handler}.
 	 * 
 	 * @param client
 	 *            The socket with the accepted connection.

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

@@ -14,7 +14,7 @@ import java.util.TimeZone;
 import android.content.Context;
 import android.os.AsyncTask;
 
-import de.tudarmstadt.informatik.hostage.HoneyService;
+import de.tudarmstadt.informatik.hostage.Hostage;
 import de.tudarmstadt.informatik.hostage.R;
 import de.tudarmstadt.informatik.hostage.commons.HelperUtils;
 import de.tudarmstadt.informatik.hostage.wrapper.Packet;
@@ -30,10 +30,10 @@ public class HTTP implements Protocol {
 	
 	public HTTP() {
 		htmlDocumentContent = HelperUtils.getRandomString(32, false);
-		Context context = HoneyService.getContext();
+		Context context = Hostage.getContext();
 		String sharedPreferencePath = context.getString(R.string.shared_preference_path);
 		boolean useQotd = context.getSharedPreferences(sharedPreferencePath,
-				HoneyService.MODE_PRIVATE).getBoolean("useQotd", true);
+				Hostage.MODE_PRIVATE).getBoolean("useQotd", true);
 		if (useQotd) {
 			new QotdTask().execute(new String[] {});
 		}

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

@@ -5,7 +5,7 @@ import java.security.KeyStore;
 import javax.net.ssl.KeyManagerFactory;
 import javax.net.ssl.SSLContext;
 
-import de.tudarmstadt.informatik.hostage.HoneyService;
+import de.tudarmstadt.informatik.hostage.Hostage;
 
 /**
  * HTTPS protocol. Extends HTTP. Implementation of RFC document 2818. It can handle the
@@ -30,7 +30,7 @@ public class HTTPS extends HTTP implements SSLProtocol {
 		try {
 			keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
 			keyStore.load(
-					HoneyService.getContext().getAssets().open(keyStoreName),
+					Hostage.getContext().getAssets().open(keyStoreName),
 					keyStorePassword);
 			keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory
 					.getDefaultAlgorithm());

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

@@ -9,7 +9,7 @@ import java.util.List;
 import java.util.TimeZone;
 
 import android.content.Context;
-import de.tudarmstadt.informatik.hostage.HoneyService;
+import de.tudarmstadt.informatik.hostage.Hostage;
 import de.tudarmstadt.informatik.hostage.R;
 import de.tudarmstadt.informatik.hostage.commons.HelperUtils;
 import de.tudarmstadt.informatik.hostage.wrapper.Packet;
@@ -95,9 +95,9 @@ public class SMB implements Protocol {
 	}
 
 	private static String[] initServerVersion() {
-		String sharedPreferencePath = HoneyService.getContext().getString(
+		String sharedPreferencePath = Hostage.getContext().getString(
 				R.string.shared_preference_path);
-		String profile = HoneyService
+		String profile = Hostage
 				.getContext()
 				.getSharedPreferences(sharedPreferencePath,
 						Context.MODE_PRIVATE).getString("os", "");

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

@@ -5,7 +5,7 @@ import java.util.List;
 
 import android.content.Context;
 
-import de.tudarmstadt.informatik.hostage.HoneyService;
+import de.tudarmstadt.informatik.hostage.Hostage;
 import de.tudarmstadt.informatik.hostage.R;
 import de.tudarmstadt.informatik.hostage.commons.HelperUtils;
 import de.tudarmstadt.informatik.hostage.wrapper.Packet;
@@ -204,9 +204,9 @@ public class TELNET implements Protocol {
 	}
 	
 	private static String initServerVersion() {
-		String sharedPreferencePath = HoneyService.getContext().getString(
+		String sharedPreferencePath = Hostage.getContext().getString(
 				R.string.shared_preference_path);
-		String profile = HoneyService
+		String profile = Hostage
 				.getContext()
 				.getSharedPreferences(sharedPreferencePath,
 						Context.MODE_PRIVATE).getString("os", "");

+ 5 - 5
src/de/tudarmstadt/informatik/hostage/ui/MainActivity.java

@@ -33,8 +33,8 @@ import android.widget.ListView;
 import android.widget.TextView;
 import android.widget.ToggleButton;
 import android.widget.ViewAnimator;
-import de.tudarmstadt.informatik.hostage.HoneyService;
-import de.tudarmstadt.informatik.hostage.HoneyService.LocalBinder;
+import de.tudarmstadt.informatik.hostage.Hostage;
+import de.tudarmstadt.informatik.hostage.Hostage.LocalBinder;
 import de.tudarmstadt.informatik.hostage.R;
 import de.tudarmstadt.informatik.hostage.persistence.HostageDBOpenHelper;
 
@@ -72,7 +72,7 @@ public class MainActivity extends FragmentActivity {
 
 	private SharedPreferences connectionInfo;
 
-	private HoneyService mService;
+	private Hostage mService;
 	private boolean serviceBound;
 
 	// variables for the swipe animation
@@ -227,7 +227,7 @@ public class MainActivity extends FragmentActivity {
 	 * @return An Intent to start HoneyService
 	 */
 	private Intent getServiceIntent() {
-		return new Intent(this, HoneyService.class);
+		return new Intent(this, Hostage.class);
 	}
 
 	/**
@@ -307,7 +307,7 @@ public class MainActivity extends FragmentActivity {
 	private boolean isServiceRunning() {
 		ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
 		for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
-			if (service.service.getClassName().equals(HoneyService.class.getName())) {
+			if (service.service.getClassName().equals(Hostage.class.getName())) {
 				return true;
 			}
 		}