Beispiel #1
0
def argv_parser():
    """
    parse ARGVs using argparse

    Returns:
        parser, parsed ARGVs
    """
    # create parser
    parser = argparse.ArgumentParser(prog="OWASP Honeypot", add_help=False)
    # create menu
    engineOpt = parser.add_argument_group(messages("en", "engine"), messages("en", "engine_input"))
    # add select module options + list of available modules
    engineOpt.add_argument("-m", "--select-module", action="store",
                           dest="selected_modules", default=user_configuration()["default_selected_modules"],
                           help=messages("en", "select_module").format(load_all_modules() + ["all"]))
    # by default all modules are selected, in case users can exclude one or some (separated with comma)
    engineOpt.add_argument("-x", "--exclude-module", action="store",
                           dest="excluded_modules", default=user_configuration()["default_excluded_modules"],
                           help=messages("en", "exclude_module").format(load_all_modules()))
    # limit the virtual machine storage to avoid related abuse
    engineOpt.add_argument("-s", "--vm-storage-limit", action="store",
                           dest="virtual_machine_storage_limit", type=float,
                           default=docker_configuration()["virtual_machine_storage_limit"],
                           help=messages("en", "vm_storage_limit"))
    # reset the containers once in a time to prevent being continues botnet zombie
    engineOpt.add_argument("-r", "--vm-reset-factory-time", action="store",
                           dest="virtual_machine_container_reset_factory_time_seconds", type=int,
                           default=docker_configuration()["virtual_machine_container_reset_factory_time_seconds"],
                           help=messages("en", "vm_reset_factory_time"))
    # start api
    engineOpt.add_argument("--start-api-server", action="store_true", dest="start_api_server", default=False,
                           help="start API server")
    # enable verbose mode (debug mode)
    engineOpt.add_argument("--verbose", action="store_true", dest="verbose_mode", default=False,
                           help="enable verbose mode")
    # disable color CLI
    engineOpt.add_argument("--disable-colors", action="store_true", dest="disable_colors", default=False,
                           help="disable colors in CLI")
    # test CI/ETC
    engineOpt.add_argument("--test", action="store_true", dest="run_as_test", default=False, help="run a test and exit")
    # help menu
    engineOpt.add_argument("-h", "--help", action="store_true", default=False, dest="show_help_menu",
                           help=messages("en", "show_help_menu"))
    return parser, parser.parse_args()
Beispiel #2
0
def argv_parser():
    """
    parse ARGVs using argparse

    Returns:
        parser, parsed ARGVs
    """
    # create parser
    parser = argparse.ArgumentParser(prog="OWASP Honeypot", add_help=False)
    # create menu
    docker_config = docker_configuration()
    user_config = user_configuration()
    engineOpt = parser.add_argument_group("OHP Engine",
                                          "OHP Engine input options")
    # add select module options + list of available modules
    engineOpt.add_argument(
        "-m",
        "--select-module",
        action="store",
        dest="selected_modules",
        default=user_config["default_selected_modules"],
        help="select module(s) {0}".format(load_all_modules() + ["all"]))
    # by default all modules are selected, in case users can exclude one or
    # some (separated with comma)
    engineOpt.add_argument("-x",
                           "--exclude-module",
                           action="store",
                           dest="excluded_modules",
                           default=user_config["default_excluded_modules"],
                           help="select modules(s) to exclude {0}".format(
                               load_all_modules()))
    # limit the virtual machine storage to avoid related abuse
    engineOpt.add_argument(
        "-s",
        "--vm-storage-limit",
        action="store",
        dest="virtual_machine_storage_limit",
        type=float,
        default=docker_config["virtual_machine_storage_limit"],
        help="virtual machine storage limit")
    # reset the containers once in a time to prevent being continues botnet
    # zombie
    engineOpt.add_argument(
        "-r",
        "--vm-reset-factory-time",
        action="store",
        dest="virtual_machine_container_reset_factory_time_seconds",
        type=int,
        default=docker_config[
            "virtual_machine_container_reset_factory_time_seconds"],
        help="virtual machine reset factory time")
    # start API
    engineOpt.add_argument("--start-api-server",
                           action="store_true",
                           dest="start_api_server",
                           default=False,
                           help="start API server")
    # Store Network captured files
    engineOpt.add_argument("--store-pcap",
                           action="store_true",
                           dest="store_pcap",
                           default=False,
                           help="store network traffic as pcap files")
    # Set Timeout value for splitting network captured files
    engineOpt.add_argument(
        "-t",
        "--split-pcap-file-timeout",
        type=int,
        dest="timeout_value",
        default=3600,
        help="timeout value used to split network captured files")
    # enable verbose mode (debug mode)
    engineOpt.add_argument("-v",
                           "--verbose",
                           action="store_true",
                           dest="verbose_mode",
                           default=False,
                           help="enable verbose mode")
    # disable color CLI
    engineOpt.add_argument("--disable-colors",
                           action="store_true",
                           dest="disable_colors",
                           default=False,
                           help="disable colors in CLI")
    # set language
    engineOpt.add_argument("--language",
                           type=str,
                           dest="language",
                           default="en_US",
                           help="Set the default language. {languages}".format(
                               languages=load_messages().languages_list))
    # test CI/ETC
    engineOpt.add_argument("--test",
                           action="store_true",
                           dest="run_as_test",
                           default=False,
                           help="run a test and exit")
    # help menu
    engineOpt.add_argument("-h",
                           "--help",
                           action="store_true",
                           default=False,
                           dest="show_help_menu",
                           help="print this help menu")

    return parser, parser.parse_args()