-
Notifications
You must be signed in to change notification settings - Fork 16
/
crack.py
executable file
·76 lines (56 loc) · 2.59 KB
/
crack.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
#!/usr/bin/env python
'''
Module for performing a standalone cracking operation rather than using the
client server capabilities of crackserver.py and crackclient.py. Uses the same
core modules as the crackserver applications for performing cracking operation.
Takes a file, a server:port combination, and a hash type.
Acceptable hash types are defined in config file associated with
listening crackserver instance.
While crackserver.py is dependent upon core modules contained in other files,
crackclient.pl is dependent only upon standard python modules
'''
import argparse
from modules.core_crackserver import *
from modules.core import *
class hashlist:
'''
TODO: Find a more elegant way of doing this!!!
Hashes that are passed to the cracking mechanism via RPC are passed using
xmlrpclib binary class, and are stored in a 'data' attribute. This dummy
class is to allow us a local class in which to store the hashes in
a similarly named attribute so we can re-use the functionality
Need to re-write the core module
'''
def __init__(self, data):
self.data = data
#check to see if specified config file exists; if not copy default
config_file = "config/crack.cfg"
config_default = "config/crack.default"
check_default_config(config_file, config_default)
#------------------------------------------------------------------------------
# Configure Argparse to handle command line arguments
#------------------------------------------------------------------------------
desc = """Crack takes a file and a hash type."""
parser = argparse.ArgumentParser(description=desc)
parser.add_argument('file', action='store', default='hashes.txt',
help='Specify a hash file (default: hashes.txt)')
parser.add_argument('type', action='store', default='md5',
help='Specify the hash type (default: md5)')
parser.add_argument('-c', action='store', default='config/crack.cfg',
help='Configuration file. (default: config/crack.cfg)')
#------------------------------------------------------------------------------
# Main Program
#------------------------------------------------------------------------------
args = parser.parse_args()
htype = args.type
hashfile = open(args.file, "r")
hlist = hashlist(hashfile.read())
# Create new CrackManager object to handle cracking process.
try:
c = CrackManager(args.c)
print "CrackManager configured successfully using config file " + args.c
except Exception, err:
print "CrackManager configuration unsuccessful:\n"
print str(err)
exit()
c.crack_passwords(hlist, htype)