forked from p15670423/monkey
GC-3598: added info collection infrastructure
This commit is contained in:
parent
d984641f53
commit
234781bc47
|
@ -76,7 +76,7 @@ class Configuration(object):
|
|||
return result
|
||||
|
||||
###########################
|
||||
### logging config
|
||||
# logging config
|
||||
###########################
|
||||
|
||||
use_file_logging = True
|
||||
|
@ -84,7 +84,7 @@ class Configuration(object):
|
|||
monkey_log_path = os.path.expandvars("%temp%\~df1563.tmp") if sys.platform == "win32" else '/tmp/user-1563'
|
||||
|
||||
###########################
|
||||
### dropper config
|
||||
# dropper config
|
||||
###########################
|
||||
|
||||
dropper_try_move_first = sys.argv[0].endswith(".exe")
|
||||
|
@ -94,7 +94,7 @@ class Configuration(object):
|
|||
dropper_target_path_linux = '/bin/monkey'
|
||||
|
||||
###########################
|
||||
### monkey config
|
||||
# monkey config
|
||||
###########################
|
||||
|
||||
alive = True
|
||||
|
@ -128,7 +128,7 @@ class Configuration(object):
|
|||
retry_failed_explotation = True
|
||||
|
||||
###########################
|
||||
### scanners config
|
||||
# scanners config
|
||||
###########################
|
||||
|
||||
|
||||
|
@ -147,7 +147,7 @@ class Configuration(object):
|
|||
ping_scan_timeout = 1000
|
||||
|
||||
###########################
|
||||
### exploiters config
|
||||
# exploiters config
|
||||
###########################
|
||||
|
||||
skip_exploit_if_file_exist = True
|
||||
|
@ -167,4 +167,7 @@ class Configuration(object):
|
|||
# rdp exploiter
|
||||
rdp_use_vbs_download = True
|
||||
|
||||
# system info collection
|
||||
collect_system_info = True
|
||||
|
||||
WormConfiguration = Configuration()
|
||||
|
|
|
@ -2,15 +2,16 @@ import sys
|
|||
import os
|
||||
import time
|
||||
import logging
|
||||
import tunnel
|
||||
import argparse
|
||||
import subprocess
|
||||
from system_singleton import SystemSingleton
|
||||
from network.firewall import app as firewall
|
||||
from control import ControlClient
|
||||
from config import WormConfiguration
|
||||
from network.network_scanner import NetworkScanner
|
||||
import tunnel
|
||||
import argparse
|
||||
import subprocess
|
||||
from model import DELAY_DELETE_CMD
|
||||
from system_info import SystemInfoCollector
|
||||
|
||||
__author__ = 'itamar'
|
||||
|
||||
|
@ -59,6 +60,12 @@ class ChaosMonkey(object):
|
|||
if monkey_tunnel:
|
||||
monkey_tunnel.start()
|
||||
|
||||
if WormConfiguration.collect_system_info:
|
||||
LOG.debug("Calling system info collection")
|
||||
system_info_collector = SystemInfoCollector()
|
||||
system_info = system_info_collector.get_info()
|
||||
ControlClient.send_telemetry("system_info_collection", system_info)
|
||||
|
||||
for _ in xrange(WormConfiguration.max_iterations):
|
||||
ControlClient.keepalive()
|
||||
ControlClient.load_control_config()
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
import sys
|
||||
from enum import IntEnum
|
||||
|
||||
__author__ = 'uri'
|
||||
|
||||
|
||||
class OperatingSystem(IntEnum):
|
||||
Windows = 0
|
||||
Linux = 1
|
||||
|
||||
|
||||
class SystemInfoCollector(object):
|
||||
"""
|
||||
A class that checks the current operating system and calls system information collecting modules accordingly
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.os = SystemInfoCollector.get_os()
|
||||
if OperatingSystem.Windows == self.os:
|
||||
from windows_info_collector import WindowsInfoCollector
|
||||
self.collector = WindowsInfoCollector()
|
||||
else:
|
||||
from linux_info_collector import LinuxInfoCollector
|
||||
self.collector = LinuxInfoCollector()
|
||||
|
||||
def get_info(self):
|
||||
return self.collector.get_info()
|
||||
|
||||
@staticmethod
|
||||
def get_os():
|
||||
if sys.platform.startswith("win"):
|
||||
return OperatingSystem.Windows
|
||||
else:
|
||||
return OperatingSystem.Linux
|
|
@ -0,0 +1,19 @@
|
|||
import socket
|
||||
__author__ = 'uri'
|
||||
|
||||
|
||||
class LinuxInfoCollector(object):
|
||||
"""
|
||||
System information collecting module for Linux operating systems
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.info = {}
|
||||
|
||||
def collect(self):
|
||||
self.info['hostname'] = socket.gethostname()
|
||||
|
||||
def get_info(self):
|
||||
self.collect()
|
||||
return self.info
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
import socket
|
||||
__author__ = 'uri'
|
||||
|
||||
|
||||
class WindowsInfoCollector(object):
|
||||
"""
|
||||
System information collecting module for Windows operating systems
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.info = {}
|
||||
|
||||
def collect(self):
|
||||
self.info['hostname'] = socket.gethostname()
|
||||
|
||||
def get_info(self):
|
||||
self.collect()
|
||||
return self.info
|
Loading…
Reference in New Issue