导航菜单

页面标题

页面副标题

新暖心缘 v8.1.1 - ComprehensiveSecurityDetector.java 源代码

正在查看: 新暖心缘 v8.1.1 应用的 ComprehensiveSecurityDetector.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.luanxingyuan.app.util;

import android.content.Context;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.ProxyInfo;
import android.os.Build;
import android.os.Debug;
import android.os.Handler;
import android.os.Process;
import android.widget.Toast;
import com.faceunity.core.utils.CameraUtils;
import com.tencent.qcloud.core.util.IOUtils;
import java.io.File;
import java.net.InetSocketAddress;
import java.net.Socket;

public class ComprehensiveSecurityDetector {
    private static final String TAG = "SecurityDetector";
    private static final String[] XPOSED_PACKAGES = {"de.robv.android.xposed.installer", "org.meowcat.edxposed.manager", "io.github.lsposed.manager", "org.lsposed.manager"};
    private static final String[] XPOSED_FILES = {"/system/framework/XposedBridge.jar", "/system/bin/app_process32_xposed", "/system/bin/app_process64_xposed"};

    private static boolean checkMultipleProcesses() {
        if (Debug.isDebuggerConnected()) {
            try {
                Thread.sleep(100L);
                if (Debug.isDebuggerConnected() && Debug.waitingForDebugger()) {
                    System.exit(0);
                    return true;
                }
            } catch (InterruptedException unused) {
                Thread.currentThread().interrupt();
            }
        }
        return false;
    }

    private static boolean checkRootMethod1() {
        String[] strArr = {"/system/app/Superuser.apk", "/sbin/su", "/system/bin/su", "/system/xbin/su", "/data/local/xbin/su", "/data/local/bin/su", "/system/sd/xbin/su", "/system/bin/failsafe/su", "/data/local/su", "/su/bin/su"};
        for (int i8 = 0; i8 < 10; i8++) {
            String str = strArr[i8];
            if (new File(str).exists()) {
                StringBuilder sb = new StringBuilder();
                sb.append("检测到root文件: ");
                sb.append(str);
                System.exit(0);
                return true;
            }
        }
        return false;
    }

    private static boolean checkRootMethod2() {
        try {
            Process exec = Runtime.getRuntime().exec("su");
            exec.getOutputStream().write("exit\n".getBytes());
            exec.getOutputStream().flush();
            if (exec.waitFor() != 0) {
                return false;
            }
            System.exit(0);
            return true;
        } catch (Exception unused) {
            return false;
        }
    }

    private static boolean checkRootMethod3() {
        String str = Build.TAGS;
        if (str == null || !str.contains("test-keys")) {
            return false;
        }
        System.exit(0);
        return true;
    }

    private static boolean detectFridaByFiles() {
        String[] strArr = {"/data/local/tmp/frida-server", "/data/local/tmp/re.frida.server", "/sdcard/frida-server"};
        for (int i8 = 0; i8 < 3; i8++) {
            String str = strArr[i8];
            if (new File(str).exists()) {
                StringBuilder sb = new StringBuilder();
                sb.append("检测到Frida文件: ");
                sb.append(str);
                System.exit(0);
                return true;
            }
        }
        return false;
    }

    private static boolean detectFridaByPort() {
        try {
            Socket socket = new Socket();
            socket.connect(new InetSocketAddress("127.0.0.1", 27042), 100);
            socket.close();
            return true;
        } catch (Exception unused) {
            try {
                Socket socket2 = new Socket();
                socket2.connect(new InetSocketAddress("127.0.0.1", 27043), 100);
                socket2.close();
                System.exit(0);
                return true;
            } catch (Exception unused2) {
                return false;
            }
        }
    }

    private static boolean detectSpecificPackages(Context context, String[] strArr) {
        try {
            PackageManager packageManager = context.getPackageManager();
            for (String str : strArr) {
                try {
                    packageManager.getPackageInfo(str, 1);
                    StringBuilder sb = new StringBuilder();
                    sb.append("启动检测到关键威胁应用: ");
                    sb.append(str);
                    return true;
                } catch (PackageManager.NameNotFoundException unused) {
                }
            }
        } catch (Exception unused2) {
            System.exit(0);
        }
        return false;
    }

    private static boolean detectXposedClasses() {
        try {
            Class.forName("de.robv.android.xposed.XposedBridge");
            System.exit(0);
            return true;
        } catch (ClassNotFoundException unused) {
            return false;
        }
    }

