0
点赞
收藏
分享

微信扫一扫

frida 简单试用

内容来自官方访问,主要是一个学习试用

安装frida

推荐基于venv

python3 -m venv venv
source venv/bin/activate
pip install frida-tools

案例

进行分析c 语言的函数调用

hello.c
#include <stdio.h>
#include <unistd.h>

void
f (int n)
{
printf ("Number: %d\n", n);
}

int
main (int argc,
char * argv[])
{
int i = 0;

printf ("f() is at %p\n", f);

while (1)
{
f (i++);
sleep (1);
}
}
构建

gcc -Wall hello.c -o hello
frida 钩子
hook.py

from __future__ import print_function
import frida
import sys

session = frida.attach("hello")
script = session.create_script("""
Interceptor.attach(ptr("%s"), {
onEnter: function(args) {
send(args[0].toInt32());
}
});
""" % int(sys.argv[1], 16))
def on_message(message, data):
print(message)
script.on('message', on_message)
script.load()
sys.stdin.read()

运行

  • 运行hello
    同时会包含地址
    地址信息 0x40057d

 

./hello 
f() is at 0x40057d
Number: 0

捕捉

python hook.py  0x40057d

效果

frida 简单试用_#include

 

 

说明

以上是frida 一个简单使用,从功能体验上,frida 还是比较强大的,而且还是比较灵活的,很值得深入学习下

参考资料

​​https://frida.re/docs/functions/​​

举报

相关推荐

0 条评论