2121import android .content .Context ;
2222import android .content .Intent ;
2323import android .content .SharedPreferences ;
24+ import android .graphics .Color ;
2425import android .graphics .Typeface ;
2526import android .net .Uri ;
2627import android .os .Bundle ;
28+ import android .support .v4 .content .ContextCompat ;
2729import android .text .Html ;
2830import android .view .LayoutInflater ;
2931import android .view .Menu ;
6163import java .util .List ;
6264import java .util .concurrent .Future ;
6365
66+ import static org .csploit .android .net .metasploit .MsfExploit .Ranking ;
67+
6468public 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