6363import org .csploit .android .plugins .Traceroute ;
6464import org .csploit .android .plugins .VulnerabilityFinder ;
6565import org .csploit .android .plugins .mitm .MITM ;
66- import org .csploit .android .net . metasploit .MsfRpcd ;
66+ import org .csploit .android .tools .MsfRpcd ;
6767import org .csploit .android .tools .ToolBox ;
6868
6969import java .io .IOException ;
@@ -108,7 +108,7 @@ public class MainActivity extends SherlockListActivity {
108108 private boolean isWifiAvailable = false ;
109109 private TargetAdapter mTargetAdapter = null ;
110110 private NetworkRadar mNetworkRadar = null ;
111- private MsfRpcd mMsfRpcd = null ;
111+ private Child mMsfRpcd = null ;
112112 private RadarReceiver mRadarReceiver = new RadarReceiver ();
113113 private UpdateReceiver mUpdateReceiver = new UpdateReceiver ();
114114 private WipeReceiver mWipeReceiver = new WipeReceiver ();
@@ -377,7 +377,7 @@ public boolean onPrepareOptionsMenu(Menu menu) {
377377
378378 if (MsfRpcd .isLocal ()) {
379379 if (System .getMsfRpc () != null
380- || (mMsfRpcd != null && mMsfRpcd .isRunning () ))
380+ || (mMsfRpcd != null && mMsfRpcd .running ))
381381 item .setTitle (getString (R .string .stop_msfrpcd ));
382382 else
383383 item .setTitle (getString (R .string .start_msfrpcd ));
@@ -389,7 +389,7 @@ public boolean onPrepareOptionsMenu(Menu menu) {
389389 }
390390
391391 item .setEnabled (!MsfRpcd .isLocal () ||
392- (tools != null && tools .msf .isEnabled () &&
392+ (tools != null && tools .msfrpcd .isEnabled () &&
393393 !System .isServiceRunning ("org.csploit.android.core.UpdateService" )));
394394
395395 mMenu = menu ;
@@ -526,9 +526,6 @@ public void stopNetworkRadar(boolean silent) {
526526 public void StartRPCServer () {
527527 StopRPCServer (true );
528528
529- if (mMsfRpcd == null )
530- mMsfRpcd = new MsfRpcd ();
531-
532529 new Thread ( new Runnable () {
533530 @ Override
534531 public void run () {
@@ -542,49 +539,54 @@ public void run() {
542539
543540 if (msfHost .equals ("127.0.0.1" )) {
544541 try {
545- mMsfRpcd .start (msfUser , msfPassword , msfPort , msfSsl , new MsfRpcd .MsfRpcdReceiver () {
546- @ Override
547- public void onReady () {
548- try {
549- System .setMsfRpc (new RPCClient (msfHost , msfUser , msfPassword , msfPort , msfSsl ));
550- Logger .info ("successfully connected to MSF RPC Daemon " );
551- MainActivity .this .runOnUiThread (new Runnable () {
552- @ Override
553- public void run () {
554- Toast .makeText (MainActivity .this , "connected to MSF RPC Daemon" , Toast .LENGTH_SHORT ).show ();
555- }
556- });
557- } catch (Exception e ) {
558- Logger .error (e .getClass ().getName () + ": " + e .getMessage ());
559- MainActivity .this .runOnUiThread (new Runnable () {
560- @ Override
561- public void run () {
562- Toast .makeText (MainActivity .this , "connection to MSF RPC Daemon failed" , Toast .LENGTH_LONG ).show ();
563- }
564- });
565- }
566- }
567-
568- @ Override
569- public void onEnd (final int exitValue ) {
570- MainActivity .this .runOnUiThread (new Runnable () {
571- @ Override
572- public void run () {
573- Toast .makeText (MainActivity .this , "MSF RPC Daemon returned #" + exitValue , Toast .LENGTH_LONG ).show ();
574- }
575- });
576- }
577-
578- @ Override
579- public void onDeath (final int signal ) {
580- MainActivity .this .runOnUiThread (new Runnable () {
581- @ Override
582- public void run () {
583- Toast .makeText (MainActivity .this , " MSF RPC Daemon killed by signal #" + signal , Toast .LENGTH_LONG ).show ();
584- }
585- });
586- }
587- });
542+ mMsfRpcd = System .getTools ().msfrpcd .async (
543+ msfUser , msfPassword , msfPort , msfSsl ,
544+ new MsfRpcd .MsfRpcdReceiver () {
545+ @ Override
546+ public void onReady () {
547+ try {
548+ System .setMsfRpc (new RPCClient (msfHost , msfUser , msfPassword , msfPort , msfSsl ));
549+ Logger .info ("successfully connected to MSF RPC Daemon " );
550+ MainActivity .this .runOnUiThread (new Runnable () {
551+ @ Override
552+ public void run () {
553+ Toast .makeText (MainActivity .this , "connected to MSF RPC Daemon" , Toast .LENGTH_SHORT ).show ();
554+ }
555+ });
556+ } catch (Exception e ) {
557+ Logger .error (e .getClass ().getName () + ": " + e .getMessage ());
558+ MainActivity .this .runOnUiThread (new Runnable () {
559+ @ Override
560+ public void run () {
561+ Toast .makeText (MainActivity .this , "connection to MSF RPC Daemon failed" , Toast .LENGTH_LONG ).show ();
562+ }
563+ });
564+ }
565+ }
566+
567+ @ Override
568+ public void onEnd (final int exitValue ) {
569+ if (exitValue == 0 )
570+ return ;
571+
572+ MainActivity .this .runOnUiThread (new Runnable () {
573+ @ Override
574+ public void run () {
575+ Toast .makeText (MainActivity .this , "MSF RPC Daemon returned #" + exitValue , Toast .LENGTH_LONG ).show ();
576+ }
577+ });
578+ }
579+
580+ @ Override
581+ public void onDeath (final int signal ) {
582+ MainActivity .this .runOnUiThread (new Runnable () {
583+ @ Override
584+ public void run () {
585+ Toast .makeText (MainActivity .this , " MSF RPC Daemon killed by signal #" + signal , Toast .LENGTH_LONG ).show ();
586+ }
587+ });
588+ }
589+ });
588590 } catch (ChildManager .ChildNotStartedException e ) {
589591 Logger .error (e .getMessage ());
590592 MainActivity .this .runOnUiThread (new Runnable () {
@@ -624,17 +626,22 @@ public void run() {
624626 */
625627 public void StopRPCServer (final boolean silent ) {
626628
627- if (System .getMsfRpc () == null && ( mMsfRpcd == null || !mMsfRpcd .isRunning () ))
629+ if (System .getMsfRpc () == null && ( mMsfRpcd == null || !mMsfRpcd .running ))
628630 return ;
629631
632+ final Child process = mMsfRpcd ;
633+ mMsfRpcd = null ;
634+
630635 new Thread ( new Runnable () {
631636 @ Override
632637 public void run () {
633638 try {
634639 System .setMsfRpc (null );
635640
636- if (mMsfRpcd .isRunning ())
637- mMsfRpcd .stop ();
641+ if (process .running ) {
642+ process .kill (2 );
643+ process .join ();
644+ }
638645
639646 if (!silent ) {
640647 MainActivity .this .runOnUiThread (new Runnable () {
@@ -825,7 +832,7 @@ public void onItemSelected(int index) {
825832 return true ;
826833
827834 case R .id .ss_msfrpcd :
828- if (System .getMsfRpc ()!=null || (mMsfRpcd != null && mMsfRpcd .isRunning () )) {
835+ if (System .getMsfRpc ()!=null || (mMsfRpcd != null && mMsfRpcd .running )) {
829836 StopRPCServer (false );
830837 if (MsfRpcd .isLocal ())
831838 item .setTitle (R .string .start_msfrpcd );
@@ -1176,6 +1183,9 @@ private void onUpdateAvailable(final String desc, final UpdateService.action tar
11761183 }
11771184
11781185 private void onUpdateDone (UpdateService .action target ) {
1186+
1187+ System .reloadTools ();
1188+
11791189 switch (target ) {
11801190 case ruby_update :
11811191 case msf_update :
@@ -1205,6 +1215,8 @@ public void run() {
12051215 getString (message ),MainActivity .this ).show ();
12061216 }
12071217 });
1218+
1219+ System .reloadTools ();
12081220 }
12091221
12101222 @ SuppressWarnings ("ConstantConditions" )
0 commit comments