forked from openwall/john
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dashlane2john.py
executable file
·80 lines (62 loc) · 2.51 KB
/
dashlane2john.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env python
# Extracts "hashes" from Dashlane's .aes and .dash files.
#
# This software is Copyright (c) 2017, Dhiru Kholia <kholia at kth.se> and it is
# hereby released to the general public under the following terms:
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted.
import sys
import os.path
from binascii import hexlify
import base64
PY3 = sys.version_info[0] == 3
def process_secure_archive(filename):
dump_next = False
vline = None
with open(filename, "rb") as f:
for line in f:
if b"Data BEGIN" in line:
dump_next = True
continue
if dump_next:
vline = line.strip()
dump_next = False
if vline:
return base64.b64decode(vline)[:256]
return None
def process(filename, plaintext=None, cipher=0, md=0):
with open(filename, "rb") as f:
data = f.read()
if b"Data BEGIN" in data:
data = process_secure_archive(filename)
else:
data = data[:256] # this is enough for cracking .aes files
if len(data) < 32:
sys.stderr.write("%s: too short to be valid database?\n" % filename)
return
salt = hexlify(data[0:32])
if PY3:
salt = salt.decode("ascii")
v = 0
if data[32:].startswith(b'KWC3'):
v = 1
aes_data = data[32+4:] # skip over KWC3 which implies compression
else:
aes_data = data[32:]
aes_data = hexlify(aes_data)
if PY3:
aes_data = aes_data.decode("ascii")
sys.stdout.write("%s:$dashlane$%s*%s*%s*%s\n" % (os.path.basename(filename), v, salt,
len(aes_data) // 2,
aes_data))
return
if __name__ == '__main__':
if len(sys.argv) < 2:
sys.stderr.write("Usage: %s <.aes or .dash files from Dashlane for Windows Desktop / macOS>\n" % sys.argv[0])
sys.stderr.write("\nNote: This only works with data from Windows and macOS Desktop version of Dashlane.\n")
sys.stderr.write("\nThe required .aes files can be found inside %AppData%\Dashlane\profiles directory tree on Windows.\n")
sys.stderr.write("\nThe required .aes files can be found inside ~/Library/Application\ Support/Dashlane/profiles/ directory tree on macOS.\n")
sys.exit(1)
for i in range(1, len(sys.argv)):
process(sys.argv[i])