weblogic密码加解密

weblogic密码加解密
摘要由CSDN通过智能技术生成
   通常在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/dom
  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值