文章目录
1. 安装
推荐使用 py 版本 3.7 直接 (其余版本安装时都有点问题 3.7最简单)
pip install frida-tools 即可
2. inspect
先写一段 c++ 代码
#include<stdio.h>
#include<Windows.h>
void f(int a) {
printf(":%d\n", a);
}
int main() {
int a = 1;
printf("f: %p\n", f);
while (a > 0){
f(a);
Sleep(10 * 1000);
a += 1;
}
}
运行 打印出函数 f 的地址如下:
0x005C13BB
py 代码:
import frida
import sys
session = frida.attach("fri.exe")
// 这里脚本修改了函数 f 的入参
script = session.create_script("""
Interceptor.attach(ptr("%s"), {
onEnter: function(args) {
args[0] = ptr("-1");
}
});
""" % int(sys.argv[1], 16))
def on_message(message, data):
print(message)
script.on("message", on_message)
script.load()
sys.stdin.read()
可以看到 inspect 的代码运行后 命令行打印的值都是 -1