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 一个简单使用,从功能体验上,frida 还是比较强大的,而且还是比较灵活的,很值得深入学习下

参考资料

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

posted on   荣锋亮  阅读(62)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2021-09-04 修改java jar内容的方法
2021-09-04 基于minfs 的静态网站部署模式
2021-09-04 minfs 简单介绍
2021-09-04 几个不错的s3 压力测试工具
2020-09-04 Interpreting /proc/meminfo and free output for Red Hat Enterprise Linux 5, 6 and 7
2018-09-04 restheart 基本使用
2017-09-04 centos 7 bbr 安装

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示