From d02e832695e72f75057e99ae9510df8910f8b7b0 Mon Sep 17 00:00:00 2001
From: tux_mind <massimo.dragano@gmail.com>
Date: Wed, 14 Oct 2015 11:05:37 +0200
Subject: [PATCH 01/10] fixes #404

---
 cSploit/build.gradle                              | 4 ++--
 cSploit/src/org/csploit/android/MainActivity.java | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/cSploit/build.gradle b/cSploit/build.gradle
index 1271813146..ffa986128a 100644
--- a/cSploit/build.gradle
+++ b/cSploit/build.gradle
@@ -52,8 +52,8 @@ android {
     defaultConfig {
         minSdkVersion 9
         targetSdkVersion 22
-        versionCode 3
-        versionName "1.6.1"
+        versionCode 4
+        versionName "1.6.2"
         if(System.getenv("NIGHTLY_BUILD")) {
             versionName += "+" + System.getenv("NIGHTLY_BUILD_COMMIT").substring(0, 7)
         }
diff --git a/cSploit/src/org/csploit/android/MainActivity.java b/cSploit/src/org/csploit/android/MainActivity.java
index 157d8ad230..0d1a076b98 100644
--- a/cSploit/src/org/csploit/android/MainActivity.java
+++ b/cSploit/src/org/csploit/android/MainActivity.java
@@ -1130,7 +1130,7 @@ public void onReceive(Context context, Intent intent) {
             mUpdateStatus.setText(UPDATE_MESSAGE.replace(
                     "#STATUS#", getString(R.string.no_updates_available)));
 
-          if (!System.isCoreInitialized()) {
+          if (!System.isCoreInstalled()) {
             onInitializationError(getString(R.string.no_core_found));
           }
           break;

From 77020ccf7bf3a58b27c427a67706f945da213784 Mon Sep 17 00:00:00 2001
From: tux_mind <massimo.dragano@gmail.com>
Date: Fri, 25 Dec 2015 03:38:48 +0100
Subject: [PATCH 02/10] Define the floating button at the end of the
 RelativeLayout, to put it over all the others widgets. Thanks to @0MazaHacka0
 for reporting it.

---
 cSploit/res/layout/plugin_inspector.xml | 30 ++++++++++++++-----------
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/cSploit/res/layout/plugin_inspector.xml b/cSploit/res/layout/plugin_inspector.xml
index 1c9ee175ef..026735c44a 100644
--- a/cSploit/res/layout/plugin_inspector.xml
+++ b/cSploit/res/layout/plugin_inspector.xml
@@ -6,19 +6,6 @@
     android:paddingTop="16sp"
     android:id="@+id/whatever">
 
-    <android.support.design.widget.FloatingActionButton
-        android:id="@+id/inspectToggleButton"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:padding="20dp"
-        android:src="@drawable/ic_play_arrow_24dp"
-        android:checked="false"
-        android:translationZ="8dp"
-        android:layout_alignParentBottom="true"
-        android:layout_alignParentRight="true"
-        android:layout_margin="20dp"
-        android:focusableInTouchMode="true" />
-
     <ProgressBar
         android:id="@+id/inspectActivity"
         android:layout_width="wrap_content"
@@ -156,4 +143,21 @@
         android:gravity="center_vertical"
         />
     </ScrollView>
+
+    <!--
+    Later children in a RelativeLayout tend to float over earlier children in a RelativeLayout.
+    https://www.stackoverflow.com/a/28651543
+    -->
+    <android.support.design.widget.FloatingActionButton
+        android:id="@+id/inspectToggleButton"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:padding="20dp"
+        android:src="@drawable/ic_play_arrow_24dp"
+        android:checked="false"
+        android:translationZ="8dp"
+        android:layout_alignParentBottom="true"
+        android:layout_alignParentRight="true"
+        android:layout_margin="20dp"
+        android:focusableInTouchMode="true" />
 </RelativeLayout>
\ No newline at end of file

From 8c5a9cc5048b30a2e1a1809711b623861375e56d Mon Sep 17 00:00:00 2001
From: tux_mind <massimo.dragano@gmail.com>
Date: Fri, 25 Dec 2015 03:41:15 +0100
Subject: [PATCH 03/10] version bump

---
 cSploit/build.gradle | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cSploit/build.gradle b/cSploit/build.gradle
index ffa986128a..d719669179 100644
--- a/cSploit/build.gradle
+++ b/cSploit/build.gradle
@@ -52,8 +52,8 @@ android {
     defaultConfig {
         minSdkVersion 9
         targetSdkVersion 22
-        versionCode 4
-        versionName "1.6.2"
+        versionCode 5
+        versionName "1.6.3"
         if(System.getenv("NIGHTLY_BUILD")) {
             versionName += "+" + System.getenv("NIGHTLY_BUILD_COMMIT").substring(0, 7)
         }

From 539f98252a35a1be8718233b5d1d2b66e897360f Mon Sep 17 00:00:00 2001
From: tux_mind <massimo.dragano@gmail.com>
Date: Fri, 25 Dec 2015 03:43:57 +0100
Subject: [PATCH 04/10] use stable version of gradle android plugin

---
 build.gradle         | 2 +-
 cSploit/build.gradle | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/build.gradle b/build.gradle
index c0bd27756b..dea94eb99c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,7 +5,7 @@ buildscript {
         mavenCentral()
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:1.4.0-beta6'
+        classpath 'com.android.tools.build:gradle:1.5.0'
     }
 }
 
diff --git a/cSploit/build.gradle b/cSploit/build.gradle
index d719669179..dcbe82d686 100644
--- a/cSploit/build.gradle
+++ b/cSploit/build.gradle
@@ -4,7 +4,7 @@ buildscript {
         mavenCentral()
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:1.4.0-beta6'
+        classpath 'com.android.tools.build:gradle:1.5.0'
     }
 }
 

From d29597b91cbb6493abdd153544657587b88bc315 Mon Sep 17 00:00:00 2001
From: tux_mind <massimo.dragano@gmail.com>
Date: Thu, 7 Jan 2016 14:26:26 +0100
Subject: [PATCH 05/10] fixes #555

---
 .../services/receivers/MsfRpcdServiceReceiver.java     | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/cSploit/src/org/csploit/android/services/receivers/MsfRpcdServiceReceiver.java b/cSploit/src/org/csploit/android/services/receivers/MsfRpcdServiceReceiver.java
index d832e90f62..63dacf81ac 100644
--- a/cSploit/src/org/csploit/android/services/receivers/MsfRpcdServiceReceiver.java
+++ b/cSploit/src/org/csploit/android/services/receivers/MsfRpcdServiceReceiver.java
@@ -2,6 +2,7 @@
 
 import android.app.Activity;
 import android.app.NotificationManager;
+import android.app.PendingIntent;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
@@ -68,7 +69,7 @@ private void showToastForStatus(Context context, MsfRpcdService.Status status) {
   }
 
   private void updateNotificationForStatus(Context context, MsfRpcdService.Status status) {
-    NotificationCompat.Builder mBuilder =
+    NotificationCompat.Builder builder =
             new NotificationCompat.Builder(context)
             .setSmallIcon(R.drawable.exploit_msf)
             .setContentTitle(context.getString(R.string.msf_status))
@@ -76,8 +77,13 @@ private void updateNotificationForStatus(Context context, MsfRpcdService.Status
             .setContentText(context.getString(status.getText()))
             .setColor(ContextCompat.getColor(context, status.getColor()));
 
+    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
+            new Intent(), PendingIntent.FLAG_UPDATE_CURRENT);
+
+    builder.setContentIntent(pendingIntent);
+
     NotificationManager mNotificationManager =
             (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
-    mNotificationManager.notify(MSF_NOTIFICATION, mBuilder.build());
+    mNotificationManager.notify(MSF_NOTIFICATION, builder.build());
   }
 }

From 5a120d732171938f8bc5342bf2711ef4e18eb146 Mon Sep 17 00:00:00 2001
From: tux_mind <massimo.dragano@gmail.com>
Date: Thu, 7 Jan 2016 14:33:18 +0100
Subject: [PATCH 06/10] version bump

---
 cSploit/build.gradle | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cSploit/build.gradle b/cSploit/build.gradle
index dcbe82d686..5475b4df46 100644
--- a/cSploit/build.gradle
+++ b/cSploit/build.gradle
@@ -53,7 +53,7 @@ android {
         minSdkVersion 9
         targetSdkVersion 22
         versionCode 5
-        versionName "1.6.3"
+        versionName "1.6.4"
         if(System.getenv("NIGHTLY_BUILD")) {
             versionName += "+" + System.getenv("NIGHTLY_BUILD_COMMIT").substring(0, 7)
         }

From f92cde5420828df24788009b1ae5b4ca2fe759c5 Mon Sep 17 00:00:00 2001
From: tux-mind <massimo.dragano@gmail.com>
Date: Sat, 16 Jan 2016 08:16:01 +0100
Subject: [PATCH 07/10] force user to choose empty or old directories.

---
 cSploit/res/values/strings.xml                |   1 +
 .../org/csploit/android/SettingsActivity.java | 107 +++++++++++++-----
 2 files changed, 81 insertions(+), 27 deletions(-)

diff --git a/cSploit/res/values/strings.xml b/cSploit/res/values/strings.xml
index d03780c5c9..43af23b7c5 100644
--- a/cSploit/res/values/strings.xml
+++ b/cSploit/res/values/strings.xml
@@ -529,4 +529,5 @@
     <string name="mitm_ss_select_target_prompt">Select %s ?</string>
     <string name="github_issues_url" translatable="false">https://github.com/cSploit/android/issues</string>
     <string name="issue_message"><![CDATA[<p>Before opening a new issue, please, take the time to read the already <a href="%1$s">open issues</a>, probably it\' s already open. If it\' s not open we\'ll need as much information as you can get, so please, read <a href="%2$s">this guide</a> in order to know how to report a bug properly.</p>]]></string>
+    <string name="pref_err_empty_or_old">must be empty or an old installation directory.</string>
 </resources>
diff --git a/cSploit/src/org/csploit/android/SettingsActivity.java b/cSploit/src/org/csploit/android/SettingsActivity.java
index 4a64f9787a..dbb71f2026 100644
--- a/cSploit/src/org/csploit/android/SettingsActivity.java
+++ b/cSploit/src/org/csploit/android/SettingsActivity.java
@@ -214,14 +214,84 @@ public void onEnd(int exitCode) {
       }
     }
 
+    private boolean isDirectoryEmptyOrWithVersion(File folder) {
+      String[] files = folder.list();
+
+      if(files.length > 0) {
+        for(String fname : files) {
+          if("VERSION".equals(fname)) {
+            return true;
+          }
+        }
+        return false;
+      }
+
+      return true;
+    }
+
+    private ExecChecker getCheckerForKey(String key) {
+      switch (key) {
+        case "RUBY_DIR":
+          return ExecChecker.ruby();
+        case "MSF_DIR":
+          return ExecChecker.msf();
+      }
+      return null;
+    }
+
+    private String getCurrentPathForKey(String key) {
+      switch (key) {
+        case "RUBY_DIR":
+          return System.getRubyPath();
+        case "MSF_DIR":
+          return System.getMsfPath();
+      }
+      return null;
+    }
+
+    private boolean shallAskForDelete(String key) {
+      return key.equals("RUBY_DIR") || key.equals("MSF_DIR");
+    }
+
+    /**
+     * check if selected directory is valid for the given key.
+     * @param key to be updated
+     * @param path of the chosen directory
+     * @return true if {@code path} is valid, false otherwise
+     */
+    private boolean canChangeDirectoryTo(String key, String path) {
+      File folder = new File(path);
+      ExecChecker checker = getCheckerForKey(key);
+      String oldPath = getCurrentPathForKey(key);
+      String toastMessage = null;
+      boolean valid = false;
+      boolean checkEmptyOrVersion = shallAskForDelete(key);
+
+      if (!folder.exists()) {
+        toastMessage = getString(R.string.pref_folder) + " " + path + " " + getString(R.string.pref_err_exists);
+      } else if (!folder.canWrite()) {
+        toastMessage = getString(R.string.pref_folder) + " " + path + " " + getString(R.string.pref_err_writable);
+      } else if (checker != null && !checker.canExecuteInDir(path)) {
+        toastMessage = getString(R.string.pref_folder) + " " + path + " " + getString(R.string.pref_err_executable);
+      } else if (checkEmptyOrVersion && !isDirectoryEmptyOrWithVersion(folder)) {
+        toastMessage = getString(R.string.pref_folder) + " " + path + " " + getString(R.string.pref_err_empty_or_old);
+      } else if (oldPath == null || !oldPath.equals(path)) {
+        valid = true;
+      }
+
+      if(toastMessage != null) {
+        Toast.makeText(getContext(), toastMessage, Toast.LENGTH_LONG).show();
+      }
+
+      return valid;
+    }
+
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent intent) {
       if (requestCode == DirectoryPicker.PICK_DIRECTORY && resultCode != RESULT_CANCELED) {
         Bundle extras = intent.getExtras();
         String path;
         String key;
-        File folder;
-        String oldPath = null;
 
         if (extras == null) {
           Logger.debug("null extra: " + intent);
@@ -236,35 +306,18 @@ public void onActivityResult(int requestCode, int resultCode, Intent intent) {
           return;
         }
 
-        folder = new File(path);
-        ExecChecker checker = null;
-
-
-        if (key.equals("RUBY_DIR")) {
-          oldPath = System.getRubyPath();
-          checker = ExecChecker.ruby();
-        } else if (key.equals("MSF_DIR")) {
-          oldPath = System.getMsfPath();
-          checker = ExecChecker.msf();
-        }
-
-        if (!folder.exists())
-          Toast.makeText(getActivity(), getString(R.string.pref_folder) + " " + path + " " + getString(R.string.pref_err_exists), Toast.LENGTH_SHORT).show();
-
-        else if (!folder.canWrite())
-          Toast.makeText(getActivity(), getString(R.string.pref_folder) + " " + path + " " + getString(R.string.pref_err_writable), Toast.LENGTH_SHORT).show();
+        if(canChangeDirectoryTo(key, path)) {
 
-        else if (checker != null && !checker.canExecuteInDir(path))
-          Toast.makeText(getActivity(), getString(R.string.pref_folder) + " " + path + " " + getString(R.string.pref_err_executable), Toast.LENGTH_LONG).show();
 
-        else {
-          //noinspection ConstantConditions
           getPreferenceManager().getSharedPreferences().edit().putString(key, path).commit();
-          if (oldPath != null && !oldPath.equals(path)) {
-            File current = new File(oldPath);
 
-            if (current.exists() && current.isDirectory() && current.listFiles().length > 2) {
-              wipe_prompt_older(current);
+          if(shallAskForDelete(key)) {
+            String oldPath = getCurrentPathForKey(key);
+            if(oldPath != null) {
+              File current = new File(oldPath);
+              if(current.exists() && current.isDirectory() && current.list().length > 0) {
+                wipe_prompt_older(current);
+              }
             }
           }
         }

From cc505266783be1296c7b9b77d51b8e1fce46c879 Mon Sep 17 00:00:00 2001
From: tux-mind <massimo.dragano@gmail.com>
Date: Sat, 16 Jan 2016 08:17:14 +0100
Subject: [PATCH 08/10] version bump

---
 cSploit/build.gradle | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cSploit/build.gradle b/cSploit/build.gradle
index 5475b4df46..2c5d5117ed 100644
--- a/cSploit/build.gradle
+++ b/cSploit/build.gradle
@@ -52,8 +52,8 @@ android {
     defaultConfig {
         minSdkVersion 9
         targetSdkVersion 22
-        versionCode 5
-        versionName "1.6.4"
+        versionCode 6
+        versionName "1.6.5"
         if(System.getenv("NIGHTLY_BUILD")) {
             versionName += "+" + System.getenv("NIGHTLY_BUILD_COMMIT").substring(0, 7)
         }

From 8a268aca59c45ebc24d6c8f5921e09853f01c332 Mon Sep 17 00:00:00 2001
From: pahapoika <pahapoika91@protonmail.com>
Date: Fri, 3 Feb 2017 13:36:10 +0200
Subject: [PATCH 09/10] create ISSUE_TEMPLATE.md

---
 ISSUE_TEMPLATE.md | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 ISSUE_TEMPLATE.md

diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md
new file mode 100644
index 0000000000..cca0066ac0
--- /dev/null
+++ b/ISSUE_TEMPLATE.md
@@ -0,0 +1,35 @@
+##DEVICE:
+
+
+##OS version:
+
+
+##cSploit version:
+
+
+##busybox (installed or not):
+
+
+##Rooted with supersu?
+
+
+##logcat (filter it!):
+
+
+**Daemon specific questions**
+
+##Go version:
+
+
+##OS:
+
+
+##Using Docker (incase of unofficial build.)
+
+
+##Actions performed:
+
+#Logs:
+
+##Issue:
+*Remember to search for issues alike before creating new one.

From 39ee303d2498a8ffc702158d094c6b6f7dd5fedf Mon Sep 17 00:00:00 2001
From: pahapoika <pahapoika91@protonmail.com>
Date: Fri, 3 Feb 2017 13:42:36 +0200
Subject: [PATCH 10/10] Delete ISSUE_TEMPLATE.md

---
 ISSUE_TEMPLATE.md | 35 -----------------------------------
 1 file changed, 35 deletions(-)
 delete mode 100644 ISSUE_TEMPLATE.md

diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md
deleted file mode 100644
index cca0066ac0..0000000000
--- a/ISSUE_TEMPLATE.md
+++ /dev/null
@@ -1,35 +0,0 @@
-##DEVICE:
-
-
-##OS version:
-
-
-##cSploit version:
-
-
-##busybox (installed or not):
-
-
-##Rooted with supersu?
-
-
-##logcat (filter it!):
-
-
-**Daemon specific questions**
-
-##Go version:
-
-
-##OS:
-
-
-##Using Docker (incase of unofficial build.)
-
-
-##Actions performed:
-
-#Logs:
-
-##Issue:
-*Remember to search for issues alike before creating new one.