Created
January 1, 2023 14:33
-
-
Save hldr4/4be825ab07d8a84d4e653106a8664a38 to your computer and use it in GitHub Desktop.
Decrypts passwords stored in rclone configuration files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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