Kaynağa Gözat

talking android

Fabio Arnold 9 yıl önce
ebeveyn
işleme
4a22643b65

+ 4 - 0
res/values/strings.xml

@@ -37,6 +37,10 @@
     <string name="helpPortbinder">Please follow the instructions in our website to install \'Portbinder\'.\n\nAlternatively, you can use the automated installer by pressing the \'Just Help Me!\' button.</string>
     <string name="confirm_msg">This automated installer fetches the appropriate Portbinder binary and installs in a location within the device.\n\nThis automated process will CHANGE some folder permissions to work. Proceed on your own risk.\n\nConfirm to proceed with automated installation of Portbinder?</string>
     <string name="help_me">Just Help Me!</string>
+	<string name="honeypot_not_monitoring"><![CDATA[<h3>Android says:</h3><p><i>&quot;I\'m currently not looking for attacks. Zzz...&quot;</i></p>]]></string>
+	<string name="honeypot_no_threat"><![CDATA[<h3>Android says:</h3><p><i>&quot;Looks safe!&quot;</i></p>]]></string>
+	<string name="honeypot_past_threat"><![CDATA[<h3>Android says:</h3><p><i>&quot;There have been attacks in this network! This doesn\'t look safe...&quot;</i></p>]]></string>
+	<string name="honeypot_live_threat"><![CDATA[<h3>Android says:</h3><p><i>&quot;Under attack!!!&quot;</i></p>]]></string>
 
 	<string name="profile_needs_name">An profile needs a name. Please type in a name and press save again.</string>
     <string name="monitor_current_connection">Monitor current connection</string>

+ 33 - 6
src/de/tudarmstadt/informatik/hostage/ui/fragment/HomeFragment.java

@@ -17,6 +17,7 @@ import android.content.IntentFilter;
 import android.content.SharedPreferences;
 import android.os.Bundle;
 import android.support.v4.content.LocalBroadcastManager;
+import android.text.Html;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -78,6 +79,8 @@ public class HomeFragment extends Fragment {
 	private boolean isActive = false;
 	private boolean isConnected = false;
 
+	private ThreatIndicatorGLRenderer.ThreatLevel mThreatLevel = ThreatIndicatorGLRenderer.ThreatLevel.NOT_MONITORING;
+
 	private void assignViews() {
 		mHomeSwitchConnection = (Switch) mRootView.findViewById(R.id.home_switch_connection);
 		mHomeTextName = (TextView) mRootView.findViewById(R.id.home_text_name);
@@ -182,18 +185,17 @@ public class HomeFragment extends Fragment {
 
 		boolean hasActiveListeners = false;
 		int totalAttacks = mDbHelper.numBssidSeen(mConnectionInfo.getString(getString(R.string.connection_info_bssid), null));
-		ThreatIndicatorGLRenderer.ThreatLevel threatLevel = ThreatIndicatorGLRenderer.ThreatLevel.NOT_MONITORING;
 
 		if (MainActivity.getInstance().getHostageService() != null) {
 			if (MainActivity.getInstance().getHostageService().hasRunningListeners()) {
 				hasActiveListeners = true;
 
 				if (MainActivity.getInstance().getHostageService().hasActiveAttacks() && totalAttacks > 0) {
-					threatLevel = ThreatIndicatorGLRenderer.ThreatLevel.LIVE_THREAT;
+					mThreatLevel = ThreatIndicatorGLRenderer.ThreatLevel.LIVE_THREAT;
 				} else if (totalAttacks > 0) {
-					threatLevel = ThreatIndicatorGLRenderer.ThreatLevel.PAST_THREAT;
+					mThreatLevel = ThreatIndicatorGLRenderer.ThreatLevel.PAST_THREAT;
 				} else {
-					threatLevel = ThreatIndicatorGLRenderer.ThreatLevel.NO_THREAT;
+					mThreatLevel = ThreatIndicatorGLRenderer.ThreatLevel.NO_THREAT;
 				}
 			}
 		}
@@ -206,7 +208,7 @@ public class HomeFragment extends Fragment {
 				mHomeTextAttacks.setText("");
 				mHomeTextSecurity.setText("");
 			} else {
-				switch (threatLevel) {
+				switch (mThreatLevel) {
 					case NO_THREAT:
 						mHomeTextAttacks.setText(R.string.zero_attacks);
 						mHomeTextSecurity.setText(R.string.secure);
@@ -231,7 +233,7 @@ public class HomeFragment extends Fragment {
 						break;
 				}
 
-				ThreatIndicatorGLRenderer.setThreatLevel(threatLevel);
+				ThreatIndicatorGLRenderer.setThreatLevel(mThreatLevel);
 			}
 		} else {
 			setStateNotActive();
@@ -255,6 +257,31 @@ public class HomeFragment extends Fragment {
 		mRootView = inflater.inflate(R.layout.fragment_home, container, false);
 		assignViews();
 
+		mRootView.findViewById(R.id.surfaceview).setOnClickListener(new View.OnClickListener() {
+			@Override
+			public void onClick(View v) {
+				String message = "???";
+				switch (mThreatLevel) {
+					case NOT_MONITORING:
+						message = getString(R.string.honeypot_not_monitoring);
+						break;
+					case NO_THREAT:
+						message = getString(R.string.honeypot_no_threat);
+						break;
+					case PAST_THREAT:
+						message = getString(R.string.honeypot_past_threat);
+						break;
+					case LIVE_THREAT:
+						message = getString(R.string.honeypot_live_threat);
+						break;
+				}
+				AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.getInstance());
+				builder.setMessage(Html.fromHtml(message));
+				AlertDialog alert = builder.create();
+				alert.show();
+			}
+		});
+
 		// hook up the connection info button
 		mHomeConnectionInfoButton.setOnClickListener(new View.OnClickListener() {
 			@Override