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
Ejemplo n.º 2
0
    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())
Ejemplo n.º 3
0
                        '--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'
    BaseWorld.apply_config('default',
                           BaseWorld.strip_yml('conf/%s.yml' % config)[0])
    BaseWorld.apply_config('agents', BaseWorld.strip_yml('conf/agents.yml')[0])
    BaseWorld.apply_config('payloads',
                           BaseWorld.strip_yml('conf/payloads.yml')[0])

    data_svc = DataService()
    contact_svc = ContactService()
    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())
Ejemplo n.º 4
0
def contact_svc():
    return ContactService()
Ejemplo n.º 5
0
async def contact_svc():
    contact_svc = ContactService()
    yield contact_svc
    await contact_svc.deregister_contacts()
Ejemplo n.º 6
0
    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())