Objection简介
什么是Objection
Objection是一个基于Frida的移动安全测试工具,主要特点:
核心优势
- 易用性:简单的命令行操作
- 功能丰富:内置多种安全测试功能
- 基于Frida:继承Frida的强大能力
- 社区活跃:持续更新和维护
Objection安装配置
1. 安装Objection
1 2 3 4 5 6 7 8
| pip install objection
objection --version
objection --help
|
2. Android环境配置
1 2 3 4 5 6 7 8
| adb shell /data/local/tmp/frida-server &
frida-ls-devices
frida-ps -U
|
3. 连接设备
1 2 3 4 5 6 7 8
| objection -g com.example.app explore
objection -g com.example.app -N explore
objection -g com.example.app -d 设备ID explore
|
基础使用命令
1. 环境信息
1 2 3 4 5 6 7 8 9 10 11
| env
device info
app info
memory list modules
|
2. 文件系统操作
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| ls
cat /path/to/file
file download /path/to/file
file upload local_file /path/to/remote
ls -la
|
3. 进程管理
1 2 3 4 5 6 7 8 9 10 11
| ps
ps | grep target
kill <pid>
memory list modules
|
核心功能模块
1. 内存分析
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| memory list modules
memory search --string "target_string"
memory search --pattern "41 42 43 44"
memory list ranges
memory read <address> <size>
|
2. Hook功能
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| android hooking list classes
android hooking list classes | grep -i target
android hooking watch class_method "com.example.TargetClass.targetMethod" --dump-args --dump-return
android hooking watch class_method "com.example.TargetClass.*" --dump-args --dump-return
android hooking watch class_method "com.example.TargetClass.$init" --dump-args --dump-return
|
3. 网络监控
1 2 3 4 5 6 7 8
| android hooking watch class_method "okhttp3.OkHttpClient.newCall" --dump-args --dump-return
android hooking watch class_method "okhttp3.Request$Builder.build" --dump-args --dump-return
android hooking watch class_method "javax.net.ssl.SSLContext.init" --dump-args --dump-return
|
4. 加密分析
1 2 3 4 5 6 7 8
| android hooking watch class_method "javax.crypto.Cipher.doFinal" --dump-args --dump-return
android hooking watch class_method "java.security.MessageDigest.digest" --dump-args --dump-return
android hooking watch class_method "java.security.SecureRandom.nextBytes" --dump-args --dump-return
|
实用Hook技巧
1. 绕过Root检测
1 2 3 4 5 6 7 8
| android hooking watch class_method "java.io.File.exists" --dump-args --dump-return
android hooking watch class_method "android.os.SystemProperties.get" --dump-args --dump-return
android hooking watch class_method "java.lang.Runtime.exec" --dump-args --dump-return
|
2. 绕过SSL Pinning
1 2 3 4 5 6 7 8
| android hooking watch class_method "javax.net.ssl.X509TrustManager.checkServerTrusted" --dump-args --dump-return
android hooking watch class_method "javax.net.ssl.SSLContext.init" --dump-args --dump-return
android hooking watch class_method "okhttp3.CertificatePinner.check" --dump-args --dump-return
|
3. 监控数据库操作
1 2 3 4 5 6 7 8
| android hooking watch class_method "android.database.sqlite.SQLiteDatabase.execSQL" --dump-args --dump-return
android hooking watch class_method "android.database.sqlite.SQLiteDatabase.query" --dump-args --dump-return
android hooking watch class_method "android.database.sqlite.SQLiteDatabase.insert" --dump-args --dump-return
|
高级功能
1. 内存搜索
1 2 3 4 5 6 7 8 9 10 11
| memory search --string "password"
memory search --pattern "41 42 43 44"
memory search --regex ".*password.*"
memory search --string "target" --range 0x1000 0x2000
|
2. 内存修改
1 2 3 4 5 6 7 8
| memory write <address> <value>
memory write_string <address> "new_string"
memory write_bytes <address> "41 42 43 44"
|
3. 动态分析
1 2 3 4 5 6 7 8
| android hooking watch class_method "com.example.TargetClass.targetMethod" --dump-args --dump-return
android hooking watch class_method "com.example.TargetClass.*" --dump-args --dump-return
android hooking watch class_method "com.example.TargetClass.targetMethod" --dump-args --dump-return --dump-backtrace
|
实战案例
案例1:绕过银行APP检测
这个案例演示如何使用Objection绕过银行APP的各种安全检测机制:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| objection -g com.bank.app explore
android hooking watch class_method "com.bank.security.RootDetector.isRooted" --dump-args --dump-return
android hooking watch class_method "com.bank.security.DebugDetector.isDebugging" --dump-args --dump-return
android hooking watch class_method "java.io.File.exists" --dump-args --dump-return
android hooking watch class_method "android.os.SystemProperties.get" --dump-args --dump-return
android hooking watch class_method "java.lang.Runtime.exec" --dump-args --dump-return
android hooking watch class_method "android.net.ConnectivityManager.getActiveNetworkInfo" --dump-args --dump-return
|
案例2:分析加密算法
这个案例演示如何使用Objection分析应用的加密算法和密钥管理:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| objection -g com.example.app explore
android hooking watch class_method "com.example.Crypto.encrypt" --dump-args --dump-return
android hooking watch class_method "com.example.Crypto.decrypt" --dump-args --dump-return
android hooking watch class_method "com.example.Crypto.generateKey" --dump-args --dump-return
android hooking watch class_method "java.security.MessageDigest.digest" --dump-args --dump-return
android hooking watch class_method "java.security.SecureRandom.nextBytes" --dump-args --dump-return
android hooking watch class_method "java.security.cert.Certificate.getPublicKey" --dump-args --dump-return
|
案例3:监控网络请求
这个案例演示如何使用Objection监控和分析应用的网络通信:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| objection -g com.example.app explore
android hooking watch class_method "okhttp3.Request$Builder.build" --dump-args --dump-return
android hooking watch class_method "okhttp3.Response.body" --dump-args --dump-return
android hooking watch class_method "okhttp3.HttpUrl$Builder.build" --dump-args --dump-return
android hooking watch class_method "okhttp3.Request$Builder.addHeader" --dump-args --dump-return
android hooking watch class_method "okhttp3.Request$Builder.post" --dump-args --dump-return
android hooking watch class_method "okhttp3.ResponseBody.string" --dump-args --dump-return
|
Objection插件系统
1. 插件安装
Objection支持多种插件安装方式:
内置插件
1 2 3 4 5 6 7 8
| plugin list
plugin show <plugin_name>
plugin load <plugin_name>
|
第三方插件安装
1 2 3 4 5 6 7 8 9 10
| pip install objection-plugin-name
mkdir -p ~/.objection/plugins/ cp plugin.py ~/.objection/plugins/
objection -g com.example.app explore
|
2. 常用插件
Android Hook插件
1 2 3 4 5 6 7 8 9 10 11
| plugin load android
android hooking watch class_method "android.app.Activity.onCreate" --dump-args --dump-return
android hooking watch class_method "android.app.Service.onCreate" --dump-args --dump-return
android hooking watch class_method "android.content.BroadcastReceiver.onReceive" --dump-args --dump-return
|
内存分析插件
1 2 3 4 5 6 7 8 9 10 11
| plugin load memory
memory search --string "password"
memory search --pattern "41 42 43 44"
memory read <address> <size>
|
网络监控插件
1 2 3 4 5 6 7 8 9 10 11
| plugin load network
network monitor
network ssl
network dns
|
3. 重要第三方插件
Wallbreaker插件
Wallbreaker是一个强大的内存分析插件,专门用于Android应用的内存dump和分析:
安装方法:
1 2 3 4 5 6 7 8
| git clone https://github.com/hluwa/Wallbreaker.git
pip install objection
cp Wallbreaker/objection_plugin.py ~/.objection/plugins/wallbreaker.py
|
主要功能:
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
| objection -g com.example.app explore plugin load wallbreaker
memory search --string "password"
memory search --string "com.example.TargetClass"
memory search --string "targetMethod"
memory export classes
memory export class com.example.TargetClass
memory export method com.example.TargetClass.targetMethod
memory write <address> <value>
memory write_string <address> "new_string"
memory monitor alloc
memory monitor free
|
实战应用:
1 2 3 4 5 6 7 8 9 10 11 12
|
memory search --string "Cipher"
memory export class javax.crypto.Cipher
memory monitor method javax.crypto.Cipher.doFinal
memory write <key_address> <new_key>
|
FRIDA-DEXDump插件
FRIDA-DEXDump是一个专门用于Android应用DEX文件dump的插件:
安装方法:
1 2 3 4 5 6 7 8
| git clone https://github.com/hluwa/FRIDA-DEXDump.git
pip install frida
cp FRIDA-DEXDump/objection_plugin.py ~/.objection/plugins/frida_dexdump.py
|
主要功能:
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
| objection -g com.example.app explore plugin load frida_dexdump
dexdump search
dexdump search --name "classes.dex"
dexdump export
dexdump export --name "classes.dex"
dexdump export --output /path/to/output/
dexdump analyze <dex_file>
dexdump analyze --class com.example.TargetClass
dexdump analyze --method com.example.TargetClass.targetMethod
dexdump fix <dex_file>
dexdump fix --export <dex_file>
|
实战应用:
1 2 3 4 5 6 7 8 9 10 11 12
|
dexdump search
dexdump export --output ./dex_files/
dexdump analyze --class com.example.Crypto
dexdump analyze --method com.example.Crypto.encrypt
|
4. 自定义插件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| class CustomPlugin: def __init__(self): self.name = "custom_plugin" self.description = "自定义插件" def load(self): pass def unload(self): pass
plugin_manager.register(CustomPlugin())
|
检测应对方法
1. 反调试检测
当遇到反调试检测时,可以使用以下方法:
1 2 3 4 5 6 7 8 9 10 11
| android hooking watch class_method "android.os.Debug.isDebuggerConnected" --dump-args --dump-return
android hooking watch class_method "java.lang.System.getProperty" --dump-args --dump-return
android hooking watch class_method "android.app.ActivityManager.getRunningAppProcesses" --dump-args --dump-return
android hooking watch class_method "java.net.Socket.connect" --dump-args --dump-return
|
2. 反Hook检测
当遇到反Hook检测时,可以使用以下方法:
1 2 3 4 5 6 7 8 9 10 11
| android hooking watch class_method "com.example.HookDetector.detectHook" --dump-args --dump-return
android hooking watch class_method "java.lang.reflect.Method.invoke" --dump-args --dump-return
android hooking watch class_method "java.lang.ClassLoader.loadClass" --dump-args --dump-return
android hooking watch class_method "java.lang.Exception.printStackTrace" --dump-args --dump-return
|
3. 反Frida检测
当遇到反Frida检测时,可以使用以下方法:
1 2 3 4 5 6 7 8 9 10 11
| android hooking watch class_method "com.example.FridaDetector.detectFrida" --dump-args --dump-return
android hooking watch class_method "java.net.ServerSocket.bind" --dump-args --dump-return
android hooking watch class_method "java.lang.Runtime.exec" --dump-args --dump-return
android hooking watch class_method "java.io.File.exists" --dump-args --dump-return
|
4. 反Xposed检测
当遇到反Xposed检测时,可以使用以下方法:
1 2 3 4 5 6 7 8 9 10 11
| android hooking watch class_method "com.example.XposedDetector.detectXposed" --dump-args --dump-return
android hooking watch class_method "java.lang.ClassLoader.loadClass" --dump-args --dump-return
android hooking watch class_method "java.lang.reflect.Method.invoke" --dump-args --dump-return
android hooking watch class_method "java.lang.Exception.printStackTrace" --dump-args --dump-return
|
5. 反模拟器检测
当遇到反模拟器检测时,可以使用以下方法:
1 2 3 4 5 6 7 8 9 10 11
| android hooking watch class_method "com.example.EmulatorDetector.detectEmulator" --dump-args --dump-return
android hooking watch class_method "android.os.Build.HARDWARE" --dump-args --dump-return
android hooking watch class_method "android.os.SystemProperties.get" --dump-args --dump-return
android hooking watch class_method "android.hardware.SensorManager.getSensorList" --dump-args --dump-return
|
常用脚本
1. 自动Hook脚本
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
| Java.perform(function() { var File = Java.use("java.io.File"); File.exists.implementation = function() { var path = this.getAbsolutePath(); console.log("检查文件: " + path); if (path.includes("su") || path.includes("magisk")) { console.log("隐藏Root文件: " + path); return false; } return this.exists(); }; var SystemProperties = Java.use("android.os.SystemProperties"); SystemProperties.get.overload("java.lang.String", "java.lang.String").implementation = function(key, def) { console.log("获取属性: " + key); if (key === "ro.debuggable") { return "0"; } if (key === "ro.secure") { return "1"; } return this.get(key, def); }; });
|
2. 使用脚本
1 2 3 4 5
| objection -g com.example.app -l hook_script.js explore
frida -U -f com.example.app -l hook_script.js --no-pause
|
高级技巧
1. 批量Hook
1 2 3 4 5
| android hooking watch class_method "com.example.TargetClass.*" --dump-args --dump-return
android hooking watch class_method "com.example.*.*" --dump-args --dump-return
|
2. 条件Hook
1 2 3 4 5
| android hooking watch class_method "com.example.TargetClass.targetMethod" --dump-args --dump-return --dump-backtrace
android hooking watch class_method "com.example.TargetClass.targetMethod" --dump-args --dump-return --dump-return
|
3. 性能优化
1 2 3 4 5
| android hooking watch class_method "com.example.TargetClass.targetMethod" --dump-args
android hooking watch class_method "com.example.TargetClass.specificMethod" --dump-args --dump-return
|
结语
Objection,这货现在在移动安全圈子里可以说是相当火的一个工具了。它基于Frida构建,但比直接写Frida脚本要简单得多,基本上就是”开箱即用”的感觉。
目前Objection在移动安全测试领域已经站稳了脚跟,很多安全研究员都在用它。它的优势很明显——门槛低,功能全,社区活跃。不过说实话,它也有一些局限性,比如对某些复杂的Hook场景支持还不够完善,性能上也有优化空间。比如说遇到一些特定的对frida的检测的时候,可能会需要自己添加一些特别的hook代码 —– 比如说去翻源码的agent.js的内容里加上自己的hook代码
总的来说,Objection在移动安全测试这个细分领域里算是比较实用的工具,虽然不是什么真正意义上的”神器”,但确实能解决很多实际问题。对于刚入门的朋友来说,是个不错的选择。