Win at Reversing
API Tracing and Sandboxing through Inline Hooking
Win at Reversing API Tracing and Sandboxing through Inline Hooking - - PowerPoint PPT Presentation
Win at Reversing API Tracing and Sandboxing through Inline Hooking Nick Harbour Agenda Reverse Engineering Primer Approaches to Dynamic Analysis Inline Hooks Advantages Over Other Techniques Usages 2 Reverse Engineering
API Tracing and Sandboxing through Inline Hooking
2
3
devided into two categories: Static and Dynamic Analysis
4
5
SSDT SSDT
User Mode Process Kernel32.dll Kernel32.dll Ntdll.dll Ntdll.dll Calls CreateFile() Kernel
ZwCreateFile ZwCreateFile() ()
System Call Performed
6
SSDT SSDT
User Mode Process Kernel32.dll Kernel32.dll Ntdll.dll Ntdll.dll Calls CreateFile() Kernel
ZwCreateFile ZwCreateFile() ()
Procmon.sys Procmon.sys
System Call Performed
7
calls
is implemented as a system call
housekeeping and calls from usercode
8
9
system calls
to the program’s operation
10
to the program’s operation
11
SSDT SSDT
User Mode Process Kernel32.dll Kernel32.dll Ntdll.dll Ntdll.dll Calls CreateFile() Kernel
ZwCreateFile ZwCreateFile() ()
System Call Performed
Hook Hook Handler Handler
12
function
instruction
function
13
a DLL, for example, you might run into a function such as the one below
beyond the end of the function. somefunction: 31 C0 xor eax, eax C3 retn
14
55 push ebp 89 E5 mov ebp, esp 81 EC 18 00 00 00 sub esp, 24 31 C9 xor ecx, ecx … hooked_function: E9 E4 7C FF FF jmp <handler> 18 00 00 00 ;unused 31 C9 xor ecx, ecx
15
gathering data from stack and report to console
function
intended function
16
fixed IP address.
reads and writes to files and netwok sockets.
MapViewOfFile()…
17
before the target process is resumed
process monitor-style console
handlers for specific hooked functions
18
nick.harbour@mandiant.com nickharbour@gmail.com