Skip to content

Instantly share code, notes, and snippets.

@Wh1terat
Last active June 18, 2024 19:24
Show Gist options
  • Save Wh1terat/046c2ba67b8f5cb3f767c30f4199efae to your computer and use it in GitHub Desktop.
Save Wh1terat/046c2ba67b8f5cb3f767c30f4199efae to your computer and use it in GitHub Desktop.
Decrypt <pack:Password> from service42 files
#!/usr/bin/env python3
import sys
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.backends import default_backend
from base64 import b64decode
__title__ = "service42 Password Decryptor"
__version__ = "0.1"
__author__ = "Whiterat"
def decrypt_pass(encrypted_pass):
kdf_salt = b'\xa2\xba\x12\x99\x37\x41\x0a\x67\xc3'
kdf_key = b"FRoaHAsSHAsVGhkLEhke"
kdf = PBKDF2HMAC(
algorithm=hashes.SHA1(),
length=32,
salt=kdf_salt,
iterations=1000,
backend=default_backend()
)
key = kdf.derive(kdf_key)
cipher = Cipher(
algorithms.AES(key),
modes.ECB(),
backend=default_backend()
)
decryptor = cipher.decryptor()
decrypted_pass = decryptor.update(b64decode(encrypted_pass))
decrypted_pass += decryptor.finalize()
try:
return decrypted_pass.decode('utf-8').strip()
except UnicodeDecodeError:
return decrypted_pass
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: decrypt_pass.py <encrypted_pass>")
sys.exit(1)
encrypted_pass = sys.argv[1]
print(decrypt_pass(encrypted_pass))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment