示例#1
0
def celery():
    from burpui.utils import lookup_file

    parser = ArgumentParser("bui-celery")
    parser.add_argument(
        "-c",
        "--config",
        dest="config",
        help="burp-ui configuration file",
        metavar="<CONFIG>",
    )
    parser.add_argument("-t",
                        "--type",
                        dest="type",
                        help="celery mode",
                        metavar="<worker|beat|flower>")
    parser.add_argument(
        "-m",
        "--mode",
        dest="mode",
        help="application mode",
        metavar="<agent|server|worker|manage|legacy>",
    )
    parser.add_argument("remaining", nargs=REMAINDER)

    options, unknown = parser.parse_known_args()
    env = os.environ

    if options.config:
        conf = lookup_file(options.config, guess=False)
    else:
        if "BUI_CONFIG" in env:
            conf = env["BUI_CONFIG"]
        else:
            conf = lookup_file()

    if options.type:
        celery_mode = options.type
    else:
        celery_mode = "worker"

    # make conf path absolute
    if not conf.startswith("/"):
        curr = os.getcwd()
        conf = os.path.join(curr, conf)

    check_config(conf)

    os.chdir(ROOT)

    env["BUI_MODE"] = "celery"
    env["BUI_CONFIG"] = conf

    args = ["celery", "-A", "engines.worker.celery", celery_mode]
    args += unknown
    args += [x for x in options.remaining if x != "--"]

    os.execvpe(args[0], args, env)
示例#2
0
def celery():
    from burpui.utils import lookup_file

    parser = ArgumentParser('bui-celery')
    parser.add_argument('-c',
                        '--config',
                        dest='config',
                        help='burp-ui configuration file',
                        metavar='<CONFIG>')
    parser.add_argument('-t',
                        '--type',
                        dest='type',
                        help='celery mode',
                        metavar='<worker|beat|flower>')
    parser.add_argument('-m',
                        '--mode',
                        dest='mode',
                        help='application mode',
                        metavar='<agent|server|worker|manage|legacy>')
    parser.add_argument('remaining', nargs=REMAINDER)

    options, unknown = parser.parse_known_args()
    env = os.environ

    if options.config:
        conf = lookup_file(options.config, guess=False)
    else:
        if 'BUI_CONFIG' in env:
            conf = env['BUI_CONFIG']
        else:
            conf = lookup_file()

    if options.type:
        celery_mode = options.type
    else:
        celery_mode = 'worker'

    # make conf path absolute
    if not conf.startswith('/'):
        curr = os.getcwd()
        conf = os.path.join(curr, conf)

    check_config(conf)

    os.chdir(ROOT)

    env['BUI_MODE'] = 'celery'
    env['BUI_CONFIG'] = conf

    args = ['celery', celery_mode, '-A', 'engines.worker.celery']
    args += unknown
    args += [x for x in options.remaining if x != '--']

    os.execvpe(args[0], args, env)
示例#3
0
def manage():
    from burpui.utils import lookup_file

    parser = ArgumentParser('bui-manage')
    parser.add_argument('-v', '--verbose', dest='log', help='increase output verbosity (e.g., -vv is more verbose than -v)', action='count')
    parser.add_argument('-c', '--config', dest='config', help='burp-ui configuration file', metavar='<CONFIG>')
    parser.add_argument('-i', '--migrations', dest='migrations', help='migrations directory', metavar='<MIGRATIONSDIR>')
    parser.add_argument('-m', '--mode', dest='mode', help='application mode', metavar='<agent|server|worker|manage|legacy>')
    parser.add_argument('-l', '--logfile', dest='logfile', help='output logs in defined file', metavar='<FILE>')
    parser.add_argument('remaining', nargs=REMAINDER)

    options, unknown = parser.parse_known_args()
    env = os.environ

    if options.logfile:
        env['BUI_LOGFILE'] = options.logfile
    if options.config:
        conf = lookup_file(options.config, guess=False)
    else:
        if 'BUI_CONFIG' in env:
            conf = env['BUI_CONFIG']
        else:
            conf = lookup_file()
    check_config(conf)

    if options.migrations:
        migrations = lookup_file(options.migrations, guess=False, directory=True, check=False)
    else:
        migrations = lookup_file('migrations', directory=True)

    env['BUI_MODE'] = 'manage'
    env['BUI_CONFIG'] = conf
    env['BUI_VERBOSE'] = str(options.log)
    if migrations:
        env['BUI_MIGRATIONS'] = migrations
    if os.path.isdir('burpui') and os.path.isfile('burpui/cli.py'):
        env['FLASK_APP'] = 'burpui/cli.py'
    else:
        env['FLASK_APP'] = 'burpui.cli'

    args = [
        'flask'
    ]
    args += unknown
    args += [x for x in options.remaining if x != '--']

    os.execvpe(args[0], args, env)
