/minitks_pintool

A mini team knowledge sharing of Pin Tool

Primary LanguageC++

MiniTKS: Pin Tool

Intro

  • Pin is a dynamic binary instrumentation framework for dynamic program analysis
  • What's the Dynamic Binary Instrumentation?
    Machine Code --> IR --> IR --> Machine Code
            ^        ^      ^
            |        |      |
        translate    |      |
                     |      |
                instrument  |
                            |
                         translate  
    
  • Instrumentation is performed at run time on the compiled binary files
    • No requirement to recompile the source code
  • With the Pin framework, you can develop your own pin tool for what you want to analysis

Prerequisites

  • g++
  • make

Exercises

01: Download Pin and build an example Pin Tool

First, download Pin from the link: Pin - A Binary Instrumentation Tool - Downloads

Then,

$ tar zxf pin-3.24-98612-g6bd5931f2-gcc-linux.tar.gz

Build a Pin Tool:

$ tar zxf pin-3.24-98612-g6bd5931f2-gcc-linux.tar.gz
$ cd pin-3.24-98612-g6bd5931f2-gcc-linux/source/tools/ManualExamples
$ make obj-intel64/malloctrace.so TARGET=intel64

Run the Pin Tool and check the result:

$ ../../../pin -t obj-intel64/malloctrace.so -- /bin/ls
$ cat malloctrace.out

02: Correct the lost function of the simple instruction counter

$ cd pin-3.24-98612-g6bd5931f2-gcc-linux/source/tools
$ git clone <This repo>
$ cd minitks_pintool/
$ make
$ ../../../pin -t ./obj-intel64/inscount_broken.so -- ls
$ cat inscount.out

Other Applications

References