frida初探2:obection常见用法

文章最后更新时间为:2023年08月01日 15:17:08

安装

pip3 install objection

启动frida后,启动objection:

objection -d -g com.xxx.xxx explore
在高版本frida中com.xxx.xxx要换成process name

memory操作

# 列举加载的modules,也就是so文件
memory list modules
memory list modules --json result.txt

# 列举so文件的导出方法
memory list exports xxx.so

# dump所有内存
memory dump all /tmp/dump

# dump内存指定地址和大小
memory dump from_base 0x130b4060 1024 /tmp/dump

# 在内存搜索
memory search "64 65 78 0a 30 33 35 00"
memory search "99999999999" --string
memory search "66 72 ?? ?? 61"

# 修改内存
memory write 0x130b4060 "99999999999" --string

activity/services/receivers组件相关

# 列出应用程序具有的组件
android hooking list activities
android hooking list services
android hooking list receivers

# 获取当前activity
android hooking get current_activity

# 启动某个activity
android intent launch_activity com.xxx.xxx.Activity

# 启动某个service
android intent launch_service xxxx

class/method相关

# 列举所有加载的类
android hooking list classes

# 查找已加载的类中带有关键词的类
android hooking search classes xxx

# 查看xx类有哪些方法
android hooking list class_methods com.xx.xx

# 在内存中所有已加载的类的方法中搜索包含特定关键词的方法
android hooking search methods xxx

# 查找所有类的实例
android heap search instances xxx

# 主动调用指定实例的函数
android heap execute instance_ID function

# hook指定类的所有方法, 会打印该类下的所有调用
android hooking watch class com.xxx.xxx            

# hook指定方法, 如果有重载会hook所有重载
android hooking watch class_method com.xxx.xxx.methodName

# 以上命令支持下面参数
# --dump-args : 打印参数
# --dump-backtrace : 打印调用栈
# --dump-return : 打印返回值
# eg:
android hooking watch class_method com.xxx.xxx.methodName --dump-args --dump-backtrace --dump-return
android hooking set return_value com.xxx.xxx.methodName false    # 设置返回值(只支持bool类型)


# 生成某个类的hook js代码
android hooking generate  simple  com.xxx.xxx

任务管理

# 列举出当前任务
jobs list

# 关闭任务
jobs kill [job_id]

文件操作

# 文件基本操作
ls
file download
file upload
file cat

# 文件服务器,在当前目录下启动一个http server
file http start/stop/status

抓包

#关闭ssl校验
android sslpinning disable

其他操作

# 打印出应用程序文件、缓存和其他目录的位置
env

# 对APP隐藏root
android root disable 

# 执行命令
android shell_exec ls 

# 截屏
android ui screenshot /sdcard/1.png

# 导入外部js脚本
import 1.js 

spawn

上面的介绍中,obejction采用attach附加模式进行Hook,这可能会让我们错过较早的Hook时机,可以通过如下的代码以spawn模式启动objection

objection -g com.xxx.xxx  explore --startup-command "android hooking watch class com.xxx.xxxxx"

日志

objection日志文件位于:

~/.objection/objection.log

命令历史文件位于:

~/.objection/objection_history

删除~/.objection目录后,在下次objection启动时会重新创建。

参考:

1 + 4 =
快来做第一个评论的人吧~