5656import org .csploit .android .net .metasploit .Payload ;
5757import org .csploit .android .net .metasploit .RPCClient ;
5858import org .csploit .android .net .metasploit .Session ;
59+ import org .csploit .android .services .Services ;
5960import org .csploit .android .tools .ToolBox ;
6061
6162import java .io .BufferedReader ;
@@ -189,21 +190,7 @@ public static void init(Context context) throws Exception{
189190 MSF_RPC_PORT = 55553 ;
190191 }
191192
192- // initialize network data at the end
193- mNetwork = new Network (mContext );
194-
195- Target network = new Target (mNetwork ),
196- gateway = new Target (mNetwork .getGatewayAddress (), mNetwork .getGatewayHardware ()),
197- device = new Target (mNetwork .getLocalAddress (), mNetwork .getLocalHardware ());
198-
199- gateway .setAlias (mNetwork .getSSID ());
200- device .setAlias (android .os .Build .MODEL );
201-
202- mTargets .add (network );
203- mTargets .add (gateway );
204- mTargets .add (device );
205-
206- mInitialized = true ;
193+ uncaughtReloadNetworkMapping ();
207194
208195 ThreadHelper .getSharedExecutor ().execute (new Runnable () {
209196 @ Override
@@ -349,23 +336,7 @@ public static void initCore() throws DaemonException, SuException {
349336
350337 public static void reloadNetworkMapping (){
351338 try {
352- mNetwork = new Network (mContext );
353-
354- Target network = new Target (mNetwork ),
355- gateway = new Target (mNetwork .getGatewayAddress (), mNetwork .getGatewayHardware ()),
356- device = new Target (mNetwork .getLocalAddress (), mNetwork .getLocalHardware ());
357-
358- gateway .setAlias (mNetwork .getSSID ());
359- device .setAlias (android .os .Build .MODEL );
360-
361- synchronized (mTargets ) {
362- mTargets .clear ();
363- mTargets .add (network );
364- mTargets .add (gateway );
365- mTargets .add (device );
366- }
367-
368- mInitialized = true ;
339+ uncaughtReloadNetworkMapping ();
369340 }
370341 catch (NoRouteToHostException nrthe ){
371342 // swallow bitch
@@ -375,6 +346,14 @@ public static void reloadNetworkMapping(){
375346 }
376347 }
377348
349+ private static void uncaughtReloadNetworkMapping () throws UnknownHostException , SocketException {
350+ mNetwork = new Network (mContext );
351+
352+ reset ();
353+
354+ mInitialized = true ;
355+ }
356+
378357 public static boolean checkNetworking (final Activity current ){
379358 if (!Network .isWifiConnected (mContext )){
380359
@@ -917,18 +896,26 @@ else if(name.endsWith(".tiff"))
917896 return type ;
918897 }
919898
920- public static void reset () throws SocketException {
899+ public static void reset () {
921900 mCurrentTarget = null ;
922901
923902 synchronized (mTargets ) {
924903 mTargets .clear ();
925904
926- // local network
927- mTargets .add (new Target (System .getNetwork ()));
928- // network gateway
929- mTargets .add (new Target (System .getNetwork ().getGatewayAddress (), System .getNetwork ().getGatewayHardware ()));
930- // device network address
931- mTargets .add (new Target (System .getNetwork ().getLocalAddress (), System .getNetwork ().getLocalHardware ()));
905+ Target network = new Target (mNetwork ),
906+ gateway = new Target (mNetwork .getGatewayAddress (), mNetwork .getGatewayHardware ()),
907+ device = new Target (mNetwork .getLocalAddress (), mNetwork .getLocalHardware ());
908+
909+ gateway .setAlias (mNetwork .getSSID ());
910+ device .setAlias (android .os .Build .MODEL );
911+
912+ mTargets .add (network );
913+ mTargets .add (gateway );
914+ mTargets .add (device );
915+
916+ for (Target t : mTargets ) {
917+ Services .getNetworkRadar ().onNewTargetFound (t );
918+ }
932919 }
933920 }
934921
@@ -1004,12 +991,13 @@ public static boolean addOrderedTarget(Target target){
1004991 for (int i = 0 ; i < mTargets .size (); i ++) {
1005992 if (mTargets .get (i ).comesAfter (target )) {
1006993 mTargets .add (i , target );
994+ Services .getNetworkRadar ().onNewTargetFound (target );
1007995 return true ;
1008996 }
1009997 }
1010998
1011999 mTargets .add (target );
1012-
1000+ Services . getNetworkRadar (). onNewTargetFound ( target );
10131001 return true ;
10141002 }
10151003 }
0 commit comments