Skip to content

Instantly share code, notes, and snippets.

@ykoster
Created December 24, 2020 04:44
Show Gist options
  • Save ykoster/f9130d6223ad0272ccb20706312dcd0c to your computer and use it in GitHub Desktop.
Save ykoster/f9130d6223ad0272ccb20706312dcd0c to your computer and use it in GitHub Desktop.
IBM Installation Manager imcl / imutilsc encryptString command decrypt script
#!/usr/bin/env python3
import re
import sys
import base64
from Crypto.Cipher import AES
val = '^(?:[A-Z0-9+/]{4})*(?:[A-Z0-9+/]{2}==|[A-Z0-9+/]{3}=)?$'
key = base64.b64decode(b'BTQOll+YFPIcsB+vMfXNTg==')
def decrypt(e):
p = re.compile(val, re.IGNORECASE)
if p.match(e):
cipher = AES.new(key, AES.MODE_ECB)
dec = cipher.decrypt(base64.b64decode(e))
pwd = dec[:-ord(dec[len(dec)-1:])].decode('utf8')
print(f'{e}:\t{pwd}')
else:
print(f'Invalid format: {e}', file=sys.stderr)
def main(argv):
for arg in argv:
decrypt(arg)
if __name__ == "__main__":
if len(sys.argv) < 2:
print(f'Usage: {sys.argv[0]} b64 [b64 ...]')
print(f'Example: {sys.argv[0]} U4DQSKB8w2r6uZlbcdHAPQ==')
else:
main(sys.argv[1:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment