-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgetpw.py
More file actions
59 lines (43 loc) · 1.67 KB
/
getpw.py
File metadata and controls
59 lines (43 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import binascii
import struct
import sys
import win32crypt
from Crypto.Cipher import AES
from Crypto.Util.Padding import unpad
# The Master Password is encrypted with this static key
# https://github.com/JetBrains/intellij-community/blob/93dde45a41a9d152e01a151d7ae411faa3cf7f61/platform/credential-store/src/EncryptionSupport.kt#L16
CONTAINER_KEY = "Proxy Config Sec"
def decrypt(path):
print("[+] Reading encrypted container as bytes")
enc_bytes = []
with open(path, "rb") as f:
byte = f.read(1)
while byte:
enc_bytes.append(byte)
byte = f.read(1)
enc_bytes_array = b''.join(enc_bytes)
print("[+] Encrypted bytes:")
print(binascii.hexlify(enc_bytes_array))
print("[+] Decrypted bytes from Credential Manager")
decrypted_container = win32crypt.CryptUnprotectData(
enc_bytes_array, None, None, None, 0
)[1]
print(binascii.hexlify(decrypted_container))
iv_length = struct.unpack('>i', decrypted_container[:4])[0]
print("IV Length: " + str(iv_length))
iv = decrypted_container[4:4 + iv_length]
print("[+] IV: " + str(binascii.hexlify(iv)))
data = decrypted_container[4 + iv_length:]
print("[+] Payload length: " + str(len(data)))
key = CONTAINER_KEY.encode('ascii')
cipher = AES.new(key, AES.MODE_CBC, iv=iv)
result = unpad(cipher.decrypt(data), AES.block_size).decode('ascii')
print("-------------------------------------")
print("[+] DECODED PASSWORD")
print(result)
if __name__ == '__main__':
# Program Entry Point
if len(sys.argv) != 2:
print("This program takes one parameter: the path to pdb.pwd.")
exit(1)
decrypt(sys.argv[1])