Created
June 5, 2020 02:19
-
-
Save jedy/60d5559ae80acf6a0414e42995802fc1 to your computer and use it in GitHub Desktop.
read mylogin.cnf
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 struct | |
from Crypto.Cipher import AES | |
LOGIN_KEY_LEN = 20 | |
MY_LOGIN_HEADER_LEN = 24 | |
MAX_CIPHER_STORE_LEN = 4 | |
f = open(".mylogin.cnf", "rb") | |
f.seek(4) | |
b = f.read(LOGIN_KEY_LEN) | |
key = [0] * 16 | |
for i in range(LOGIN_KEY_LEN): | |
key[i % 16] ^= b[i] | |
key = struct.pack('16B', *key) | |
encryptor = AES.new(key, AES.MODE_ECB) | |
f.seek(MY_LOGIN_HEADER_LEN) | |
while True: | |
b = f.read(MAX_CIPHER_STORE_LEN) | |
if len(b) < MAX_CIPHER_STORE_LEN: | |
break | |
cipher_len, = struct.unpack("<i", b) | |
b = f.read(cipher_len) | |
plain = encryptor.decrypt(b) | |
print(plain[:-plain[-1]]) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment