最終更新:ID:cruIrYQZ0g 2012年04月05日(木) 23:34:12履歴
Rapid7の資金提供で開発されているペネトレーションテストのためのフレームワーク。以前のバージョンはPythonで書かれていたが、現在はRubyで描き直されており、Rubyを使用した大きなシステムのひとつとなっている。このMetasploitを中心に他のツールを連携させてペネトレーションテストを行うことができる。
3つのエディションがあるが、Metasploit Community Editionは無償で使用することができる。
- Metasploit Pro
- Metasploit Express
- Metasploit Community Edition
svnから最新のファイルを取得するにはmsfupdateコマンドを使用する。
root@bt:~# msfupdate [*] [*] Attempting to update the Metasploit Framework... [*] ..... ..... A data/exploits/mp4player.fla Updated to revision 15057.
対話しながらペネトレを行う。
# msfconsole msf >
オプションを与えてシェルからペネトレを行う。
# msfcli
NeXposeはRapid7の提供する脆弱性スキャナ。Metasploitと同様にコミュニティバージョンが無償で利用できる。
Nessus?
DBを使用してペネトレを行う。ここではBackTrack 5 R2に付属のPostgreSQLを使用する。
# /etc/init.d/framework-postgres start
nmapでポートスキャンを行い、MetasploitのDBに結果を取り込む。
NMAPによる出力形式
仮想マシンで動作しているWindows2000に対してポートスキャンを行った例。
# nmap -Pn -sS -A -oX result1.xml 192.168.0.0/24
- -Pn
- pingに応答しないホストも対象とする。
- -sS
- stealth TCP scanを行う。
- -A
- a
- -oX filename.xml
- XML形式で結果を出力する。filename.xmlというファイルが作成される。
NMAPによる出力形式
- interactive output
- 標準出力への出力
- XML
- grep
- ホスト毎に1行で出力されgrepで検索可能な形式
- sCRiPt KiDDi3
- スクリプトキディ向け?たぶんジョーク
仮想マシンで動作しているWindows2000に対してポートスキャンを行った例。
# nmap -Pn -sS -A 172.16.104.149 Starting Nmap 5.61TEST4 ( http://nmap.org ) at 2012-03-30 08:44 EDT Nmap scan report for 172.16.104.149 Host is up (0.00054s latency). Not shown: 996 closed ports PORT STATE SERVICE VERSION 135/tcp open mstask Microsoft mstask (task server - c:\winnt\system32\Mstask.exe) 139/tcp open netbios-ssn 445/tcp open microsoft-ds Microsoft Windows XP microsoft-ds 1025/tcp open msrpc Microsoft Windows RPC MAC Address: 00:0C:29:FF:8E:A8 (VMware) Device type: general purpose Running: Microsoft Windows 2000|XP OS CPE: cpe:/o:microsoft:windows_2000 cpe:/o:microsoft:windows_xp OS details: Microsoft Windows 2000 SP3/SP4 or Windows XP SP1/SP2 Network Distance: 1 hop Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows Host script results: |_nbstat: NetBIOS name: WINDOWS2000VM, NetBIOS user: ADMINISTRATOR, NetBIOS MAC: 00:0c:29:ff:8e:a8 (VMware) |_smbv2-enabled: Server doesn't support SMBv2 protocol | smb-security-mode: | Account that was used for smb scripts: guest | User-level authentication | SMB Security: Challenge/response passwords supported |_ Message signing disabled (dangerous, but default) TRACEROUTE HOP RTT ADDRESS 1 0.54 ms 172.16.104.149 OS and Service detection performed. Please report any incorrect results at http://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 9.18 seconds
msf > db_import result1.xml msf > db_hosts -c address
/opt/metasploit/postgresql/scripts/ctl.sh が/etc/init.d/framework-postgresから呼び出される起動スクリプト本体になっている。
database.ymlの設定で接続すればいいのかな?
# cat /opt/metasploit/config/database.yml # # These settings are for the database used by the Metasploit Framework # unstable tree included in this installer, not the commercial editions. # development: adapter: "postgresql" database: "msf3dev" username: "msf3" password: "c80c3cea" port: 7337 host: "localhost" pool: 256 timeout: 5 production: adapter: "postgresql" database: "msf3dev" username: "msf3" password: "c80c3cea" port: 7337 host: "localhost" pool: 256 timeout: 5
とりあえず接続はできたみたいだけど。ぐぐるとでてくるページではdb_driverというコマンドがあることになっているので、バージョン違いなのかなあ?
msf > db_connect msf3:c80c3cea@127.0.0.1:7337/msf3dev msf > db_status [*] postgresql connected to msf3dev
PostgreSQLに取り込む。
msf > db_import result1.xml [*] Importing 'Nmap XML' data [*] Import: Parsing with 'Rex::Parser::NmapXMLStreamParser' [*] Importing host 172.16.104.149 [*] Successfully imported /root/result1.xml
うまくインポートできたようだ。
msf > hosts Hosts ===== address mac name os_name os_flavor os_sp purpose info comments ------- --- ---- ------- --------- ----- ------- ---- -------- 172.16.104.149 00:0C:29:FF:8E:A8 Microsoft Windows XP device
ホストで動いているサービスを確認できるようになった。
msf > services Services ======== host port proto name state info ---- ---- ----- ---- ----- ---- 172.16.104.149 135 tcp mstask open Microsoft mstask task server - c:\winnt\system32\Mstask.exe 172.16.104.149 139 tcp netbios-ssn open 172.16.104.149 445 tcp microsoft-ds open Microsoft Windows XP microsoft-ds 172.16.104.149 1025 tcp msrpc open Microsoft Windows RPC
ターゲットがWindowsと分かっているので、SMBを利用したWindows向けの詳細なスキャンを行なってみる。
Windows2000SP4日本語版などといったことが分かった。
msf > use scanner/smb/smb_version msf auxiliary(smb_version) > msf auxiliary(smb_version) > show options Module options (auxiliary/scanner/smb/smb_version): Name Current Setting Required Description ---- --------------- -------- ----------- RHOSTS yes The target address range or CIDR identifier SMBDomain WORKGROUP no The Windows domain to use for authentication SMBPass no The password for the specified username SMBUser no The username to authenticate as THREADS 1 yes The number of concurrent threads msf auxiliary(smb_version) > setg RHOSTS 172.16.104.149 RHOSTS => 172.16.104.149 msf auxiliary(smb_version) > show options Module options (auxiliary/scanner/smb/smb_version): Name Current Setting Required Description ---- --------------- -------- ----------- RHOSTS 172.16.104.149 yes The target address range or CIDR identifier SMBDomain WORKGROUP no The Windows domain to use for authentication SMBPass no The password for the specified username SMBUser no The username to authenticate as THREADS 1 yes The number of concurrent threads msf auxiliary(smb_version) > run [*] 172.16.104.149:445 is running Windows 2000 Service Pack 4 with MS05-010+ (language: Japanese) (name:WINDOWS2000VM) (domain:WORKGROUP) [*] Scanned 1 of 1 hosts (100% complete) [*] Auxiliary module execution completed
最新コメント