Skip to content

Commit 8746c4e

Browse files
committed
Merge pull #290 into develop
2 parents 35b585b + 4454aed commit 8746c4e

6 files changed

Lines changed: 79 additions & 35 deletions

File tree

cSploit/res/values/colors.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@
1010
<color name="holo_blue_dark">#ff0d222f</color>
1111
<color name="selectable_blue">#ff36ccff</color>
1212
<color name="selectable_blue_dark">#ff144d5d</color>
13+
<color name="pink">#E91E63</color>
14+
<color name="red">#F44336</color>
15+
<color name="green">#4CAF50</color>
16+
<color name="purple">#3F51B5</color>
17+
<color name="orange">#FFC107</color>
1318
</resources>

cSploit/res/values/strings.xml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,11 @@
237237
<string name="error_rpc">RPC error</string>
238238
<string name="error_rpcd_inval">bad settings</string>
239239
<string name="error_rpcd_shell">cannot execute shell</string>
240-
<string name="rpcd_starting">Starting MetaSploit RPCD&#8230;</string>
240+
<string name="rpcd_starting">Starting MetaSploit RPCD. Standby&#8230;</string>
241241
<string name="rpcd_started">MetaSploit RPCD started</string>
242242
<string name="rpcd_stopped">MetaSploit RPCD stopped</string>
243243
<string name="rpcd_running">MetaSploit RPCD is already running</string>
244244
<string name="rpcd_timedout">MetaSploit RPCD does not respond</string>
245-
<string name="error_rcpd_fatal">fatal error occurred, i\'m searching that bug for send it to my developers.
246-
if i won\'t exit please close me from preferences->applications,
247-
and ALERT MY DEVELOPERS.
248-
</string>
249245

250246
<!-- mitm modules -->
251247
<string name="mitm_simple_sniff">Simple Sniff</string>
@@ -400,6 +396,8 @@
400396
<string name="pref_folder">Folder</string>
401397
<string name="pref_msf_enable">Enable MSF</string>
402398
<string name="pref_msf_enable_desc">Enable the MetaSploit Framework</string>
399+
<string name="pref_msf_notifications">MSF status notifications</string>
400+
<string name="pref_msf_notifications_desc">View MSF RPC connection status</string>
403401
<string name="pref_msf_delete">Delete MSF</string>
404402
<string name="pref_msf_delete_desc">Delete the MetaSploit Framework from your device</string>
405403
<string name="pref_msfwipe_message">Do you really want to delete the MetaSploit Framework?</string>
@@ -513,4 +511,5 @@
513511
<string name="new_apk_found">App verision %s is available, do you want to upgrade ?</string>
514512
<string name="new_ruby_found">A new version for ruby is available, do you want to upgrade ?</string>
515513
<string name="new_msf_found">A new msf version is available, do you want to upgrade ?</string>
514+
<string name="msf_status">MetaSploit Status</string>
516515
</resources>

cSploit/res/xml-v14/preferences.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@
163163
android:title="@string/pref_msf_enable"
164164
android:summary="@string/pref_msf_enable_desc" />
165165

166+
<SwitchPreference
167+
android:defaultValue="true"
168+
android:key="MSF_NOTIFICATIONS"
169+
android:title="@string/pref_msf_notifications"
170+
android:summary="@string/pref_msf_notifications_desc" />
171+
166172
<ListPreference
167173
android:key="MSF_BRANCH"
168174
android:summary="@string/pref_msf_branch_desc"

cSploit/res/xml/preferences.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@
163163
android:title="@string/pref_msf_enable"
164164
android:summary="@string/pref_msf_enable_desc" />
165165

166+
<CheckBoxPreference
167+
android:defaultValue="true"
168+
android:key="MSF_NOTIFICATIONS"
169+
android:title="@string/pref_msf_notifications"
170+
android:summary="@string/pref_msf_notifications_desc" />
171+
166172
<ListPreference
167173
android:key="MSF_BRANCH"
168174
android:summary="@string/pref_msf_branch_desc"

cSploit/src/org/csploit/android/services/MsfRpcdService.java

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,37 @@ public void buildMenuItem(MenuItem item) {
5858
}
5959

