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初探的更多相关文章

  1. 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 ...

  2. intel Pin:动态二进制插桩的安装和使用,以及如何开发一个自己的Pintool

    先贴几个你可能用得上的链接 intel Pin的官方介绍Pin: Pin 3.21 User Guide (intel.com) intel Pin的API文档Pin: API Reference ( ...

  3. Intel Pin基础

    参考:http://software.intel.com/sites/landingpage/pintool/docs/62732/Pin/html/ http://blog.nruns.com/bl ...

  4. [转]Data Structure Recovery using PIN and PyGraphviz

    Source:http://v0ids3curity.blogspot.com/2015/04/data-structure-recovery-using-pin-and.html --------- ...

  5. 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 ...

  6. pin-a-binary-instrumentation-tool

    https://software.intel.com/en-us/articles/pin-a-binary-instrumentation-tool-downloads Introduction t ...

  7. Vuzzer自动漏洞挖掘工具简单分析附使用介绍

    Vuzzer 是由计算机科学机构  Vrije Universiteit Amsterdam.Amsterdam Department of Informatics 以及 International ...

  8. VEX IR语言语法

    /*---------------------------------------------------------------*//*--- High-level IR description - ...

  9. libVEX学习

    VEX IR是一种更加接近于compiler使用的中间语言/中间表示,它是不依赖于特定体系架构的. 1. Code Blocks code blocks是VEX处理代码的一个单元,使用IRSB结构体表 ...

  10. Valgrind学习

    Valgrind与其他DBI(Pin, DynamoRIO)的区别 我们需要了解DBI的几个 D&R Disassemble-and-Resynthesise 反汇编后重新组装 Valgrin ...

随机推荐

  1. Java如何将Object转换成指定Class对象

    在Java中,将Object转换为指定类型的Class对象实际上是两个不同概念的操作: 将Object实例转换为特定类型的实例:这通常涉及到类型转换(如(MyType) myObject)或者通过反射 ...

  2. JIT编译选项

    JIT(Just-In-Time)优化在编译过程中有多种编译选项可以支持,不同语言和平台可能有不同的实现.以通用的 JIT 编译器为例,以下是一些常见的编译选项: 编译级别(Compilation L ...

  3. 【ARMv8】异常级别的定义EL0、EL1、EL2、EL3

    Exception levels ARMv8-A系列定义了一系列的异常等级,从EL0到EL3,下面具体说明其含义: ELn中,随着n的增加,软件的执行权限也相应的增加: EL0被称为无特权执行: EL ...

  4. iOS生成ipa包的时候总是弹窗提示macOS想要使用系统钥匙串

    最近新换了一台苹果电脑,性能不错,不过证书和描述文件需要重新配置,遇到了一系列奇怪的问题.在这里整理记录下来,希望能给其他人提供一些帮助.iOS生成ipa包的时候总是弹窗提示[macOS想要使用系统钥 ...

  5. 轨道控制器 threejs

    就是一个可以360转动的相机,通过不断的改变相机的参数 然后渲染达到效果. // 引入相机控件  -- 轨道控制器 // console.log('OrbitControls',OrbitContro ...

  6. CSharp的@microsoft/signalr实时通信教程 - 前端 vue

    1. 安装@microsoft/signalr pnpm install @microsoft/signalr --save signalr 是微软对 websocket技术的封装,优化了操作 :1. ...

  7. 59 张高清大图,带你实战入门 KubeSphere DevOps

    作者:运维有术星主 KubeSphere 基于 Jenkins 的 DevOps 系统是专为 Kubernetes 中的 CI/CD 工作流设计的,它提供了一站式的解决方案,帮助开发和运维团队用非常简 ...

  8. vue中的prop组件封装

    学习vue有一段时间了,也写了一些东西.今天看文档突然看到了一个好玩的东西,那就是prop.prop的作用是父组件中引用了子组件并给子组件加了一个属性,这个属性可以是静态的,可以是动态的,可以是数字, ...

  9. Abp源码分析之Abp最小系统

    最小系统 创建API项目 创建API项目并安装以下依赖 修改Program.cs为以下内容 using BookApp; var builder = WebApplication.CreateBuil ...

  10. C240731B

    B 游戏类问题 先假设一瓶毒药都不用, 先把治疗的贡献加进答案里面,这样治疗.毒药.攻击的贡献分别是独立的. 如果 \(i\) 位置本来是治疗, 那么用毒药多扣的血是 \(a[i]=(p+r) \ti ...