基础操作
import frida
print(frida.get_local_device())
# 获取远程usb 连接的设备
# rdev = frida.get_usb_device()
# 获取设备信息
rdev = frida.get_remote_device()
print(rdev)
获取在前台运行的APP
front_app = rdev.get_frontmost_application()
print("============》》》 正在运行的应用为:", front_app)
查看所有在模拟器上的应用
applications = rdev.enumerate_applications()
for application in applications:
print(application)
获取顶层应用进程
front_app = rdev.get_frontmost_application()
print(front_app)
frida操作的基础模板
# python
# -*- coding: utf-8 -*-
import frida
import sys
def on_message(message, data):
if message['type'] == 'send':
print("*****[frida hook]***** : {0}".format(message['payload']))
else:
print("*****[frida hook]***** : " + str(message))
def get_javascript(filepath):
code = ''
with open(filepath, 'r') as file:
code = code + file.read()
return code
# 连接远端设备
device = frida.get_remote_device()
# 附加到进程
session = device.attach(package_name)
# 1、直接写入 javascript 代码
javascript = """
<javascript code>
"""
# 2、从文件中加载 javascript 脚本代码
javascript = get_javascript(javascript_file)
# 基于脚本内容创建运行脚本对象
script = session.create_script(javascript)
script.on('message', on_message)
# 加载脚本并执行
script.load()
sys.stdin.read()
参考文章:https://blog.csdn.net/tabactivity/article/details/88313965
参考文章:https://blog.csdn.net/zouyuanxc/article/details/80922387?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.channel_param