当前位置:   article > 正文

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);
    }
}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329
  • 330
  • 331
  • 332
  • 333
  • 334
  • 335
  • 336
  • 337
  • 338
  • 339
  • 340
  • 341
  • 342
  • 343
  • 344
  • 345
  • 346
  • 347
  • 348
  • 349
  • 350
  • 351
  • 352
  • 353
  • 354
  • 355
  • 356
  • 357
  • 358
  • 359
  • 360
  • 361
  • 362
  • 363
  • 364
  • 365
  • 366
  • 367
  • 368
  • 369
  • 370
  • 371
  • 372
  • 373
  • 374
  • 375
  • 376
  • 377
  • 378
  • 379
  • 380
  • 381
  • 382
  • 383
  • 384
  • 385
  • 386
  • 387
  • 388
  • 389
  • 390
  • 391
  • 392
  • 393
  • 394
  • 395
  • 396
  • 397
  • 398
  • 399
  • 400
  • 401
  • 402
  • 403
  • 404
  • 405
  • 406
  • 407
  • 408
  • 409
  • 410
  • 411
  • 412
  • 413
  • 414
  • 415
  • 416
  • 417
  • 418
  • 419
  • 420
  • 421
  • 422
  • 423
  • 424
  • 425
  • 426
  • 427
  • 428
  • 429
  • 430
  • 431
  • 432
  • 433
  • 434
  • 435
  • 436
  • 437
  • 438
  • 439
  • 440
  • 441
  • 442
  • 443
  • 444
  • 445
  • 446
  • 447
  • 448
  • 449
  • 450
  • 451
  • 452
  • 453
  • 454
  • 455
  • 456
  • 457
  • 458
  • 459
  • 460
  • 461
  • 462
  • 463
  • 464
  • 465
  • 466
  • 467
  • 468
  • 469
  • 470
  • 471
  • 472
  • 473
  • 474
  • 475
  • 476
  • 477
  • 478
  • 479
  • 480
  • 481
  • 482
  • 483
  • 484
  • 485
  • 486
  • 487
  • 488
  • 489
  • 490
  • 491
  • 492
  • 493
  • 494
  • 495
  • 496
  • 497
  • 498
  • 499
  • 500
  • 501
  • 502
  • 503
  • 504
  • 505
  • 506
  • 507
  • 508
  • 509
  • 510
  • 511
  • 512
  • 513
  • 514
  • 515
  • 516
  • 517
  • 518
  • 519
  • 520
  • 521
  • 522
  • 523
  • 524
  • 525
  • 526
  • 527
  • 528
  • 529
  • 530
  • 531
  • 532
  • 533
  • 534
  • 535
  • 536
  • 537
  • 538
  • 539
  • 540
  • 541
  • 542
  • 543
  • 544
  • 545
  • 546
  • 547
  • 548
  • 549
  • 550
  • 551
  • 552
  • 553
  • 554
  • 555
  • 556
  • 557
  • 558
  • 559
  • 560
  • 561
  • 562
  • 563
  • 564
  • 565
  • 566
  • 567
  • 568
  • 569
  • 570
  • 571
  • 572
  • 573
  • 574
  • 575
  • 576
  • 577
  • 578
  • 579
  • 580
  • 581
  • 582
  • 583
  • 584
  • 585
  • 586
  • 587
  • 588
  • 589
  • 590
  • 591
  • 592
  • 593
  • 594
  • 595
  • 596
  • 597
  • 598
  • 599
  • 600
  • 601
  • 602
  • 603
  • 604
  • 605
  • 606
  • 607
  • 608
  • 609
  • 610
  • 611
  • 612
  • 613
  • 614
  • 615
  • 616
  • 617
  • 618
  • 619
  • 620
  • 621
  • 622
  • 623
  • 624
  • 625
  • 626
  • 627
  • 628
  • 629
  • 630
  • 631
  • 632
  • 633
  • 634
  • 635
  • 636
  • 637
  • 638
  • 639
  • 640
  • 641
  • 642
  • 643
  • 644
  • 645
  • 646
  • 647
  • 648
  • 649
  • 650
  • 651
  • 652
  • 653
  • 654
  • 655
  • 656
  • 657
  • 658
  • 659
  • 660
  • 661
  • 662
  • 663
  • 664
  • 665
  • 666
  • 667
  • 668
  • 669
  • 670
  • 671
  • 672
  • 673
  • 674
  • 675
  • 676
  • 677
  • 678
  • 679
  • 680
  • 681
  • 682
  • 683
  • 684
  • 685
  • 686
  • 687
  • 688
  • 689
  • 690
  • 691
  • 692
  • 693
  • 694
  • 695
  • 696
  • 697
  • 698
  • 699
  • 700
  • 701
  • 702
  • 703
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/158463
推荐阅读
相关标签
  

闽ICP备14008679号