Skip to content

Commit 17caa2d

Browse files
committed
Add "Auto port-scan" preference to Settings.
This allows you to disable the default behavior, which is to do a port scan for each discovered host.
1 parent 622a207 commit 17caa2d

File tree

3 files changed

+45
-34
lines changed

3 files changed

+45
-34
lines changed

cSploit/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,8 @@
415415
<string name="pref_err_buffer_size">Buffer size must be between 1024 and 104857600.</string>
416416
<string name="pref_persistent_network_monitor">persistent network monitor</string>
417417
<string name="pref_persistent_network_monitor_desc">keep network monitor watching the network</string>
418+
<string name="pref_auto_portscan">Auto port-scan</string>
419+
<string name="pref_auto_portscan_desc">Always SYN scan for open ports when new host is discovered</string>
418420

419421
<string name="exploit_finder">Exploit Finder</string>
420422
<string name="exploit_finder_desc">Search for exploit that matches found vulnerabilities.</string>

cSploit/res/xml/preferences.xml

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
33
android:layout_width="match_parent"
4-
android:layout_height="wrap_content" >
4+
android:layout_height="wrap_content">
55

6-
<PreferenceCategory android:title="@string/pref_general" >
6+
<PreferenceCategory android:title="@string/pref_general">
77

88
<SwitchPreferenceCompat
99
android:defaultValue="true"
@@ -33,9 +33,16 @@
3333
android:key="PREF_DARK_THEME"
3434
android:summary="@string/pref_choose_theme"
3535
android:title="@string/pref_theme" />
36+
37+
<SwitchPreferenceCompat
38+
android:defaultValue="true"
39+
android:key="PREF_AUTO_PORTSCAN"
40+
android:summary="@string/pref_auto_portscan_desc"
41+
android:title="@string/pref_auto_portscan" />
42+
3643
</PreferenceCategory>
3744

38-
<PreferenceCategory android:title="@string/pref_updates" >
45+
<PreferenceCategory android:title="@string/pref_updates">
3946
<SwitchPreferenceCompat
4047
android:defaultValue="true"
4148
android:key="PREF_CHECK_UPDATES"
@@ -44,42 +51,42 @@
4451

4552
<SwitchPreferenceCompat
4653
android:defaultValue="true"
47-
android:key="PREF_UPDATES_APP"
4854
android:dependency="PREF_CHECK_UPDATES"
55+
android:key="PREF_UPDATES_APP"
4956
android:summary="@string/pref_updates_app_desc"
5057
android:title="@string/pref_updates_app" />
5158

5259
<SwitchPreferenceCompat
5360
android:defaultValue="true"
54-
android:key="PREF_UPDATES_CORE"
5561
android:dependency="PREF_CHECK_UPDATES"
62+
android:key="PREF_UPDATES_CORE"
5663
android:summary="@string/pref_updates_core_desc"
5764
android:title="@string/pref_updates_core" />
5865

5966
<SwitchPreferenceCompat
6067
android:defaultValue="true"
61-
android:key="PREF_UPDATES_RUBY"
6268
android:dependency="PREF_CHECK_UPDATES"
69+
android:key="PREF_UPDATES_RUBY"
6370
android:summary="@string/pref_updates_ruby_desc"
6471
android:title="@string/pref_updates_ruby" />
6572

6673
<SwitchPreferenceCompat
6774
android:defaultValue="true"
68-
android:key="PREF_UPDATES_GEMS"
6975
android:dependency="PREF_CHECK_UPDATES"
76+
android:key="PREF_UPDATES_GEMS"
7077
android:summary="@string/pref_updates_gems_desc"
7178
android:title="@string/pref_updates_gems" />
7279

7380
<SwitchPreferenceCompat
7481
android:defaultValue="true"
75-
android:key="PREF_UPDATES_MSF"
7682
android:dependency="PREF_CHECK_UPDATES"
83+
android:key="PREF_UPDATES_MSF"
7784
android:summary="@string/pref_updates_msf_desc"
7885
android:title="@string/pref_updates_msf" />
7986

8087
</PreferenceCategory>
8188

82-
<PreferenceCategory android:title="@string/pref_modules" >
89+
<PreferenceCategory android:title="@string/pref_modules">
8390

8491
<EditTextPreference
8592
android:defaultValue="1.0"
@@ -129,7 +136,7 @@
129136
android:title="@string/pref_password_filename" />
130137
</PreferenceCategory>
131138