6060
public enum Status {
61-
STARTING,
62-
CONNECTED,
63-
DISCONNECTED,
64-
STOPPED,
65-
KILLED,
66-
START_FAILED,
67-
CONNECTION_FAILED,
61+
STARTING(R.string.rpcd_starting, R.color.selectable_blue),
62+
CONNECTED(R.string.connected_msf, R.color.green),
63+
DISCONNECTED(R.string.msfrpc_disconnected, R.color.purple),
64+
STOPPED(R.string.rpcd_stopped, R.color.purple),
65+
KILLED(R.string.msfrpcd_killed, R.color.purple),
66+
START_FAILED(R.string.msfrcd_start_failed, R.color.red),
67+
CONNECTION_FAILED(R.string.msf_connection_failed, R.color.red);
68+
69+
private final int text;
70+
private final int color;
71+
72+
Status(int text, int color) {
73+
this.text = text;
74+
this.color = color;
75+
}
76+
77+
public boolean inProgress() {
78+
return text == R.string.rpcd_starting;
79+
}
80+
81+
public boolean isError() {
82+
return color == R.color.red;
83+
}
84+
85+
public int getText() {
86+
return text;
87+
}
88+
89+
public int getColor() {
90+
return color;
91+
}
6892
}
6993

7094
public MsfRpcdService(Context context) {

cSploit/src/org/csploit/android/services/receivers/MsfRpcdServiceReceiver.java

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
package org.csploit.android.services.receivers;
22

33
import android.app.Activity;
4+
import android.app.NotificationManager;
45
import android.content.Context;
56
import android.content.Intent;
67
import android.content.IntentFilter;
8+
import android.content.SharedPreferences;
9+
import android.support.v4.app.NotificationCompat;
10+
import android.support.v4.content.ContextCompat;
711
import android.widget.Toast;
812

913
import org.csploit.android.R;
1014
import org.csploit.android.core.ManagedReceiver;
15+
import org.csploit.android.core.System;
1116
import org.csploit.android.services.MsfRpcdService;
1217

1318
/**
1419
* Receive and manage intents from the MsfRpcd service
1520
*/
1621
public class MsfRpcdServiceReceiver extends ManagedReceiver {
1722

23+
final int MSF_NOTIFICATION = 1337;
1824
private final IntentFilter filter;
1925

2026
public MsfRpcdServiceReceiver() {
@@ -47,31 +53,29 @@ public void run() {
4753
} else {
4854
showToastForStatus(context, status);
4955
}
56+
57+
SharedPreferences myPrefs = System.getSettings();
58+
if (myPrefs.getBoolean("MSF_NOTIFICATIONS", true)) {
59+
updateNotificationForStatus(context, status);
60+
}
61+
5062
}
5163

5264
private void showToastForStatus(Context context, MsfRpcdService.Status status) {
53-
switch (status) {
54-
case STARTING:
55-
Toast.makeText(context, R.string.rpcd_starting, Toast.LENGTH_SHORT).show();
56-
break;
57-
case CONNECTED:
58-
Toast.makeText(context, R.string.connected_msf, Toast.LENGTH_SHORT).show();
59-
break;
60-
case DISCONNECTED:
61-
Toast.makeText(context, R.string.msfrpc_disconnected, Toast.LENGTH_SHORT).show();
62-
break;
63-
case STOPPED:
64-
Toast.makeText(context, R.string.rpcd_stopped, Toast.LENGTH_SHORT).show();
65-
break;
66-
case KILLED:
67-
Toast.makeText(context, R.string.msfrpcd_killed, Toast.LENGTH_SHORT).show();
68-
break;
69-
case START_FAILED:
70-
Toast.makeText(context, R.string.msfrcd_start_failed, Toast.LENGTH_LONG).show();
71-
break;
72-
case CONNECTION_FAILED:
73-
Toast.makeText(context, R.string.msf_connection_failed, Toast.LENGTH_LONG).show();
74-
break;
75-
}
65+
Toast.makeText(context, status.getText(), (status.isError() ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT)).show();
66+
}
67+
68+
private void updateNotificationForStatus(Context context, MsfRpcdService.Status status) {
69+
NotificationCompat.Builder mBuilder =
70+
new NotificationCompat.Builder(context)
71+
.setSmallIcon(R.drawable.exploit_msf)
72+
.setContentTitle(context.getString(R.string.msf_status))
73+
.setProgress(0, 0, status.inProgress())
74+
.setContentText(context.getString(status.getText()))
75+
.setColor(ContextCompat.getColor(context, status.getColor()));
76+
77+
NotificationManager mNotificationManager =
78+
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
79+
mNotificationManager.notify(MSF_NOTIFICATION, mBuilder.build());
7680
}
7781
}

0 commit comments

Comments
 (0)