最近因公司安全要求,必须修改weblogic弱口令。通过weblogic的console修改完成之后发现weblogic服务启动不了了。
1. 在console修改weblogic密码后weblogic无法启动的问题
再现场景:
weblogic启动的情况下,在浏览器访问console:localhost:7001/console,登录进去,进入“安全领域”–“myrealm”–“weblogic”,进行口令修改。
解决方法:
修改配置文件(注意准确路径)::$BEA_BASE/user_projects/domains/{your domain name}/servers/AdminServer/security/boot.properties
, 将username与password修改为新的明文,例如
password=weblogggic
username=weblogic
这样就可以使用启动命令文件startWebLogic.cmd
启动weblogic了。细心的孩纸会发现启动后该配置文件中的明文变成了三重DES的密文base64,格式如下:
{3DES}[密文...]
##延伸:
域管理账号的配置文件还有一个::$BEA_BASE/user_projects/domains/{your domain name}/config/config.xml
,可参考博文:https://blog.csdn.net/zhouxzcsdn/article/details/53376820
2. 如何解密weblogic的三重DES密文
使用下面的代码,注意将weblogic的lib库(在安装目录中)引入,注意注释中提示的使用weblogic的SerializedSystemIni.dat替换工程中的对应文件
操作步骤,拷贝进工程 – 引入weblogic的lib – 运行一次main函数 – 替换解密密文与dat文件 – 运行main函数。
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 或者您输入的待解密的字符串不正确!");
}
}
}