-
Notifications
You must be signed in to change notification settings - Fork 16
/
crackserver.py
executable file
·75 lines (61 loc) · 2.82 KB
/
crackserver.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
#!/usr/bin/env python
'''
Launches an XMLRPC listener for password cracking requests from crackclient.py
'''
import SimpleXMLRPCServer as sxml
import argparse
from modules.core import *
from modules.core_crackserver import *
#------------------------------------------------------------------------------
# Get values from config file
#------------------------------------------------------------------------------
#check to see if specified config file exists; if not copy default
config_file = "config/crackserver.cfg"
config_default = "config/crackserver.default"
check_default_config(config_file, config_default)
server_ip = check_config("SERVER_IP", config_file)
if server_ip == "": server_ip = "127.0.0.1"
server_port = check_config("SERVER_PORT", config_file)
if server_port == "": server_port = "8000"
crack_config = check_config("CRACK_CONFIG", config_file)
if crack_config == "": crack_config = "config/crack.cfg"
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 = """ Crackserver launches a XMLRPC server to handle password cracking
requests."""
parser = argparse.ArgumentParser(description=desc)
parser.add_argument('-l', action='store', default=server_ip,
help='IP address to listen on. (default: ' + server_ip + ')')
parser.add_argument('-p', action='store', default=server_port,
help='Port to listen on. (default: ' + server_port +')')
parser.add_argument('-c', action='store', default=crack_config,
help='Configuration file. (default: ' + crack_config + ')')
args = parser.parse_args()
#------------------------------------------------------------------------------
# Main Program
#------------------------------------------------------------------------------
# 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()
try:
server = sxml.SimpleXMLRPCServer((args.l, int(args.p)),
requestHandler=sxml.SimpleXMLRPCRequestHandler)
print "XMLRPC server configuration successful; listening on " + args.l+":"+args.p
except Exception, err:
print "XMLRPC server configuration unsuccessful:\n"
print str(err)
exit()
# Register CrackManager functions to be used with by XMLRPC client.
server.register_introspection_functions()
server.register_function(c.crack_passwords, 'crack')
server.register_function(c.get_progress, 'results')
server.serve_forever()