Practical Malware Analysis (by Michael Sikorski and Andrew Honig) Lab17のWriteUp。
まずは自分の解答を載せて、最後に模範解答を載せる。不正解の解答も戒めとしてそのまま載せる事とする。
ラボはこちらからダウンロード可能。
Lab 17-1
解析対象のファイルは以下の通り。
ファイル名 | ファイルの種類 | MD5ハッシュ値 |
Lab17-01.exe | 32ビット EXE | 6BDC203BDFBB3FD263DADF1653D52039 |
※このファイルはLab07-01.exeにアンチ・VMが施されたものである。
1. What anti-VM techniques does this malware use?
- Red Pill (sidt)
- str命令
- No Pill (sldt)
2. If you have the commercial version of IDA Pro, run the IDA Python script from Listing 17-4 in Chapter 17 (provided here as findAntiVM.py). What does it find?
商用のIDA Proを使用していないので割愛。
3. What happens when each anti-VM technique succeeds?
Red Pill アンチ・VMでVMが検知されると、マルウェアは自身を消去する。
.text:004011B5 loc_4011B5: ; Red Pill Anti VM
.text:004011B5 0F 01 8D D8 FB FF FF sidt fword ptr [ebp+var_428]
.text:004011BC 8B 85 DA FB FF FF mov eax, dword ptr [ebp+var_428+2]
.text:004011C2 89 85 E0 FB FF FF mov [ebp+var_420], eax
.text:004011C8 68 5C 60 40 00 push offset Name ; "HGL345"
.text:004011CD 6A 00 push 0 ; bInitialOwner
.text:004011CF 6A 00 push 0 ; lpMutexAttributes
.text:004011D1 FF 15 20 50 40 00 call ds:CreateMutexA
.text:004011D7 89 85 F8 FB FF FF mov [ebp+var_408], eax
.text:004011DD 8B 8D E0 FB FF FF mov ecx, [ebp+var_420]
.text:004011E3 C1 E9 18 shr ecx, 18h
.text:004011E6 81 F9 FF 00 00 00 cmp ecx, 0FFh
.text:004011EC 0F 84 3B 01 00 00 jz loc_40132D ; jump to self delete function if VM is detected.
str命令によるアンチ・VMでVMが検知されると、マルウェアは自身を消去する。
.text:00401204 0F 00 8D E8 FB FF FF str word ptr [ebp+var_418] ; str Anti VM
.text:0040120B FF 15 1C 50 40 00 call ds:GetCurrentProcess
.text:00401211 89 45 EC mov [ebp+hModule], eax
.text:00401214 8B 55 E8 mov edx, [ebp+nSize]
.text:00401217 52 push edx ; nSize
.text:00401218 8D 85 00 FC FF FF lea eax, [ebp+Filename]
.text:0040121E 50 push eax ; lpFilename
.text:0040121F 8B 4D EC mov ecx, [ebp+hModule]
.text:00401222 51 push ecx ; hModule
.text:00401223 FF 15 28 50 40 00 call ds:GetModuleFileNameA
.text:00401229 8B 95 E8 FB FF FF mov edx, [ebp+var_418]
.text:0040122F 81 E2 FF 00 00 00 and edx, 0FFh
.text:00401235 85 D2 test edx, edx
.text:00401237 75 15 jnz short loc_40124E
---
.text:00401239 8B 85 E9 FB FF FF mov eax, [ebp+var_418+1]
.text:0040123F 25 FF 00 00 00 and eax, 0FFh
.text:00401244 83 F8 40 cmp eax, 40h
.text:00401247 75 05 jnz short loc_40124E ; Ultimately jump to self delete function if VM is detected.
No Pill アンチ・VMでVMが検知されると、マルウェアはC2サーバーとの通信を行わずに終了する。
.text:004012D1 E8 2A FE FF FF call NoPill_AntiVM_401100 ; This func performs No Pill AntiVM check
.text:004012D6 3D 00 00 CC DD cmp eax, 0DDCC0000h
.text:004012DB 75 4E jnz short loc_40132B ; Malware will exit without contacting C2 server if VM is detected.
4. Which of these anti-VM techniques work against your virtual machine?
自分の解析環境ではいずれのアンチ・VMにも引っかからなかった。
5. Why does each anti-VM technique work or fail?
Red Pill アンチ・VMに引っかからなかったのは、解析に使用しているマシンがマルチコアのため。
str命令によるアンチ・VMに引っかからなかったのは、解析に使用しているマシンがマルチプロセッサのため。
No Pill アンチ・VMに引っかからなかった理由は不明。
6. How could you disable these anti-VM techniques and get the malware to run?
Red Pill アンチ・VMを回避するにはマルチコアのマシンを解析に用いる。
str命令によるアンチ・VMを回避するにはマルチプロセッサのマシンを解析に用いる。
No Pill アンチ・VMを回避するにはVMware のアクセラレーションを無効化する。
Lab 17-2
解析対象のファイルは以下の通り。
ファイル名 | ファイルの種類 | MD5ハッシュ値 |
Lab17-02.dll | 32ビット DLL | D98B63A319AD92B6C3A8347ADE5A351A |
1. What are the exports for this DLL?
- InstallRT
- InstallSA
- InstallSB
- PSLIST
- ServiceMain
- StartEXS
- UninstallRT
- UninstallSA
- UninstallSB
2. What happens after the attempted installation using rundll32.exe?
以下のコマンドでLab17-02.dllを実行した。
rundll32.exe Lab17-02.dll,InstallRT
すると、Lab17-02.dllと同一のディレクトリにxinstall.log
というファイルが作成された。
またLab17-02.dllがディスクから削除されていた。
3. Which files are created and what do they contain?
Lab17-02.dllと同一のディレクトリにxinstall.log
というファイルが作成された。ファイルには以下のメッセージが記録されていた。
[01/23/22 09:17:06]
Found Virtual Machine,Install Cancel.
VMを検知したため、インストールを中止した模様。
4. What method of anti-VM is in use?
InstallRT、InstallSA、InstallSB、それぞれのエクスポート関数内でサブルーチン0x10006196が呼び出されていた。
.text:1000D867 E8 2A 89 FF FF call AntiVM_IOport_10006196 ; al will be non-zero if VM is detected
.text:1000D86C 84 C0 test al, al
.text:1000D86E 74 1E jz short loc_1000D88E
サブルーチン0x10006196はVMwareがホストOS - ゲストOS間の通信に使用する仮想I/Oポートの状態を確認することでVMを検知する。以下は該当のコードの抜粋。
.text:100061B6 53 push ebx
.text:100061B7 56 push esi
.text:100061B8 57 push edi
.text:100061B9 89 65 E8 mov [ebp+ms_exc.old_esp], esp
.text:100061BC C6 45 E4 01 mov [ebp+var_1C], 1
.text:100061C0 83 65 FC 00 and [ebp+ms_exc.registration.TryLevel], 0
.text:100061C4 52 push edx
.text:100061C5 51 push ecx
.text:100061C6 53 push ebx
.text:100061C7 B8 68 58 4D 56 mov eax, 'VMXh'
.text:100061CC BB 00 00 00 00 mov ebx, 0
.text:100061D1 B9 0A 00 00 00 mov ecx, 0Ah ; 0xA means "get VMware version type"
.text:100061D6 BA 58 56 00 00 mov edx, 'VX'
.text:100061DB ED in eax, dx
.text:100061DC 81 FB 68 58 4D 56 cmp ebx, 'VMXh'
.text:100061E2 0F 94 45 E4 setz [ebp+var_1C]
.text:100061E6 5B pop ebx
.text:100061E7 59 pop ecx
.text:100061E8 5A pop edx
.text:100061E9 EB 0B jmp short loc_100061F6
---
.text:100061F6 loc_100061F6:
.text:100061F6 83 4D FC FF or [ebp+ms_exc.registration.TryLevel], 0FFFFFFFFh
.text:100061FA 8A 45 E4 mov al, [ebp+var_1C] ; VMware type will be stored to al
.text:100061FD 8B 4D F0 mov ecx, [ebp+ms_exc.registration.Next]
.text:10006200 64 89 0D 00 00 00 00 mov large fs:0, ecx
.text:10006207 5F pop edi
.text:10006208 5E pop esi
.text:10006209 5B pop ebx
.text:1000620A C9 leave
.text:1000620B C3 retn
5. How could you force the malware to install during runtime?
以下のin命令をnopすることで、アンチ・VMを回避出来る。
00000000100061DB ED in eax, dx
Lab17-02.dllをx32dbgにロードして、該当のコードを選択して右クリック、BinaryからFill with NOPsを選んでパッチした。
以下のコマンドを実行して、パッチしたDLLをインストールした。
rundll32.exe Lab17-02-patched.dll,InstallRT
すると同一のディレクトリにxinstall.log
が作成された。ファイルには以下のメッセージが記録されていた。
[01/24/22 08:50:02]
Copy 'C:\Users\user\Desktop\do_not_scan\PracticalMalwareAnalysis-Labs\Practical_Malware_Analysis_Labs\BinaryCollection\Chapter_17L\Lab17-02-patched.dll' To 'C:\Windows\system32\Lab17-02-patched.dll' Successfully
The PID Of Process 'iexplore.exe' is '0'
Process 'iexplore.exe' Not Found ,Inject Failed
上記のログによると、C:\Windows\System32
にDLLがコピーされた模様。C:\Windows\SysWOW64
を確認してみると、確かにDLLがコピーされていた。
※ C:\Windows\System32
ではなく、C:\Windows\SysWOW64
にDLLが作成されたのは、WOW64によってリダイレクトされたため。

