File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
cSploit/src/main/java/org/csploit/android/net Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 2424import android .net .NetworkInfo ;
2525import android .net .wifi .WifiInfo ;
2626import android .net .wifi .WifiManager ;
27+ import android .util .Patterns ;
2728
2829import org .apache .commons .compress .utils .IOUtils ;
2930import org .apache .commons .net .util .SubnetUtils ;
@@ -150,18 +151,29 @@ private static Method getTetheredIfacesMethod(ConnectivityManager connectivityMa
150151
151152 public boolean initNetworkInterface (String iface ) {
152153
154+ InterfaceAddress ifaceAddress = null ;
153155 try {
154156 if (iface == null )
155157 iface = getAvailableInterfaces ().get (0 );
156158
157159 mInterface = NetworkInterface .getByName (iface );
158- InterfaceAddress ifaceAddress ;
159160
160161 if (mInterface .getInterfaceAddresses ().isEmpty ()) {
161162 return false ;
162163 }
163164
164- ifaceAddress = mInterface .getInterfaceAddresses ().get (1 );
165+ for (InterfaceAddress ia : mInterface .getInterfaceAddresses ()) {
166+ if (Patterns .IP_ADDRESS .matcher (ia .getAddress ().getHostAddress ()).matches ()) {
167+ ifaceAddress = ia ;
168+ Logger .warning ("interfaceAddress: " + ia .getAddress ().getHostAddress () + "/" + Short .toString (ia .getNetworkPrefixLength ()));
169+ break ;
170+ }
171+ else
172+ Logger .error ("not valid ip: " + ia .getAddress ().getHostAddress () + "/" + Short .toString (ia .getNetworkPrefixLength ()));
173+ }
174+ if (ifaceAddress == null ){
175+ return false ;
176+ }
165177
166178 SubnetUtils su = new SubnetUtils (
167179 // get(1) == ipv4
You can’t perform that action at this time.
0 commit comments