ios_hook.py
# _*_ coding: utf-8 _*_
# @Time:2021/10/28 4:10 下午
# @Author:YwY(慕白)
# @File:ios_frida_hook.py
import logging
import frida
import sys
logging.basicConfig(level=logging.DEBUG)
def on_message(message, data):
if message['type'] == 'send':
print("[*] {0}".format(message['payload']))
else:
print(message)
with open("ios_hook.js", 'r', encoding='utf-8') as f:
sta = ''.join(f.readlines())
rdev = frida.get_device(id ="设备id")
print("设备连接成功")
session = rdev.attach('app包名') #app包名
print("淘宝连接成功")
print(session)
script = session.create_script(sta)
print(script)
def show(message,data):
print(message)
script.on("message",show)
# 加载脚本
script.load()
sys.stdin.read()
ios_hook.js
var PDDURLRequestSetHeadersHook = eval('ObjC.classes.方法名["- 类名"]') #xxx["- xxx:xx:xxx:xx:xxxx:"]'
Interceptor.attach(PDDURLRequestSetHeadersHook.implementation, {
onEnter: function(args) {
console.log(`2----${ObjC.Object(args[2])}`)
console.log(`3----${ObjC.Object(args[3])}`)
console.log(`4----${ObjC.Object(args[4])}`)
console.log(`5----${ObjC.Object(args[5])}`)
console.log(`6----${ObjC.Object(args[6])}`)
//logBacktrace(this.context, "operationFromDict:")
}, onLeave: function(retval) {
console.log(`factorSign-result:${ObjC.Object(retval)}n`);
}
});