weblogic密码加解密

本文介绍了如何在WebLogic中设置环境变量进行密码加密和解密,并提供了相关命令。文章提到了需要将`SerializedSystemIni.dat`文件与解密工具在同一目录下。作者还分享了从渗透测试中解密WebLogic密码的过程,强调了静态加密密钥的安全隐患,以及WebLogic安装在SMB共享上的风险。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

   通常在weblogic的config.xml文件中,对于关键字符串、密码会自动加密,例如数据库JDBC连接池连接密码等。通常加密之后前面会加上{3DES}的标识。
   3DES就是DES算法的增强,相关资料如下:
   1、DES(Data Encryption Standard)是一种经典的对称算法。其数据分组长度为64位,使用的密钥为64位,有效密钥长度为56位(有8位用于奇偶校验)。它由IBM公司在70年代开发,经过政府的加密标准筛选后,于1976年11月被美国政府采用,随后被美国国家标准局和美国国家标准协会(American National Standard Institute, ANSI) 承认。
   该技术算法公开,在各行业有着广泛的应用。DES算法从公布到现在已有20多年的历史,由于计算机能力的飞速发展,DES的56位密钥长度显得有些太短了,已经有可能通过穷举的
   方法来对其进行攻击。但是除此以外,直到现在还没有发现穷举以外的能有效破译DES的方法。
   2、DES算法现在已经不能提供足够的安全性,因为其有效密钥只有56位。因此,后来又提出了三重DES(或称3DES),该方法的强度大约和112比特的密钥强度相当。
   这种方法用两个密钥对明文进行三次运算。设两个密钥是K1和K2,其算法的步骤如图3所示:
   1. 用密钥K1进行DES加密。
   2. 用K2对步骤1的结果进行DES解密。
   3. 用步骤2的结果使用密钥K1进行DES加密。

   首先需要找到加密的密钥,根据BEA文档可以发现是文件SerializedSystemIni.dat,查找一下安装目录就可以找到整个问见,通常系统管理员应该将该文件设置为不能直接访问,以提高安全性。
   加密、解密的大致演示算法代码如下,在WebLogic 9.2下面调试通过,。对于低版本的WebLogic,例如WebLogic 7.0/8.1可能不能直接在命令行执行,因为SerializedSystemIni必须在控制台Console环境下面才能调用。需要用到weblogic.jar和webservices.jar这2个jar包。9.X版本的在安装目录下的weblogic92/server/lib下,10.X的版本在wlserver_10.3/server/lib下。SerializedSystemIni.dat文件在本域的security目录下。
   加解密代码如下:
import weblogic.security.internal.*;
import weblogic.security.internal.encryption.EncryptionService;
import weblogic.utils.encoders.BASE64Decoder;
import weblogic.utils.encoders.BASE64Encoder;
public class CrackData 
{
    public static void main(String[] args) 
    {
        byte[] salt,keys;
        salt=SerializedSystemIni.getSalt();
        keys=SerializedSystemIni.getEncryptedSecretKey();
        String data="";
        for(int i=0;i<salt.length;i++){
   
   
            data+=salt[i]+",";
        }
        System.out.println("salt:"+data);
        data="";
        for(int i=0;i<keys.length;i++){
   
   
            data+=keys[i]+",";
        }
        System.out.println("Key:"+data);
        //EncryptionService svr=SerializedSystemIni.getExistingEncryptionService();
        EncryptionService svr=SerializedSystemIni.getEncryptionService();
        System.out.println(svr);
        System.out.println(svr.getAlgorithm());
        if(args.length>1){
            if(args[0].equals("encrypt")){
                byte[] edata=svr.encryptString(args[1]);
                String s = (new BASE64Encoder()).encodeBuffer(edata);
                System.out.println("Encode:"+s);
            }
            if(args[0].equals("decrypt")){
                try{
                byte[] edata = (new BASE64Decoder()).decodeBuffer(args[1]);
                String txt=svr.decryptString(edata);
                System.out.println("Decode:"+txt);
                }catch(Exception ex){
                    ex.printStackTrace();
                }
            }
        }

    }
}

设置环境变量:

set classpath=.;D:\beainstall\weblogic92\server\lib\weblogic.jar;D:\beainstall\weblogic92\server\lib\webservices.jar

或者直接

javac -classpath .;D:\beainstall\weblogic92\server\lib\weblogic.jar;D:\beainstall\weblogic92\server\lib\webservices.jar CrackData.java

设置环境变量比较简洁些。
加密:

java -classpath .;D:\beainstall\weblogic92\server\lib\weblogic.jar;D:\beainstall\weblogic92\server\lib\webservices.jar CrackData encrypt weblogic
salt:-42,33,43,65,
Key:-57,110,44,88,-16,-53,-83,35,-4,-31,-1,100,-112,42,33,-76,-77,-37,76,-35,-66
,-85,-120,93,110,42,-108,-65,-46,40,-112,55,
weblogic.security.internal.encryption.JSafeEncryptionServiceImpl@fb34e70
3DES
Encode:S3uUHeLlkLECCGYMYJnuFA==

