GC-5050: better configuration handling
This commit is contained in:
parent
a0e87a82f7
commit
047939b80d
|
@ -15,6 +15,9 @@ EXTERNAL_CONFIG_FILE = os.path.join(os.path.dirname(sys.argv[0]), 'monkey.bin')
|
||||||
|
|
||||||
|
|
||||||
def _cast_by_example(value, example):
|
def _cast_by_example(value, example):
|
||||||
|
"""
|
||||||
|
a method that casts a value to the type of the parameter given as example
|
||||||
|
"""
|
||||||
example_type = type(example)
|
example_type = type(example)
|
||||||
if example_type is str:
|
if example_type is str:
|
||||||
return str(os.path.expandvars(value))
|
return str(os.path.expandvars(value))
|
||||||
|
@ -42,12 +45,13 @@ class Configuration(object):
|
||||||
for key, value in data.items():
|
for key, value in data.items():
|
||||||
if key.startswith('_'):
|
if key.startswith('_'):
|
||||||
continue
|
continue
|
||||||
|
if key in ["name", "id"]:
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
default_value = getattr(Configuration, key)
|
default_value = getattr(Configuration, key)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
setattr(self, key, _cast_by_example(value, default_value))
|
setattr(self, key, _cast_by_example(value, default_value))
|
||||||
|
|
||||||
def as_dict(self):
|
def as_dict(self):
|
||||||
|
@ -99,17 +103,17 @@ class Configuration(object):
|
||||||
|
|
||||||
alive = True
|
alive = True
|
||||||
|
|
||||||
self_delete_in_cleanup = False
|
self_delete_in_cleanup = True
|
||||||
|
|
||||||
singleton_mutex_name = "{2384ec59-0df8-4ab9-918c-843740924a28}"
|
singleton_mutex_name = "{2384ec59-0df8-4ab9-918c-843740924a28}"
|
||||||
|
|
||||||
# how long to wait between scan iterations
|
# how long to wait between scan iterations
|
||||||
timeout_between_iterations = 10
|
timeout_between_iterations = 100
|
||||||
|
|
||||||
# how many scan iterations to perform on each run
|
# how many scan iterations to perform on each run
|
||||||
max_iterations = 1
|
max_iterations = 1
|
||||||
|
|
||||||
scanner_class = PingScanner
|
scanner_class = TcpScanner
|
||||||
finger_classes = (SMBFinger, SSHFinger, PingScanner)
|
finger_classes = (SMBFinger, SSHFinger, PingScanner)
|
||||||
exploiter_classes = (SmbExploiter, WmiExploiter, RdpExploiter, Ms08_067_Exploiter, SSHExploiter)
|
exploiter_classes = (SmbExploiter, WmiExploiter, RdpExploiter, Ms08_067_Exploiter, SSHExploiter)
|
||||||
|
|
||||||
|
@ -120,7 +124,7 @@ class Configuration(object):
|
||||||
victims_max_exploit = 7
|
victims_max_exploit = 7
|
||||||
|
|
||||||
# depth of propagation
|
# depth of propagation
|
||||||
depth = -1
|
depth = 2
|
||||||
current_server = ""
|
current_server = ""
|
||||||
|
|
||||||
command_servers = [
|
command_servers = [
|
||||||
|
@ -136,10 +140,9 @@ class Configuration(object):
|
||||||
# scanners config
|
# scanners config
|
||||||
###########################
|
###########################
|
||||||
|
|
||||||
range_class = ClassCRange
|
range_class = FixedRange
|
||||||
# range_size = 1
|
range_size = 1
|
||||||
# range_class = FixedRange
|
range_fixed = ("", )
|
||||||
# range_fixed = ("", )
|
|
||||||
|
|
||||||
# TCP Scanner
|
# TCP Scanner
|
||||||
tcp_target_ports = [22, 2222, 445, 135, 3389]
|
tcp_target_ports = [22, 2222, 445, 135, 3389]
|
||||||
|
|
|
@ -120,9 +120,12 @@ class ControlClient(object):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
WormConfiguration.from_dict(reply.json().get('config'))
|
WormConfiguration.from_dict(reply.json().get('config'))
|
||||||
|
LOG.info("New configuration was loaded from server: %r" % (WormConfiguration.as_dict(),))
|
||||||
except Exception, exc:
|
except Exception, exc:
|
||||||
LOG.warn("Error parsing JSON reply from control server %s (%s): %s",
|
# we don't continue with default conf here because it might be dangerous
|
||||||
WormConfiguration.current_server, reply._content, exc)
|
LOG.error("Error parsing JSON reply from control server %s (%s): %s",
|
||||||
|
WormConfiguration.current_server, reply._content, exc)
|
||||||
|
raise Exception("Couldn't load from from server's configuration, aborting. %s" % exc)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def download_monkey_exe(host):
|
def download_monkey_exe(host):
|
||||||
|
|
Loading…
Reference in New Issue