示例#1
0
文件: server.py 项目: kiwings/caldera
                        '--environment',
                        required=False,
                        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'],
示例#2
0
    with open('conf/%s.yml' % args.environment) as c:
        cfg = yaml.load(c)
        logging.getLogger('aiohttp.access').setLevel(logging.FATAL)
        logging.getLogger('aiohttp_session').setLevel(logging.FATAL)
        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', 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,