|
@@ -1,5 +1,9 @@
|
|
|
package de.tudarmstadt.informatik.hostage.ui;
|
|
|
|
|
|
+import java.io.BufferedReader;
|
|
|
+import java.io.DataInputStream;
|
|
|
+import java.io.File;
|
|
|
+import java.io.InputStreamReader;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
|
|
@@ -27,6 +31,7 @@ import android.os.AsyncTask;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.IBinder;
|
|
|
import android.support.v4.content.LocalBroadcastManager;
|
|
|
+import android.util.Log;
|
|
|
import android.view.GestureDetector;
|
|
|
import android.view.GestureDetector.SimpleOnGestureListener;
|
|
|
import android.view.Menu;
|
|
@@ -42,6 +47,7 @@ import android.widget.CheckBox;
|
|
|
import android.widget.ImageView;
|
|
|
import android.widget.ListView;
|
|
|
import android.widget.TextView;
|
|
|
+import android.widget.Toast;
|
|
|
import android.widget.ToggleButton;
|
|
|
import android.widget.ViewAnimator;
|
|
|
import de.tudarmstadt.informatik.hostage.HoneyService;
|
|
@@ -78,6 +84,15 @@ public class MainActivity extends Activity {
|
|
|
public static final String BSSID = "BSSID";
|
|
|
public static final String INTERNAL_IP = "INTERNAL_IP";
|
|
|
public static final String EXTERNAL_IP = "EXTERNAL_IP";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Flag for root acces. True if phone has root acces, else false.
|
|
|
+ */
|
|
|
+ public static boolean isRooted = false;
|
|
|
+ /**
|
|
|
+ * Flag for porthack. True if porthack is installed, else false.
|
|
|
+ */
|
|
|
+ public static boolean porthackInstalled = false;
|
|
|
|
|
|
/**
|
|
|
* Integer representing a grey light.
|
|
@@ -132,6 +147,7 @@ public class MainActivity extends Activity {
|
|
|
sessionPref = getSharedPreferences(MainActivity.SESSION_DATA, Context.MODE_PRIVATE);
|
|
|
logger = new SQLLogger(this);
|
|
|
sessionEditor = sessionPref.edit();
|
|
|
+ checkRootAndPorthack();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -295,6 +311,39 @@ public class MainActivity extends Activity {
|
|
|
|
|
|
};
|
|
|
|
|
|
+ /**
|
|
|
+ * Checks if the phone ist rooted and if porthack is installed. Sets flags {@link isRooted} and {@link porthackInstalled}
|
|
|
+ */
|
|
|
+ private void checkRootAndPorthack(){
|
|
|
+ isRooted = false;
|
|
|
+ porthackInstalled = false;
|
|
|
+ Process p;
|
|
|
+ try {
|
|
|
+ String found = "Found";
|
|
|
+ String notFound = "Not found";
|
|
|
+ String command = "[ -f /data/local/p ] && echo " + found + " || echo " + notFound;
|
|
|
+ p = Runtime.getRuntime().exec(new String[] { "su", "-c", command });
|
|
|
+ BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
|
|
+ /* int av =
|
|
|
+ byte[] b = new byte[av];
|
|
|
+ if (av != 0) {
|
|
|
+ in.read(b);
|
|
|
+ }
|
|
|
+ */
|
|
|
+ String echoResponse = in.readLine();
|
|
|
+ Log.i("MainAc", echoResponse);
|
|
|
+ if(echoResponse.equals(found)){
|
|
|
+ isRooted = true;
|
|
|
+ porthackInstalled = true;
|
|
|
+ } else if(echoResponse.equals(notFound)){
|
|
|
+ isRooted = true;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ Log.i("MainAc", "Rooted: " + isRooted + " Porthack: " + porthackInstalled);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Returns an intent to start HoneyService.
|
|
|
* @return An Intent to start HoneyService
|