unidbg-点评补设备环境

这篇具有很好参考价值的文章主要介绍了unidbg-点评补设备环境。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

package com.jniunidbg.part7;

import com.github.unidbg.AndroidEmulator;
import com.github.unidbg.Module;
import com.github.unidbg.linux.android.AndroidEmulatorBuilder;
import com.github.unidbg.linux.android.AndroidResolver;
import com.github.unidbg.linux.android.dvm.*;
import com.github.unidbg.linux.android.dvm.api.SystemService;
import com.github.unidbg.memory.Memory;

import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.UUID;

public class DianPing extends AbstractJni {
    private final AndroidEmulator emulator;
    private final VM vm;
    private final Module module;
    private DvmObject SIUACollector;
    public FileInputStream fileInputStream;
    public InputStreamReader inputStreamReader;
    public BufferedReader bufferedReader;
    private SimpleDateFormat simpleDateFormat;

    DianPing() {

        // 创建模拟器实例
        emulator = AndroidEmulatorBuilder.for32Bit().setRootDir(new File("target/rootfs")).build();

        // 模拟器的内存操作接口
        final Memory memory = emulator.getMemory();
        // 设置系统类库解析
        memory.setLibraryResolver(new AndroidResolver(23));
        // 创建Android虚拟机
        vm = emulator.createDalvikVM(new File("unidbg-android/src/test/resources/lession2/part7/dazhongdianping.apk"));

        vm.setJni(this);
        vm.setVerbose(true);

        DalvikModule dm = vm.loadLibrary("mtguard", true);
        // 加载好的 libhookinunidbg.so对应为一个模块
        module = dm.getModule();

        // 执行JNIOnLoad(如果有的话)
        dm.callJNI_OnLoad(emulator);

        SIUACollector = vm.resolveClass("com/meituan/android/common/mtguard/NBridge$SIUACollector").newObject(null);
    }

    public static void main(String[] args) {
        DianPing dp = new DianPing();
        System.out.println("call getHWProperty");
        dp.getHWProperty();
        System.out.println("call getHWStatus");
        dp.getHWStatus();
        System.out.println("call getHWEquipmentInfo");
        dp.getHWEquipmentInfo();
        System.out.println("call getExternalEquipmentInfo");
        dp.getExternalEquipmentInfo();
        System.out.println("call getUserAction");
        dp.getUserAction();
        System.out.println("call getEnvironmentInfo");
        dp.getEnvironmentInfo();
        System.out.println("call getEnvironmentInfoExtra");
        dp.getEnvironmentInfoExtra();
        System.out.println("call getPlatformInfo");
        dp.getPlatformInfo();
        System.out.println("call getLocationInfo");
        dp.getLocationInfo();
        System.out.println("call startCollection");
        String result = dp.startCollection();
        System.out.println(result);
    }

    public String getHWProperty(){
        String ret = (String) SIUACollector.callJniMethodObject(emulator, "getHWProperty()Ljava/lang/String;").getValue();
        System.out.println("getHWProperty:"+ret);
        return ret;
    }

    public String getHWStatus(){
        String ret = (String) SIUACollector.callJniMethodObject(emulator, "getHWStatus()Ljava/lang/String;").getValue();
        System.out.println("getHWStatus:"+ret);
        return ret;
    }

    public String getHWEquipmentInfo(){
        String ret = (String) SIUACollector.callJniMethodObject(emulator, "getHWEquipmentInfo()Ljava/lang/String;").getValue();
        System.out.println("getHWEquipmentInfo:"+ret);
        return ret;
    }

    public String  getExternalEquipmentInfo(){
        String ret = (String) SIUACollector.callJniMethodObject(emulator, "getExternalEquipmentInfo()Ljava/lang/String;").getValue();
        System.out.println("getExternalEquipmentInfo:"+ret);
        return ret;
    }

