Frida Python库使用
启动 Frida 服务
包名附加
import frida, sys
jsCode = """ ...... """
process = frida.get_usb_device().attach('com.dodonew.online')
script = process.create_script(jsCode)
script.load()
sys.stdin.read()
pid 附加
process = frida.get_usb_device().attach(1234) # 1234 pid
spawn 方式启动
device = frida.get_usb_device()
pid = device.spawn(["com.dodonew.online"]) # 以挂起方式创建进程
process = device.attach(pid)
script = process.create_script(jsCode)
script.load()
device.resume(pid) # 加载完脚本, 恢复进程运行
sys.stdin.read()
连接非标准端口
process = frida.get_device_manager().add_remote_device('192.168.3.68:8888').attach('com.dodonew.online')
连接多个设备
process = frida.get_device_manager().add_remote_device('192.168.3.68:8888').attach('com.dodonew.online')
script = process.create_script(jsCode)
script.load()
process1 = frida.get_device_manager().add_remote_device('192.168.3.69:8888').attach('com.dodonew.online')
script1 = process.create_script(jsCode)
script1.load()
sys.stdin.read()
frida 与 Python 的交互
# -*- coding: UTF-8 -*-
import frida, sys
jsCode = """"""
def onMessage(message, data):
# print(message)
# {'type': 'send', 'payload':'some strings'}
if message["type"] == 'send':
print(u"[*] {0}".format(message['payload']))
else:
print(message)
process = frida.get_usb_device().attach('com.dodonew.online')
script = process.create_script(jsCode)
script.on('message', onMessage)
script.load()
sys.stdin.read()
在 jscode 中可以使用send(data)
,将数据传入到 onMessage 回调函数中处理。