また、実行したDLLも削除されずにディスクに残っていた。
6. How could you permanently disable the anti-VM technique?
上述した問5の解答を参照。アドレス0x100061DBのin命令をnopして、DLLをパッチして保存すればアンチ・VMを恒久的に無効化出来る。
7. How does each installation export function work?
それぞれのエクスポート関数を実行して、挙動を確認した。
InstallRT
問5で解析したとおり、InstallRT関数はLab17-02.dllをシステム・ディレクトリにコピーする。
さらにiexplore.exe
に対してプロセス・インジェクションを行う。
.text:1000D55A E8 CC 61 FF FF call PrivilegeEscalation_1000372B
.text:1000D55F 8D 85 F0 FB FF FF lea eax, [ebp+Dest]
.text:1000D565 50 push eax ; Source
.text:1000D566 56 push esi ; dwProcessId
.text:1000D567 E8 A1 FB FF FF call ProcessInjection_1000D10D ; perform process injection against arbitrary process (default is iexplore.exe)
.text:1000D56C 59 pop ecx
.text:1000D56D 85 C0 test eax, eax
.text:1000D56F 59 pop ecx
.text:1000D570 8D 85 FC FE FF FF lea eax, [ebp+ArgList]
.text:1000D576 50 push eax
.text:1000D577 8D 85 F0 FB FF FF lea eax, [ebp+Dest]
.text:1000D57D 50 push eax ; ArgList
.text:1000D57E 74 0F jz short loc_1000D58F
---
000000001000D580 68 08 4E 09 10 push offset aInjectSToProce ; "Inject '%s' To Process '%s' Successfull"...
デフォルトだとプロセス・インジェクションの標的プロセスはiexplore.exe
だが、IntallRTを引数付きで実行することで任意のプロセスに対してインジェクションを行える。
rundll32.exe Lab17-02.dll,InstallRT <target process name>
コマンドをrundll32.exe Lab17-02-patched.dll,InstallRT notepad.exe
に変更して実行したところ、xinstall.log
に以下のメッセージが記録され、notepad.exe
に対してLab17-02-patched.dllをインジェクトしようとしたことが伺えた。
[01/29/22 09:04:43]
Copy 'C:\Users\user\Desktop\do_not_scan\PracticalMalwareAnalysis-Labs\Practical_Malware_Analysis_Labs\BinaryCollection\Chapter_17L\Lab17-02-patched.dll' To 'C:\Windows\system32\Lab17-02-patched.dll' Successfully
The PID Of Process 'notepad.exe' is '3800'
Inject 'Lab17-02-patched.dll' To Process 'notepad.exe' Failed
InstallSA
InstallSA関数は(HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Svchost
で定義されている) 任意のWindowsサービスにマルウェアをインストールすることができる。デフォルトではIrmon
サービスが使用される。また任意のサービス・ディスクリプション (説明)を指定できる。
指定したサービス名がすでにシステムに存在する場合は、マルウェアをインストールできない。
rundll32.exe Lab17-02dll,InstallSA <service name> <description>
以下のコマンドを実行したところ、Ntmssvc
サービスが作成され、サービスDLLとしてLab17-02-patched.dllが登録された。
rundll32.exe Lab17-02-patched.dll,InstallSA Ntmssvc test-description
[01/29/22 08:34:50]
CreateService(Ntmssvc) With Description 'test-description' SUCCESS. Config it
Config service Ntmssvc ok.
StartService 'Ntmssvc' Successfully


