Auto clicker v2.8.5版本的 MD5 值为:23db090d65f60ed8999bca7ef16207e2
以下内容为反编译后的 VirtualApkCheckUtil.java 源代码,内容仅作参考
package com.lahm.library;
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.net.LocalServerSocket;
import android.text.TextUtils;
import android.util.Log;
import com.alipay.sdk.m.p0.c;
import com.baidu.android.common.util.HanziToPinyin;
import com.baidu.mobstat.Config;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.BindException;
import java.net.ConnectException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Locale;
import java.util.Random;
public class VirtualApkCheckUtil {
private static volatile VirtualApkCheckUtil singleInstance;
private volatile LocalServerSocket localServerSocket;
private String TAG = "test";
private String[] virtualPkgs = {"com.bly.dkplat", "com.by.chaos", "com.lbe.parallel", "com.excelliance.dualaid", "com.lody.virtual", "com.qihoo.magic"};
public class ClientThread extends Thread {
int port;
String secret;
private ClientThread(String str, int i) {
this.secret = str;
this.port = i;
}
@Override
public void run() {
super.run();
try {
Socket socket = new Socket("127.0.0.1", this.port);
socket.setSoTimeout(c.n);
OutputStream outputStream = socket.getOutputStream();
outputStream.write((this.secret + "\n").getBytes("utf-8"));
outputStream.flush();
socket.shutdownOutput();
InputStream inputStream = socket.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
while (true) {
String readLine = bufferedReader.readLine();
if (readLine == null) {
bufferedReader.close();
inputStream.close();
socket.close();
return;
} else {
Log.i(VirtualApkCheckUtil.this.TAG, "ClientThread: " + readLine);
}
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ConnectException unused) {
Log.i(VirtualApkCheckUtil.this.TAG, this.port + "port refused");
} catch (SocketException e2) {
e2.printStackTrace();
} catch (UnknownHostException e3) {
e3.printStackTrace();
} catch (IOException e4) {
e4.printStackTrace();
}
}
}
public class ReadThread extends Thread {
private ReadThread(String str, Socket socket, VirtualCheckCallback virtualCheckCallback) {
try {
InputStream inputStream = socket.getInputStream();
byte[] bArr = new byte[4096];
while (true) {
int read = inputStream.read(bArr);
if (read == -1) {
inputStream.close();
socket.close();
return;
} else if (new String(bArr, 0, read).contains(str) && virtualCheckCallback != null) {
virtualCheckCallback.findSuspect();
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
private class ServerThread extends Thread {
VirtualCheckCallback callback;
String secret;
private ServerThread(String str, VirtualCheckCallback virtualCheckCallback) {
this.secret = str;
this.callback = virtualCheckCallback;
}
@Override
public void run() {
super.run();
VirtualApkCheckUtil.this.startServer(this.secret, this.callback);
}
}
private VirtualApkCheckUtil() {
}
public static VirtualApkCheckUtil getSingleInstance() {
if (singleInstance == null) {
synchronized (VirtualApkCheckUtil.class) {
if (singleInstance == null) {
singleInstance = new VirtualApkCheckUtil();
}
}
}
return singleInstance;
}
private String getUidStrFormat() {
String exec = CommandUtil.getSingleInstance().exec("cat /proc/self/cgroup");
if (exec != null && exec.length() != 0) {
int lastIndexOf = exec.lastIndexOf(Config.CUSTOM_USER_ID);
int lastIndexOf2 = exec.lastIndexOf("/pid");
if (lastIndexOf < 0) {
return null;
}
if (lastIndexOf2 <= 0) {
lastIndexOf2 = exec.length();
}
try {
if (isNumber(exec.substring(lastIndexOf + 4, lastIndexOf2).replaceAll("\n", ""))) {
return String.format("u0_a%d", Integer.valueOf(Integer.valueOf(r0).intValue() - 10000));
}
return null;
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
private boolean isNumber(String str) {
if (str == null || str.length() == 0) {
return false;
}
for (int i = 0; i < str.length(); i++) {
if (!Character.isDigit(str.charAt(i))) {
return false;
}
}
return true;
}
private void startClient(String str) {
String exec = CommandUtil.getSingleInstance().exec("cat /proc/net/tcp6");
if (TextUtils.isEmpty(exec)) {
return;
}
String[] split = exec.split("\n");
ArrayList arrayList = new ArrayList();
int length = split.length;
for (int i = 0; i < length; i++) {
int indexOf = split[i].indexOf("0100007F:");
if (indexOf >= 0) {
arrayList.add(Integer.valueOf(Integer.parseInt(split[i].substring(indexOf + 9, indexOf + 13), 16)));
}
}
if (arrayList.isEmpty()) {
return;
}
Iterator it = arrayList.iterator();
while (it.hasNext()) {
new ClientThread(str, ((Integer) it.next()).intValue()).start();
}
}
public void startServer(String str, VirtualCheckCallback virtualCheckCallback) {
Random random = new Random();
try {
ServerSocket serverSocket = new ServerSocket();
serverSocket.bind(new InetSocketAddress("127.0.0.1", random.nextInt(55534) + 10000));
while (true) {
new ReadThread(str, serverSocket.accept(), virtualCheckCallback).start();
}
} catch (BindException unused) {
startServer(str, virtualCheckCallback);
} catch (IOException e) {
e.printStackTrace();
}
}
public boolean checkByCreateLocalServerSocket(String str, VirtualCheckCallback virtualCheckCallback) {
if (this.localServerSocket != null) {
return false;
}
try {
this.localServerSocket = new LocalServerSocket(str);
return false;
} catch (IOException unused) {
if (virtualCheckCallback == null) {
return true;
}
virtualCheckCallback.findSuspect();
return true;
}
}
public boolean checkByHasSameUid(VirtualCheckCallback virtualCheckCallback) {
String[] split;
String uidStrFormat = getUidStrFormat();
if (TextUtils.isEmpty(uidStrFormat)) {
return false;
}
String exec = CommandUtil.getSingleInstance().exec("ps");
if (TextUtils.isEmpty(exec) || (split = exec.split("\n")) == null || split.length <= 0) {
return false;
}
int i = 0;
for (int i2 = 0; i2 < split.length; i2++) {
if (split[i2].contains(uidStrFormat)) {
int lastIndexOf = split[i2].lastIndexOf(HanziToPinyin.Token.SEPARATOR);
if (new File(String.format("/data/data/%s", split[i2].substring(lastIndexOf <= 0 ? 0 : lastIndexOf + 1, split[i2].length()), Locale.CHINA)).exists()) {
i++;
}
}
}
if (i > 1 && virtualCheckCallback != null) {
virtualCheckCallback.findSuspect();
}
return i > 1;
}
public boolean checkByMultiApkPackageName(VirtualCheckCallback virtualCheckCallback) {
BufferedReader bufferedReader = null;
try {
try {
BufferedReader bufferedReader2 = new BufferedReader(new FileReader("/proc/self/maps"));
loop0: while (true) {
try {
String readLine = bufferedReader2.readLine();
if (readLine == null) {
bufferedReader2.close();
break;
}
for (String str : this.virtualPkgs) {
if (readLine.contains(str)) {
break loop0;
}
}
} catch (Exception unused) {
bufferedReader = bufferedReader2;
if (bufferedReader != null) {
bufferedReader.close();
}
return false;
} catch (Throwable th) {
th = th;
bufferedReader = bufferedReader2;
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (IOException unused2) {
}
}
throw th;
}
}
} catch (IOException unused3) {
}
} catch (Exception unused4) {
} catch (Throwable th2) {
th = th2;
}
return false;
}
public boolean checkByOriginApkPackageName(Context context, VirtualCheckCallback virtualCheckCallback) {
try {
if (context == null) {
throw new IllegalArgumentException("you have to set context first");
}
String packageName = context.getPackageName();
Iterator<PackageInfo> it = context.getPackageManager().getInstalledPackages(0).iterator();
int i = 0;
while (it.hasNext()) {
if (packageName.equals(it.next().packageName)) {
i++;
}
}
if (i > 1 && virtualCheckCallback != null) {
virtualCheckCallback.findSuspect();
}
return i > 1;
} catch (Exception unused) {
return false;
}
}
@Deprecated
public void checkByPortListening(String str, VirtualCheckCallback virtualCheckCallback) {
startClient(str);
new ServerThread(str, virtualCheckCallback).start();
}
public boolean checkByPrivateFilePath(Context context, VirtualCheckCallback virtualCheckCallback) {
String path = context.getFilesDir().getPath();
for (String str : this.virtualPkgs) {
if (path.contains(str)) {
if (virtualCheckCallback == null) {
return true;
}
virtualCheckCallback.findSuspect();
return true;
}
}
return false;
}
public String checkByTopActivity(Context context) {
return ((ActivityManager) context.getSystemService("activity")).getRunningTasks(1).get(0).topActivity.getClassName();
}
public String checkByTopTask(Context context) {
return ((ActivityManager) context.getSystemService("activity")).getRunningTasks(1).get(0).topActivity.getPackageName();
}
}