forked from p15670423/monkey
configuration print and meaningless spaces fixes
This commit is contained in:
parent
7466cdccfb
commit
3081ac6d91
|
@ -14,6 +14,7 @@ GUID = str(uuid.getnode())
|
|||
|
||||
EXTERNAL_CONFIG_FILE = os.path.join(os.path.dirname(sys.argv[0]), 'monkey.bin')
|
||||
|
||||
|
||||
def _cast_by_example(value, example):
|
||||
example_type = type(example)
|
||||
if example_type is str:
|
||||
|
@ -35,17 +36,18 @@ def _cast_by_example(value, example):
|
|||
else:
|
||||
return None
|
||||
|
||||
|
||||
class Configuration(object):
|
||||
|
||||
def from_dict(self, data):
|
||||
for key,value in data.items():
|
||||
for key, value in data.items():
|
||||
if key.startswith('_'):
|
||||
continue
|
||||
|
||||
try:
|
||||
default_value = getattr(Configuration, key)
|
||||
except AttributeError:
|
||||
continue
|
||||
raise
|
||||
|
||||
setattr(self, key, _cast_by_example(value, default_value))
|
||||
|
||||
|
@ -79,7 +81,7 @@ class Configuration(object):
|
|||
###########################
|
||||
|
||||
use_file_logging = True
|
||||
dropper_log_path = os.path.expandvars("%temp%\~df1562.tmp") if sys.platform == "win32" else '/tmp/user-1562'
|
||||
dropper_log_path = os.path.expandvars("%temp%\~df1562.tmp") if sys.platform == "win32" else '/tmp/user-1562'
|
||||
monkey_log_path = os.path.expandvars("%temp%\~df1563.tmp") if sys.platform == "win32" else '/tmp/user-1563'
|
||||
|
||||
###########################
|
||||
|
@ -98,7 +100,7 @@ class Configuration(object):
|
|||
|
||||
alive = True
|
||||
|
||||
self_delete_in_cleanup = True
|
||||
self_delete_in_cleanup = False
|
||||
|
||||
singleton_mutex_name = "{2384ec59-0df8-4ab9-918c-843740924a28}"
|
||||
|
||||
|
@ -134,7 +136,7 @@ class Configuration(object):
|
|||
#range_class = RelativeRange
|
||||
range_size = 8
|
||||
range_class = FixedRange
|
||||
range_fixed = ("10.0.0.9", "10.0.0.13", "192.168.1.100", "192.168.1.95", "50.50.50.56", "50.50.50.4")
|
||||
range_fixed = ("10.0.1.39", )
|
||||
|
||||
# TCP Scanner
|
||||
tcp_target_ports = [22, 2222, 445, 135, 3389]
|
||||
|
@ -157,7 +159,7 @@ class Configuration(object):
|
|||
|
||||
# psexec exploiter
|
||||
psexec_user = "Administrator"
|
||||
psexec_passwords = ["Password1!", "1234", "password", "password", "12345678"]
|
||||
psexec_passwords = ["Password1!", "1234", "password", "12345678"]
|
||||
|
||||
#ssh exploiter
|
||||
ssh_user = "root"
|
||||
|
|
|
@ -23,6 +23,7 @@ LOG = logging.getLogger(__name__)
|
|||
|
||||
MOVEFILE_DELAY_UNTIL_REBOOT = 4
|
||||
|
||||
|
||||
class MonkeyDrops(object):
|
||||
def __init__(self, args):
|
||||
if args:
|
||||
|
|
|
@ -30,6 +30,7 @@ LOG_CONFIG = {'version': 1,
|
|||
'handlers': ['console']},
|
||||
}
|
||||
|
||||
|
||||
def main():
|
||||
global LOG
|
||||
|
||||
|
@ -39,7 +40,7 @@ def main():
|
|||
monkey_mode = sys.argv[1]
|
||||
|
||||
if not monkey_mode in [MONKEY_ARG, DROPPER_ARG]:
|
||||
return True
|
||||
return True
|
||||
|
||||
config_file = EXTERNAL_CONFIG_FILE
|
||||
|
||||
|
@ -47,17 +48,18 @@ def main():
|
|||
arg_parser.add_argument('-c', '--config')
|
||||
opts, monkey_args = arg_parser.parse_known_args(sys.argv[2:])
|
||||
if opts.config:
|
||||
config_file = opts.config
|
||||
|
||||
config_file = opts.config
|
||||
print "Config file is: %s" % config_file
|
||||
if os.path.isfile(config_file):
|
||||
# using print because config can also change log locations
|
||||
print "Loading config from %s." % config_file
|
||||
try:
|
||||
with open(config_file) as config_fo:
|
||||
json_dict = json.load(config_fo)
|
||||
WormConfiguration.from_dict(json_dict)
|
||||
except ValueError:
|
||||
print "Error loading config, using default."
|
||||
with open(config_file) as config_fo:
|
||||
json_dict = json.load(config_fo)
|
||||
WormConfiguration.from_dict(json_dict)
|
||||
print "Configuration loaded: %r" % WormConfiguration.as_dict()
|
||||
except ValueError as e:
|
||||
print "Error loading config, using default: %s" % e
|
||||
|
||||
try:
|
||||
if MONKEY_ARG == monkey_mode:
|
||||
|
|
|
@ -61,7 +61,6 @@ class ChaosMonkey(object):
|
|||
firewall.add_firewall_rule()
|
||||
|
||||
ControlClient.wakeup(parent=self._parent, default_tunnel=self._default_tunnel)
|
||||
|
||||
monkey_tunnel = ControlClient.create_control_tunnel()
|
||||
if monkey_tunnel:
|
||||
monkey_tunnel.start()
|
||||
|
|
|
@ -13,6 +13,7 @@ LOG = logging.getLogger(__name__)
|
|||
|
||||
SCAN_DELAY = 0
|
||||
|
||||
|
||||
class NetworkScanner(object):
|
||||
def __init__(self):
|
||||
self._ip_addresses = None
|
||||
|
@ -26,14 +27,12 @@ class NetworkScanner(object):
|
|||
raise Exception("Cannot find local IP address for the machine")
|
||||
|
||||
LOG.info("Found local IP addresses of the machine: %r", self._ip_addresses)
|
||||
|
||||
# for fixed range, only scan once.
|
||||
if WormConfiguration.range_class is FixedRange:
|
||||
self._ranges = [WormConfiguration.range_class('0.0.0.0')]
|
||||
else:
|
||||
self._ranges = [WormConfiguration.range_class(ip_address)
|
||||
for ip_address in self._ip_addresses]
|
||||
|
||||
LOG.info("Base local networks to scan are: %r", self._ranges)
|
||||
|
||||
def get_victim_machines(self, scan_type, max_find=5):
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
import socket
|
||||
import random
|
||||
import struct
|
||||
|
@ -7,6 +6,7 @@ from model.host import VictimHost
|
|||
|
||||
__author__ = 'itamar'
|
||||
|
||||
|
||||
class NetworkRange(object):
|
||||
__metaclass__ = ABCMeta
|
||||
|
||||
|
|
|
@ -37,7 +37,8 @@ MONKEY_DOWNLOADS = [
|
|||
{
|
||||
'type' : 'windows',
|
||||
'filename' : 'monkey-windows-32.exe',
|
||||
},]
|
||||
},
|
||||
]
|
||||
|
||||
MONGO_URL = os.environ.get('MONGO_URL')
|
||||
if not MONGO_URL:
|
||||
|
@ -49,7 +50,6 @@ mongo = PyMongo(app)
|
|||
|
||||
|
||||
class Monkey(restful.Resource):
|
||||
|
||||
def get(self, **kw):
|
||||
guid = kw.get('guid')
|
||||
timestamp = request.args.get('timestamp')
|
||||
|
@ -77,9 +77,7 @@ class Monkey(restful.Resource):
|
|||
if monkey_json.has_key('tunnel'):
|
||||
update['$set']['tunnel'] = monkey_json['tunnel']
|
||||
|
||||
return mongo.db.monkey.update({"guid": guid},
|
||||
update,
|
||||
upsert=False)
|
||||
return mongo.db.monkey.update({"guid": guid}, update, upsert=False)
|
||||
|
||||
def post(self, **kw):
|
||||
monkey_json = json.loads(request.data)
|
||||
|
@ -117,6 +115,7 @@ class Monkey(restful.Resource):
|
|||
{"$set" : monkey_json},
|
||||
upsert=True)
|
||||
|
||||
|
||||
class Telemetry(restful.Resource):
|
||||
def get(self, **kw):
|
||||
monkey_guid = kw.get('monkey_guid')
|
||||
|
@ -157,6 +156,7 @@ class Telemetry(restful.Resource):
|
|||
|
||||
return mongo.db.telemetry.find_one_or_404({"_id": telem_id})
|
||||
|
||||
|
||||
class NewConfig(restful.Resource):
|
||||
def get(self):
|
||||
config = mongo.db.config.find_one({'name' : 'newconfig'}) or {}
|
||||
|
@ -180,7 +180,7 @@ class MonkeyDownload(restful.Resource):
|
|||
result = None
|
||||
for download in MONKEY_DOWNLOADS:
|
||||
if host_os.get('type') == download.get('type') and \
|
||||
host_os.get('machine') == download.get('machine'):
|
||||
host_os.get('machine') == download.get('machine'):
|
||||
result = download
|
||||
break
|
||||
|
||||
|
@ -192,6 +192,7 @@ class MonkeyDownload(restful.Resource):
|
|||
|
||||
return {}
|
||||
|
||||
|
||||
class Root(restful.Resource):
|
||||
def get(self):
|
||||
return {
|
||||
|
@ -199,6 +200,7 @@ class Root(restful.Resource):
|
|||
'mongo': str(mongo.db),
|
||||
}
|
||||
|
||||
|
||||
def normalize_obj(obj):
|
||||
if obj.has_key('_id') and not obj.has_key('id'):
|
||||
obj['id'] = obj['_id']
|
||||
|
@ -217,12 +219,14 @@ def normalize_obj(obj):
|
|||
value[i] = normalize_obj(value[i])
|
||||
return obj
|
||||
|
||||
|
||||
def output_json(obj, code, headers=None):
|
||||
obj = normalize_obj(obj)
|
||||
resp = make_response(bson.json_util.dumps(obj), code)
|
||||
resp.headers.extend(headers or {})
|
||||
return resp
|
||||
|
||||
|
||||
@app.route('/admin/<path:path>')
|
||||
def send_admin(path):
|
||||
return send_from_directory('admin/ui', path)
|
||||
|
|
Loading…
Reference in New Issue