Skip to content

Instantly share code, notes, and snippets.

@thikade
Last active November 9, 2023 15:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thikade/4e49844a077b7acfa01f65de762b40bb to your computer and use it in GitHub Desktop.
Save thikade/4e49844a077b7acfa01f65de762b40bb to your computer and use it in GitHub Desktop.
WebSphere wsadmin-embedded password en/decoder

Decode WAS password using wsadmin.sh:

./wsadmin.sh -lang jython -conntype none -c 'import com.ibm.ws.security.util.PasswordDecoder as pd; pd.main(["{xor}KzosK25tbH4n"]);'

Encode WAS password using wsadmin.sh:

./wsadmin.sh -lang jython -conntype none -c 'import com.ibm.ws.security.util.PasswordEncoder as pd; pd.main(["test123!x"]);'

Pure Perl wasdecode

  • decode
    echo 'KzosK25tbH4n' | perl -e 'use MIME::Base64; print join("", map { chr(ord($_) ^ 0x5f); } split("", decode_base64(<>)))'

  • result: test123!x

  • encode
    echo 'test123!x' | perl -e 'use MIME::Base64; print "{xor}",encode_base64(join("", map { ord($_)!=10?(chr(ord($_) ^ 0x5f)):()} split("", <>)));'

  • result: {xor}KzosK25tbH4n

@thikade
Copy link
Author

thikade commented Nov 11, 2019

Note2Self

map { ord($_)!=10?(chr(ord($_) ^ 0x5f)):() ... is required during encode to remove any linefeed. It is better and safer than trying to remember and using echo -n <password> to suppress the linefeed in the first place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment