アセンブラ命令から動作を把握しよう
参考書籍 : たのしいバイナリの歩き方
・関数にブレイクポイントをセットする
OllyDbgでsample_mal.exeを開く。
逆アセンブルウィンドウで右クリックをし、検索→同上モジュール内を選択
CopyFileAと入力して検索し、Exportの方をダブルクリックする。
関数の最初に移動するので、F2でブレークポイントを設置し、F9で実行する。
そして、Ctrl+F9で関数のリターンまで実行できる。
これにより、関数内部での詳細な動作を確認できる。
・逆アセンブルして重要な部分を見ていく
IDAでsample_mal.exeを開き、0.exeと1.exeをコピーする部分を見ていく
.text:004013C2 push 400h ; nSize .text:004013C7 lea eax, [esp+85Ch+Filename] .text:004013CE push eax ; lpFilename .text:004013CF push ecx ; hModule .text:004013D0 call ds:GetModuleFileNameA .text:004013D6 mov esi, ds:SHGetSpecialFolderPathA .text:004013DC push 0 ; fCreate .text:004013DE push 7 ; csidl .text:004013E0 lea ecx, [esp+860h+pszPath] .text:004013E4 push ecx ; pszPath .text:004013E5 push 0 ; hwnd .text:004013E7 call esi ; SHGetSpecialFolderPathA .text:004013E9 mov edi, ds:lstrcatA .text:004013EF push offset String2 ; "\\0.exe" .text:004013F4 lea edx, [esp+85Ch+pszPath] .text:004013F8 push edx ; lpString1 .text:004013F9 call edi ; lstrcatA .text:004013FB mov ebx, ds:CopyFileA .text:00401401 push 0 ; bFailIfExists .text:00401403 lea eax, [esp+85Ch+pszPath] .text:00401407 push eax ; lpNewFileName .text:00401408 lea ecx, [esp+860h+Filename] .text:0040140F push ecx ; lpExistingFileName .text:00401410 call ebx ; CopyFileA .text:00401412 push 0 ; fCreate .text:00401414 push 5 ; csidl .text:00401416 lea edx, [esp+860h+pszPath] .text:0040141A push edx ; pszPath .text:0040141B push 0 ; hwnd .text:0040141D call esi ; SHGetSpecialFolderPathA .text:0040141F push offset a1Exe ; "\\1.exe" .text:00401424 lea eax, [esp+85Ch+pszPath] .text:00401428 push eax ; lpString1 .text:00401429 call edi ; lstrcatA .text:0040142B push 0 ; bFailIfExists .text:0040142D lea ecx, [esp+85Ch+pszPath] .text:00401431 push ecx ; lpNewFileName .text:00401432 lea edx, [esp+860h+Filename] .text:00401439 push edx ; lpExistingFileName .text:0040143A call ebx ; CopyFileA .text:0040143C lea eax, [esp+858h+pszPath] .text:00401440 lea edx, [eax+1] .text:00401443 .text:00401443 loc_401443: ; CODE XREF: sub_401380+C8↓j .text:00401443 mov cl, [eax] .text:00401445 inc eax .text:00401446 test cl, cl .text:00401448 jnz short loc_401443 .text:0040144A sub eax, edx .text:0040144C push eax ; cbData .text:0040144D lea eax, [esp+85Ch+pszPath] .text:00401451 push eax ; lpData .text:00401452 call sub_401310 .text:00401457 add esp, 8 .text:0040145A call sub_401220 .text:0040145F push 0 ; nExitCode .text:00401461 call ds:PostQuitMessage .text:00401467 jmp loc_40151F
どのような引数が積まれたか、など処理の概要を掴むことができる。