Intel Pin初探
1、在/home/hf/Desktop/pin/pin-3.30-98830-g1d7b601b3-gcc-linux/source/tools/ManualExamples/目录下写自己的pintools
去到该目录
cd /home/hf/Desktop/pin/pin-3.30-98830-g1d7b601b3-gcc-linux/source/tools/ManualExamples/
编写pintools
vim Mycmp.cpp
下面是Mycmp.cpp内容
#include "pin.H"
#include <iostream>
#include <fstream>
std::ofstream outfile;
VOID Instruction(INS ins, VOID *v)
{
if (INS_Opcode(ins) == XED_ICLASS_CMP)
{
outfile << "CMP Instruction at address: " << INS_Address(ins) << std::endl;
for (UINT32 i = 0; i < INS_OperandCount(ins); ++i)
{
if (INS_OperandIsReg(ins, i))
{
outfile << "Operand " << i << ": Register" << std::endl;
}
else if (INS_OperandIsMemory(ins, i))
{
outfile << "Operand " << i << ": Memory" << std::endl;
}
else if (INS_OperandIsImmediate(ins, i))
{
outfile << "Operand " << i << ": Immediate Value: " << INS_OperandImmediate(ins, i) << std::endl;
}
}
outfile << std::endl;
}
}
VOID Fini(INT32 code, VOID *v)
{
outfile.close();
}
int main(int argc, char *argv[])
{
// Initialize Pin
PIN_InitSymbols();
if (PIN_Init(argc, argv))
{
return -1;
}
// Open output file
outfile.open("cmp_operations.txt");
// Register Instruction to be called to instrument instructions
INS_AddInstrumentFunction(Instruction, 0);
// Register Fini to be called when the application exits
PIN_AddFiniFunction(Fini, 0);
// Start the program, never returns
PIN_StartProgram();
return 0;
}
2、生成pintool
当前在目录下
输入
make obj-intel64/Mycmp.so TARGET=intel64
这时可以在obj-intel64目录下查看到Mycmp.so

