關于TinyTracer

TinyTracer是一款功能強大的API調用跟蹤工具,在該工具的幫助下,廣大研究人員能夠輕松實現API的調用跟蹤。

功能介紹

1、支持跟蹤API調用,其中包括參數和選擇的目標函數;
2、選擇的指令,包括RDTSCCPUIDINT
3、內聯系統調用,包括參數和選擇的syscall;
4、支持在被跟蹤模塊的各個部分之間切換(可以幫助找到封裝模塊的OEP);
5、支持基于RDTSC繞過反跟蹤機制;

工具要求

Intel PIN
Visual Studio(Windows)
g++、make(Linux)

工具下載

廣大研究人員可以使用下列命令將該項目源碼克隆至本地:

git clone https://github.com/hasherezade/tiny_tracer.git

工具構建

Windows

在Windows平臺上,我們需要使用Visual Studio( >= 2012)來編譯和構建工具代碼,當前版本的TinyTracer已在Intel Pin 3.28上進行過測試。

接下來,將克隆下來的代碼拷貝到Pin根目錄的\source\tools路徑下,然后在Visual Studio中導入項目,并進行代碼構建即可。

Linux

在Linux平臺下,我們可以直接運行tiny_runner.sh腳本來完成工具的構建:

ln -s $HOME/pin/source/tools/tiny_tracer/install32_64/tiny_runner.sh ~/bin/tiny_runner.sh

ln -s $HOME/pin/source/tools/tiny_tracer/install32_64/ $HOME/Desktop/install32_64

注意事項

1、為了保證工具能夠正常運行,內核調試功能必須被禁用;
2、在項目的install32_64目錄中,提供了用于檢測內核調試功能是否已禁用的腳本,該腳本可能會被Windows Defender檢測為惡意軟件;
3、請在Windows 8+環境使用該工具;

工具使用

下面給出的是一個跟蹤調用的演示樣例:

~/Desktop/pin_tests$ tiny_runner.sh ./demo


Linux runner for Tiny Tracer

Usage: <target_app> [target_module*]

*-optional; default: target app's main module

Traced App: ./demo

Traced Module Name: demo

The app is 64 bit.

Watch 5 functions

Watch 0 syscalls

===============================================

This application is instrumented by TinyTracer v.2.2

Tracing module: demo

See file ./demo.tag for analysis results

===============================================

Hello World!

以.tag格式生成一份跟蹤報告,之后可將其加載到其他分析工具中進行進一步分析:

RVA;traced event

生成結果如下:

345c2;section: .text

58069;called: C:\Windows\SysWOW64\kernel32.dll.IsProcessorFeaturePresent

3976d;called: C:\Windows\SysWOW64\kernel32.dll.LoadLibraryExW

3983c;called: C:\Windows\SysWOW64\kernel32.dll.GetProcAddress

3999d;called: C:\Windows\SysWOW64\KernelBase.dll.InitializeCriticalSectionEx

398ac;called: C:\Windows\SysWOW64\KernelBase.dll.FlsAlloc

3995d;called: C:\Windows\SysWOW64\KernelBase.dll.FlsSetValue

49275;called: C:\Windows\SysWOW64\kernel32.dll.LoadLibraryExW

4934b;called: C:\Windows\SysWOW64\kernel32.dll.GetProcAddress

...

我們也可以通過修改install32_64目錄中的TinyTracer.ini和parameters.txt來啟用或禁用某些功能。

項目地址

TinyTracer:https://github.com/hasherezade/tiny_tracer"

參考資料

https://c9x.me/x86/html/file_module_x86_id_278.html
https://c9x.me/x86/html/file_module_x86_id_45.html
https://c9x.me/x86/html/file_module_x86_id_142.html
https://visualstudio.microsoft.com/downloads/
https://software.intel.com/en-us/articles/pin-a-binary-instrumentation-tool-downloads?