本文整理汇总了Python中exrex.generate方法的典型用法代码示例。如果您正苦于以下问题:Python exrex.generate方法的具体用法?Python exrex.generate怎么用?Python exrex.generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exrex
的用法示例。
在下文中一共展示了exrex.generate方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: gen_fuzz_subdomains
# 需要导入模块: import exrex [as 别名]
# 或者: from exrex import generate [as 别名]
def gen_fuzz_subdomains(expression, rule):
"""
Generate subdomains based on fuzz mode
:param str expression: generate subdomains's expression
:param str rule: regexp rule
:return list subdomains: list of subdomains
"""
subdomains = list()
fuzz_count = exrex.count(rule)
if fuzz_count > 10000000:
logger.log('ALERT', f'The dictionary generated by this rule is too large:{fuzz_count} > 10000000')
logger.log('DEBUG', f'Dictionary size based on fuzz mode: {fuzz_count}')
for fuzz_string in exrex.generate(rule):
fuzz_string = fuzz_string.lower()
if not fuzz_string.isalnum():
continue
fuzz_domain = expression.replace('*', fuzz_string)
subdomains.append(fuzz_domain)
random_domain = random.choice(subdomains)
logger.log('ALERT', f'Please check whether {random_domain} is correct or not')
return subdomains
示例2: gen_word_subdomains
# 需要导入模块: import exrex [as 别名]
# 或者: from exrex import generate [as 别名]
def gen_word_subdomains(expression, path):
"""
Generate subdomains based on word mode
:param str expression: generate subdomains's expression
:param str path: path of wordlist
:return list subdomains: list of subdomains
"""
subdomains = list()
with open(path, encoding='utf-8', errors='ignore') as fd:
for line in fd:
word = line.strip().lower()
if len(word) == 0:
continue
if not utils.is_subname(word):
continue
if word.startswith('.'):
word = word[1:]
if word.endswith('.'):
word = word[:-1]
subdomain = expression.replace('*', word)
subdomains.append(subdomain)
random_domain = random.choice(subdomains)
logger.log('DEBUG', f'Dictionary based on word mode size: {len(subdomains)}')
logger.log('ALERT', f'Please check whether {random_domain} is correct or not')
return subdomains
示例3: regex_to_str
# 需要导入模块: import exrex [as 别名]
# 或者: from exrex import generate [as 别名]
def regex_to_str(self, all_combo: bool = False):
"""Convert a regex to a matching string
Args:
all_combo (bool, optional): Generate all combos that match regex. Defaults to False.
Returns:
Chepy: The Chepy object.
"""
if all_combo:
self.state = list(exrex.generate(self._convert_to_str()))
else:
self.state = exrex.getone(self._convert_to_str())
return self
示例4: get_list_of_values
# 需要导入模块: import exrex [as 别名]
# 或者: from exrex import generate [as 别名]
def get_list_of_values(self, num_values):
"""Returns a list of num_values strings matching regex; note that strings that match in
multiple ways may be repeated (e.g. regex 'a|a|a' would yield 'a' as a match three times)"""
regex_gen = exrex.generate(self.options['regex'])
try:
return [next(regex_gen) for _ in range(num_values)]
except StopIteration:
raise ValueError('Fewer than {} regex matches could be generated'.format(num_values))
示例5: get_max_value
# 需要导入模块: import exrex [as 别名]
# 或者: from exrex import generate [as 别名]
def get_max_value(self):
raise NotImplementedError('Regex input generator cannot generate maximum values')
示例6: get_min_value
# 需要导入模块: import exrex [as 别名]
# 或者: from exrex import generate [as 别名]
def get_min_value(self):
raise NotImplementedError('Regex input generator cannot generate minimum values')
示例7: get_greater_than
# 需要导入模块: import exrex [as 别名]
# 或者: from exrex import generate [as 别名]
def get_greater_than(self, value):
raise NotImplementedError('Regex input generator cannot generate relative values')
示例8: get_less_than
# 需要导入模块: import exrex [as 别名]
# 或者: from exrex import generate [as 别名]
def get_less_than(self, value):
raise NotImplementedError('Regex input generator cannot generate relative values')
示例9: regex_parser
# 需要导入模块: import exrex [as 别名]
# 或者: from exrex import generate [as 别名]
def regex_parser(regex):
try:
string_list = list(exrex.generate(regex))
return string_list
except:
print "Incorrect regex syntax"
sys.exit(1)
示例10: __iter__
# 需要导入模块: import exrex [as 别名]
# 或者: from exrex import generate [as 别名]
def __iter__(self):
for string in generate(self.regex, self.limit):
value = bytes(string, encoding=CONFIG["GLOBALS"]["CODEC"])
yield Value(value, len(value) * 8)