Added scoutsuite_api to monkey

This commit is contained in:
VakarisZ 2020-09-03 12:07:04 +03:00
parent a365d2eb3c
commit 3f725c1639
4 changed files with 66 additions and 0 deletions

View File

@ -4,6 +4,7 @@ from common.cloud.aws.aws_instance import AwsInstance
from common.common_consts.system_info_collectors_names import AWS_COLLECTOR
from infection_monkey.system_info.system_info_collector import \
SystemInfoCollector
from infection_monkey.system_info.collectors.scoutsuite_collector.scoutsuite_collector import CLOUD_TYPES, scan_cloud_security
logger = logging.getLogger(__name__)
@ -25,6 +26,8 @@ class AwsCollector(SystemInfoCollector):
{
'instance_id': aws.get_instance_id()
}
# TODO add IF ON ISLAND check
scan_cloud_security(cloud_type=CLOUD_TYPES.AWS)
else:
logger.info("Machine is NOT an AWS instance")

View File

@ -0,0 +1,20 @@
import pkgutil
import sys
from pathlib import PurePath
_scoutsuite_api_package = pkgutil.get_loader('infection_monkey.system_info.collectors.'
'scoutsuite_collector.scoutsuite.ScoutSuite.__main__')
def _add_scoutsuite_to_python_path():
scoutsuite_path = PurePath(_scoutsuite_api_package.path).parent.parent.__str__()
sys.path.append(scoutsuite_path)
_add_scoutsuite_to_python_path()
import infection_monkey.system_info.collectors.scoutsuite_collector.scoutsuite.ScoutSuite.api_run as scoutsuite_api
def run(*args, **kwargs):
return scoutsuite_api.run(*args, **kwargs)

View File

@ -0,0 +1,23 @@
import infection_monkey.system_info.collectors.scoutsuite_collector.scoutsuite_api as scoutsuite_api
from infection_monkey.telemetry.scoutsuite_telem import ScoutSuiteTelem
class CLOUD_TYPES:
AWS = 'aws'
AZURE = 'azure'
GCP = 'gcp'
ALIBABA = 'aliyun'
ORACLE = 'oci'
def scan_cloud_security(cloud_type: CLOUD_TYPES):
results = run_scoutsuite(cloud_type)
send_results(results)
def run_scoutsuite(cloud_type):
return scoutsuite_api.run(provider=cloud_type)
def send_results(results):
ScoutSuiteTelem.send(results)

View File

@ -0,0 +1,20 @@
from common.common_consts.telem_categories import TelemCategoryEnum
from infection_monkey.telemetry.base_telem import BaseTelem
class ScoutSuiteTelem(BaseTelem):
def __init__(self, data):
"""
Default ScoutSuite telemetry constructor
:param data: Data gathered via ScoutSuite (
"""
super().__init__()
self.data = data
telem_category = TelemCategoryEnum.SCOUTSUITE
def get_data(self):
return {
'data': self.data
}