解密:

java -classpath .;D:\beainstall\weblogic92\server\lib\weblogic.jar;D:\be
ainstall\weblogic92\server\lib\webservices.jar CrackData decrypt S3uUHeLlkLECCGY
MYJnuFA==
salt:-42,33,43,65,
Key:-57,110,44,88,-16,-53,-83,35,-4,-31,-1,100,-112,42,33,-76,-77,-37,76,-35,-66
,-85,-120,93,110,42,-108,-65,-46,40,-112,55,
weblogic.security.internal.encryption.JSafeEncryptionServiceImpl@fb34ea8
3DES
Decode:weblogic

注意:需要将本域的security目录下SerializedSystemIni.dat文件拷贝到CrackData.class同目录下的security目录下方可。

部分内容参考网络。
这篇博文讲述的很清楚:https://blog.netspi.com/decrypting-weblogic-passwords/
翻译:http://bobao.360.cn/learning/detail/337.html
将上述博客内容转过来:
The following blog walks through part of a recent penetration test and the the decryption process for WebLogic passwords that came out of it. Using these passwords I was able to escalate onto other systems and Oracle databases. If you just want code and examples to perform this yourself, head here: https://github.com/NetSPI/WebLogicPasswordDecryptor.

Introduction

Recently on an internal penetration test I came across a couple of Linux servers with publicly accessible Samba shares. Often times, open shares contain something interesting. Whether it be user credentials or sensitive information, and depending on the client, open shares will contain something useful. In this instance, one of the shares contained a directory named “wls1035”. Going through the various acronyms in my head for software, this could either be Windows Live Spaces or WebLogic Server. Luckily it was the later and not Microsoft’s failed blogging platform.

WebLogic is an application server from Oracle for serving up enterprise Java applications. I was somewhat familiar with it, as I do see it time to time in enterprise environments, but I’ve never actually installed it or taken a look at its file structure. At this point I started to poke around the files to see if I could find anything useful, such as credentials. Doing a simple grep search for “password” revealed a whole lot of information. (This is not actual client data)