これによりNtmssvcサービスが次回起動すると、マルウェア(Lab17-02-patched.dll)がsvchost.exeに読み込まれることになる。
InstallSB
InstallSBはInstallSA同様、引数に (HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Svchost
で定義されている) 任意のサービス名を指定できる。デフォルトだとNtmsSvc
サービスが使用される。ただし、InstallSAとは異なり、サービス・ディスクリプションは指定できない。さらにInstallSAと異なる点として、引数に指定するサービスはシステムにインストール済でなければならない。言い換えるとIntallSBは既存のWindowsサービスに対してマルウェアをインストールする。
rundll32.exe Lab17-02-patched.dll,InstallSB <service name>
以下のコマンドは既存のTermService
サービスに対して、マルウェアをインストールする。
rundll32.exe Lab17-02-patched.dll,InstallSB TermService
[01/29/22 07:42:51]
Query service starttype->3
Change Service 'TermService' To Be Auto-Start
Service 'TermService' Status already is Stopped.
Not Found Module 'termsrv.dll' In Any 'svchost.exe' Process
Copy 'C:\Windows\system32\termsrv.dll' To 'C:\Windows\system32\termsrv.dll.obak' Failed
Copy 'C:\Windows\SysWOW64\Lab17-02-patched.dll' To 'C:\Windows\system32\termsrv.dll' Successfully
Copy 'C:\Windows\SysWOW64\Lab17-02-patched.dll' To 'C:\Windows\system32\dllcache\termsrv.dll' Failed
Old Module Not Runing,New ModuleName As Old,Will Take Effect Soon.
StartService 'TermService' Successfully
上記のログからTermService
サービスのサービスDLLを Lab17-02-patched.dllに置き換え、サービスを再起動しようとしていることが伺える。また、正規のサービスDLL termsrv.dll
のバックアップとしてtermsrv.dll.obak
というファイルを作成しようとしていた。
まとめると、IntallSBは任意のWindowsサービスのサービスDLLをマルウェアに置き換えて、サービスを乗っ取る。この乗っ取りにより、サービスが起動すると、正規のサービスDLLではなく、マルウェアがsvchost.exeによって読み込まれることになる。
要約すると、
InstallRT
マルウェア (Lab17-02.dll
) をシステム・ディレクトリにコピーし、任意のプロセス (デフォルトではiexplore.exe
)に対してプロセス・インジェクションを行い、マルウェア (DLL) をインジェクトする。
InstallSA
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Svchost
で定義されているWindowsサービスにマルウェアをサービスDLLとしてインストールすることができる。ただし、使用するWindowsサービスがすでにシステムに存在する場合はインストール出来ない。デフォルトではIrmon
サービスが使用される。サービスの作成が完了すると、サービスの起動時にマルウェアがsvchost.exeに読み込まれることになる。
InstallSB
既存のWindowsサービス (デフォルトではNtmsSvc
サービス) のサービスDLLをマルウェアに置き換える。乗っ取られたWindowsサービスが起動すると、正規のサービスDLLではなく、マルウェアがsvchost.exeに読み込まれることになる。
Lab 17-3
解析対象のファイルは以下の通り。
ファイル名 | ファイルの種類 | MD5ハッシュ値 |
Lab17-03.exe | 32ビット EXE | 7A2E485D1BEA00EE5907E4CC02CB2552 |
※このファイルはLab12-02.exeにアンチ・VMが施されたものである。
1. What happens when you run this malware in a virtual machine?
マルウェアを実行したが、特に目立った挙動は見つからなかった。
2. How could you get this malware to run and drop its keylogger?
このマルウェアはサブルーチン0x401A80と0x4011C0にて自身がVM上で実行されているかチェックする。それぞれのアンチ・デバッグの結果はeaxに格納される。VMが検知された場合、eaxの値は1となるので、この値を0に書き換えることで、アンチ・VMを突破することができる。
.text:0040199A E8 E1 00 00 00 call AntiVM_IOport__401A80
.text:0040199F 85 C0 test eax, eax ; change eax to 0 to pass anti VM
.text:004019A1 74 07 jz short loc_4019AA
.text:004019AA 6A 02 push 2
.text:004019AC 68 C4 30 40 00 push offset SubKey ; "SYSTEM\\CurrentControlSet\\Control\\Dev"...
.text:004019B1 68 02 00 00 80 push 80000002h ; hKey HKLM
.text:004019B6 E8 05 F8 FF FF call AntiVM_CheckRegkey_4011C0
.text:004019BB 83 C4 0C add esp, 0Ch
.text:004019BE 85 C0 test eax, eax ; change eax to 0 to pass anti VM
.text:004019C0 74 07 jz short loc_4019C9
アンチ・VMのチェックが完了すると、マルウェアはリソース・セクションからキー・ロガーを抽出し、プロセス・ホロウイングを駆使してsvchost.exe
にキー・ロガーのペイロードをインジェクトする。
.text:00401A00 68 00 04 00 00 push 400h ; uSize
.text:00401A05 8D 85 FC FB FF FF lea eax, [ebp+ApplicationName]
.text:00401A0B 50 push eax ; lpBuffer
.text:00401A0C 68 30 30 40 00 push offset Source ; "\\svchost.exe"
.text:00401A11 E8 2A FF FF FF call GetSystemDirectoryA_401940
.text:00401A16 83 C4 0C add esp, 0Ch
.text:00401A19 8B 8D F8 FB FF FF mov ecx, [ebp+hModule]
.text:00401A1F 51 push ecx ; hModule
.text:00401A20 E8 4B FC FF FF call DropKeylogger_401670
.text:00401A25 83 C4 04 add esp, 4
.text:00401A28 89 45 FC mov [ebp+lpAddress], eax
.text:00401A2B 83 7D FC 00 cmp [ebp+lpAddress], 0
.text:00401A2F 74 33 jz short loc_401A64
---
.text:00401A31 8B 55 FC mov edx, [ebp+lpAddress]
.text:00401A34 52 push edx ; lpBuffer
.text:00401A35 8D 85 FC FB FF FF lea eax, [ebp+ApplicationName]
.text:00401A3B 50 push eax ; lpApplicationName C:\windows\system32\svchost.exe
.text:00401A3C E8 BF F9 FF FF call ProcessHollowing_401400
3. Which anti-VM techniques does this malware use?
サブルーチン0x401A80はVMwareがホストOS - ゲストOS間の通信に使用する仮想I/Oポートの状態を確認することでVMを検知する。以下は該当のコードの抜粋。
.text:00401AB4 B8 68 58 4D 56 mov eax, 'VMXh'
.text:00401AB9 BB 00 00 00 00 mov ebx, 0
.text:00401ABE B9 0A 00 00 00 mov ecx, 0Ah ; 0xA means "get VMware version type"
.text:00401AC3 BA 58 56 00 00 mov edx, 'VX'
.text:00401AC8 ED in eax, dx
.text:00401AC9 81 FB 68 58 4D 56 cmp ebx, 'VMXh'
.text:00401ACF 75 27 jnz short loc_401AF8
サブルーチン0x4011C0はHKLM\SYSTEM\CurrentControlSet\Control\DeviceClasses
レジストリを列挙してvmware
というエントリーを探す。
.text:00401285 8D 85 EC FE FF FF lea eax, [ebp+cchName]
.text:0040128B 50 push eax ; lpcchName
.text:0040128C 8D 8D E8 FD FF FF lea ecx, [ebp+Name]
.text:00401292 51 push ecx ; lpName
.text:00401293 8B 95 E8 FE FF FF mov edx, [ebp+dwIndex]
.text:00401299 52 push edx ; dwIndex
.text:0040129A 8B 45 F4 mov eax, [ebp+phkResult]
.text:0040129D 50 push eax ; hKey
.text:0040129E FF 15 00 20 40 00 call ds:RegEnumKeyExA
---
.text:004012A8 8B 8D EC FE FF FF mov ecx, [ebp+cchName]
.text:004012AE 8D B5 E8 FD FF FF lea esi, [ebp+Name]
.text:004012B4 8D BD E8 FC FF FF lea edi, [ebp+var_318]
.text:004012BA 8B D1 mov edx, ecx
.text:004012BC C1 E9 02 shr ecx, 2
.text:004012BF F3 A5 rep movsd
.text:004012C1 8B CA mov ecx, edx
.text:004012C3 83 E1 03 and ecx, 3
.text:004012C6 F3 A4 rep movsb
.text:004012C8 8D 85 E8 FC FF FF lea eax, [ebp+var_318]
.text:004012CE 50 push eax
.text:004012CF E8 8C FD FF FF call sub_401060
.text:004012D4 83 C4 04 add esp, 4
.text:004012D7 68 40 30 40 00 push offset aVmware ; "vmware"
.text:004012DC 8D 8D E8 FC FF FF lea ecx, [ebp+var_318]
.text:004012E2 51 push ecx
.text:004012E3 E8 C8 FD FF FF call sub_4010B0
.text:004012E8 83 C4 08 add esp, 8
.text:004012EB 85 C0 test eax, eax
.text:004012ED 74 09 jz short loc_4012F8
4. What system changes could you make to permanently avoid the anti-VM techniques used by this malware?
1つ目のアンチ・VMはVMware Toolsをアンインストールすれば突破できると思われる。
2つ目のアンチ・VMはHKLM\SYSTEM\CurrentControlSet\Control\DeviceClasses
配下のVMware関連のエントリーを削除すれば突破できると思われる。
5. How could you patch the binary in OllyDbg to force the anti-VM techniques to permanently failed?
1つ目のアンチ・VMを恒久的に無効化するには、以下のin命令をnopする。
0000000000401AC8 ED in eax, dx
ファイルをx32dbgにロードして、該当のコードを選択して右クリック、BinaryからFill with NOPsを選んでパッチすれば良い。