    public String getUserAction(){
        String ret = (String) SIUACollector.callJniMethodObject(emulator, "getUserAction()Ljava/lang/String;").getValue();
        System.out.println("getUserAction:"+ret);
        return ret;
    }

    public String getEnvironmentInfo(){
        String ret = (String) SIUACollector.callJniMethodObject(emulator, "getEnvironmentInfo()Ljava/lang/String;").getValue();
        System.out.println("getEnvironmentInfo:"+ret);
        emulator.set("getEnvironmentInfo", ret);
        return ret;
    }

    public String getEnvironmentInfoExtra(){
        String ret = (String) SIUACollector.callJniMethodObject(emulator, "getEnvironmentInfoExtra()Ljava/lang/String;").getValue();
        System.out.println("getEnvironmentInfoExtra:"+ret);
        return ret;
    }

    public String getPlatformInfo(){
        String ret = (String) SIUACollector.callJniMethodObject(emulator, "getPlatformInfo()Ljava/lang/String;").getValue();
        System.out.println("getPlatformInfo:"+ret);
        return ret;
    }

    public String getLocationInfo(){
        String ret = (String) SIUACollector.callJniMethodObject(emulator, "getLocationInfo()Ljava/lang/String;").getValue();
        System.out.println("getLocationInfo:"+ret);
        return ret;
    }

    public String startCollection(){
        String ret = (String) SIUACollector.callJniMethodObject(emulator, "startCollection()Ljava/lang/String;").getValue();
        System.out.println("startCollection:"+ret);
        return ret;
    }