    private static boolean detectXposedFiles() {
        for (String str : XPOSED_FILES) {
            if (new File(str).exists()) {
                StringBuilder sb = new StringBuilder();
                sb.append("检测到Xposed文件: ");
                sb.append(str);
                System.exit(0);
                return true;
            }
        }
        return false;
    }

    private static boolean detectXposedPackages(Context context) {
        try {
            for (String str : XPOSED_PACKAGES) {
                try {
                    context.getPackageManager().getPackageInfo(str, 0);
                    StringBuilder sb = new StringBuilder();
                    sb.append("检测到Xposed包: ");
                    sb.append(str);
                    System.exit(0);
                    return true;
                } catch (Exception unused) {
                }
            }
        } catch (Exception unused2) {
            System.exit(0);
        }
        return false;
    }

    public static String getLaunchSecurityReport(Context context) {
        StringBuilder sb = new StringBuilder();
        sb.append("=== 启动安全检测报告 ===\n");
        sb.append("关键抓包工具: ");
        sb.append(hasCriticalCaptureApps(context) ? "❌" : "✅");
        sb.append(IOUtils.LINE_SEPARATOR_UNIX);
        sb.append("Xposed框架: ");
        sb.append(hasXposedFramework(context) ? "❌" : "✅");
        sb.append(IOUtils.LINE_SEPARATOR_UNIX);
        sb.append("Root权限: ");
        sb.append(isRooted() ? "❌" : "✅");
        sb.append(IOUtils.LINE_SEPARATOR_UNIX);
        sb.append("调试器: ");
        sb.append(hasDebugger() ? "❌" : "✅");
        sb.append(IOUtils.LINE_SEPARATOR_UNIX);
        sb.append("是否可启动: ");
        sb.append(isSafeForLaunch(context) ? "✅" : "❌");
        return sb.toString();
    }

    public static String getSecurityReport(Context context) {
        StringBuilder sb = new StringBuilder();
        sb.append("=== 安全检测报告 ===\n");
        sb.append("Xposed框架: ");
        sb.append(hasXposedFramework(context) ? "❌" : "✅");
        sb.append(IOUtils.LINE_SEPARATOR_UNIX);
        sb.append("代理设置: ");
        sb.append(hasProxy(context) ? "❌" : "✅");
        sb.append(IOUtils.LINE_SEPARATOR_UNIX);
        sb.append("调试器: ");
        sb.append(hasDebugger() ? "❌" : "✅");
        sb.append(IOUtils.LINE_SEPARATOR_UNIX);
        sb.append("VPN: ");
        sb.append(hasVPN(context) ? "❌" : "✅");
        sb.append(IOUtils.LINE_SEPARATOR_UNIX);
        sb.append("抓包工具: ");
        sb.append(hasPacketCaptureApp(context) ? "❌" : "✅");
        sb.append(IOUtils.LINE_SEPARATOR_UNIX);
        sb.append("Root权限: ");
        sb.append(isRooted() ? "❌" : "✅");
        sb.append(IOUtils.LINE_SEPARATOR_UNIX);
        sb.append("Frida工具: ");
        sb.append(isFridaDetected() ? "❌" : "✅");
        sb.append(IOUtils.LINE_SEPARATOR_UNIX);
        sb.append("多进程调试: ");
        sb.append(isMultiProcess() ? "❌" : "✅");
        sb.append(IOUtils.LINE_SEPARATOR_UNIX);
        sb.append("整体安全: ");
        sb.append(isCompletelySafe(context) ? "✅" : "❌");
        return sb.toString();
    }

    public static void handleLaunchUnsafeEnvironment(Context context) {
        String launchSecurityReport = getLaunchSecurityReport(context);
        StringBuilder sb = new StringBuilder();
        sb.append("应用启动被阻止:\n");
        sb.append(launchSecurityReport);
        try {
            Toast.makeText(context, "检测到不安全环境,应用无法启动\n", 1).show();
            new Handler().postDelayed(new Runnable() {
                @Override
                public final void run() {
                    ComprehensiveSecurityDetector.lambda$handleLaunchUnsafeEnvironment$1();
                }
            }, 3000L);
        } catch (Exception unused) {
            Process.killProcess(Process.myPid());
            System.exit(0);
        }
    }

    public static void handleUnsafeEnvironment(Context context, String str) {
        StringBuilder sb = new StringBuilder();
        sb.append("安全威胁: ");
        sb.append(str);
        try {
            Toast.makeText(context, "安全检测失败: " + str, 1).show();
            new Handler().postDelayed(new Runnable() {
                @Override
                public final void run() {
                    System.exit(0);
                }
            }, CameraUtils.FOCUS_TIME);
        } catch (Exception unused) {
            System.exit(0);
        }
    }

