柬埔寨通 v6.1.5版本的 MD5 值为:9b68581ac30883219d6a25858a099d6b
以下内容为反编译后的 IpScanner.java 源代码,内容仅作参考
package com.snail.antifake.deviceid;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
import com.alipay.sdk.m.u.c;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
public class IpScanner {
private Handler mHandler = new Handler(Looper.getMainLooper());
public interface OnScanListener {
void scan(Map<String, String> map);
}
public void startScan(final OnScanListener onScanListener) {
new ArrayList();
new HashMap();
String hostIP = getHostIP();
if (TextUtils.isEmpty(hostIP)) {
return;
}
final String substring = hostIP.substring(0, hostIP.lastIndexOf(".") + 1);
new Thread(new Runnable() {
@Override
public void run() {
DatagramPacket datagramPacket = new DatagramPacket(new byte[0], 0, 0);
try {
DatagramSocket datagramSocket = new DatagramSocket();
int i = 2;
while (i < 255) {
Log.e("kalshen", "run: udp-" + substring + i);
StringBuilder sb = new StringBuilder();
sb.append(substring);
sb.append(String.valueOf(i));
datagramPacket.setAddress(InetAddress.getByName(sb.toString()));
datagramSocket.send(datagramPacket);
i++;
if (i == 125) {
datagramSocket.close();
datagramSocket = new DatagramSocket();
}
}
datagramSocket.close();
IpScanner.this.execCatForArp(onScanListener);
} catch (SocketException e) {
e.printStackTrace();
} catch (UnknownHostException e2) {
e2.printStackTrace();
} catch (IOException e3) {
e3.printStackTrace();
}
}
}).start();
}
public void execCatForArp(final OnScanListener onScanListener) {
new Thread(new Runnable() {
@Override
public void run() {
try {
final HashMap hashMap = new HashMap();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec("cat proc/net/arp").getInputStream()));
while (true) {
String readLine = bufferedReader.readLine();
if (readLine == null) {
IpScanner.this.mHandler.post(new Runnable() {
@Override
public void run() {
onScanListener.scan(hashMap);
}
});
return;
}
Log.e("kalshen", "run: " + readLine);
if (!readLine.contains(c.a) && !readLine.contains("IP")) {
String[] split = readLine.split("\\s+");
hashMap.put(split[3], split[0]);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
}
private String getHostIP() {
String str = null;
try {
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
while (networkInterfaces.hasMoreElements()) {
Enumeration<InetAddress> inetAddresses = networkInterfaces.nextElement().getInetAddresses();
while (true) {
if (inetAddresses.hasMoreElements()) {
InetAddress nextElement = inetAddresses.nextElement();
if (!(nextElement instanceof Inet6Address) && !"127.0.0.1".equals(nextElement.getHostAddress())) {
str = nextElement.getHostAddress();
break;
}
}
}
}
} catch (SocketException e) {
Log.i("kalshen", "SocketException");
e.printStackTrace();
}
return str;
}
}