async def initialize(): with open(Path(__file__).parents[2] / 'conf' / 'default.yml', 'r') as fle: BaseWorld.apply_config('main', yaml.safe_load(fle)) with open(Path(__file__).parents[2] / 'conf' / 'payloads.yml', 'r') as fle: BaseWorld.apply_config('payloads', yaml.safe_load(fle)) app_svc = AppService(web.Application()) _ = DataService() _ = RestService() _ = PlanningService() _ = LearningService() auth_svc = AuthService() _ = ContactService() _ = FileSvc() services = app_svc.get_services() os.chdir(str(Path(__file__).parents[2])) await app_svc.register_contacts() await app_svc.load_plugins(['sandcat', 'ssl']) _ = await RestApi(services).enable() await auth_svc.apply(app_svc.application, auth_svc.get_config('users')) await auth_svc.set_login_handlers(services) return app_svc.application
def knowledge_webapp(event_loop, app_svc, base_world, data_svc): app_svc.add_service('auth_svc', AuthService()) app_svc.add_service('knowledge_svc', KnowledgeService()) app_svc.add_service('file_svc', FileSvc( )) # This needs to be done this way, or it we won't have a valid BaseWorld services = app_svc.get_services() app = web.Application(middlewares=[ authentication_required_middleware_factory(services['auth_svc']), json_request_validation_middleware ]) FactApi(services).add_routes(app) return app
async def initialize(): with open(Path(__file__).parents[1] / 'conf' / 'default.yml', 'r') as fle: BaseWorld.apply_config('main', yaml.safe_load(fle)) with open(Path(__file__).parents[1] / 'conf' / 'payloads.yml', 'r') as fle: BaseWorld.apply_config('payloads', yaml.safe_load(fle)) app_svc = AppService(web.Application(client_max_size=5120**2)) _ = DataService() _ = RestService() _ = PlanningService() _ = LearningService() auth_svc = AuthService() _ = FileSvc() _ = EventService() services = app_svc.get_services() os.chdir(str(Path(__file__).parents[1])) _ = await RestApi(services).enable() await app_svc.register_contacts() await auth_svc.apply(app_svc.application, auth_svc.get_config('users')) await auth_svc.set_login_handlers(services) app_svc.register_subapp('/api/v2', make_app(svcs=services)) aiohttp_apispec.setup_aiohttp_apispec(app=app_svc.application, title='CALDERA', version=version.get_version(), swagger_path='/api/docs', url='/api/docs/swagger.json', static_path='/static/swagger') app_svc.application.middlewares.append( apispec_request_validation_middleware) app_svc.application.middlewares.append(validation_middleware) return app_svc
parser = argparse.ArgumentParser('Welcome to the system') parser.add_argument('-E', '--environment', required=False, default='local', help='Select an env. file to use') parser.add_argument('--fresh', action='store_true', required=False, default=False, help='remove object_store on start') args = parser.parse_args() config = args.environment if pathlib.Path( 'conf/%s.yml' % args.environment).exists() else 'default' with open('conf/%s.yml' % config) as c: BaseWorld.apply_config(yaml.load(c, Loader=yaml.FullLoader)) data_svc = DataService() contact_svc = ContactService( BaseWorld.strip_yml('conf/agents.yml')[0]['agent_config']) planning_svc = PlanningService() rest_svc = RestService() auth_svc = AuthService() file_svc = FileSvc( BaseWorld.strip_yml('conf/payloads.yml')[0]['payload_config']) learning_svc = LearningService() app_svc = AppService(application=web.Application()) if args.fresh: asyncio.get_event_loop().run_until_complete(data_svc.destroy()) run_tasks(services=app_svc.get_services())
parser = argparse.ArgumentParser('Welcome to the system') parser.add_argument('-E', '--environment', required=False, default='local', help='Select an env. file to use') parser.add_argument('--fresh', action='store_true', required=False, default=False, help='remove object_store on start') args = parser.parse_args() config = args.environment if pathlib.Path( 'conf/%s.yml' % args.environment).exists() else 'default' with open('conf/%s.yml' % config) as c: BaseWorld.apply_config(yaml.load(c, Loader=yaml.FullLoader)) data_svc = DataService() contact_svc = ContactService( BaseWorld.strip_yml('conf/agents.yml')[0]['agent_config']) planning_svc = PlanningService() rest_svc = RestService() auth_svc = AuthService() file_svc = FileSvc() learning_svc = LearningService() app_svc = AppService(application=web.Application()) if args.fresh: asyncio.get_event_loop().run_until_complete(data_svc.destroy()) run_tasks(services=app_svc.get_services())
logging.getLogger('aiohttp.server').setLevel(logging.FATAL) logging.getLogger('asyncio').setLevel(logging.FATAL) logging.getLogger().setLevel(logging.DEBUG) sys.path.append('') plugin_modules = build_plugins(cfg['plugins']) utility_svc = UtilityService() data_svc = DataService(CoreDao('core.db'), utility_svc) planning_svc = PlanningService(data_svc, utility_svc) operation_svc = OperationService(data_svc=data_svc, utility_svc=utility_svc, planning_svc=planning_svc, planner=cfg['planner']) auth_svc = AuthService(utility_svc=utility_svc) logging.debug('Uploaded files will be put in %s' % cfg['exfil_dir']) logging.debug('Downloaded payloads will come from %s' % cfg['payloads']) file_svc = FileSvc(cfg['payloads'], cfg['exfil_dir']) services = dict(data_svc=data_svc, auth_svc=auth_svc, utility_svc=utility_svc, operation_svc=operation_svc, file_svc=file_svc, planning_svc=planning_svc, plugins=plugin_modules) logging.debug('Serving at http://%s:%s' % (cfg['host'], cfg['port'])) main(services=services, host=cfg['host'], port=cfg['port'], users=cfg['users'])
help='Select an env. file to use') args = parser.parse_args() with open('conf/%s.yml' % args.environment) as c: config = yaml.load(c) logging.getLogger('aiohttp.access').setLevel(logging.WARNING) logging.getLogger('asyncio').setLevel(logging.FATAL) logging.getLogger().setLevel(config['debug_level']) sys.path.append('') plugin_modules = build_plugins(config['plugins']) utility_svc = UtilityService() data_svc = DataService(CoreDao('core.db')) operation_svc = OperationService(data_svc=data_svc, utility_svc=utility_svc, planner=config['planner']) auth_svc = AuthService(data_svc=data_svc, ssl_cert=SSL_CERT) file_svc = FileSvc(config['stores']) services = dict(data_svc=data_svc, auth_svc=auth_svc, utility_svc=utility_svc, operation_svc=operation_svc, file_svc=file_svc, logger=Logger('plugin'), plugins=plugin_modules) main(services=services, host=config['host'], port=config['port'], terminal_host=config['terminal_host'], terminal_port=config['terminal_port'], users=config['users'])
help='Select an env. file to use') args = parser.parse_args() with open('conf/%s.yml' % args.environment) as c: cfg = yaml.load(c) logging.getLogger('aiohttp.access').setLevel(logging.WARNING) logging.getLogger('asyncio').setLevel(logging.FATAL) logging.getLogger().setLevel('CRITICAL') sys.path.append('') plugin_modules = build_plugins(cfg['plugins']) utility_svc = UtilityService() data_svc = DataService(CoreDao('core.db')) operation_svc = OperationService(data_svc=data_svc, utility_svc=utility_svc, planner=cfg['planner']) auth_svc = AuthService(data_svc=data_svc, ssl_cert=SSL_CERT) file_svc = FileSvc(cfg['stores']) services = dict(data_svc=data_svc, auth_svc=auth_svc, utility_svc=utility_svc, operation_svc=operation_svc, file_svc=file_svc, plugins=plugin_modules) terminal = CustomShell(services) welcome_msg(cfg['host'], cfg['port']) main(services=services, host=cfg['host'], port=cfg['port'], sockets=cfg['sockets'], users=cfg['users'])
default='local', help='Select an env. file to use') args = parser.parse_args() with open('conf/%s.yml' % args.environment) as c: cfg = yaml.load(c, Loader=yaml.FullLoader) set_logging_state() sys.path.append('') plugin_modules = build_plugins(cfg['plugins']) plugin_svc = PluginService(plugin_modules) data_svc = DataService(CoreDao('core.db', memory=cfg['memory'])) logging.debug('Using an in-memory database: %s' % cfg['memory']) planning_svc = PlanningService() parsing_svc = ParsingService() operation_svc = OperationService() auth_svc = AuthService(cfg['api_key']) logging.debug('Uploaded files will be put in %s' % cfg['exfil_dir']) file_svc = FileSvc([p.name.lower() for p in plugin_modules], cfg['exfil_dir']) agent_svc = AgentService(untrusted_timer=cfg['untrusted_timer']) logging.debug( 'Agents will be considered untrusted after %s seconds of silence' % cfg['untrusted_timer']) logging.debug('Serving at http://%s:%s' % (cfg['host'], cfg['port'])) main(services=data_svc.get_services(), host=cfg['host'], port=cfg['port'], users=cfg['users'])
def file_svc(): return FileSvc()
sys.path.append('') plugin_modules = build_plugins(cfg['plugins']) utility_svc = UtilityService() data_svc = DataService(CoreDao('core.db', memory=cfg['memory']), utility_svc) logging.debug('Using an in-memory database: %s' % cfg['memory']) planning_svc = PlanningService(data_svc, utility_svc) parsing_svc = ParsingService(data_svc) operation_svc = OperationService(data_svc=data_svc, utility_svc=utility_svc, planning_svc=planning_svc, parsing_svc=parsing_svc) auth_svc = AuthService(utility_svc=utility_svc) logging.debug('Uploaded files will be put in %s' % cfg['exfil_dir']) file_svc = FileSvc( ['plugins/%s/payloads' % p.name.lower() for p in plugin_modules], cfg['exfil_dir']) services = dict(data_svc=data_svc, auth_svc=auth_svc, utility_svc=utility_svc, operation_svc=operation_svc, file_svc=file_svc, planning_svc=planning_svc, plugins=plugin_modules) logging.debug('Serving at http://%s:%s' % (cfg['host'], cfg['port'])) main(services=services, host=cfg['host'], port=cfg['port'], users=cfg['users'])
parser.add_argument('--fresh', action='store_true', required=False, default=False, help='remove object_store on start') args = parser.parse_args() config = args.environment if pathlib.Path( 'conf/%s.yml' % args.environment).exists() else 'default' with open('conf/%s.yml' % config) as c: cfg = yaml.load(c, Loader=yaml.FullLoader) setup_logger(cfg) cfg['agent_config'] = BaseWorld.strip_yml( 'conf/agents.yml')[0]['agent_config'] cfg['secrets']['core'] = BaseWorld.strip_yml('conf/secrets.yml') logging.debug('Serving at http://%s:%s' % (cfg['host'], cfg['port'])) data_svc = DataService() contact_svc = ContactService(cfg['agent_config']) planning_svc = PlanningService() rest_svc = RestService() auth_svc = AuthService(cfg['api_key']) file_svc = FileSvc(cfg['exfil_dir'], file_encryption=cfg['file_encryption'], api_key=cfg['api_key'], crypt_salt=cfg['crypt_salt']) app_svc = AppService(application=web.Application(), config=cfg) if args.fresh: asyncio.get_event_loop().run_until_complete(data_svc.destroy()) main(config=cfg, services=app_svc.get_services())
default='local', help='Select an env. file to use') parser.add_argument('--fresh', action='store_true', required=False, default=False, help='remove object_store on start') args = parser.parse_args() config = args.environment if pathlib.Path( 'conf/%s.yml' % args.environment).exists() else 'default' with open('conf/%s.yml' % config) as c: cfg = yaml.load(c, Loader=yaml.FullLoader) setup_logger(cfg) logging.debug( 'Agents will be considered untrusted after %s seconds of silence' % cfg['untrusted_timer']) logging.debug('Uploaded files will be put in %s' % cfg['exfil_dir']) logging.debug('Serving at http://%s:%s' % (cfg['host'], cfg['port'])) data_svc = DataService() contact_svc = ContactService() planning_svc = PlanningService() rest_svc = RestService() auth_svc = AuthService(cfg['api_key']) file_svc = FileSvc(cfg['exfil_dir']) app_svc = AppService(application=web.Application(), config=cfg) if args.fresh: asyncio.get_event_loop().run_until_complete(data_svc.destroy()) main(config=cfg, services=app_svc.get_services())