user@box:~/wls1035# grep -R "password" *
Binary file oracle_common/modules/oracle.jdbc_12.1.0/aqapi.jar matches
oracle_common/plugins/maven/com/oracle/maven/oracle-common/12.1.3/oracle-common-12.1.3.pom:    <!-- and password for your server here. -->
user_projects/domains/mydomain/bin/startManagedWebLogic.sh:#  to your system password for no username and password prompt 
user_projects/domains/mydomain/bin/stopManagedWebLogic.sh:# WLS_PW         - cleartext password for server shutdown
user_projects/domains/mydomain/bin/stopWebLogic.sh: if [ "${password}"<
<think>首先,用户的问题是:“我想寻找用于解密WebLogic相关密码的工具 请问WebLogic password decryption tool”。这是在询问解密WebLogic密码的工具。 根据系统级指令: - 所有行内数学表达式必须使用$...$格式。 - 独立公式必须使用$$...$$格式并单独成段。 - LaTeX语法正确。 - 使用中文回答。 - 生成相关问题。 - 回答中引用的段落末尾自然地添加引用标识。 用户可见层的指令: - 回答结构清晰,帮助用户逐步解决问题。 - 尽量保证回答真实可靠。 参考站内引用: - 引用[1]:描述了WebLogic解密过程,涉及SerializedSystemIni和ClearOrEncryptedService。 - 引用[2]:解释了WebLogic加密的复杂性,包括AES和DES加密方式,以及解密方法。 - 引用[3]:关于SSL调试标志。 - 引用[4]:列出了一些安全工具和漏洞靶场,但似乎不直接相关。 用户的问题是关于WebLogic密码解密工具,所以我需要基于引用提供信息。引用[2]提到WebLogic使用AES或DES加密,并且解密需要调用WebLogic的代码包。引用[1]给出了具体的解密方法:使用SerializedSystemIni.getEncryptionService和ClearOrEncryptedService.decrypt。 因此,我应该解释如何解密WebLogic密码,并推荐工具。 可能的工具: - 由于解密需要WebLogic的库,工具可能涉及使用WebLogic的JAR文件。 - 常见工具包括wlst.sh(WebLogic Scripting Tool)或自定义脚本。 - 引用中没有直接提到特定工具,但基于描述,我可以建议使用WebLogic自带的工具或编写脚本。 步骤: 1. 解释WebLogic密码加密机制。 2. 描述解密过程。 3. 推荐工具或方法。 4. 提供示例或指导。 生成相关问题: - 在回答末尾添加相关问题,如“如何手动解密WebLogic密码?”或“WebLogic加密的常见问题?” 确保回答真实可靠: - 基于引用[1]和[2],WebLogic密码存储在序列化系统初始化文件中,解密需要加密服务。 - 工具如wlst.sh可以用于解密。 结构化回答: - 引言:简要介绍。 - 详细步骤:如何解密。 - 工具推荐。 - 相关问题。 最终用中文回答。</think>根据您的查询,我将为您详细介绍WebLogic密码解密工具及相关方法。WebLogic密码加密机制较为复杂,它使用AES或DES加密算法(取决于版本),并基于每个应用或服务器随机生成的密钥进行加密。因此,解密通常需要调用WebLogic自带的库和工具,而不是独立的第三方软件。以下是基于可靠来源的逐步解答,我会确保回答真实可靠,并参考了站内引用信息。 ### 1. **WebLogic密码加密机制概述** - WebLogic从11gR1版本开始采用AES加密,早期版本使用DES加密[^2]。 - 加密密码存储在配置文件(如`config.xml`或`boot.properties`)中,形式为`{AES}...`或`{DES}...`的密文。 - 每个WebLogic实例的加密密钥是随机生成的,存储在`SerializedSystemIni.dat`文件中(位于域目录下),这使得解密必须依赖该文件[^2]。 - 解密过程涉及调用WebLogic的内部API,例如`weblogic.security.internal.SerializedSystemIni`和`weblogic.security.internal.encryption.ClearOrEncryptedService`[^1]。 ### 2. **推荐解密工具和方法** 由于WebLogic的加密机制紧密绑定其运行时环境,解密通常需要使用WebLogic自带的工具或编写自定义脚本。以下是几种可靠方法: #### **方法一:使用WebLogic Scripting Tool (WLST)** WLST是WebLogic官方提供的命令行工具,能直接调用解密API。适合脚本化操作。 - **步骤**: 1. 确保已安装WebLogic服务器,并设置环境变量(如`WL_HOME`)。 2. 创建Python脚本(例如`decrypt.py`),内容如下: ```python from weblogic.security.internal import * from weblogic.security.internal.encryption import * # 设置域路径,包含SerializedSystemIni.dat domain_path = "/path/to/your/weblogic/domain" encrypted_pwd = "{AES}your_encrypted_password_here" # 替换为实际密文 # 获取加密服务 encrypt_srv = SerializedSystemIni.getEncryptionService(domain_path) ces = ClearOrEncryptedService(encrypt_srv) # 解密密码 decrypted_pwd = ces.decrypt(encrypted_pwd) print("Decrypted Password:", decrypted_pwd) ``` 3. 运行脚本: ```bash java -Dweblogic.security.SSL.debugEaten=true weblogic.WLST decrypt.py # 可选调试标志[^3] ``` - **优点**:官方支持,无需额外工具。 - **缺点**:需要访问WebLogic安装目录和域文件,适合管理员操作。 #### **方法二:使用第三方开源工具(基于WebLogic库)** 一些社区工具封装了上述过程,简化操作。推荐以下工具: - **WebLogic Password Decryptor**: - 项目地址:[GitHub - WebLogic Password Decryptor](https://github.com/NetSPI/WebLogicPasswordDecryptor) - 描述:一个Java工具,直接调用WebLogic的JAR文件进行解密。使用时需提供`SerializedSystemIni.dat`和密文。 - 使用步骤: 1. 下载工具并编译(需Maven)。 2. 运行命令: ```bash java -jar decryptor.jar -d /path/to/domain -p "{AES}encrypted_password" ``` - **优点**:开源免费,支持批量解密。 - **缺点**:依赖WebLogic库,可能需调整类路径。 #### **方法三:手动Java程序** 如果无法使用现成工具,可编写简易Java程序: - **步骤**: 1. 确保`wlserver/server/lib`下的JAR文件(如`weblogic.jar`)在类路径中。 2. 创建Java类: ```java import weblogic.security.internal.*; import weblogic.security.internal.encryption.*; public class Decryptor { public static void main(String[] args) throws Exception { String domainPath = "/path/to/domain"; String encryptedPwd = "{AES}your_encrypted_password"; EncryptionService es = SerializedSystemIni.getEncryptionService(domainPath); ClearOrEncryptedService ces = new ClearOrEncryptedService(es); String decryptedPwd = ces.decrypt(encryptedPwd); System.out.println("Decrypted Password: " + decryptedPwd); } } ``` 3. 编译并运行: ```bash javac -cp ".:/path/to/weblogic.jar" Decryptor.java java -cp ".:/path/to/weblogic.jar" Decryptor ``` - **参考**:此方法基于WebLogic内部API调用[^1]。 ### 3. **注意事项** - **安全风险**:解密操作应在受控环境进行,避免泄露敏感信息。WebLogic的随机密钥机制提高了安全性[^2]。 - **版本兼容**:确保工具与您的WebLogic版本匹配(如11g使用AES,10g使用DES)。 - **调试帮助**:添加`-Dweblogic.security.SSL.debugEaten=true`标志可输出详细日志,但可能产生冗余信息[^3]。 - **替代方案**:如果无法访问域文件,解密可能不可行,因为密钥是唯一的。 ### 相关问题 1. 如何手动生成WebLogic加密密码? 2. WebLogic密码加密机制有哪些安全漏洞? 3. 如何配置WebLogic以增强密码存储的安全性? 如果您提供更多细节(如WebLogic版本或具体场景),我可以进一步优化建议。引用来源基于站内信息[^1][^2][^3]。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值