畅玩新葡京 v8.2.8版本的 MD5 值为:1e36e0a7adef719a26e0a466b52c398d
以下内容为反编译后的 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 androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
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 AnonymousClass1 {
}
public class ClientThread extends Thread {
String a;
int b;
private ClientThread(String str, int i) {
this.a = str;
this.b = i;
}
ClientThread(VirtualApkCheckUtil virtualApkCheckUtil, String str, int i, AnonymousClass1 anonymousClass1) {
this(str, i);
}
@Override
public void run() {
super.run();
try {
Socket socket = new Socket("127.0.0.1", this.b);
socket.setSoTimeout(2000);
OutputStream outputStream = socket.getOutputStream();
outputStream.write((this.a + "\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;
}
String str = VirtualApkCheckUtil.this.TAG;
Log.i(str, "ClientThread: " + readLine);
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ConnectException unused) {
String str2 = VirtualApkCheckUtil.this.TAG;
Log.i(str2, this.b + "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[AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD];
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();
}
}
ReadThread(VirtualApkCheckUtil virtualApkCheckUtil, String str, Socket socket, VirtualCheckCallback virtualCheckCallback, AnonymousClass1 anonymousClass1) {
this(str, socket, virtualCheckCallback);
}
}
class ServerThread extends Thread {
String a;
VirtualCheckCallback b;
private ServerThread(String str, VirtualCheckCallback virtualCheckCallback) {
this.a = str;
this.b = virtualCheckCallback;
}
ServerThread(VirtualApkCheckUtil virtualApkCheckUtil, String str, VirtualCheckCallback virtualCheckCallback, AnonymousClass1 anonymousClass1) {
this(str, virtualCheckCallback);
}
@Override
public void run() {
super.run();
VirtualApkCheckUtil.this.startServer(this.a, this.b);
}
}
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("uid");
int lastIndexOf2 = exec.lastIndexOf("/pid");
if (lastIndexOf < 0) {
return null;
}
if (lastIndexOf2 <= 0) {
lastIndexOf2 = exec.length();
}
try {
String replaceAll = exec.substring(lastIndexOf + 4, lastIndexOf2).replaceAll("\n", "");
if (isNumber(replaceAll)) {
return String.format("u0_a%d", Integer.valueOf(Integer.valueOf(replaceAll).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(this, str, ((Integer) it.next()).intValue(), null).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(this, str, serverSocket.accept(), virtualCheckCallback, null).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) {
virtualCheckCallback.findSuspect();
return true;
}
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(" ");
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;
try {
bufferedReader = new BufferedReader(new FileReader("/proc/self/maps"));
} catch (Exception unused) {
bufferedReader = null;
} catch (Throwable th) {
th = th;
bufferedReader = null;
}
while (true) {
try {
String readLine = bufferedReader.readLine();
if (readLine != null) {
String[] strArr = this.virtualPkgs;
int length = strArr.length;
int i = 0;
while (true) {
if (i < length) {
if (readLine.contains(strArr[i])) {
break;
}
i++;
}
}
}
} catch (Exception unused2) {
} catch (Throwable th2) {
th = th2;
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (IOException unused3) {
}
}
throw th;
}
try {
break;
} catch (IOException unused4) {
return false;
}
}
}
public boolean checkByOriginApkPackageName(Context context, VirtualCheckCallback virtualCheckCallback) {
try {
if (context != null) {
String packageName = context.getPackageName();
int i = 0;
for (PackageInfo packageInfo : context.getPackageManager().getInstalledPackages(0)) {
if (packageName.equals(packageInfo.packageName)) {
i++;
}
}
if (i > 1 && virtualCheckCallback != null) {
virtualCheckCallback.findSuspect();
}
return i > 1;
}
throw new IllegalArgumentException("you have to set context first");
} catch (Exception unused) {
return false;
}
}
@Deprecated
public void checkByPortListening(String str, VirtualCheckCallback virtualCheckCallback) {
startClient(str);
new ServerThread(this, str, virtualCheckCallback, null).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) {
virtualCheckCallback.findSuspect();
return true;
}
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();
}
}