本文主要记录了Frida的一些模板和配置及一些场景目录和问题记录
前提是已经安装了Frida,查看其他文章
启动和配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| adb root adb shell
cd /data/local/tmp
chmod 755 frida-server
./frida-server
adb forward tcp:27042 tcp:27042 adb forward tcp:27043 tcp:27043
frida-ps -U
|
Frida的一些模板和配置
python模板
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 38 39 40 41 42 43 44 45 46
| import frida import sys
def on_message(message, data): if message["type"] == "send": print(message["payload"]) else: print(message)
def hook_target_application(app_name, js_file): with open(js_file, encoding="utf-8") as fin: script_source = fin.read()
device = frida.get_usb_device()
process = device.attach(app_name) script = process.create_script(script_source) script.on("message", on_message) script.load()
sys.stdin.read()
script.unload() process.detach()
if __name__ == "__main__": app_name = "My Application" js_file = "scripts/js_file.js" hook_target_application(app_name, js_file)
|
js模板
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| Java.perform(function () { var Activity = Java.use('com.example.myapplication.MainActivity'); Activity.check.implementation = function (str) { console.log('getResult called with:', str); var result = this.check(str); console.log('getResult returned:', result); result = "right"; return result; }; });
|
利用脚本
有这样一个场景 打开闪退
所以需要frida进行自启动app
1 2 3
| adb shell pm list packages|findstr che
frida -U -f com.chehejia.oc.m01 -l hook.js
|
Q
process = device.attach(app_name)
如果使用包名的话,会报错,需要使用进程id或者应用名称
Github也有这个issue?