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. Ai大模型推理-未完善

    环境 安装Conda 最低要求 CUDA 版本为 11.3 #获取安装脚本 wget -c 'https://repo.anaconda.com/archive/Anaconda3-2024.06-1 ...

  2. SpringBoot项目使用yml文件链接数据库异常

    SpringBoot使用properties连接数据库时没有出现问题 SpringBoot使用yml连接数据库时出现:Unable to connect to Redis 并在报错信息中出现: 发现是 ...

  3. Oracle 23c 新特性实操体验优质文章汇总 | 有奖征文进行中欢迎参与

    继4月3日甲骨文宣布推出免费开发者版 Oracle Database 23c后,墨天轮社区发起 "Oracle 23c 免费开发者版特性体验"有奖征文活动,邀请大家分享Oracle ...

  4. iOS中RunLoop和线程的关系

    RunLoop又叫运行循环,主要用来管理线程.一个线程对应一个RunLoop,一个RunLoop又有五种模式.只有主线程的RunLoop是默认开启的,所以程序在开启后,会一直运行,不会退出.其他线程的 ...

  5. signalR的身份认证

  6. 02-react中jsx的基本使用

    // 使用 createElement太繁琐 不直观 不优雅开发体验不好 代码维护不行 // jsx 不是 js 而是 js的扩展语法 // jsx 是react的核心内容 // react项目中已经 ...

  7. npm install报错 SyntaxError: Unexpected end of JSON input while parsing near '...=GmVg\r\n-----END PGP'

    解决方法:  npm cache clean --force 然后重新执行:npm install即可

  8. 云原生周刊:K8sGPT 加入 CNCF | 2024.1.8

    开源项目推荐 VolSync VolSync 使用 rsync 或 rclone 在集群之间异步复制 Kubernetes 持久卷.它还支持通过 Restic 创建持久卷的备份. KubeClarit ...

  9. 掌控物体运动艺术:图扑 Easing 函数实践应用

    现如今,前端开发除了构建功能性的网站和应用程序外,还需要创建具有吸引力且尤为流畅交互的用户界面,其中动画技术在其中发挥着至关重要的作用.在数字孪生领域,动画的应用显得尤为重要.数字孪生技术通过精确模拟 ...

  10. Redis数据结构:List类型全面解析

    文章目录 一.List数据类型 1.1 简介 1.2 应用场景 1.3 底层结构 二.数据结构 2.1 压缩列表ZipList 2.2 双向链表LinkedList(后续已废弃) 2.3 快速链表Qu ...