Skip to content

Instantly share code, notes, and snippets.

@hldr4
Created January 1, 2023 14:33
Show Gist options
  • Save hldr4/4be825ab07d8a84d4e653106a8664a38 to your computer and use it in GitHub Desktop.
Save hldr4/4be825ab07d8a84d4e653106a8664a38 to your computer and use it in GitHub Desktop.
Decrypts passwords stored in rclone configuration files
import sys
import base64
from Crypto.Cipher import AES
# Constant key rclone uses
key = bytearray.fromhex('9c935b48730a554d6bfd7c63c886a92bd390198eb8128afbf4de162b8b95f638')
enc_pwd = sys.argv[1]
enc_pwd += '=' * (-len(enc_pwd) % 4) # add padding, else some passwords will fail
ciphertext = base64.urlsafe_b64decode(enc_pwd)
buffer = ciphertext[16:]
iv = ciphertext[:16]
dec = AES.new(key, AES.MODE_CTR, initial_value=iv, nonce=b'')
print(f'\nPlaintext password: {dec.decrypt(buffer).decode()}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment