面向开发人员、逆向工程师和安全研究人员的动态检测工具包。
https://github.com/frida/frida
pip install frida-tools # CLI tools
pip install frida # Python bindings
npm install frida # Node.js bindings
npm 是 Node.js 的包管理器,需要安装Node.js才能使用npm命令。
ADB调试模式
手机连接电脑,开启USB调试模式(手机设置点击版本号7次,进入开发人员选项)
命令行终端执行
adb devices
adb push ./frida_server /data/local/tmp
adb shell
frida_server下载地址:https://github.com/frida/frida/releases/
根据手机架构选择对应架构软件
adb 终端执行
su
cd /data/local/tmp
chmod +x frida_server
./frida_server &
import frida
import sys
# 消息处理
def on_message(message, data):
if message['type'] == 'send':
print("[*] {0}".format(message['payload']))
else:
print(message)
# 获取usb设备
device = frida.get_usb_device()
# 获取本地设备
# device = frida.get_local_device()
# 获取远程设备
# device = frida.get_remote_device()
# 设置应用程序包名
pid = device.spawn(['com.example.frida_test'])
# attach 前不加resume可能会报错
device.resume(pid)
session = device.attach(pid)
# 打开js文件
with open("hook.js", encoding="utf-8") as f:
script = session.create_script(f.read())
script.on("message", on_message)
script.load()
sys.stdin.read()
hook_1.js