forked from p15670423/monkey
Report now uses initial config when makes sense
This commit is contained in:
parent
d8aff72da0
commit
f2e464f2a6
|
@ -62,6 +62,8 @@ class Monkey(flask_restful.Resource):
|
||||||
|
|
||||||
monkey_json['modifytime'] = datetime.now()
|
monkey_json['modifytime'] = datetime.now()
|
||||||
|
|
||||||
|
ConfigService.save_initial_config_if_needed()
|
||||||
|
|
||||||
# if new monkey telem, change config according to "new monkeys" config.
|
# if new monkey telem, change config according to "new monkeys" config.
|
||||||
db_monkey = mongo.db.monkey.find_one({"guid": monkey_json["guid"]})
|
db_monkey = mongo.db.monkey.find_one({"guid": monkey_json["guid"]})
|
||||||
if not db_monkey:
|
if not db_monkey:
|
||||||
|
|
|
@ -800,23 +800,23 @@ class ConfigService:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_config():
|
def get_config(is_initial_config=False):
|
||||||
config = mongo.db.config.find_one({'name': 'newconfig'}) or {}
|
config = mongo.db.config.find_one({'name': 'initial' if is_initial_config else 'newconfig'}) or {}
|
||||||
for field in ('name', '_id'):
|
for field in ('name', '_id'):
|
||||||
config.pop(field, None)
|
config.pop(field, None)
|
||||||
return config
|
return config
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_config_value(config_key_as_arr):
|
def get_config_value(config_key_as_arr, is_initial_config=False):
|
||||||
config_key = reduce(lambda x, y: x+'.'+y, config_key_as_arr)
|
config_key = reduce(lambda x, y: x+'.'+y, config_key_as_arr)
|
||||||
config = mongo.db.config.find_one({'name': 'newconfig'}, {config_key: 1})
|
config = mongo.db.config.find_one({'name': 'initial' if is_initial_config else 'newconfig'}, {config_key: 1})
|
||||||
for config_key_part in config_key_as_arr:
|
for config_key_part in config_key_as_arr:
|
||||||
config = config[config_key_part]
|
config = config[config_key_part]
|
||||||
return config
|
return config
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_flat_config():
|
def get_flat_config(is_initial_config=False):
|
||||||
config_json = ConfigService.get_config()
|
config_json = ConfigService.get_config(is_initial_config)
|
||||||
flat_config_json = {}
|
flat_config_json = {}
|
||||||
for i in config_json:
|
for i in config_json:
|
||||||
for j in config_json[i]:
|
for j in config_json[i]:
|
||||||
|
@ -888,6 +888,16 @@ class ConfigService:
|
||||||
config["cnc"]["servers"]["command_servers"] = ["%s:%d" % (ip, ISLAND_PORT) for ip in ips]
|
config["cnc"]["servers"]["command_servers"] = ["%s:%d" % (ip, ISLAND_PORT) for ip in ips]
|
||||||
config["cnc"]["servers"]["current_server"] = "%s:%d" % (ips[0], ISLAND_PORT)
|
config["cnc"]["servers"]["current_server"] = "%s:%d" % (ips[0], ISLAND_PORT)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def save_initial_config_if_needed():
|
||||||
|
if mongo.db.config.find_one({'name': 'initial'}) is not None:
|
||||||
|
return
|
||||||
|
|
||||||
|
initial_config = mongo.db.config.find_one({'name': 'newconfig'})
|
||||||
|
initial_config['name'] = 'initial'
|
||||||
|
initial_config.pop('_id')
|
||||||
|
mongo.db.config.insert(initial_config)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _extend_config_with_default(validator_class):
|
def _extend_config_with_default(validator_class):
|
||||||
validate_properties = validator_class.VALIDATORS["properties"]
|
validate_properties = validator_class.VALIDATORS["properties"]
|
||||||
|
|
|
@ -282,11 +282,11 @@ class ReportService:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_config_users():
|
def get_config_users():
|
||||||
return ConfigService.get_config_value(['basic', 'credentials', 'exploit_user_list'])
|
return ConfigService.get_config_value(['basic', 'credentials', 'exploit_user_list'], True)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_config_passwords():
|
def get_config_passwords():
|
||||||
return ConfigService.get_config_value(['basic', 'credentials', 'exploit_password_list'])
|
return ConfigService.get_config_value(['basic', 'credentials', 'exploit_password_list'], True)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_config_exploits():
|
def get_config_exploits():
|
||||||
|
@ -294,7 +294,7 @@ class ReportService:
|
||||||
default_exploits = ConfigService.get_default_config()
|
default_exploits = ConfigService.get_default_config()
|
||||||
for namespace in exploits_config_value:
|
for namespace in exploits_config_value:
|
||||||
default_exploits = default_exploits[namespace]
|
default_exploits = default_exploits[namespace]
|
||||||
exploits = ConfigService.get_config_value(exploits_config_value)
|
exploits = ConfigService.get_config_value(exploits_config_value, True)
|
||||||
|
|
||||||
if exploits == default_exploits:
|
if exploits == default_exploits:
|
||||||
return ['default']
|
return ['default']
|
||||||
|
@ -304,13 +304,13 @@ class ReportService:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_config_ips():
|
def get_config_ips():
|
||||||
if ConfigService.get_config_value(['basic_network', 'network_range', 'range_class']) != 'FixedRange':
|
if ConfigService.get_config_value(['basic_network', 'network_range', 'range_class'], True) != 'FixedRange':
|
||||||
return []
|
return []
|
||||||
return ConfigService.get_config_value(['basic_network', 'network_range', 'range_fixed'])
|
return ConfigService.get_config_value(['basic_network', 'network_range', 'range_fixed'], True)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_config_scan():
|
def get_config_scan():
|
||||||
return ConfigService.get_config_value(['basic_network', 'general', 'local_network_scan'])
|
return ConfigService.get_config_value(['basic_network', 'general', 'local_network_scan'], True)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_report():
|
def get_report():
|
||||||
|
|
Loading…
Reference in New Issue