132-
<PreferenceCategory android:title="@string/pref_performance" >
139+
<PreferenceCategory android:title="@string/pref_performance">
133140

134141
<ListPreference
135142
android:defaultValue="BOTH"
@@ -151,28 +158,27 @@
151158
android:defaultValue="false"
152159
android:key="WIDE_SCAN"
153160
android:summary="@string/pref_performance_widescan_desc"
154-
android:title="@string/pref_performance_widescan"
155-
/>
161+
android:title="@string/pref_performance_widescan" />
156162
</PreferenceCategory>
157163

158-
<PreferenceCategory android:title="@string/pref_msf" >
164+
<PreferenceCategory android:title="@string/pref_msf">
159165

160166
<SwitchPreferenceCompat
161167
android:defaultValue="true"
162168
android:key="MSF_ENABLED"
163-
android:title="@string/pref_msf_enable"
164-
android:summary="@string/pref_msf_enable_desc" />
169+
android:summary="@string/pref_msf_enable_desc"
170+
android:title="@string/pref_msf_enable" />
165171

166172
<SwitchPreferenceCompat
167173
android:defaultValue="true"
168174
android:key="MSF_NOTIFICATIONS"
169-
android:title="@string/pref_msf_notifications"
170-
android:summary="@string/pref_msf_notifications_desc" />
175+
android:summary="@string/pref_msf_notifications_desc"
176+
android:title="@string/pref_msf_notifications" />
171177

172178
<ListPreference
179+
android:dialogTitle="@string/choose_branch"
173180
android:key="MSF_BRANCH"
174181
android:summary="@string/pref_msf_branch_desc"
175-
android:dialogTitle="@string/choose_branch"
176182
android:title="@string/pref_msf_branch_title" />
177183

178184
<Preference
@@ -211,8 +217,8 @@
211217

212218
<EditTextPreference
213219
android:defaultValue="55553"
214-
android:key="MSF_RPC_PORT"
215220
android:inputType="number"
221+
android:key="MSF_RPC_PORT"
216222
android:summary="@string/pref_rpc_port_desc"
217223
android:title="@string/pref_rpc_port" />
218224

@@ -224,8 +230,8 @@
224230

225231
<Preference
226232
android:key="PREF_MSF_WIPE"
227-
android:title="@string/pref_msf_delete"
228-
android:summary="@string/pref_msf_delete_desc"/>
233+
android:summary="@string/pref_msf_delete_desc"
234+
android:title="@string/pref_msf_delete" />
229235
</PreferenceCategory>
230236

231237
</PreferenceScreen>

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

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
import android.app.Activity;
44
import android.content.Context;
5+
import android.content.SharedPreferences;
56
import android.view.MenuItem;
67

78
import org.csploit.android.R;
9+
import org.csploit.android.core.ChildManager;
810
import org.csploit.android.core.Logger;
911
import org.csploit.android.core.System;
10-
import org.csploit.android.core.ChildManager;
1112
import org.csploit.android.helpers.ThreadHelper;
1213
import org.csploit.android.net.Endpoint;
1314
import org.csploit.android.net.Network;
@@ -69,23 +70,25 @@ public void buildMenuItem(MenuItem item) {
6970
}
7071

7172
public void onNewTargetFound(final Target target) {
72-
if(target.getType() == Target.Type.NETWORK)
73+
if (target.getType() == Target.Type.NETWORK)
7374
return;
7475

75-
if(!System.isCoreInitialized()) {
76+
if (!System.isCoreInitialized()) {
7677
return;
7778
}
78-
79-
ThreadHelper.getSharedExecutor().execute(new Runnable() {
80-
@Override
81-
public void run() {
82-
try {
83-
System.getTools().nmap.synScan(target, new ScanReceiver(target));
84-
} catch (ChildManager.ChildNotStartedException e) {
85-
System.errorLogging(e);
79+
SharedPreferences prefs = System.getSettings();
80+
if (prefs.getBoolean("PREF_AUTO_PORTSCAN", true)) {
81+
ThreadHelper.getSharedExecutor().execute(new Runnable() {
82+
@Override
83+
public void run() {
84+
try {
85+
System.getTools().nmap.synScan(target, new ScanReceiver(target));
86+
} catch (ChildManager.ChildNotStartedException e) {
87+
System.errorLogging(e);
88+
}
8689
}
87-
}
88-
});
90+
});
91+
}
8992
}
9093

9194
private class Receiver extends HostReceiver {

0 commit comments

Comments
 (0)