Browse Source

--Temporarily fixedbug of 3g-networks
--Added notification to users when PortBinder not present

shankar.karuppayah 10 years ago
parent
commit
80d6197de7

+ 2 - 2
AndroidManifest.xml

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="de.tudarmstadt.informatik.hostage"
-    android:versionCode="1"
-    android:versionName="1.0" >
+    android:versionCode="2"
+    android:versionName="1.1" >
 
     <uses-sdk
         android:minSdkVersion="14"

+ 2 - 2
build.gradle

@@ -3,7 +3,7 @@ buildscript {
         mavenCentral()
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:0.9.0'
+        classpath 'com.android.tools.build:gradle:0.10.1'
     }
 }
 apply plugin: 'android'
@@ -28,7 +28,7 @@ dependencies {
 
 android {
     compileSdkVersion 19
-    buildToolsVersion "19.0.0"
+    buildToolsVersion "19.0.3"
 
     sourceSets {
         main {

+ 4 - 1
res/values/strings.xml

@@ -23,7 +23,10 @@
 	<string name="wifi_not_connected_msg">You are not connected to a WiFi network. \n\nPlease connect to one, before trying to activate HosTaGe.</string>
 	<string name="network_not_connected_msg">You are not connected to any network. \n\nPlease connect to one, before trying to activate HosTaGe.</string>
 	<string name="no_network_connection_threatmap_msg">Currently you are not connected to the Internet.\n\nPlease establish a connection to use the Threatmap.</string>
-	<string name="profile_no_services_msg">The current active profile does not seem to monitor any services.\n\nPlease activate some services to monitor in the profile.</string>
+    <string name="profile_no_services_msg">The current active profile does not seem to monitor any services.\n\nPlease activate some services to monitor in the profile.</string>
+    <string name="no_portbinder_msg">Your device does not have \'Portbinder\' installed. Due to the limitations of Android OS, you could only use services that are utilizing ports > 1024.\n\nTo enable the full functionality of HosTaGe, please make sure your device is rooted and \'Portbinder\' is installed.</string>
+    <string name="Help">Help Me Get \'Portbinder\'!</string>
+    <string name="HelpPortbinder">Have a look at our video tutorials : https://www.youtube.com/watch?v=gi6fSiIJASk \n\nor visit http://www.tk.informatik.tu-darmstadt.de/my/research/secure-smart-infrastructures/hostage/ for more information.</string>
 
 	<string name="profile_needs_name">An profile needs a name. Please type in a name and press save again.</string>
 

+ 2 - 1
src/de/tudarmstadt/informatik/hostage/system/PrivilegedPort.java

@@ -26,7 +26,7 @@ public class PrivilegedPort implements Runnable {
 	private FileDescriptor fd;
 
 	public PrivilegedPort(TYPE type, int port) {
-		LOG_TAG = String.format("hostage (porthack %s %d)", type.toString(), port);
+		LOG_TAG = String.format("HosTaGe (PortBinder %s %d)", type.toString(), port);
 		this.type = type;
 		this.port = port;
 		try {
@@ -52,6 +52,7 @@ public class PrivilegedPort implements Runnable {
 
 	@Override
 	public void run() {
+        /*@Shankar TODO: Update the location of PortBinder to GUI-Input*/
 		String command = String.format("/data/local/bind %s %d", type.toString(), port);
 		try {
 			Process p = new ProcessBuilder("su", "-c", command).start();

+ 6 - 0
src/de/tudarmstadt/informatik/hostage/ui2/activity/MainActivity.java

@@ -284,6 +284,7 @@ public class MainActivity extends Activity {
 
 		mSharedPreferences = getSharedPreferences(getString(R.string.shared_preference_path), Hostage.MODE_PRIVATE);
 
+
 		if(mSharedPreferences.getBoolean("isFirstRun", true)){
 
 			// opens navigation drawer if first run
@@ -320,6 +321,11 @@ public class MainActivity extends Activity {
 						editor.putBoolean("isFirstRun", false);
 						// Commit the edits!
 						editor.commit();
+
+                        // Enabled shared preferences for 'first' time non-portbinder activation
+                        SharedPreferences.Editor editor1= mSharedPreferences.edit();
+                        editor1.putBoolean("isFirstEmulation", true);
+                        editor1.commit();
 					}
 				})
 				.setNegativeButton(getString(R.string.disagree), new DialogInterface.OnClickListener() {

+ 41 - 0
src/de/tudarmstadt/informatik/hostage/ui2/fragment/HomeFragment.java

@@ -18,6 +18,7 @@ import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.SharedPreferences;
+import android.net.Uri;
 import android.os.Bundle;
 import android.support.v4.content.LocalBroadcastManager;
 import android.view.LayoutInflater;
@@ -28,6 +29,7 @@ import android.widget.ImageView;
 import android.widget.Switch;
 import android.widget.TextView;
 
+import de.tudarmstadt.informatik.hostage.Hostage;
 import de.tudarmstadt.informatik.hostage.HostageApplication;
 import de.tudarmstadt.informatik.hostage.R;
 import de.tudarmstadt.informatik.hostage.commons.HelperUtils;
@@ -37,6 +39,7 @@ import de.tudarmstadt.informatik.hostage.persistence.HostageDBOpenHelper;
 import de.tudarmstadt.informatik.hostage.ui2.model.LogFilter;
 import de.tudarmstadt.informatik.hostage.ui2.activity.MainActivity;
 import de.tudarmstadt.informatik.hostage.ui2.fragment.opengl.ThreatIndicatorGLRenderer;
+import de.tudarmstadt.informatik.hostage.system.Device;
 
 /**
  * This fragments displays the current hostage state and attacks on the device in form of an animation and simple view components
@@ -83,6 +86,11 @@ public class HomeFragment extends TrackerFragment {
 	 */
 	private SharedPreferences mConnectionInfo;
 
+    /**
+     * Hold the shared preferences for the app
+     */
+    private SharedPreferences mSharedPreferences;
+
 	/**
 	 * An Helper to access the sqllite database with all the records
 	 */
@@ -380,6 +388,39 @@ public class HomeFragment extends TrackerFragment {
 						if (isChecked) {
 
 							boolean protocolActivated = false;
+
+                            mSharedPreferences = getActivity().getSharedPreferences(getString(R.string.shared_preference_path), Hostage.MODE_PRIVATE);
+
+
+                            if(mSharedPreferences.getBoolean("isFirstEmulation", true)) {
+                                //Notify Porthack is not installed to user
+                                if(!Device.isPorthackInstalled()) {
+                                    new AlertDialog.Builder(getActivity()).setTitle(R.string.information).setMessage(R.string.no_portbinder_msg)
+                                            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+                                                public void onClick(DialogInterface dialog, int which) {
+
+                                                }
+                                            })
+                                            .setNeutralButton(R.string.Help, new DialogInterface.OnClickListener() {
+
+                                                public void onClick(DialogInterface dialog, int which) {
+                                                    Uri uri = Uri.parse("https://www.youtube.com/watch?v=gi6fSiIJASk");
+                                                    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
+                                                    startActivity(intent);
+                                                }
+                                            })
+                                            .setIcon(android.R.drawable.ic_dialog_info).show()
+                                        ;
+
+                                }
+
+                                // Disable hint for 'first' time emulation notification
+                                SharedPreferences.Editor editor = mSharedPreferences.edit();
+                                editor.putBoolean("isFirstEmulation", false);
+                                editor.commit();
+
+                            }
+
 							if (ProfileManager.getInstance().getCurrentActivatedProfile() == null) {
 								// starts all services
 								MainActivity.getInstance().startMonitorServices(Arrays.asList(getResources().getStringArray(R.array.protocols)));