示例#4
0
def celery():
    from burpui.utils import lookup_file

    parser = ArgumentParser('bui-celery')
    parser.add_argument('-c', '--config', dest='config', help='burp-ui configuration file', metavar='<CONFIG>')
    parser.add_argument('-t', '--type', dest='type', help='celery mode', metavar='<worker|beat|flower>')
    parser.add_argument('-m', '--mode', dest='mode', help='application mode', metavar='<agent|server|worker|manage|legacy>')
    parser.add_argument('remaining', nargs=REMAINDER)

    options, unknown = parser.parse_known_args()
    env = os.environ

    if options.config:
        conf = lookup_file(options.config, guess=False)
    else:
        if 'BUI_CONFIG' in env:
            conf = env['BUI_CONFIG']
        else:
            conf = lookup_file()

    if options.type:
        celery_mode = options.type
    else:
        celery_mode = 'worker'

    # make conf path absolute
    if not conf.startswith('/'):
        curr = os.getcwd()
        conf = os.path.join(curr, conf)

    check_config(conf)

    os.chdir(ROOT)

    env['BUI_MODE'] = 'celery'
    env['BUI_CONFIG'] = conf

    args = [
        'celery',
        celery_mode,
        '-A',
        'engines.worker.celery'
    ]
    args += unknown
    args += [x for x in options.remaining if x != '--']

    os.execvpe(args[0], args, env)
示例#5
0
def monitor(options=None):
    import trio
    from burpui.engines.monitor import MonitorPool
    from burpui.utils import lookup_file

    if not options:
        options, _ = parse_args(mode=False, name='bui-agent')

    conf = ['buimonitor.cfg', 'buimonitor.sample.cfg']
    if options.config:
        conf = lookup_file(options.config, guess=False)
    else:
        conf = lookup_file(conf)
    check_config(conf)

    monitor = MonitorPool(conf, options.log, options.logfile)
    trio.run(monitor.run)
示例#6
0
def agent(options=None):
    import trio
    from burpui.engines.agent import BUIAgent as Agent
    from burpui.utils import lookup_file

    if not options:
        options, _ = parse_args(mode=False, name='bui-agent')

    conf = ['buiagent.cfg', 'buiagent.sample.cfg']
    if options.config:
        conf = lookup_file(options.config, guess=False)
    else:
        conf = lookup_file(conf)
    check_config(conf)

    agent = Agent(conf, options.log, options.logfile)
    trio.run(agent.run)
示例#7
0
def monitor(options=None):
    import trio
    from burpui.engines.monitor import MonitorPool
    from burpui.utils import lookup_file

    if not options:
        options, _ = parse_args(mode=False, name='bui-agent')

    conf = ['buimonitor.cfg', 'buimonitor.sample.cfg']
    if options.config:
        conf = lookup_file(options.config, guess=False)
    else:
        conf = lookup_file(conf)
    check_config(conf)

    monitor = MonitorPool(conf, options.log, options.logfile)
    trio.run(monitor.run)
示例#8
0
def agent(options=None):
    import trio
    from burpui.engines.agent import BUIAgent as Agent
    from burpui.utils import lookup_file

    if not options:
        options, _ = parse_args(mode=False, name='bui-agent')

    conf = ['buiagent.cfg', 'buiagent.sample.cfg']
    if options.config:
        conf = lookup_file(options.config, guess=False)
    else:
        conf = lookup_file(conf)
    check_config(conf)

    agent = Agent(conf, options.log, options.logfile)
    trio.run(agent.run)
