forked from willstruggle/john
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhtdigest2john.py
More file actions
executable file
·33 lines (27 loc) · 1.04 KB
/
htdigest2john.py
File metadata and controls
executable file
·33 lines (27 loc) · 1.04 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
#!/usr/bin/env python
# The htdigest2john.py utility processes htdigest files into a format suitable
# for use with JtR.
#
# This software is Copyright (c) 2012, 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
def process_file(filename):
with open(filename, "r") as f:
for line in f.readlines():
line = line.rstrip()
try:
username, realm, htdigesthash = line.split(":")
except (ValueError, TypeError):
continue
sys.stdout.write("%s:$dynamic_4$%s$HEX$%s\n" % (username,
htdigesthash, binascii.hexlify("%s:%s:" % (username, realm))))
if __name__ == "__main__":
if len(sys.argv) < 2:
sys.stdout.write("Usage: %s <htdigest file(s)>\n" % sys.argv[0])
sys.exit(-1)
for i in range(1, len(sys.argv)):
process_file(sys.argv[i])