用python写pintool
来源:互联网 发布:阿里云邮件推送 编辑:程序博客网 时间:2024/06/02 02:22
1. 今天看到有人公布了一个用python来写pin的源码:
https://github.com/blankwall/Python_Pin
所以下载下来试了试。
2. Pin介绍
Pin是intel出的二进制插桩工具,主要用于二进制程序分析。用户可以通过其提供的接口编写pintool。不过编写pintool都是用c++语言编写的。官网:
https://software.intel.com/en-us/articles/pin-a-dynamic-binary-instrumentation-tool
Python-pin主要对pin做了一层包装,使用户可以用python写pintool,减少代码量。
3. 编译
环境:Ubuntu 12.04
下载python-pin后,放到~/pin/source/tools目录下。
cd Python-Pin-mastermake
报错,应该是对REG_EBX等进行了重定义。
将ucontext.h中相关定义全部注释掉。
重新make成功。
4. 使用
Example目录下有一些作者写好的例子,这里选择了一个统计运行指令条数的例子:
import sys, pin total = 0 info =file("inscount.out", "w") defcounter(trace_addr): globaltotal x =pin.TRACE_BblHead(trace_addr) y =pin.BBL_Address(x) instrucs =pin.BBL_NumIns(x) total +=instrucs info.write("Basic Block @ %x SIZE: %x NUM INS= IN BLOCK: %x TOTAL: %x\n" % (y, pin.BBL_Size(x),instrucs, total )) pin.TRACE_AddInstrumentFunction(counter)
运行命令:
../../../pin -t obj-ia32/Python_Pin.so -mexamples/ins_count.py -- /bin/ls
5. 64位系统使用pin
../../../pin是一个32位的程序,所以不能直接用它。
所以命令应该为
../../../intel64/bin/pinbin -tobj-intel64/Python_Pin.so -m examples/ins_count.py -- /bin/ls
不过报错了。
报错了,不过这个库是有的,只是没有找到而已。
设置LD_LIBRARY_PATH来指定库的查找路径:
exportLD_LIBRARY_PATH=/home/ling/pin/intel64/lib-ext/
之后,再运行就不会报错了。
0 0
- 用python写pintool
- pintool
- PinTool使用小结
- 用 Python写 daemon
- 用python写exploit
- 用python写游戏
- 用python写爬虫
- 用Python写Exploit
- 用 Python写 daemon
- 用python写makefile
- 用python写makefile
- 用python写ASP脚本
- 用python写一个singleton
- 用python写Hello World
- 用Eclipse+Pydev写Python
- 用Emacs 写python了
- 用Python写post请求
- 用Python写的日历
- CentOS编译OpenJDK
- 数据结构实验2——链表
- javascript var
- 基于ARM的nucleus plus的执行
- Print all nodes that are at distance k from a leaf node
- 用python写pintool
- 网络基本功(三):细说VLAN与Trunk
- 《设计模式之禅》笔记16 -- 组合模式
- myeclipse2014关闭html,jsp等页面的可视化编辑器
- Spring Framework源码(八):SpringMVC概览
- 设计模式几点原则
- 遍历可变数组的同时删除元素
- Spring(三) spring对jdbc的封装
- 网络基本功(四):细说路由(上)