Beispiel #1
0
def main():
    global REMAINING
    parser = argparse.ArgumentParser(
        description="replay saved proxy logs to network"
    )
    parser.add_argument('-x',
                        '--multiplier',
                        action="store",
                        default=1.0,
                        type=float,
                        dest="multiplier",
                        help="Modify replay speed to a given multiple.")

    #
    # Add database options
    #
    cli_db(parser)

    parsed = parser.parse_args()

    # -------------------------------------------------------------------------
    # Configure database
    # -------------------------------------------------------------------------
    setup_db_engine(parsed.db_connection_string)

    loop = asyncio.get_event_loop()
    loop.run_until_complete(replay_logs(get_proxy_logs,
                                        multiplier=parsed.multiplier))
    loop.run_until_complete(wait_for_requests())
Beispiel #2
0
def cli():
    parser = argparse.ArgumentParser(
        description="Generate a dataset from proxy traffic")
    parser.add_argument('fout', help="output file to store results")

    # Add global options
    cli_db(parser)
    cli_log_level(parser)

    #
    # Parse cli
    #
    args = parser.parse_args()

    #
    # Build config from CLI args
    #
    running_config = RunningConfig(args.__dict__)

    #
    # Setup log for console
    #
    setup_console_log(logger, log_level=running_config.log_level)

    #
    # Setup db
    #
    setup_db_engine(running_config.db_connection_string)

    #
    # Launch
    #
    run(running_config)
Beispiel #3
0
def cli():
    parser = argparse.ArgumentParser(
        description="API-Check manage commands"
    )

    # Add global options
    cli_db(parser)
    cli_log_level(parser)

    subparsers = parser.add_subparsers(dest="option",
                                       description="Valid options",
                                       help='Actions')

    #
    # Add subparsers
    #
    cli_apis(subparsers)
    cli_create_plugin(subparsers)
    cli_definitions(subparsers)

    #
    # Parse cli
    #
    args = parser.parse_args()

    #
    # Choice correct config object
    try:
        config, run_function = ACTION_MAP[args.option]
    except KeyError as e:
        print(f"[!] Invalid importer: '{e}'")
        exit(1)

    #
    # Delete 'importer_type' key. Used only for aux keyword in the Cli.
    #
    cli_config = args.__dict__
    del cli_config["option"]

    #
    # Build config
    #
    running_config = config(**cli_config)

    #
    # Setup log for console
    #
    setup_console_log(logger, log_level=args.log_level)

    #
    # Setup db
    #
    if ":" in running_config.db_connection_string:
        setup_db_engine(running_config.db_connection_string)

    #
    # Launch API Check
    #
    run_function(running_config)
Beispiel #4
0
def cli():
    parser = argparse.ArgumentParser(
        description="Send API definition to proxy")

    # Add global options
    cli_db(parser)
    cli_log_level(parser)

    parser.add_argument('api_id', help="api definition ID to send")
    parser.add_argument('--source',
                        dest="source",
                        default="definition",
                        choices=RunningConfig.OPERATION_MODES,
                        help="origin of data. Default: definition")
    parser.add_argument('--proxy',
                        dest="proxy_destination",
                        required=True,
                        help="proxy destination. IP:PORT")

    c = parser.add_argument_group("API Definitions")
    c.add_argument("--api-url",
                   dest="api_url",
                   help="api base url used for requests")

    #
    # Parse cli
    #
    args = parser.parse_args()

    #
    # Build config from CLI args
    #
    running_config = RunningConfig(args.__dict__)

    #
    # Setup log for console
    #
    setup_console_log(logger, log_level=running_config.log_level)

    #
    # Setup db
    #
    setup_db_engine(running_config.db_connection_string)

    #
    # Launch
    #
    run(running_config)
Beispiel #5
0
def main():
    parser = argparse.ArgumentParser(
        description="concatenate and print APIs from database"
    )
    parser.add_argument('API_AND_VERSION',
                        nargs="?",
                        help="API name and version in format: Name:Version")
    parser.add_argument('-P',
                        action="store_true",
                        default=False,
                        dest="indent",
                        help="indent json result file")

    #
    # Add database options
    #
    cli_db(parser)

    parsed = parser.parse_args()

    # -------------------------------------------------------------------------
    # Configure database
    # -------------------------------------------------------------------------
    setup_db_engine(parsed.db_connection_string)

    loop = asyncio.get_event_loop()
    x = loop.run_until_complete(get_proxy_logs(1))

    print(x)

    if parsed.YAML_FILE:

        with open(parsed.YAML_FILE, "r") as f:
            input_content = f.read()
    else:
        input_content = sys.stdin.read()
Beispiel #6
0
def cli():
    parser = argparse.ArgumentParser(
        description="Launches a local proxy to track API requests")

    # Add global options
    cli_db(parser)
    cli_log_level(parser)

    parser.add_argument('domain',
                        metavar="domain",
                        nargs="*",
                        help="Domain to inspect using proxy")
    parser.add_argument('-l',
                        '--listen',
                        dest="listen_addr",
                        default="127.0.0.1",
                        help="proxy listen address (default: 127.0.0.1)")
    parser.add_argument('-p',
                        '--port',
                        dest="listen_port",
                        help="proxy listen port (default: 8080)")
    parser.add_argument('--store-assets',
                        action="store_true",
                        default=False,
                        dest="store_assets_content",
                        help="store assets content in database")
    parser.add_argument('-a',
                        '--learning_mode',
                        action="store_true",
                        default=False,
                        dest="learning_mode",
                        help="enable learning mode to introspect the "
                        "REST API")
    parser.add_argument('--promiscuous',
                        action="store_true",
                        default=False,
                        dest="promiscuous",
                        help="save all requests that passthroughs "
                        "the proxy")

    #
    # Parse cli
    #
    args = parser.parse_args()

    #
    # Build config from CLI args
    #
    running_config = RunningConfig(**args.__dict__)

    #
    # Setup log for console
    #
    setup_console_log(logger, log_level=running_config.log_level)

    #
    # Setup db
    #
    setup_db_engine(running_config.db_connection_string)

    #
    # Launch
    #
    run(running_config)