objection -g 进程名 explore --startup-command "android hooking watch class 路径.类名"
基本命令
memory list modules -查看内存中加载的库
1 2 3 4 5 6 7 8 9 10 11 12
memory list modules Save the output by adding `--json modules.json` to this command Name Base Size Path ---------------------------------------------------------------- ------------ ------------------- ------------------------------------------------------------------------------ app_process64 0x57867c9000 40960 (40.0 KiB) /system/bin/app_process64 linker64 0x72e326a000 229376 (224.0 KiB) /system/bin/linker64 libandroid_runtime.so 0x72e164e000 2113536 (2.0 MiB) /system/lib64/libandroid_runtime.so libbase.so 0x72dfa67000 81920 (80.0 KiB) /system/lib64/libbase.so libbinder.so 0x72dec1c000 643072 (628.0 KiB) /system/lib64/libbinder.so libcutils.so 0x72de269000 86016 (84.0 KiB) /system/lib64/libcutils.so libhidlbase.so 0x72df4cc000 692224 (676.0 KiB) /system/lib64/libhidlbase.so liblog.so 0x72e0be1000 98304 (96.0 KiB) /system/lib64/liblog
memory list exports so名称 - 查看库的导出函数
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
memory list exports liblog.so Save the output by adding `--json exports.json` to this command Type Name Address -------- ------------------------------------ ------------ function android_log_write_int32 0x72e0be77c8 function android_log_write_list_begin 0x72e0be76f0 function __android_log_bswrite 0x72e0be9bd8 function __android_log_security 0x72e0bf2144 function __android_log_bwrite 0x72e0be9a18 function android_log_reset 0x72e0be75ec function android_log_write_string8 0x72e0be7a38 function android_logger_list_free 0x72e0be8c04 function __android_log_print 0x72e0be9728 function __android_logger_property_get_bool 0x72e0bf2248 function android_logger_get_id 0x72e0be8270 function android_logger_set_prune_list 0x72e0be8948
android hooking list activities -查看内存中加载的activity /android hooking list services -查看内存中加载的services
android hooking list classes -列出内存中所有的类(结果比静态分析的更准确)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
android hooking list classes
tw.idv.palatis.xappdebug.MainApplication tw.idv.palatis.xappdebug.xposed.HookMain tw.idv.palatis.xappdebug.xposed.HookMain$a tw.idv.palatis.xappdebug.xposed.HookMain$b tw.idv.palatis.xappdebug.xposed.HookMain$c tw.idv.palatis.xappdebug.xposed.HookMain$d tw.idv.palatis.xappdebug.xposed.HookSelf u v void w xposed.dummy.XResourcesSuperClass xposed.dummy.XTypedArraySuperClass
android hooking search classes wuaipojie Note that Java classes are only loaded when they are used, so if the expected class has not been found, it might not have been loaded yet. com.zj.wuaipojie.Demo com.zj.wuaipojie.Demo$Animal com.zj.wuaipojie.Demo$Companion com.zj.wuaipojie.Demo$InnerClass com.zj.wuaipojie.Demo$test$1 com.zj.wuaipojie.MainApplication com.zj.wuaipojie.databinding.ActivityMainBinding ...
android hooking list class_methods 类名 -内存漫游类中的所有方法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
android hooking list class_methods com.zj.wuaipojie.ui.ChallengeSixth private static final void com.zj.wuaipojie.ui.ChallengeSixth.onCreate$lambda-0(com.zj.wuaipojie.ui.ChallengeSixth,android.view.View) private static final void com.zj.wuaipojie.ui.ChallengeSixth.onCreate$lambda-1(com.zj.wuaipojie.ui.ChallengeSixth,android.view.View) private static final void com.zj.wuaipojie.ui.ChallengeSixth.onCreate$lambda-2(com.zj.wuaipojie.ui.ChallengeSixth,android.view.View) private static final void com.zj.wuaipojie.ui.ChallengeSixth.onCreate$lambda-3(com.zj.wuaipojie.ui.ChallengeSixth,android.view.View) protected void com.zj.wuaipojie.ui.ChallengeSixth.onCreate(android.os.Bundle) public final java.lang.String com.zj.wuaipojie.ui.ChallengeSixth.hexToString(java.lang.String) public final java.lang.String com.zj.wuaipojie.ui.ChallengeSixth.unicodeToString(java.lang.String) public final void com.zj.wuaipojie.ui.ChallengeSixth.toastPrint(java.lang.String) public static void com.zj.wuaipojie.ui.ChallengeSixth.$r8$lambda$1lrkrgiCEFWXZDHzLRibYURG1h8(com.zj.wuaipojie.ui.ChallengeSixth,android.view.View) public static void com.zj.wuaipojie.ui.ChallengeSixth.$r8$lambda$IUqwMqbTKaOGiTaeOmvy_GjNBso(com.zj.wuaipojie.ui.ChallengeSixth,android.view.View) public static void com.zj.wuaipojie.ui.ChallengeSixth.$r8$lambda$Kc_cRYZjjhjsTl6GYNHbgD-i6sE(com.zj.wuaipojie.ui.ChallengeSixth,android.view.View) public static void com.zj.wuaipojie.ui.ChallengeSixth.$r8$lambda$PDKm2AfziZQo6Lv1HEFkJWkUsoE(com.zj.wuaipojie.ui.ChallengeSixth,android.view.View)
functionhookTest2(){ Java.perform(function(){ //根据导出函数名打印地址 var helloAddr = Module.findExportByName("lib52pojie.so","Java_com_zj_wuaipojie_util_SecurityUtil_vipLevel"); if(helloAddr != null){ Interceptor.attach(helloAddr,{ //onEnter里可以打印和修改参数 onEnter: function(args){ //args传入参数 varJNIEnv = Java.vm.getEnv(); var originalStrPtr = JNIEnv.getStringUtfChars(args[2], null).readCString(); console.log("参数:", originalStrPtr); var modifiedContent = "至尊"; var newJString = JNIEnv.newStringUtf(modifiedContent); args[2] = newJString; }, //onLeave里可以打印和修改返回值 onLeave: function(retval){ //retval返回值 var returnedJString = Java.cast(retval, Java.use('java.lang.String')); console.log("返回值:", returnedJString.toString()); varJNIEnv = Java.vm.getEnv(); var modifiedContent = "无敌"; var newJString = JNIEnv.newStringUtf(modifiedContent); retval.replace(newJString); } }) } }) }
SO基址的获取方式
1 2 3
var moduleAddr1 = Process.findModuleByName("lib52pojie.so").base; var moduleAddr2 = Process.getModuleByName("lib52pojie.so").base; var moduleAddr3 = Module.findBaseAddress("lib52pojie.so");
Hook未导出函数与函数地址计算
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
functionhookTest6(){ Java.perform(function(){ //根据导出函数名打印基址 var soAddr = Module.findBaseAddress("lib52pojie.so"); console.log(soAddr); var funcaddr = soAddr.add(0x1071C); console.log(funcaddr); if(funcaddr != null){ Interceptor.attach(funcaddr,{ onEnter: function(args){ //args参数