Ejemplo n.º 1
0
                        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'])
Ejemplo n.º 2
0
    loop.run_until_complete(init(host, port, services, users))
    try:
        loop.run_forever()
    except KeyboardInterrupt:
        loop.run_until_complete(data_svc.save_state())
        logging.debug('[!] shutting down server...good-bye')


if __name__ == '__main__':
    parser = argparse.ArgumentParser('Welcome to the system')
    parser.add_argument('-E', '--environment', required=False, default='local', help='Select an env. file to use')
    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)
        set_logging_state()
        sys.path.append('')

        plugin_modules = build_plugins(cfg['plugins'])
        data_svc = DataService()
        planning_svc = PlanningService()
        auth_svc = AuthService(cfg['api_key'])
        file_svc = FileSvc([p.name.lower() for p in plugin_modules], cfg['exfil_dir'])
        agent_svc = AgentService()
        application = AppService(config=cfg, plugins=plugin_modules)

        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']))
        main(services=data_svc.get_services(), host=cfg['host'], port=cfg['port'], users=cfg['users'])