文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

unidbg-补环境之无障碍模式

2023-08-17 05:18

关注
package com.dta.lesson35;import com.dta.lesson34.Base64;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.array.ArrayObject;import com.github.unidbg.memory.Memory;import java.io.File;import java.util.ArrayList;import java.util.List;public class MainActivity2 extends AbstractJni {    private final AndroidEmulator emulator;    private final VM vm;    private final Memory memory;    private final Module module;    private final DvmObject obj;    public MainActivity2(){        emulator = AndroidEmulatorBuilder                .for32Bit()                //.setRootDir(new File("target/rootfs/default"))                //.addBackendFactory(new DynarmicFactory(true))                .build();        memory = emulator.getMemory();        memory.setLibraryResolver(new AndroidResolver(23));        vm = emulator.createDalvikVM(new File("unidbg-android/src/test/java/com/dta/lesson35/DogPlus.apk"));        vm.setVerbose(true);        vm.setJni(this);        DalvikModule dalvikModule = vm.loadLibrary("dogplus", false);        module = dalvikModule.getModule();        vm.callJNI_OnLoad(emulator,module);        obj = vm.resolveClass("com/example/dogplus/MainActivity").newObject(null);    }    public static void main(String[] args) {        long start = System.currentTimeMillis();        MainActivity2 mainActivity = new MainActivity2();        System.out.println("load the vm "+( System.currentTimeMillis() - start )+ "ms");        mainActivity.detectAccessibilityManager();    }    //public native void detectAccessibilityManager();    private void detectAccessibilityManager(){        obj.callJniMethod(emulator,"detectAccessibilityManager()V");    }    @Override    public DvmObject callObjectMethodV(BaseVM vm, DvmObject dvmObject, String signature, VaList vaList) {        if (signature.equals("android/app/ActivityThread->getApplication()Landroid/app/Application;")){            return vm.resolveClass("android/app/Application").newObject(null);        }        if (signature.equals("android/view/accessibility/AccessibilityManager->getInstalledAccessibilityServiceList()Ljava/util/List;")){            List> list = new ArrayList<>();            //AccessibilityServiceInfo            DvmClass dvmClass = vm.resolveClass("android/accessibilityservice/AccessibilityServiceInfo");            AccessibilityServiceInfo info1 = new AccessibilityServiceInfo("TalkBackService","com.google.android.marvin.talkback","TalkBack");            AccessibilityServiceInfo info2= new AccessibilityServiceInfo("SelectToSpeakService","com.google.android.marvin.talkback","随选朗读");            list.add(dvmClass.newObject(info1));            list.add(dvmClass.newObject(info2));            return new ArrayListObject(vm,list);        }        if (signature.equals("android/accessibilityservice/AccessibilityServiceInfo->getResolveInfo()Landroid/content/pm/ResolveInfo;")){            //dvmObject            return vm.resolveClass("android/content/pm/ResolveInfo").newObject(dvmObject.getValue());        }        if (signature.equals("android/content/pm/ServiceInfo->loadLabel(Landroid/content/pm/PackageManager;)Ljava/lang/CharSequence;")){            AccessibilityServiceInfo info = (AccessibilityServiceInfo) dvmObject.getValue();            return vm.resolveClass("java/lang/CharSequence").newObject(info.lable);        }        if (signature.equals("java/lang/CharSequence->toString()Ljava/lang/String;")){            return new StringObject(vm,dvmObject.getValue().toString());        }        return super.callObjectMethodV(vm, dvmObject, signature, vaList);    }    @Override    public DvmObject getObjectField(BaseVM vm, DvmObject dvmObject, String signature) {        if (signature.equals("android/content/pm/ResolveInfo->serviceInfo:Landroid/content/pm/ServiceInfo;")){            return vm.resolveClass("android/content/pm/ServiceInfo").newObject(dvmObject.getValue());        }        if (signature.equals("android/content/pm/ServiceInfo->name:Ljava/lang/String;")){            AccessibilityServiceInfo info = (AccessibilityServiceInfo) dvmObject.getValue();            return new StringObject(vm, info.name);        }        if (signature.equals("android/content/pm/ServiceInfo->packageName:Ljava/lang/String;")){            AccessibilityServiceInfo info = (AccessibilityServiceInfo) dvmObject.getValue();            return new StringObject(vm, info.packageName);        }        if (signature.equals("android/accessibilityservice/AccessibilityServiceInfo->packageNames:[Ljava/lang/String;")){            return new ArrayObject();        }        return super.getObjectField(vm, dvmObject, signature);    }}

来源地址:https://blog.csdn.net/weixin_38927522/article/details/127910728

阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     813人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     354人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     318人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     435人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     224人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-后端开发
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