2つ目のアンチ・VMを恒久的に無効化するには、以下のcall命令をnopする。
.text:004019AA 6A 02 push 2
.text:004019AC 68 C4 30 40 00 push offset SubKey ; "SYSTEM\\CurrentControlSet\\Control\\Dev"...
.text:004019B1 68 02 00 00 80 push 80000002h ; hKey HKLM
.text:004019B6 E8 05 F8 FF FF call AntiVM_CheckRegkey_4011C0
.text:004019BB 83 C4 0C add esp, 0Ch
.text:004019BE 85 C0 test eax, eax ; change eax to 0 to pass anti VM
.text:004019C0 74 07 jz short loc_4019C9
ファイルをx32dbgにロードして、該当のコードを選択して右クリック、BinaryからFill with NOPsを選んでパッチすれば良い。

模範解答
Lab 17-1
1. This malware uses vulnerable x86 instructions to determine if it is running in a VM.
2. The script finds three potential anti-VM instructions and highlights them in red: sidt, str, and sldt.
3. The malware will delete itself if either sidt or str detects VMware. If the sldt instruction detects malware, the malware will exit without creating its main thread, but it will create the malicious service MalService.
4. On our machine running VMware Workstation 7 on an Intel Core i7, none of the techniques succeeded. Your results will vary depending on the hardware and software you use.
5. See the details analysis for an explanation of whey each technique did or didn't work.
6. You can NOP-out the sidt and str instructions or flip the jump flags live while debugging the malware.
Lab 17-2
1. The exports are InstallRT, InstallSA, InstallSB, PSLIST, ServiceMain, StartEXS, UninstallRT, UninstallSA, and UninstallSB.
2. The DLL is deleted from the system using a .bat file.
3. A .bat file containing self-deletion code is created, as well as a file named xinstall.log containing the string "Found Virtual Machine, Install Cancel".
4. This malware queries the VMware backdoor I/O communication port using the magic value VX and the action 0xA by using the in x86 instruction.
5. To get the malware to install, patch the in instruction at 0x100061DB at runtime.
6. To permanently disable the VM check, use a hex editor to modify the static string in the binary from [This is DVM]5 to [This is DVM]0. Alternatively NOP-out the check in Ollydbg and write the change to disk.
7. InstallRT performs installation via DLL injection with an optional parameter containing the process to inject into. InstallSA performs installation via service installation. InstallSB performs installation via service install and DLL injection if the service to overwrite is still running.
Lab 17-3
1. The malware immediately terminates inside a VM, unlike Lab 12-2, which performs process replacement on svchost.exe
2. If you force the jumps at 0x4019A1, 0x4019C0, and 0x401467 to be taken, and the jump at 0x401A2F to not be taken, the malware performs process replacement using a keylogger from its resource section.
3. The malware uses four different anti-VM techniques:
- It uses the backdoor I/O communication port.
- It searches the registry key SYSTEM\CurrentControlSet\Control\DeviceClasses for the string vmware
- It checks MAC address to see if it is the default used by VMware.
- It searches the process list with a string-hashing function for process starting with the string vmware.
4. To avoid the anti-VM techniques used by this malware, you can remove VMware tools and modify the MAC address.
5. In OllyDbg, you can apply the following patches:
- NOP-out the instructions at 0x40145D.
- Change the instructions at 0x40199F and 0x4019BE to xor eax, eax.
- Modify the instruction at 0x40169F to jmp 0x40184A.
答え合わせ
Lab 17-2
自分の解析には以下の事柄が不足していた。
マルウェアがVMを検知した場合、vmselfdel.bat
というバッチ・ファイルを作成・実行してDLLを削除する。