示例#9
0
def agent(options=None):
    from gevent import monkey
    from burpui.agent import BUIAgent as Agent
    from burpui.utils import lookup_file
    from burpui._compat import patch_json

    monkey.patch_all()
    patch_json()

    if not options:
        options, _ = parse_args(mode=False, name='bui-agent')

    conf = ['buiagent.cfg', 'buiagent.sample.cfg']
    if options.config:
        conf = lookup_file(options.config, guess=False)
    else:
        conf = lookup_file(conf)
    check_config(conf)

    agent = Agent(conf, options.log, options.logfile, options.debug)
    agent.run()
示例#10
0
def server(options=None, unknown=None):
    from burpui.utils import lookup_file

    if unknown is None:
        unknown = []
    if not options:
        options, unknown = parse_args(mode=False)
    env = os.environ

    if options.config:
        conf = lookup_file(options.config, guess=False)
    else:
        if 'BUI_CONFIG' in env:
            conf = env['BUI_CONFIG']
        else:
            conf = lookup_file()
    check_config(conf)

    if os.path.isdir('burpui'):
        env['FLASK_APP'] = 'burpui/cli.py'
    else:
        env['FLASK_APP'] = 'burpui.cli'
    env['BUI_CONFIG'] = conf
    env['BUI_VERBOSE'] = str(options.log)
    if options.logfile:
        env['BUI_LOGFILE'] = options.logfile
    if options.debug:
        env['BUI_DEBUG'] = '1'
        env['FLASK_DEBUG'] = '1'
    env['BUI_MODE'] = 'server'

    args = [
        'flask',
        'run'
    ]
    args += unknown
    args += [x for x in options.remaining if x != '--']

    os.execvpe(args[0], args, env)
示例#11
0
def legacy(options=None, unknown=None):
    from burpui.utils import lookup_file

    if unknown is None:
        unknown = []
    if not options:
        options, unknown = parse_args(mode=False, name='burpui-legacy')
    env = os.environ

    if options.config:
        conf = lookup_file(options.config, guess=False)
    else:
        if 'BUI_CONFIG' in env:
            conf = env['BUI_CONFIG']
        else:
            conf = lookup_file()
    check_config(conf)

    env['BUI_MODE'] = 'legacy'
    env['BUI_CONFIG'] = conf
    if os.path.isdir('burpui'):
        env['FLASK_APP'] = 'burpui/cli.py'
    else:
        env['FLASK_APP'] = 'burpui.cli'
    env['BUI_VERBOSE'] = str(options.log)
    if options.logfile:
        env['BUI_LOGFILE'] = options.logfile
    if options.debug:
        env['BUI_DEBUG'] = '1'
        env['FLASK_DEBUG'] = '1'

    args = ['flask', 'legacy']
    args += unknown
    args += [x for x in options.remaining if x != '--']

    os.execvpe(args[0], args, env)
示例#12
0
def legacy(options=None, unknown=None):
    from burpui.utils import lookup_file

    if unknown is None:
        unknown = []
    if not options:
        options, unknown = parse_args(mode=False, name="burpui-legacy")
    env = os.environ

    if options.config:
        conf = lookup_file(options.config, guess=False)
    else:
        if "BUI_CONFIG" in env:
            conf = env["BUI_CONFIG"]
        else:
            conf = lookup_file()
    check_config(conf)

    env["BUI_MODE"] = "legacy"
    env["BUI_CONFIG"] = conf
    if os.path.isdir("burpui"):
        env["FLASK_APP"] = "burpui/cli.py"
    else:
        env["FLASK_APP"] = "burpui.cli"
    env["BUI_VERBOSE"] = str(options.log)
    if options.logfile:
        env["BUI_LOGFILE"] = options.logfile
    if options.debug:
        env["BUI_DEBUG"] = "1"
        env["FLASK_DEBUG"] = "1"

    args = ["flask", "legacy"]
    args += unknown
    args += [x for x in options.remaining if x != "--"]

    os.execvpe(args[0], args, env)
