Created
March 25, 2019 02:52
-
-
Save hghwng/36a9263b29c3bbf279cbfb5cc8b4af13 to your computer and use it in GitHub Desktop.
Decrypt TrainerRoad Course
This file contains 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
#!/usr/bin/env python | |
def decode_buf(ciphertext): | |
from Crypto.Protocol.KDF import PBKDF2 | |
(KEY_SIZE, IV_SIZE) = (256 // 8, 128 // 8) | |
key_iv = PBKDF2("4ZpHznL4ELiAiZEXpAloFPA7sO4NqVLLd8qavZ8D", b"vxZIH70vLr9i8pymHC0U", dkLen=KEY_SIZE + IV_SIZE) | |
(key, iv) = (key_iv[:KEY_SIZE], key_iv[KEY_SIZE:]) | |
from Crypto.Cipher import AES | |
cipher = AES.new(key, mode=AES.MODE_CBC, IV=iv) | |
plaintext = cipher.decrypt(ciphertext[4:]) | |
plaintext = plaintext[:-plaintext[-1]] | |
import gzip | |
return gzip.decompress(plaintext) | |
def decode_file(path): | |
data = decode_buf(open(path, 'rb').read()) | |
open(path + '.dec', 'wb').write(data) | |
def main(): | |
from sys import argv | |
for i in argv[1:]: | |
print(i) | |
decode_file(i) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment