当前位置: 代码迷 >> Web前端 >> weblogic9/weblogic10 DES3解密步骤详解
  详细解决方案

weblogic9/weblogic10 DES3解密步骤详解

热度:929   发布时间:2012-09-03 09:48:39.0
weblogic9/weblogic10 DES3解密方法详解
import weblogic.security.internal.SerializedSystemIni;
import weblogic.security.internal.encryption.EncryptionService;
import weblogic.utils.encoders.BASE64Decoder;
import weblogic.utils.encoders.BASE64Encoder;

/**
 * 需要包含 C:\bea\wlserver_10.3\server\lib\相关jar包!否则会抛出异常
 * 
 * @author powerxsu
 * @project testspring
 * @date Oct 24, 2009
 * @version 1.0
 */
public class CrackData {
    
    public static void main(String[] args) {
        byte[] salt, keys;
        /**
         * 找到weblogic对应domain下的
         * user_projects\domains\base_domain\security\SerializedSystemIni.dat文件
         * 把它拷贝到当前project的"security"目录下覆盖即可
         * 这样就可以把config.xml中的加密的密码串拿出来进行解密处理了!^_^
         */
        
        String path = SerializedSystemIni.getPath();
        System.out.println(path);
        
        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();
                }
            }
        }
        
        // decrypt awF/L0fQdXgGs2JoKePo5Q==
        // 模拟加密处理-------!
        String _pass = "lbxhis";
        byte[] edata2 = svr.encryptString(_pass);
        String s = (new BASE64Encoder()).encodeBuffer(edata2);
        System.out.println("Encode:" + s);
        // 模拟解密处理--------!
        try {
            String pass = "awF/L0fQdXgGs2JoKePo5Q==";
            byte[] edata = (new BASE64Decoder()).decodeBuffer(pass);
            
            String txt = svr.decryptString(edata);
            System.out.println("Decode:" + txt);
        } catch (Exception ex) {
            System.err.println("/**\n" + "      * 找到weblogic对应domain下的\n"
                + "      * user_projects\\domains\\base_domain\\security\\SerializedSystemIni.dat文件\n"
                + "      * 把它拷贝到当前project的\"security\"目录下覆盖即可\n" + "      * 这样就可以把config.xml中的加密的密码串拿出来进行解密处理了!^_^\n"
                + "      */" + "\n\n 或者您输入的待解密的字符串不正确!");
        }
        
    }
}