    private static boolean hasCriticalCaptureApps(Context context) {
        return detectSpecificPackages(context, new String[]{"com.guoshi.httpcanary", "com.guoshi.httpcanary.premium", "com.guoshi.httpcanary.beta", "com.reqable.android", "com.rrr.android.sec", "app.grapheneos.glyph", "com.parrot.tools", "org.proxydroid", "com.tunnelworkshop.postern", "com.android.proxymanager", "com.wireguard.android", "org.pcap4j", "com.lechapps.cctva", "com.manichord.mgmt", "com.evozi", "bin.mt.plus", "com.termux", "com.topjohnwu.magisk", "me.weishu.exp", "org.meowcat.edxposed.manager", "io.github.lsposed.manager", "com.anydesk.anydeskandroid", "com.teamviewer.quicksupport.market"});
    }

    static boolean hasDebugger() {
        boolean z7 = Debug.isDebuggerConnected() || Debug.waitingForDebugger();
        if (z7) {
            System.exit(0);
        }
        return z7;
    }

    public static boolean hasPacketCaptureApp(Context context) {
        String[] strArr = {"com.guoshi.httpcanary", "com.reqable.android", "com.guoshi.httpcanary.premium", "com.guoshi.httpcanary.beta", "com.reqable.android"};
        try {
            PackageManager packageManager = context.getPackageManager();
            for (int i8 = 0; i8 < 5; i8++) {
                String str = strArr[i8];
                try {
                    packageManager.getPackageInfo(str, 1);
                    StringBuilder sb = new StringBuilder();
                    sb.append("检测到抓包工具: ");
                    sb.append(str);
                    System.exit(0);
                    return true;
                } catch (PackageManager.NameNotFoundException unused) {
                }
            }
        } catch (Exception unused2) {
            System.exit(0);
        }
        return false;
    }

    static boolean hasProxy(Context context) {
        return isProxyEnabled() || isUsingSystemProxy(context);
    }

    static boolean hasVPN(Context context) {
        try {
            ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
            if (connectivityManager != null && connectivityManager.getNetworkInfo(17) != null && connectivityManager.getNetworkInfo(17).isConnected()) {
                System.exit(0);
                return true;
            }
        } catch (Exception unused) {
            System.exit(0);
        }
        return false;
    }

    static boolean hasXposedFramework(Context context) {
        return detectXposedPackages(context) || detectXposedFiles() || detectXposedClasses();
    }

    public static boolean isCompletelySafe(Context context) {
        return (hasXposedFramework(context) || hasProxy(context) || hasDebugger() || hasVPN(context) || hasPacketCaptureApp(context) || isRooted() || isFridaDetected() || isMultiProcess()) ? false : true;
    }

    public static boolean isFridaDetected() {
        return detectFridaByPort() || detectFridaByFiles();
    }

    public static boolean isMultiProcess() {
        return checkMultipleProcesses();
    }

    private static boolean isProxyEnabled() {
        throw new UnsupportedOperationException("Method not decompiled: com.luanxingyuan.app.util.ComprehensiveSecurityDetector.isProxyEnabled():boolean");
    }

    public static boolean isRooted() {
        return checkRootMethod1() || checkRootMethod2() || checkRootMethod3();
    }

    public static boolean isSafeForLaunch(Context context) {
        return (hasCriticalCaptureApps(context) || hasXposedFramework(context) || isRooted() || hasDebugger()) ? false : true;
    }

    private static boolean isUsingSystemProxy(Context context) {
        ProxyInfo defaultProxy;
        try {
            if (Build.VERSION.SDK_INT >= 23) {
                ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
                if (connectivityManager != null) {
                    defaultProxy = connectivityManager.getDefaultProxy();
                    if (defaultProxy != null) {
                        System.exit(0);
                        return true;
                    }
                }
            } else {
                String str = (String) Class.forName("android.os.SystemProperties").getMethod("get", String.class).invoke(null, "http.proxyHost");
                if (str != null && !str.isEmpty()) {
                    StringBuilder sb = new StringBuilder();
                    sb.append("检测到系统代理: ");
                    sb.append(str);
                    System.exit(0);
                    return true;
                }
            }
        } catch (Exception unused) {
            System.exit(0);
        }
        return false;
    }

    public static void lambda$handleLaunchUnsafeEnvironment$1() {
        Process.killProcess(Process.myPid());
        System.exit(0);
    }
}