示例#13
0
def manage():
    from burpui.utils import lookup_file

    parser = ArgumentParser('bui-manage')
    parser.add_argument('-c',
                        '--config',
                        dest='config',
                        help='burp-ui configuration file',
                        metavar='<CONFIG>')
    parser.add_argument('-i',
                        '--migrations',
                        dest='migrations',
                        help='migrations directory',
                        metavar='<MIGRATIONSDIR>')
    parser.add_argument('-m',
                        '--mode',
                        dest='mode',
                        help='application mode',
                        metavar='<agent|server|worker|manage|legacy>')
    parser.add_argument('-l',
                        '--logfile',
                        dest='logfile',
                        help='output logs in defined file',
                        metavar='<FILE>')
    parser.add_argument('remaining', nargs=REMAINDER)

    options, unknown = parser.parse_known_args()
    env = os.environ

    if options.logfile:
        env['BUI_LOGFILE'] = options.logfile
    if options.config:
        conf = lookup_file(options.config, guess=False)
    else:
        if 'BUI_CONFIG' in env:
            conf = env['BUI_CONFIG']
        else:
            conf = lookup_file()
    check_config(conf)

    if options.migrations:
        migrations = lookup_file(options.migrations,
                                 guess=False,
                                 directory=True,
                                 check=False)
    else:
        migrations = lookup_file('migrations', directory=True)

    env['BUI_MODE'] = 'manage'
    env['BUI_CONFIG'] = conf
    if migrations:
        env['BUI_MIGRATIONS'] = migrations
    if os.path.isdir('burpui'):
        env['FLASK_APP'] = 'burpui/cli.py'
    else:
        env['FLASK_APP'] = 'burpui.cli'

    args = ['flask']
    args += unknown
    args += [x for x in options.remaining if x != '--']

    os.execvpe(args[0], args, env)
示例#14
0
def manage():
    from burpui.utils import lookup_file

    parser = ArgumentParser("bui-manage")
    parser.add_argument(
        "-v",
        "--verbose",
        dest="log",
        help="increase output verbosity (e.g., -vv is more verbose than -v)",
        action="count",
    )
    parser.add_argument(
        "-c",
        "--config",
        dest="config",
        help="burp-ui configuration file",
        metavar="<CONFIG>",
    )
    parser.add_argument(
        "-i",
        "--migrations",
        dest="migrations",
        help="migrations directory",
        metavar="<MIGRATIONSDIR>",
    )
    parser.add_argument(
        "-m",
        "--mode",
        dest="mode",
        help="application mode",
        metavar="<agent|server|worker|manage|legacy>",
    )
    parser.add_argument(
        "-l",
        "--logfile",
        dest="logfile",
        help="output logs in defined file",
        metavar="<FILE>",
    )
    parser.add_argument("remaining", nargs=REMAINDER)

    options, unknown = parser.parse_known_args()
    env = os.environ

    if options.logfile:
        env["BUI_LOGFILE"] = options.logfile
    if options.config:
        conf = lookup_file(options.config, guess=False)
    else:
        if "BUI_CONFIG" in env:
            conf = env["BUI_CONFIG"]
        else:
            conf = lookup_file()
    check_config(conf)

    if options.migrations:
        migrations = lookup_file(options.migrations,
                                 guess=False,
                                 directory=True,
                                 check=False)
    else:
        migrations = lookup_file("migrations", directory=True)

    env["BUI_MODE"] = "manage"
    env["BUI_CONFIG"] = conf
    env["BUI_VERBOSE"] = str(options.log)
    if migrations:
        env["BUI_MIGRATIONS"] = migrations
    if os.path.isdir("burpui") and os.path.isfile("burpui/cli.py"):
        env["FLASK_APP"] = "burpui/cli.py"
    else:
        env["FLASK_APP"] = "burpui.cli"

    args = ["flask"]
    args += unknown
    args += [x for x in options.remaining if x != "--"]

    os.execvpe(args[0], args, env)