Search Blog Post

Thursday, November 13, 2014

Recover weblogic password in any Weblogic Environment


In one of our weblogic environment, we forgot the weblogic password and instead of resetting the password the only option we had was to recover the same old password. So we did some research and followed the below process to recover or decrypt the weblogic password from boot.properties.

  • Set the environment by sourcing setDomainEnv.sh file under $DOMAIN_HOME/bin
-bash-3.2$ . ./setDomainEnv.sh

Check if the DOMAIN_HOME is set
-bash-3.2$ echo $DOMAIN_HOME
/u01/Oracle/Middleware/user_projects/domains/ecm_domain

  • Extract the encrypted username and password credential from the boot identify file
-bash-3.2$ USR=`grep username $DOMAIN_HOME/servers/AdminServer/security/boot.properties | sed -e "s/^username=\(.*\)[\]=$/\1=/"`

-bash-3.2$ PW=`grep password $DOMAIN_HOME/servers/AdminServer/security/boot.properties | sed -e "s/^password=\(.*\)[\]=$/\1=/"`

  • Create the small java Decrypt program and invoke it supplying the DOMAIN_HOME and encrypted value requiring decryption
-bash-3.2$ cat > /tmp/Decrypt.java <<EOF
 public class Decrypt {
   public static void main(String[] args) {
     System.out.println("Decrypted value: " + new weblogic.security.internal.encryption.ClearOrEncryptedService(
       weblogic.security.internal.SerializedSystemIni.getEncryptionService(args[0])).
         decrypt(args[1]));
   }
 }
EOF

-bash-3.2$ $JAVA_HOME/bin/javac -d /tmp /tmp/Decrypt.java

-bash-3.2$ $JAVA_HOME/bin/java -cp /tmp:$CLASSPATH Decrypt "$DOMAIN_HOME" "$USR"
Decrypted value: weblogic

-bash-3.2$ $JAVA_HOME/bin/java -cp /tmp:$CLASSPATH Decrypt "$DOMAIN_HOME" "$PW"
Decrypted value: welcome1

HTH
Thanks for reading..!!