Skip to content

Instantly share code, notes, and snippets.

@lanrat
Created April 11, 2025 01:37
Show Gist options
  • Save lanrat/46691151326f5bb7701df79441522de5 to your computer and use it in GitHub Desktop.
Save lanrat/46691151326f5bb7701df79441522de5 to your computer and use it in GitHub Desktop.
Decrypt "encrypted" Aruba credentials
#!/usr/bin/env python3
import pyDes
import sys
if len(sys.argv) != 2:
print("pass hash")
sys.exit(2)
# Key
key = (
b'\x32\x74\x10\x84\x91\x17\x75\x46\x14\x75\x82\x92'
b'\x43\x49\x04\x59\x18\x69\x15\x94\x27\x84\x30\x03'
)
def decode(h):
# Decode hex string to bytes
raw_bytes = bytes.fromhex(h)
# IV is the first 8 bytes
iv = raw_bytes[:8]
# Ciphertext is the rest
ciphertext = raw_bytes[8:]
# Ensure IV and padding character are bytes
# pyDes expects bytes for key, IV, and data in Python 3
d = pyDes.triple_des(key, pyDes.CBC, iv, pad=b'\x00', padmode=pyDes.PAD_NORMAL) # Specify padmode if needed
# Decrypt (expects bytes, returns bytes)
decrypted_bytes = d.decrypt(ciphertext)
# Attempt to decode the result as UTF-8, removing null padding
# If decoding fails, print the raw bytes representation
try:
# rstrip(b'\x00') removes potential null padding bytes
decrypted_text = decrypted_bytes.rstrip(b'\x00').decode('utf-8')
except UnicodeDecodeError:
decrypted_text = decrypted_bytes # Keep as bytes if not valid UTF-8
print(f"{h} => {decrypted_text}")
decode(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment