Skip to content

Commit c93c08f

Browse files
committed
Merge pull request #335 from fat-tire/develop
Some improvements to ExploitFinder -- thanks to ga_ for testing it on lower API devices. Can always be improved later.
2 parents f73922b + 8852899 commit c93c08f

2 files changed

Lines changed: 96 additions & 33 deletions

File tree

cSploit/res/layout/plugin_exploit_finder_item.xml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,21 @@
2424
android:fontFamily="sans-serif-condensed"
2525
android:textSize="16sp"/>
2626

27+
2728
<TextView
28-
android:id="@+id/itemDescription"
29+
android:id="@+id/itemRanking"
2930
android:layout_width="match_parent"
3031
android:layout_height="wrap_content"
3132
android:layout_below="@id/itemTitle"
3233
android:layout_toRightOf="@id/itemIcon"
33-
android:textSize="13sp"/>
34+
android:textSize="12sp"/>
35+
36+
<TextView
37+
android:id="@+id/itemDescription"
38+
android:layout_width="match_parent"
39+
android:layout_height="wrap_content"
40+
android:layout_below="@id/itemRanking"
41+
android:layout_toRightOf="@id/itemIcon"
42+
android:textSize="14sp"/>
3443

3544
</RelativeLayout>

cSploit/src/org/csploit/android/plugins/ExploitFinder.java

Lines changed: 85 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
import android.content.Context;
2222
import android.content.Intent;
2323
import android.content.SharedPreferences;
24+
import android.graphics.Color;
2425
import android.graphics.Typeface;
2526
import android.net.Uri;
2627
import android.os.Bundle;
28+
import android.support.v4.content.ContextCompat;
2729
import android.text.Html;
2830
import android.view.LayoutInflater;
2931
import android.view.Menu;
@@ -61,6 +63,8 @@
6163
import java.util.List;
6264
import java.util.concurrent.Future;
6365

66+
import static org.csploit.android.net.metasploit.MsfExploit.Ranking;
67+
6468
public class ExploitFinder extends Plugin {
6569
private ToggleButton mSearchToggleButton = null;
6670
private ProgressBar mSearchProgress = null;
@@ -75,6 +79,7 @@ class ExploitHolder {
7579
ImageView itemImage;
7680
TextView itemTitle;
7781
TextView itemDescription;
82+
TextView itemRanking;
7883
}
7984

8085
public ExploitAdapter() {
@@ -95,6 +100,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
95100
holder.itemImage = (ImageView) row.findViewById(R.id.itemIcon);
96101
holder.itemTitle = (TextView) row.findViewById(R.id.itemTitle);
97102
holder.itemDescription = (TextView) row.findViewById(R.id.itemDescription);
103+
holder.itemRanking = (TextView) row.findViewById(R.id.itemRanking);
98104

99105
row.setTag(holder);
100106
} else {
@@ -111,10 +117,46 @@ public View getView(int position, View convertView, ViewGroup parent) {
111117
"<b>" + exploit.getName() + "</b>"
112118
)
113119
);
120+
final Ranking rank = ((MsfExploit) exploit).getRank();
121+
String rString = "Ranking: ";
122+
String color;
123+
switch (rank) {
124+
case Low:
125+
rString+= "Low";
126+
color = "red";
127+
break;
128+
case Average:
129+
rString+= "Average";
130+
color = "grey4";
131+
break;
132+
case Normal:
133+
rString+= "Normal";
134+
color = "grey4";
135+
break;
136+
case Good:
137+
rString+= "Good";
138+
color = "blue";
139+
break;
140+
case Great:
141+
rString+= "Great";
142+
color = "green";
143+
break;
144+
case Excellent:
145+
rString+= "Excellent";
146+
color = "green";
147+
break;
148+
case Manual:
149+
default:
150+
rString+= "Manual";
151+
color = "gray4";
152+
break;
153+
}
154+
155+
holder.itemRanking.setText(Html.fromHtml("<font color=\"" + color + "\">" + rString + "</font>"));
114156
} else
115157
holder.itemTitle.setText(exploit.getName());
116158

117-
holder.itemTitle.setTextColor(getResources().getColor(
159+
holder.itemTitle.setTextColor(ContextCompat.getColor(getContext(),
118160
exploit.isEnabled() ? R.color.app_color : R.color.gray_text));
119161
holder.itemTitle.setTypeface(null, Typeface.NORMAL);
120162
holder.itemImage.setImageResource(exploit.getDrawableResourceId());
@@ -155,36 +197,7 @@ public void onChoice(int choice) {
155197
Intent intent;
156198
switch (availableChoices.get(choice)) {
157199
case R.string.exploit_launch:
158-
new Thread(new Runnable() {
159-
@Override
160-
public void run() {
161-
162-
int length;
163-
String message;
164-
165-
length = Toast.LENGTH_SHORT;
166-
167-
try {
168-
if (msfEx.launch())
169-
message = "Job started";
170-
else
171-
message = "launch failed";
172-
} catch (RPCClient.MSFException e) {
173-
message = String.format("launch failed: %s", e.getMessage());
174-
length = Toast.LENGTH_LONG;
175-
}
176-
177-
final int flength = length;
178-
final String fmessage = message;
179-
180-
ExploitFinder.this.runOnUiThread(new Runnable() {
181-
@Override
182-
public void run() {
183-
Toast.makeText(ExploitFinder.this, fmessage, flength).show();
184-
}
185-
});
186-
}
187-
}).start();
200+
launchExploit(msfEx);
188201
break;
189202
case R.string.exploit_edit_options:
190203
intent = new Intent(ExploitFinder.this, MsfPreferences.class);
@@ -228,6 +241,40 @@ public void onChoice(int choice) {
228241
}
229242
};
230243

244+
public void launchExploit(final MsfExploit msfEx) {
245+
246+
new Thread(new Runnable() {
247+
@Override
248+
public void run() {
249+
250+
int length;
251+
String message;
252+
253+
length = Toast.LENGTH_SHORT;
254+
255+
try {
256+
if (msfEx.launch())
257+
message = msfEx.getName() + ": Job started";
258+
else
259+
message = msfEx.getName() + ": Launch failed";
260+
} catch (RPCClient.MSFException e) {
261+
message = String.format("launch failed: %s", e.getMessage());
262+
length = Toast.LENGTH_LONG;
263+
}
264+
265+
final int flength = length;
266+
final String fmessage = message;
267+
268+
ExploitFinder.this.runOnUiThread(new Runnable() {
269+
@Override
270+
public void run() {
271+
Toast.makeText(ExploitFinder.this, fmessage, flength).show();
272+
}
273+
});
274+
}
275+
}).start();
276+
}
277+
231278
public ExploitFinder() {
232279
super
233280
(
@@ -351,6 +398,13 @@ public void onClick(View v) {
351398
public boolean onOptionsItemSelected(MenuItem item) {
352399
switch (item.getItemId()) {
353400
case R.id.exploit_launch_all:
401+
mAdapter.getCount();
402+
for (int x=0; x < mAdapter.getCount(); x++) {
403+
Exploit exp = mAdapter.getItem(x);
404+
if (exp instanceof MsfExploit) {
405+
launchExploit((MsfExploit) exp);
406+
}
407+
}
354408
return true;
355409
default:
356410
return super.onOptionsItemSelected(item);

0 commit comments

Comments
 (0)