InstallSBは乗っ取ったサービスを再起動できなかった場合、svchost.exeに対してDLLをインジェクトする。
.text:1000E55D 68 64 53 09 10 push offset aOldModuleSStil ; "Old Module '%s' Still Runing,New Module"...
.text:1000E562 E8 2B 50 FF FF call WriteTo_xinstall_log_10003592
.text:1000E567 8D 85 A0 FB FF FF lea eax, [ebp-460h]
.text:1000E56D 50 push eax ; Source
.text:1000E56E FF 75 DC push dword ptr [ebp-24h] ; dwProcessId
.text:1000E571 E8 97 EB FF FF call ProcessInjection_1000D10D
このラボではアンチ・VMに焦点が当てられていたが、Lab17-02.dllには他にも多様な機能が実装されており、これらの機能の解析は読者への宿題として詳しくは触れられなかった。いずれ時間を見つけて解析をしたいと思う。
Lab 17-3
自分の解析には以下の事柄が不足していた。
Lab17-03.exeには自分が指摘した以外に以下の2つのアンチ・VMが施されていた。
- MACアドレスをチェックして、VMwareが使用するMACアドレスのパターンと一致するか確認する。
- 実行中のプロセスを列挙して
vmware
から始まるプロセス名が存在するか確認する。この際、vmwareという文字列を直接検索するのではなく、ハッシュ化してから検索する。