當前位置: 首頁>>代碼示例>>Python>>正文


Python exrex.generate方法代碼示例

本文整理匯總了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 
開發者ID:shmilylty,項目名稱:OneForAll,代碼行數:24,代碼來源:brute.py

示例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 
開發者ID:shmilylty,項目名稱:OneForAll,代碼行數:28,代碼來源:brute.py

示例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 
開發者ID:securisec,項目名稱:chepy,代碼行數:16,代碼來源:utils.py

示例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)) 
開發者ID:twosixlabs,項目名稱:acsploit,代碼行數:10,代碼來源:regex.py

示例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') 
開發者ID:twosixlabs,項目名稱:acsploit,代碼行數:4,代碼來源:regex.py

示例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') 
開發者ID:twosixlabs,項目名稱:acsploit,代碼行數:4,代碼來源:regex.py

示例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') 
開發者ID:twosixlabs,項目名稱:acsploit,代碼行數:4,代碼來源:regex.py

示例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') 
開發者ID:twosixlabs,項目名稱:acsploit,代碼行數:4,代碼來源:regex.py

示例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) 
開發者ID:utkusen,項目名稱:rhodiola,代碼行數:9,代碼來源:rhodiola.py

示例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) 
開發者ID:ernw,項目名稱:dizzy,代碼行數:6,代碼來源:regex.py


注:本文中的exrex.generate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。