def parse_cl(self): # Usage and command line help try: opts, args = getopt.getopt( self.argv[1:], "hLAZX:vcb:e:R:d:z:r:f:t:w:V:H:m:f:o:s:p:w:u:", [ 'slice=', 'zP=', 'oF=', 'recipe=', 'dump-recipe=', 'req-delay=', 'conn-delay=', 'sc=', 'sh=', 'sl=', 'sw=', 'ss=', 'hc=', 'hh=', 'hl=', 'hw=', 'hs=', 'ntlm=', 'basic=', 'digest=', 'database=', 'follow', 'script-help=', 'script=', 'script-args=', 'prefilter=', 'filter=', 'interact', 'help', 'version', 'dry-run', 'prev' ]) optsd = defaultdict(list) payload_cache = {} for i, j in opts: if i in ["-z", "--zP", "--slice", "-w"]: if i in ["-z", "-w"]: if payload_cache: optsd["payload"].append(payload_cache) payload_cache = {} payload_cache[i] = j optsd[i].append(j) if not args and not optsd: self.show_brief_usage() sys.exit(1) if payload_cache: optsd["payload"].append(payload_cache) payload_cache = {} self._parse_help_opt(optsd) url = None if len(args) == 1: url = args[0] elif len(args) > 1: raise FuzzExceptBadOptions("Too many arguments.") options = FuzzSession() if "-u" in optsd: if url == "FUZZ": options["seed_payload"] = True url = optsd["-u"][0] elif url is None: url = optsd["-u"][0] else: raise FuzzExceptBadOptions( "Specify the URL either with -u or last argument.") # check command line options correctness self._check_options(optsd) # parse options from recipe first if "--recipe" in optsd: options.import_from_file(optsd["--recipe"][0]) # command line has priority over recipe self._parse_options(optsd, options) self._parse_conn_options(optsd, options) self._parse_filters(optsd, options) self._parse_seed(url, optsd, options) self._parse_payload(optsd, options) self._parse_scripts(optsd, options) if "--dump-recipe" in optsd: error = options.validate() if error: raise FuzzExceptBadOptions(error) options.export_to_file(optsd["--dump-recipe"][0]) print(help_banner) print("Recipe written to %s." % (optsd["--dump-recipe"][0], )) sys.exit(0) return options except FuzzException as e: self.show_brief_usage() raise e except ValueError: self.show_brief_usage() raise FuzzExceptBadOptions("Incorrect options, please check help.") except getopt.GetoptError as qw: self.show_brief_usage() raise FuzzExceptBadOptions("%s." % str(qw))
def parse_cl(self): # Usage and command line help try: opts, args = getopt.getopt(self.argv[1:], "hLAZX:vcb:e:R:d:z:r:f:t:w:V:H:m:f:o:s:p:w:u:", ['AAA', 'AA', 'slice=', 'zP=', 'oF=', 'recipe=', 'dump-recipe=', 'req-delay=', 'conn-delay=', 'sc=', 'sh=', 'sl=', 'sw=', 'ss=', 'hc=', 'hh=', 'hl=', 'hw=', 'hs=', 'ntlm=', 'basic=', 'digest=', 'follow', 'script-help=', 'script=', 'script-args=', 'prefilter=', 'filter=', 'interact', 'help', 'version', 'dry-run', 'prev']) optsd = defaultdict(list) payload_cache = {} for i, j in opts: if i in ["-z", "--zP", "--slice", "-w"]: if i in ["-z", "-w"]: if payload_cache: optsd["payload"].append(payload_cache) payload_cache = {} payload_cache[i] = j optsd[i].append(j) if not args and not optsd: self.show_brief_usage() sys.exit(1) if payload_cache: optsd["payload"].append(payload_cache) payload_cache = {} self._parse_help_opt(optsd) url = None if len(args) == 1: url = args[0] elif len(args) > 1: raise FuzzExceptBadOptions("Too many arguments.") options = FuzzSession() cli_url = None if "-u" in optsd: if (url is not None and url != "FUZZ") or url == optsd["-u"][0]: raise FuzzExceptBadOptions("Specify the URL either with -u or last argument. If you want to use a full payload, it can only be specified with FUZZ.") cli_url = optsd["-u"][0] if url == "FUZZ" or cli_url == "FUZZ": options["seed_payload"] = True if cli_url: url = cli_url # check command line options correctness self._check_options(optsd) # parse options from recipe first if "--recipe" in optsd: options.import_from_file(optsd["--recipe"][0]) # command line has priority over recipe self._parse_options(optsd, options) self._parse_conn_options(optsd, options) self._parse_filters(optsd, options) self._parse_seed(url, optsd, options) self._parse_payload(optsd, options) self._parse_scripts(optsd, options) if "--dump-recipe" in optsd: error = options.validate() if error: raise FuzzExceptBadOptions(error) options.export_to_file(optsd["--dump-recipe"][0]) print(help_banner) print("Recipe written to %s." % (optsd["--dump-recipe"][0],)) sys.exit(0) return options except FuzzException as e: self.show_brief_usage() raise e except ValueError: self.show_brief_usage() raise FuzzExceptBadOptions("Incorrect options, please check help.") except getopt.GetoptError as qw: self.show_brief_usage() raise FuzzExceptBadOptions("%s." % str(qw))
def parse_cl(self): # Usage and command line help try: opts, args = getopt.getopt(self.argv[1:], short_opts, long_opts) optsd = defaultdict(list) payload_cache = {} for i, j in opts: if i in ["-z", "--zP", "--slice", "-w", "--zD", "--zE"]: if i in ["-z", "-w"]: if payload_cache: optsd["payload"].append(payload_cache) payload_cache = {} payload_cache[i] = j optsd[i].append(j) if not args and not optsd: self.show_brief_usage() sys.exit(1) if payload_cache: optsd["payload"].append(payload_cache) payload_cache = {} self._parse_help_opt(optsd) url = None if len(args) == 1: url = args[0] elif len(args) > 1: raise FuzzExceptBadOptions("Too many arguments.") options = FuzzSession() cli_url = None if "-u" in optsd: if (url is not None and url != "FUZZ") or url == optsd["-u"][0]: raise FuzzExceptBadOptions("Specify the URL either with -u or last argument. If you want to use a full payload, it can only be specified with FUZZ.") cli_url = optsd["-u"][0] if cli_url: url = cli_url # check command line options correctness self._check_options(optsd) # parse options from recipe first if "--recipe" in optsd: for recipe in optsd["--recipe"]: options.import_from_file(recipe) # command line has priority over recipe self._parse_options(optsd, options) self._parse_conn_options(optsd, options) self._parse_filters(optsd, options) self._parse_seed(url, optsd, options) self._parse_payload(optsd, options) self._parse_scripts(optsd, options) if "--dump-recipe" in optsd: print(exec_banner) for error_msg in options.validate(): print("WARNING: {}".format(error_msg)) print("") options.export_to_file(optsd["--dump-recipe"][0]) print("Recipe written to %s." % (optsd["--dump-recipe"][0],)) sys.exit(0) return options except FuzzException as e: self.show_brief_usage() raise e except ValueError: self.show_brief_usage() raise FuzzExceptBadOptions("Incorrect options, please check help.") except getopt.GetoptError as qw: self.show_brief_usage() raise FuzzExceptBadOptions("%s." % str(qw))
def parse_cl(self): # Usage and command line help try: opts, args = getopt.getopt(self.argv[1:], self.short_opts, self.long_opts) optsd = defaultdict(list) payload_cache = {} for i, j in opts: if i in ["-z", "--zP", "--slice", "-w", "--zD", "--zE"]: if i in ["-z", "-w"]: if payload_cache: optsd["payload"].append(payload_cache) payload_cache = {} payload_cache[i] = j optsd[i].append(j) if not args and not optsd: self.show_brief_usage() sys.exit(1) if payload_cache: optsd["payload"].append(payload_cache) payload_cache = {} self._parse_help_opt(optsd) url = None if len(args) == 1: url = args[0] elif len(args) > 1: raise FuzzExceptBadOptions("Too many arguments.") options = FuzzSession() cli_url = None if "-u" in optsd: if (url is not None and url != "FUZZ") or url == optsd["-u"][0]: raise FuzzExceptBadOptions( "Specify the URL either with -u or last argument. If you want to use a full payload, it can only be specified with FUZZ." ) cli_url = optsd["-u"][0] if cli_url: url = cli_url # check command line options correctness self._check_options(optsd) # parse options from recipe first if "--recipe" in optsd: for recipe in optsd["--recipe"]: options.import_from_file(recipe) # command line has priority over recipe self._parse_options(optsd, options) self._parse_conn_options(optsd, options) self._parse_filters(optsd, options) self._parse_seed(url, optsd, options) self._parse_payload(optsd, options) self._parse_scripts(optsd, options) if "--dump-recipe" in optsd: print(exec_banner) for error_msg in options.validate(): warnings.warn("Recipe parsing error: {}".format(error_msg)) print("") options.export_to_file(optsd["--dump-recipe"][0]) print("Recipe written to %s." % (optsd["--dump-recipe"][0], )) sys.exit(0) return options except FuzzException as e: self.show_brief_usage() raise e except ValueError: self.show_brief_usage() raise FuzzExceptBadOptions("Incorrect options, please check help.") except getopt.GetoptError as qw: self.show_brief_usage() raise FuzzExceptBadOptions("%s." % str(qw))