1、ADB 命令
// 链接虚拟机 端口号:夜神:62001、网易MUMU:7555、逍遥:21503
[root@xxx/]$ adb connect 127.0.0.1:21503
connected to 127.0.0.1:21503
// 查看当前设备
[root@xxx/]$ adb devices
List of devices attached
127.0.0.1:21503 unauthorized // USB调试同意前
127.0.0.1:21503 device // USB调试同意后
// 进入虚拟机环境命令中
[root@xxx/]$ adb shell
SM-S9010:/ # // 表示已经进入虚拟机环境命令中
// push PC 端推送数据到设备环境中
// adb push 本地地址文件 目标路径
[root@xxx/]$ adb push frida-server /data/local/tmp
// frida-server推送到虚拟机环境中 需要执行 所以需要配置权限
SM-S9010:/ # adb shell
SM-S9010:/ # cd /data/local/tmp
SM-S9010:/data/local/tmp # chmod 777 frida-server
SM-S9010:/data/local/tmp # ./frida-server // 执行文件
// adb push frida-server /data/local/tmp
// 查看 虚拟机 版本编码 并下载指定的 Frida-server
SM-S9010:/ # getprop ro.product.cpu.abi
arm64-v8a
| adb 命令 |
命令描述 |
| adb devices |
列出当前设备 |
| adb connect 127.0.0.1:21503 |
链接设备(注意端口) |
| adb shell |
进入 shell |
| adb kill-server |
关闭服务 |
| adb start-server |
启动服务 |
| adb reboot |
重启服务 |
| adb forward tcp:27042 tcp:27042 |
端口转发 |
| adb shell dumpsys activity top |
查看APK包名 |
| frida -ls -devices |
列出所有连接到计算机上的设备 |
| frida-ps -U |
列出正在运行的进程 |
| frida-ps -Uai |
列出安装的程序 |
| frida-ps -Ua |
列出运行中的程序 |
| frida-ps -D '设备ID' |
连接Frida到指定的设备 |
| frida-trace -U -f Name-i '函数名' |
跟踪某个函数 |
| frida-trace -U -f Name-m '方法名' |
跟踪某个方法 |
| frida -U -l *.js '进程ID' |
加载Js脚本 |
| frida -U -l *.js -f com.package.name |
加载Js脚本(程序包名) |
| frida -discover -n Name |
发现程序内部函数 |
| frida -discover -p pid |
发现程序内部函数 |
| frida -kill -U '进程ID' |
结束进程 |
2、Frida 工作环境搭建
- 直接使用 pip3 命令安装 Frida 、Frida-tools
// 安装 Frida
[root@xxx/]$ pip3 install Frida
// 安装 Frida-tools
[root@xxx/]$ pip3 install Frida-tools
3、Hook脚本
// 启动脚本命令:frida -U -l *.js -f com.package.name
setImmediate(function() {
console.log("[*] Starting script");
Java.perform(function() {
console.log("hello world start");
var myClass = Java.use("com.handsgo.hooktest.MainActivity");
myClass.clickMsg.implementation = function(v) {
console.log("hello world = " + v);
}
})
})
import frida
import sys
jscode = '''
Java.perform(function() {
console.log("hello world start");
var myClass = Java.use("com.handsgo.hooktest.MainActivity");
myClass.clickMsg.implementation = function(v) {
console.log("hello world = " + v);
}
});
'''
def on_message(message, data):
if message["type"] == 'send':
print("[*] {0}".format(message['payload']))
else:
print(message)
def load_js(pathName):
with open(pathName) as js_code:
return js_code.read()
return ''
def get_pid_by_name(device, name):
# 查看所有进程
processes = device.enumerate_processes()
for process in processes:
if str(name).lower() in str(process.name).lower():
return process.pid
def run_hook(app_name):
# get_usb_device获取设备
device = frida.get_usb_device()
# 加载需要hook的程序
pid = get_pid_by_name(device, app_name)
session = device.attach(pid)
# 加载js脚本
js_code = load_js(pathName)
script = session.create_script(jscode)
# 打印效果
script.on('message', on_message)
# 加载脚本
script.load()
sys.stdin.read()
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。