jboss/wildfly安全域的密码加密和解密

加密:

java_path=$(source /opt/wildfly/bin/env.conf && echo $JAVA_HOME)&&$java_path/bin/java -cp /opt/wildfly/modules/system/layers/base/org/picketbox/main/picketbox-4.0.21.Beta1.jar:/opt/wildfly/modules/system/layers/base/org/jboss/logging/main/jboss-logging-3.1.4.GA.jar org.picketbox.datasource.security.SecureIdentityLoginModule 'password'

 

解密:

解密需要额外编辑jar包

1、首先使用eclipse,或其他java的IDE软件,新建一个java工程

2、创建包路径org.picketbox.datasource.security

3、在该路径下创建类文件SecureIdentityLoginModule.java

package org.picketbox.datasource.security;

public class SecureIdentityLoginModule {
    private static String encode(String secret) {
        return secret;
    }

    private static char[] decode(String secret) {
        return new char[] { '0', '1', '2', '3', '4', '5' };
    }
}

4、依然在这个包路径下创建类文件PasswordDecoder.java

package org.picketbox.datasource.security;
import java.lang.reflect.Method;

public class PasswordDecoder {
    public static void main(String args[]) throws Exception {
        Class<SecureIdentityLoginModule> cla = SecureIdentityLoginModule.class;
        Method m = cla.getDeclaredMethod("decode", String.class);
        m.setAccessible(true);
        Object obj = m.invoke(null, args[0]);
        char[] chars = (char[]) obj;
        System.out.println(new String(chars));
    }
}

5、然后编译PasswordDecoder.java这个类文件,编译成功后会生成相应的.class文件。

6、找到/opt/wildfly/modules/system/layers/base/org/picketbox/main/picketbox-4.0.21.Beta1.jar这个jar包,使用压缩软件打开,找到org\picketbox\datasource\security\这个路径,将编译得到的PasswordDecoder.class文件放到该路径下

7、然后执行下面的命令就可以得到明文密码

java_path=$(source /opt/wildfly/bin/env.conf && echo $JAVA_HOME)&&$java_path/bin/java -classpath /opt/wildfly/bin/picketbox-4.0.21.Beta1.jar:/opt/wildfly/modules/system/layers/base/org/jboss/logging/main/jboss-logging-3.1.4.GA.jar org.picketbox.datasource.security.PasswordDecoder 密文

 

posted @ 2019-04-03 14:28  一个和🔥有缘的人  阅读(1356)  评论(0编辑  收藏  举报