API hooking o Usermode n Win 32 API

  • Slides: 20
Download presentation

API hooking o User-mode n Win 32 の API を Hooking o o 演習

API hooking o User-mode n Win 32 の API を Hooking o o 演習 3の研究内容(Detours) Kernel-mode n Native API を Hooking 5

User-mode Hooking o Proxy DLL [3] n o API Patching [4] n n o

User-mode Hooking o Proxy DLL [3] n o API Patching [4] n n o DLL を置き換える API の中身を書き換える Detours IAT Patching [4][5] n n Import Address Table の値を書き換える Detours にもこの機能あり 6

Detours の適用例 Before ; ; Target Function Sleep: push ebp mov ebp, esp push

Detours の適用例 Before ; ; Target Function Sleep: push ebp mov ebp, esp push ebx push esi push edi. . ; ; Trampoline Function Untimed. Sleep: jmp Sleep ; ; Detour Function Timed. Sleep: . . After [1 [2 [1 [1 byte] bytes] byte] ; ; Target Function Sleep: jmp Timed. Sleep [5 bytes] push edi ; Sleep+5. . ; ; Trampoline Function Untimed. Sleep: push ebp mov ebp, esp push ebx push esi jmp Sleep+5 ; ; Detour Function Timed. Sleep: . . jmp Untimed. Sleep 8

IAT Patching o o o Import Address Table を書き換える Detours にもこの機能あり この手法の文献は多い 10

IAT Patching o o o Import Address Table を書き換える Detours にもこの機能あり この手法の文献は多い 10

Updating IAT DLL EXE 関数名 : IAT アドレス Create. File Open. File : :

Updating IAT DLL EXE 関数名 : IAT アドレス Create. File Open. File : : : 12

Using IAT for Hooking DLL EXE 関数名 : IAT アドレス Create. File Open. File

Using IAT for Hooking DLL EXE 関数名 : IAT アドレス Create. File Open. File : 自分の : : コード 13

IAT Patching の回避策 Getprocaddr(Load. Library(“kernel 32. dll”), “Create. File. A”) Kernel 32. dll 関数名

IAT Patching の回避策 Getprocaddr(Load. Library(“kernel 32. dll”), “Create. File. A”) Kernel 32. dll 関数名 アドレス Create. File. A プログラム Open. File o プログラムの任意の場所で読み込める o IAT は関係ない 15

API & System Call Windows Unix系 API System Call 今までの System call での テクニックが利用可能

API & System Call Windows Unix系 API System Call 今までの System call での テクニックが利用可能 17

参考文献(1) An In-Depth Look into the Win 32 Portable Executable File Format (Part 1

参考文献(1) An In-Depth Look into the Win 32 Portable Executable File Format (Part 1 & 2) 1. http: //www. msdn. microsoft. com/msdnmag/issues/02/02/PE/default. aspx http: //www. msdn. microsoft. com/msdnmag/issues/02/03/PE 2/default. aspx n n 2. Process-wide API spying n 3. http: //www. codeproject. com/system/api_spying_hack. asp API Spying Techniques n http: //www. internals. com/articles/apispy. htm 19

参考文献(2) 4. Detours n 5. Hooking Windows NT System Services n 6. http: //research.

参考文献(2) 4. Detours n 5. Hooking Windows NT System Services n 6. http: //research. microsoft. com/sn/detours/ http: //www. windowsitlibrary. com/Content/356/06/1. html A Host Intrusion Prevention System for Windows Operating Systems n Roberto Battistoni, Emanuele Gabrielli, Luigi V. Mancini ESORICS 2004 20