|
@@ -29,8 +29,10 @@ import android.widget.ListView;
|
|
import java.io.BufferedReader;
|
|
import java.io.BufferedReader;
|
|
import java.io.InputStreamReader;
|
|
import java.io.InputStreamReader;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Arrays;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
+import de.tudarmstadt.informatik.hostage.HoneyHandler;
|
|
import de.tudarmstadt.informatik.hostage.HoneyService;
|
|
import de.tudarmstadt.informatik.hostage.HoneyService;
|
|
import de.tudarmstadt.informatik.hostage.R;
|
|
import de.tudarmstadt.informatik.hostage.R;
|
|
import de.tudarmstadt.informatik.hostage.ui.LogFilter;
|
|
import de.tudarmstadt.informatik.hostage.ui.LogFilter;
|
|
@@ -96,8 +98,6 @@ public class MainActivity extends Activity {
|
|
public void onServiceConnected(ComponentName name, IBinder service) {
|
|
public void onServiceConnected(ComponentName name, IBinder service) {
|
|
mHoneyService = ((HoneyService.LocalBinder) service).getService();
|
|
mHoneyService = ((HoneyService.LocalBinder) service).getService();
|
|
mServiceBound = true;
|
|
mServiceBound = true;
|
|
-
|
|
|
|
- System.out.println(" ------------------- BOUND");
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -109,15 +109,13 @@ public class MainActivity extends Activity {
|
|
public void onServiceDisconnected(ComponentName name) {
|
|
public void onServiceDisconnected(ComponentName name) {
|
|
mHoneyService = null;
|
|
mHoneyService = null;
|
|
mServiceBound = false;
|
|
mServiceBound = false;
|
|
-
|
|
|
|
- System.out.println(" ------------------------ UNBOUND");
|
|
|
|
}
|
|
}
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
private boolean mInvalidMenuItem = false;
|
|
private boolean mInvalidMenuItem = false;
|
|
|
|
|
|
- private HashMap<String, Boolean> mAttacksOnProtocol;
|
|
|
|
|
|
+ private HashMap<String, Boolean> mAttacksOnProtocol = new HashMap<String, Boolean>();
|
|
|
|
|
|
/**
|
|
/**
|
|
* Retrieve the singleton latest instance of the activity
|
|
* Retrieve the singleton latest instance of the activity
|
|
@@ -143,14 +141,6 @@ public class MainActivity extends Activity {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- protected void onStop() {
|
|
|
|
- // Unregister Broadcast Receiver
|
|
|
|
- unregisterReceiver();
|
|
|
|
-
|
|
|
|
- super.onStop();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
super.onCreate(savedInstanceState);
|
|
@@ -240,10 +230,23 @@ public class MainActivity extends Activity {
|
|
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
|
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
|
@Override
|
|
@Override
|
|
public void onReceive(Context context, Intent intent) {
|
|
public void onReceive(Context context, Intent intent) {
|
|
|
|
+ Bundle extras = intent.getExtras();
|
|
|
|
|
|
|
|
+ String sender = extras.getString("SENDER");
|
|
|
|
+ String[] values = extras.getStringArray("VALUES");
|
|
|
|
+
|
|
|
|
+ if(sender.equals(HoneyHandler.class.getName()) && values[0].equals(getString(R.string.broadcast_started))) {
|
|
|
|
+ mAttacksOnProtocol.put(values[1], true);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ public boolean hasProtocolAttacks(String protocol){
|
|
|
|
+ if(!mAttacksOnProtocol.containsKey(protocol)) return false;
|
|
|
|
+
|
|
|
|
+ return mAttacksOnProtocol.get(protocol);
|
|
|
|
+ }
|
|
|
|
+
|
|
public void startAndBind() {
|
|
public void startAndBind() {
|
|
if(!isServiceRunning()){
|
|
if(!isServiceRunning()){
|
|
startService(getServiceIntent());
|
|
startService(getServiceIntent());
|
|
@@ -269,12 +272,16 @@ public class MainActivity extends Activity {
|
|
}
|
|
}
|
|
|
|
|
|
public void bindService() {
|
|
public void bindService() {
|
|
|
|
+ mAttacksOnProtocol.clear();
|
|
bindService(getServiceIntent(), mConnection, BIND_AUTO_CREATE);
|
|
bindService(getServiceIntent(), mConnection, BIND_AUTO_CREATE);
|
|
//mServiceBound = true;
|
|
//mServiceBound = true;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
protected void onDestroy() {
|
|
protected void onDestroy() {
|
|
|
|
+ // Unregister Broadcast Receiver
|
|
|
|
+ unregisterReceiver();
|
|
|
|
+
|
|
// Unbind running service
|
|
// Unbind running service
|
|
if(!mHoneyService.hasRunningListeners()){
|
|
if(!mHoneyService.hasRunningListeners()){
|
|
stopAndUnbind();
|
|
stopAndUnbind();
|