    @Override
    public DvmObject<?> getObjectField(BaseVM vm, DvmObject<?> dvmObject, String signature) {
        switch (signature){
            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->mContext:Landroid/content/Context;":{
                return vm.resolveClass("android/content/Context").newObject(null);
            }
            case "android/content/res/Configuration->locale:Ljava/util/Locale;":{
                return vm.resolveClass("java/util/Locale").newObject(Locale.getDefault());
            }
            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->batteryHelper:Lcom/meituan/android/common/dfingerprint/collection/utils/BatteryHelper;":{
                return vm.resolveClass("com/meituan/android/common/dfingerprint/collection/utils/BatteryHelper").newObject(null);
            }
        }
        return super.getObjectField(vm, dvmObject, signature);
    }

    @Override
    public DvmObject<?> allocObject(BaseVM vm, DvmClass dvmClass, String signature) {
        switch (signature){
            case "java/lang/StringBuilder->allocObject":{
                return dvmClass.newObject(new StringBuilder());
            }
            case "java/io/File->allocObject":{
                return dvmClass.newObject(null);
            }
            case "java/io/BufferedReader->allocObject":{
                return dvmClass.newObject(null);
            }
            case "java/io/InputStreamReader->allocObject":{
                return dvmClass.newObject(null);
            }
            case "java/io/FileInputStream->allocObject":{
                return dvmClass.newObject(null);
            }
            case "java/text/SimpleDateFormat->allocObject":{
                return dvmClass.newObject(null);
            }
            case "java/util/Date->allocObject":{
                return dvmClass.newObject(null);
            }
        }
        return super.allocObject(vm, dvmClass, signature);
    }

    @Override
    public void callVoidMethodV(BaseVM vm, DvmObject<?> dvmObject, String signature, VaList vaList) {
        switch (signature){
            case "java/lang/StringBuilder-><init>()V":
                return;

            case "java/io/File-><init>(Ljava/lang/String;)V":{
                String filePath = vaList.getObjectArg(0).getValue().toString();
                System.out.println("File init:"+filePath);
                emulator.set(dvmObject.toString(), filePath);
                return;
            }
            case "java/io/FileInputStream-><init>(Ljava/lang/String;)V":{
                String input = vaList.getObjectArg(0).getValue().toString();
                if(input.equals("/proc/cpuinfo")){
                    try {
                        fileInputStream = new FileInputStream("unidbg-android/src/test/resources/lession2/part7/cpuinfo");
                    } catch (FileNotFoundException e) {
                        e.printStackTrace();
                    }
                    return;
                }
                System.out.println("FileInputStream init:"+input);
            }
            case "java/io/InputStreamReader-><init>(Ljava/io/InputStream;)V":{
                inputStreamReader = new InputStreamReader(fileInputStream);
                return;
            }
            case "java/io/BufferedReader-><init>(Ljava/io/Reader;)V":{
                bufferedReader = new BufferedReader(inputStreamReader);
                return;
            }
            case "java/io/BufferedReader->close()V":{
                try {
                    bufferedReader.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                return;
            }
            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->safeClose(Ljava/io/Closeable;)V":{
                return;
            }
            case "java/text/SimpleDateFormat-><init>(Ljava/lang/String;Ljava/util/Locale;)V":{
                String str = vaList.getObjectArg(0).getValue().toString();
                Locale locale = (Locale) vaList.getObjectArg(1).getValue();
                simpleDateFormat = new SimpleDateFormat(str, locale);
                return;
            }
            case "java/util/Date-><init>()V":{
                return;
            }
        }
        super.callVoidMethodV(vm, dvmObject, signature, vaList);
    }

    @Override
    public DvmObject<?> getStaticObjectField(BaseVM vm, DvmClass dvmClass, String signature) {
        switch (signature){
            // 主板
            case "android/os/Build->BOARD:Ljava/lang/String;":{
                return new StringObject(vm, "sdm845");
            }
            case "android/os/Build->MANUFACTURER:Ljava/lang/String;":{
                return new StringObject(vm, "Xiaomi");
            }
            // 品牌
            case "android/os/Build->BRAND:Ljava/lang/String;":{
                return new StringObject(vm, "Xiaomi");
            }

            case "android/os/Build->MODEL:Ljava/lang/String;":{
                return new StringObject(vm, "MIX 2S");
            }
            case "android/os/Build->PRODUCT:Ljava/lang/String;":{
                return new StringObject(vm, "polaris");
            }
            case "android/os/Build->HARDWARE:Ljava/lang/String;":{
                return new StringObject(vm, "qcom");
            }
            case "android/os/Build->DEVICE:Ljava/lang/String;":{
                return new StringObject(vm, "polaris");
            }
            case "android/os/Build->HOST:Ljava/lang/String;":{
                return new StringObject(vm, "c3-miui-ota-bd134.bj");
            }
            case "android/os/Build->ID:Ljava/lang/String;":{
                return new StringObject(vm, "QKQ1.190828.002");
            }
            case "android/os/Build$VERSION->RELEASE:Ljava/lang/String;":{
                return new StringObject(vm, "10");
            }
            case "android/os/Build->TAGS:Ljava/lang/String;":{
                return new StringObject(vm, "release-keys");
            }
            case "android/os/Build->FINGERPRINT:Ljava/lang/String;":{
                return new StringObject(vm, "Xiaomi/polaris/polaris:10/QKQ1.190828.002/V12.0.2.0.QDGCNXM:user/release-keys");
            }
            case "android/os/Build->TYPE:Ljava/lang/String;":{
                return new StringObject(vm, "user");
            }
            case "android/os/Build$VERSION->SDK:Ljava/lang/String;":{
                return new StringObject(vm, "29");
            }
        }
        return super.getStaticObjectField(vm, dvmClass, signature);
    }

    @Override
    public DvmObject<?> callObjectMethodV(BaseVM vm, DvmObject<?> dvmObject, String signature, VaList vaList) {
        switch (signature){
            // copy from jadx
            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->checkBuildAttribute(Ljava/lang/String;)Ljava/lang/String;":{
                String str = vaList.getObjectArg(0).getValue().toString();
                return new StringObject(vm, (str.isEmpty() || str.equalsIgnoreCase("unknown")) ? CommonConstant.Symbol.MINUS : str);
            }
            case "java/lang/StringBuilder->append(Ljava/lang/String;)Ljava/lang/StringBuilder;":{
                StringBuilder stringBuilder = (StringBuilder) dvmObject.getValue();
                String arg1 = vaList.getObjectArg(0).getValue().toString();
                return vm.resolveClass("java/lang/StringBuilder").newObject(stringBuilder.append(arg1));
            }
            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->getSysProp(Ljava/lang/String;)Ljava/lang/String;":{
                String prop = vaList.getObjectArg(0).getValue().toString();
                System.out.println("getSysProp:"+prop);
                // abi
                if(prop.equals("ro.product.cpu.abi")){
                    return new StringObject(vm, "arm64-v8a");
                }
                if(prop.equals("ro.product.cpu.abi2")){
                    return new StringObject(vm, "");
                }
                if(prop.equals("ro.build.product")){
                    return new StringObject(vm, "polaris");
                }
                if(prop.equals("ro.build.description")){
                    return new StringObject(vm, "polaris-user 10 QKQ1.190828.002 V12.0.2.0.QDGCNXM release-keys");
                }
                // root
                if(prop.equals("ro.secure")){
                    return new StringObject(vm, "1");
                }
                // debug
                if(prop.equals("ro.debuggable")){
                    return new StringObject(vm, "1");
                }
                // 查看当前手机USB功能角色
                if(prop.equals("persist.sys.usb.config")){
                    return new StringObject(vm, "");
                }
                if(prop.equals("sys.usb.config")){
                    return new StringObject(vm, "adb");
                }
                if(prop.equals("sys.usb.state")){
                    return new StringObject(vm, "adb");
                }
                // 基带
                if(prop.equals("gsm.version.baseband")){
                    return new StringObject(vm, "4.0.c2.6-00335-0914_2350_3c8fca6,4.0.c2.6-00335-0914_2350_3c8fca6");
                }
                if(prop.equals("gsm.version.ril-impl")){
                    return new StringObject(vm, "Qualcomm RIL 1.0");
                }
                if(prop.equals("gsm.sim.state")){
                    return new StringObject(vm, "ABSENT,ABSENT");
                }
                if(prop.equals("gsm.sim.state.2")){
                    return new StringObject(vm, "");
                }
                if(prop.equals("wifi.interface")){
                    return new StringObject(vm, "wlan0");
                }

            }
            case "android/content/Context->getResources()Landroid/content/res/Resources;":{
                return vm.resolveClass("android/content/res/Resources").newObject(null);
            }

            case "android/content/res/Resources->getConfiguration()Landroid/content/res/Configuration;":{
                return vm.resolveClass("android/content/res/Configuration").newObject(null);
            }

            case "java/lang/StringBuilder->toString()Ljava/lang/String;":{
                StringBuilder stringBuilder = (StringBuilder) dvmObject.getValue();
                return new StringObject(vm, stringBuilder.toString());
            }
            case "java/lang/StringBuilder->append(I)Ljava/lang/StringBuilder;":{
                StringBuilder stringBuilder = (StringBuilder) dvmObject.getValue();
                int i = vaList.getIntArg(0);
                return vm.resolveClass("java/lang/StringBuilder").newObject(stringBuilder.append(i));
            }
            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->getCpuInfoType()Ljava/lang/String;":{
                return new StringObject(vm, "arm");
            }
            case "java/io/BufferedReader->readLine()Ljava/lang/String;":{
                String oneLine = null;
                try {
                    oneLine = bufferedReader.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }

                System.out.println("bufferread readLine:"+oneLine);
                if(oneLine==null){
                    return null;
                }
                return new StringObject(vm, oneLine);
            }
            case "java/lang/String->substring(I)Ljava/lang/String;":{
                String str = dvmObject.getValue().toString();
                return new StringObject(vm, str.substring(vaList.getIntArg(0)));
            }
            case "android/content/Context->getApplicationContext()Landroid/content/Context;":{
                return vm.resolveClass("android/content/Context").newObject(null);
            }
            case "android/content/Context->getSystemService(Ljava/lang/String;)Ljava/lang/Object;":{
                StringObject serviceName = vaList.getObjectArg(0);
                assert serviceName != null;
                if(serviceName.getValue().equals("window")){
                    return vm.resolveClass("android/view/WindowManager").newObject(null);
                }
                return new SystemService(vm, serviceName.getValue());
            }
            case "android/hardware/SensorManager->getDefaultSensor(I)Landroid/hardware/Sensor;":{
                return vm.resolveClass("android/hardware/Sensor").newObject(vaList.getIntArg(0));
            }
            case "android/hardware/Sensor->getName()Ljava/lang/String;":{
                int tag = (int) dvmObject.getValue();
                System.out.println(tag);
                if(tag==1){
                    return new StringObject(vm, "ICM20690");
                }
                if(tag==9){
                    return new StringObject(vm, "gravity  Non-wakeup");
                }
            }
            case "android/hardware/Sensor->getVendor()Ljava/lang/String;":{
                int tag = (int) dvmObject.getValue();
                if(tag==1){
                    return new StringObject(vm, "qualcomm");
                }else if(tag==9){
                    return new StringObject(vm, "qualcomm");
                }
            }
            case "android/view/WindowManager->getDefaultDisplay()Landroid/view/Display;":{
                return vm.resolveClass("android/view/Display").newObject(signature);
            }
            case "java/lang/StringBuilder->append(C)Ljava/lang/StringBuilder;":{
                StringBuilder stringBuilder = (StringBuilder) dvmObject.getValue();
                char c = (char) vaList.getIntArg(0);
                return vm.resolveClass("java/lang/StringBuilder").newObject(stringBuilder.append(c));
            }
            // 建议frida hook
            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->getTotalInternalMemorySize()Ljava/lang/String;":{
                return new StringObject(vm, "21379328");
            }
            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->getTotalExternalMemorySize()Ljava/lang/String;":{
                return new StringObject(vm, "124345246");
            }
            case "android/telephony/TelephonyManager->getSimOperator()Ljava/lang/String;":{
                return new StringObject(vm, "46009");
            }
            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->getAccessSubType()Ljava/lang/String;":{
                return new StringObject(vm, "wifi");
            }
            case "java/util/UUID->toString()Ljava/lang/String;":{
                UUID uuid = (UUID) dvmObject.getValue();
                return new StringObject(vm, uuid.toString());
            }
            // 建议frida hook 或者 jnitrace查看
            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->getDataActivity(Landroid/content/Context;)Ljava/lang/String;":{
                return new StringObject(vm, "");
            }

            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->getEnvironmentInfo()Ljava/lang/String;":{
                return new StringObject(vm, (String) emulator.get("getEnvironmentInfo"));
            }
            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->isVPN()Ljava/lang/String;":{
                return new StringObject(vm, "0");
            }
            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->brightness(Landroid/content/Context;)Ljava/lang/String;":{
                return new StringObject(vm, "22");
            }
            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->systemVolume(Landroid/content/Context;)Ljava/lang/String;":{
                return new StringObject(vm, "13");
            }
            case "java/text/SimpleDateFormat->format(Ljava/util/Date;)Ljava/lang/String;":{
                return new StringObject(vm, simpleDateFormat.format(new Date()));
            }
            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->appCache(Landroid/content/Context;)Ljava/lang/String;":{
                // 计算 APP 缓存目录大小
                return new StringObject(vm, "149045277");
            }
            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->availableSystem()Ljava/lang/String;":
                return new StringObject(vm, "unknown");
            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->totalMemory()Ljava/lang/String;":
                // 获取存储
                return new StringObject(vm, "5905510400");
            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->getFirstLaunchTime(Landroid/content/Context;)Ljava/lang/String;":{
                // 首次安装打开时间
                return new StringObject(vm, "1637665296460");
            }
            case "android/net/wifi/WifiManager->getConnectionInfo()Landroid/net/wifi/WifiInfo;":{
                return vm.resolveClass("android/net/wifi/WifiInfo").newObject(signature);
            }
            case "android/net/wifi/WifiInfo->getSSID()Ljava/lang/String;":
                // 获取wifi名
                return new StringObject(vm, "CU_TckX");
            case "android/telephony/TelephonyManager->getNetworkOperator()Ljava/lang/String;":
                return new StringObject(vm, "");
            case "java/lang/StringBuilder->append(Ljava/lang/CharSequence;II)Ljava/lang/StringBuilder;":{
                StringBuilder stringBuilder = (StringBuilder) dvmObject.getValue();
                CharSequence charSequence = (CharSequence) vaList.getObjectArg(0).getValue();
                int arg2 = vaList.getIntArg(1);
                int arg3 = vaList.getIntArg(2);
                return vm.resolveClass("java/lang/StringBuilder").newObject(stringBuilder.append(charSequence, arg2, arg3));

            }
            // 建议认真补
            case "android/net/wifi/WifiInfo->getBSSID()Ljava/lang/String;":{
                return new StringObject(vm, "");
            }
        }
        return super.callObjectMethodV(vm, dvmObject, signature, vaList);
    }

    @Override
    public int getStaticIntField(BaseVM vm, DvmClass dvmClass, String signature) {
        switch (signature){
            case "android/os/Build$VERSION->SDK_INT:I":{
                return 29;
            }
        }
        return super.getStaticIntField(vm, dvmClass, signature);
    }

    @Override
    public DvmObject<?> callStaticObjectMethodV(BaseVM vm, DvmClass dvmClass, String signature, VaList vaList) {
        switch (signature){
            case "java/lang/Integer->toString(I)Ljava/lang/String;":{
                int i = vaList.getIntArg(0);
                System.out.println("java/lang/Integer->toString:"+i);
                return new StringObject(vm, Integer.toString(i));
            }
            case "java/util/UUID->randomUUID()Ljava/util/UUID;":{
                return dvmClass.newObject(UUID.randomUUID());
            }
            case "java/lang/String->valueOf(I)Ljava/lang/String;":{
                return new StringObject(vm, String.valueOf(vaList.getIntArg(0)));
            }
        }
        return super.callStaticObjectMethodV(vm, dvmClass, signature, vaList);
    }

    @Override
    public boolean callBooleanMethodV(BaseVM vm, DvmObject<?> dvmObject, String signature, VaList vaList) {
        switch (signature){
            // 检测是否有某功能
            case "android/content/pm/PackageManager->hasSystemFeature(Ljava/lang/String;)Z":{
                String feature = vaList.getObjectArg(0).getValue().toString();
                // 加速度传感器
                if(feature.equals("android.hardware.sensor.accelerometer")){
                    return true;
                }
                // 陀螺仪
                if(feature.equals("android.hardware.sensor.gyroscope")){
                    return true;
                }
                // wifi
                if(feature.equals("android.hardware.wifi")){
                    return true;
                }
                if(feature.equals("android.hardware.bluetooth")){
                    return true;
                }
                if(feature.equals("android.hardware.bluetooth_le")){
                    return true;
                }
                if(feature.equals("android.hardware.telephony")){
                    return true;
                }
                if(feature.equals("android.hardware.usb.accessory")){
                    return true;
                }
                if(feature.equals("android.hardware.location.gps")){
                    return true;
                }
                if(feature.equals("android.hardware.nfc")){
                    return true;
                }
                System.out.println("hasSystemFeature:"+feature);
            }
            // 根据真实情况返回,我这儿乱补的
            case "java/io/File->exists()Z":{
                String tag = emulator.get(dvmObject.toString());
                if(tag.equals("/sys/class/power_supply/battery/voltage_now")){
                    return true;
                }
                if(tag.equals("/sys/class/power_supply/battery/temp")){
                    return false;
                }
            }
            case "java/lang/String->startsWith(Ljava/lang/String;)Z":{
                String str = dvmObject.getValue().toString();
                String arg =vaList.getObjectArg(0).getValue().toString();
                System.out.println("startswith");
                System.out.println(str);
                System.out.println(arg);
                return str.startsWith(arg);
            }
            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->isPermissionGranted(Ljava/lang/String;Landroid/content/Context;)Z":{
                String permission = vaList.getObjectArg(0).getValue().toString();
                System.out.println(permission);
                if(permission.equals("android.permission.READ_PHONE_STATE")){
                    return true;
                }
                if(permission.equals("android.permission.ACCESS_WIFI_STATE")){
                    return true;
                }
            }
            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->getBatteryInfo()Z":{
                return true;
            }

            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->isAccessibilityEnable()Z":{
                return false;
            }
            case "java/lang/String->equalsIgnoreCase(Ljava/lang/String;)Z":{
                String str = (String) dvmObject.getValue();
                String arg = vaList.getObjectArg(0).getValue().toString();
                return str.equalsIgnoreCase(arg);
            }
            case "java/lang/String->equals(Ljava/lang/Object;)Z":{
                String str = (String) dvmObject.getValue();
                Object object = vaList.getObjectArg(0).getValue();
                return str.equals(object);
            }
        }
        return super.callBooleanMethodV(vm, dvmObject, signature, vaList);
    }

    @Override
    public int callIntMethodV(BaseVM vm, DvmObject<?> dvmObject, String signature, VaList vaList) {
        switch (signature){
            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->boolean2Integer(Z)I":{
                return vaList.getIntArg(0);
            }
            case "java/lang/String->compareToIgnoreCase(Ljava/lang/String;)I":{
                String str = dvmObject.getValue().toString();
                String arg = vaList.getObjectArg(0).getValue().toString();
                System.out.println("compareToIgnoreCase");
                System.out.println(str);
                System.out.println(arg);
                return str.compareToIgnoreCase(arg);
            }
            case "java/lang/String->lastIndexOf(I)I":{
                String str = dvmObject.getValue().toString();
                return str.lastIndexOf(vaList.getIntArg(0));

            }
            case "android/view/Display->getHeight()I":{
                return 2030;
            }
            case "android/view/Display->getWidth()I":{
                return 1080;
            }
            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->uiAutomatorClickCount()I":{
                return 0;
            }
            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->androidAppCnt(Landroid/content/Context;)I":{
                return 0;
            }
            case "java/lang/String->length()I":{
                String str = dvmObject.getValue().toString();
                return str.length();
            }
            case "android/net/wifi/WifiInfo->getRssi()I":{
                return 0;
            }
        }
        return super.callIntMethodV(vm, dvmObject, signature, vaList);
    }

    @Override
    public boolean callStaticBooleanMethodV(BaseVM vm, DvmClass dvmClass, String signature, VaList vaList) {
        switch (signature){
            case "android/text/TextUtils->isEmpty(Ljava/lang/CharSequence;)Z":{
                String charSequence = (String) vaList.getObjectArg(0).getValue();
                System.out.println("debug");
//                return charSequence.isEmpty();
                return charSequence.isEmpty();
            }
        }
        return super.callStaticBooleanMethodV(vm, dvmClass, signature, vaList);
    }

    @Override
    public int getIntField(BaseVM vm, DvmObject<?> dvmObject, String signature) {
        switch (signature){
            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->level:I":{
                return 93;
            }
            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->scale:I":{
                return 100;
            }
            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->status:I":{
                return 3;
            }
        }
        return super.getIntField(vm, dvmObject, signature);
    }

    @Override
    public boolean getBooleanField(BaseVM vm, DvmObject<?> dvmObject, String signature) {
        switch (signature){
            case "com/meituan/android/common/mtguard/NBridge$SIUACollector->plugged:Z":{
                return false;
            }
        }
        return super.getBooleanField(vm, dvmObject, signature);
    }
}

