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. 大年初四,Flutter Forward 中国社区直播活动与你不见不散

    之前我们预告过,2023 年 1 月 25 日 (年初四),Flutter 团队将在肯尼亚首都内罗毕举办 Flutter Forward 大会,并同时开启线上直播.本次活动将为展示最新的 Flutte ...

  2. CSP-S 2023

    T1 直接 \(10^{5}\) 枚举状态就过了,合法的非零差分数量只可能为 \(1,2\)(\(0\) 相当于没转,按照题意 "都不是正确密码" 是不符的) 需要注意的是形如 0 ...

  3. Java以封装对象的方式读取CSV文件存储数据库

    依赖 <!-- https://mvnrepository.com/artifact/net.sourceforge.javacsv/javacsv --> <dependency& ...

  4. RedisTemplate设置的key,redis客户端取不到

    原因:RedisTemplate 在set key时,key被序列化 解决办法1: import org.springframework.context.annotation.Bean; import ...

  5. LeetCode 218. 天际线问题 (扫描线+优先队列)

    扫描线+优先队列 https://leetcode-cn.com/problems/the-skyline-problem/solution/tian-ji-xian-wen-ti-by-leetco ...

  6. /proc/pids/status

    /proc/279/status是一个Linux内核中的文件,其中包含了当前进程的状态信息.每行的含义如下: Name: 进程的名称,例如"java"或"bash&quo ...

  7. amfe-flexible 包设置rem的基本值 vue 移动端适配方案

    下载 安装 :npm i -S amfe-flexible gw:GitHub - amfe/lib-flexible: 可伸缩布局方案 下载 2 个第三方包即可实现移动端适配 amfe-flexib ...

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

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

  9. php运行redis测试

    在今天将官方的redis教程看完之后,想自己来一个测试. 按照官方给出的代码: 1 <?php 2 //连接本地的 Redis 服务 3 $redis = new Redis(); 4 $red ...

  10. 在浏览器输入 URL 回车之后发生了什么(流程图,超详细版)

    前言 这个问题已经是老生常谈了,更是经常被作为面试的压轴题出现,网上也有很多文章,但最近闲的无聊,然后就自己做了一篇笔记,感觉比之前理解更透彻了. 这篇笔记是我这两天看了数十篇文章总结出来的,所以相对 ...