forked from openwall/john
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilezilla2john.py
executable file
·54 lines (41 loc) · 1.68 KB
/
filezilla2john.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
#!/usr/bin/env python
"""filezilla2john.py extracts password hashes from "FileZilla Server.xml" files."""
# This software is Copyright (c) 2016, Dhiru Kholia <dhiru at openwall.com> 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 binascii
from xml.etree.ElementTree import ElementTree
def process_file(filename):
f = open(filename, "rb")
tree = ElementTree()
tree.parse(f)
r = tree.getroot()
for user in tree.findall(".//User"):
username = user.attrib.get("Name")
hsh = ""
salt = None
for option in user.findall("Option"):
if option.get("Name") == "Pass":
hsh = option.text
if option.get("Name") == "Salt":
salt = option.text
if not hsh:
continue
if hsh:
hsh = hsh.lower()
if len(hsh) == 32 and not salt: # Raw-MD5 hashes
sys.stdout.write("%s:$dynamic_0$%s\n" % (username, hsh))
elif len(hsh) == 128 and salt: # sha512($p.$s)
salt = binascii.hexlify(salt.encode("ascii")).decode("ascii") # salt can include ":" characters
sys.stdout.write("%s:$dynamic_82$%s$HEX$%s\n" % (username, hsh, salt))
else:
sys.stderr.write("Hash of length (%s) is not supported. Open a GitHub issue for reporting this!\n" % len(hsh))
if __name__ == "__main__":
if len(sys.argv) < 2:
sys.stderr.write("Usage: %s <FileZilla Server.xml file(s)>\n" % sys.argv[0])
sys.exit(1)
for k in range(1, len(sys.argv)):
process_file(sys.argv[k])