文章来源地址https://www.toymoban.com/news/detail-530122.html

到了这里,关于unidbg-点评补设备环境的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • unidbg-补环境之无障碍模式

    2024年02月16日
    浏览(41)
  • app安全之安卓native层安全分析(八):unidbg补前置环境+IO重定向

    继续跟着龙哥的unidbg学习:SO逆向入门实战教程七:main_unidbg 重定向_白龙~的博客-CSDN博客 还是那句,我会借鉴龙哥的文章,以一个初学者的角度,加上自己的理解,把内容丰富一下,尽量做到不在龙哥的基础上画蛇添足。感谢观看的朋友。 首先,抓个包 里面这个mtgsig就是该

    2024年02月08日
    浏览(40)
  • Sealos 新功能“定时任务”上线(省钱大杀器)

    流量高峰时段资源不足?低流量时段服务器成本过高? 本着好用又省钱的目标,sealos 推出 定时任务 功能,保证稳定的同时降低成本。 Sealos 国内集群:https://cloud.sealos.top Sealos 海外集群:https://cloud.sealos.io 原文链接:https://forum.laf.run/d/1034 一句话介绍:一个定时器,可以用于

    2024年02月08日
    浏览(36)
  • ChatGPT强化学习大杀器——近端策略优化(PPO)

    近端策略优化 ( P roximal P olicy O ptimization)来自 Proximal Policy Optimization Algorithms (Schulman et. al., 2017)这篇论文,是当前最先进的强化学习 (RL) 算法。这种优雅的算法可以用于各种任务,并且已经在很多项目中得到了应用,最近火爆的ChatGPT就采用了该算法。 网上讲解ChatGPT算法

    2024年01月21日
    浏览(48)
  • 【工具篇】情侣大杀器,使用postman的代理,抓取手机流量

    目录 1. postman的版本 2. 代理的原理 3. 设置postman代理 4. 查看本机ip地址 5. 手机端设置 6. postman火力全开吧 在postman没有开启代理之前,手机访问直接访问互联网上的服务器,postman开启了代理,则手机对网站服务器发送的请求,会先经过postman,再由postman转发到服务器,同样,服

    2024年02月09日
    浏览(36)
  • unidbg或者java层解密方法IDEA中打包成jar包供python调用方法

    (1)配置jar包参数 (2)创建生成jar包 成功生成!

    2024年02月16日
    浏览(42)
  • AI模型大杀器----Amazon SageMaker 实现高精度猫狗分类

    前言: Hello大家好,我是Dream。 最近受邀参与了 亚马逊云科技【云上探索实验室】 活动,基于他们的sagemaker实现了机器学习中一个非常经典的案例: 猫狗分类 。最让我惊喜的是的模型训速度比想象中 效果要好得多,而且速度十分迅速,而且总体感觉下来整个过程十分便利

    2023年04月09日
    浏览(39)
  • 【腾讯云TDSQL-C Serverless 产品体验】新时代数据库大杀器

    近年来,随着互联网行业的高速发展,关系型数据库也面临着前所未有的挑战。云原生数据库成为解决这些挑战的重要方案之一。腾讯云推出的 TDSQL-C Serverless 版正是云原生数据库领域的佼佼者之一。 我在CSDN “学习” 的过程中发现腾讯云联合CSDN推出了 “腾讯云TDSQL-C产品测

    2024年02月07日
    浏览(45)
  • unidbg 简介、基本使用、调用so中方法、unidbg-web

    爬虫工程师的unidbg入门教程:https://www.cnblogs.com/xbjss/p/12110083.html 日常逆向分析的app:https://github.com/zhaoboy9692/dailyanalysis 分析unidbg(unidbgMutil)多线程机制:https://bbs.kanxue.com/thread-266999.htm 逆向调试时还是 IDA 的图形化界面更方便,一般首选 IDA 调试分析,后期要在生产线上生成

    2024年02月13日
    浏览(41)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包