3、使用Pintool
我的mytools.so在/home/hf/Desktop/pin/pin-3.30-98830-g1d7b601b3-gcc-linux/source/tools/ManualExamples/obj-intel64/,要分析的service.exe在/home/hf/Desktop/pin/
去目录下
cd /home/hf/Desktop/pin/pin-3.30-98830-g1d7b601b3-gcc-linux/
使用命令执行pintool
./pin -t /home/hf/Desktop/pin/pin-3.30-98830-g1d7b601b3-gcc-linux/source/tools/ManualExamples/obj-intel64/Mycmp.so -- /home/hf/Desktop/pin/service.exe
这个命令的格式为 pin -t <pintool目录绝对路径> -- <要分析的程序的绝对路径>
上面的方法会将结果输出到命令行,我们还可以将结果输出到一个文本文件中,只需在命令后加上 > output.txt
即
./pin -t /home/hf/Desktop/pin/pin-3.30-98830-g1d7b601b3-gcc-linux/source/tools/ManualExamples/obj-intel64/Mycmp.so -- /home/hf/Desktop/pin/service.exe > output.txt
注意:此时可能没有操作server.exe的权限
使用命令查看server.exe的权限
ls -l /home/hf/Desktop/pin/Server.exe
如果输出中没有执行权限(x 权限),可以使用 chmod 命令添加执行权限:
chmod +x /home/hf/Desktop/pin/Server.exe
Intel Pin初探的更多相关文章
- Intel pin 2.14/CentOS 6 X86-64/安装
环境:Intel Pin 2.14 CentOS 6 X86-64 --linux.tar.gz 进入 ./source/tools/ManualExamples make all TARGET=in ...
- intel Pin:动态二进制插桩的安装和使用,以及如何开发一个自己的Pintool
先贴几个你可能用得上的链接 intel Pin的官方介绍Pin: Pin 3.21 User Guide (intel.com) intel Pin的API文档Pin: API Reference ( ...
- Intel Pin基础
参考:http://software.intel.com/sites/landingpage/pintool/docs/62732/Pin/html/ http://blog.nruns.com/bl ...
- [转]Data Structure Recovery using PIN and PyGraphviz
Source:http://v0ids3curity.blogspot.com/2015/04/data-structure-recovery-using-pin-and.html --------- ...
- Tracing Memory access of an oracle process : Intel PinTools
https://mahmoudhatem.wordpress.com/2016/11/07/tracing-memory-access-of-an-oracle-process-intel-pinto ...
- pin-a-binary-instrumentation-tool
https://software.intel.com/en-us/articles/pin-a-binary-instrumentation-tool-downloads Introduction t ...
- Vuzzer自动漏洞挖掘工具简单分析附使用介绍
Vuzzer 是由计算机科学机构 Vrije Universiteit Amsterdam.Amsterdam Department of Informatics 以及 International ...
- VEX IR语言语法
/*---------------------------------------------------------------*//*--- High-level IR description - ...
- libVEX学习
VEX IR是一种更加接近于compiler使用的中间语言/中间表示,它是不依赖于特定体系架构的. 1. Code Blocks code blocks是VEX处理代码的一个单元,使用IRSB结构体表 ...
- Valgrind学习
Valgrind与其他DBI(Pin, DynamoRIO)的区别 我们需要了解DBI的几个 D&R Disassemble-and-Resynthesise 反汇编后重新组装 Valgrin ...
随机推荐
- Linux_Bash_Shell_索引数组和关联数组及稀疏数组
1. 索引数组 一.什么是索引数组? 所谓索引数组就是普通数组,以整数作为数组元素的索引下标. 二.实例. 备注: (a)使用-a选项定义索引数组,使用一对小括号()定义数组中的元素列表. (b)索引 ...
- 普元中间件Primeton AppServer6.5安装(Windows)
本文在Windows环境下安装普元中间件Primeton AppServer6.5(以下简称PAS) 一.安装前准备 1.1使用软件版本 Primeton_AppServer_6.5_Enterpri ...
- pstore
简介 pstore文件系统(是的,这是个文件系统)是Persistent Storage的缩写,最早在2010年由 Tony Luck 设计并合入Linux主分支,设计的初衷是在内核Panic/Oop ...
- 2022年9月中国数据库排行榜:榜眼、探花纷纷易主,AnalyticDB蝉联榜单十强
夏去秋来清风至,榜首前三起涟漪. 2022年9月的 墨天轮中国数据库流行度排行榜火热出炉,相比上月新增两个数据库, 本月榜单前十名可以用一句话概括为:OceanBase新版发布先声夺人,达梦低调做事暂 ...
- C#查漏补缺----Exception处理实现,无脑抛异常不可取
前言 环境:.NET 8.0 系统:Windows11 参考资料:CLR via C#, .Net Core底层入门 https://andreabergia.com/blog/2023/05/err ...
- kotlin更多语言结构——>异常
异常类 Kotlin 中所有异常类都是 Throwable 类的子孙类.每个异常都有消息.堆栈回溯信息以及可选的原因 使用 throw-表达式来抛出异常 throw Exception("H ...
- mysql进阶-存储引擎篇
本篇是将基础篇的知识进行深化了解底层机制的同时讲解企业中涉及到的高层级知识. 存储引擎 1.MySQL体系结构 连接层 最上层是一些客户端和链接服务,主要完成一些类似于连接处理.授权认证.及相关的安全 ...
- Docker升阶
一.Docker镜像 镜像的定义:镜像是一种轻量级.可执行的独立软件包,它包含运行某个软件所需的所有内容,我们把应用程序和配置依赖打包好形成一个可交付的运行环境(包括代码.运行时需要的库以及环境变量和 ...
- python多进程完成模拟支付
#!/usr/bin/python # -*- coding: UTF-8 -*- '''@auther :mr.qin @IDE:pycharm''' from tool.Common import ...
- 写代码被大语言模型坑之使用LocalDateTime比较两个时间差了几天
自从去年ChatGPT3.5发布后使用了几次,现在写代码基本上离不开它和它的衍生产品们了.一方面查资料很方便,快速提炼要点总结:另一方面想写什么样的代码一问就能生成出来,功能大差不差,稍微改改就能用, ...