@staticmethod def leet_speak(password: str) -> List[str]: """Convert to leet speak variations""" leet_map = { 'a': ['4', '@'], 'e': ['3'], 'i': ['1', '!'], 'o': ['0'], 's': ['5', '$'], 't': ['7'] } variations = [password] for char, replacements in leet_map.items(): new_variations = [] for var in variations: for replacement in replacements: new_variations.append(var.replace(char, replacement)) variations.extend(new_variations) return list(set(variations))[:20] # Limit variations
@staticmethod def capitalize_variations(password: str) -> List[str]: """Generate capitalization variations""" variations = {password.lower(), password.upper(), password.capitalize()} # Title case for words if ' ' in password: variations.add(password.title()) return list(variations) if == " main ": demo_rockyou_feature() wordlist rockyou
def get_statistics(self) -> Dict: """ Analyze wordlist statistics Returns: Dictionary with statistics """ if not self.loaded: self.load() stats = { 'total_passwords': len(self.wordlist), 'unique_passwords': len(set(self.wordlist)), 'duplicates': len(self.wordlist) - len(set(self.wordlist)), 'length_distribution': {}, 'common_patterns': {}, 'character_types': { 'numeric_only': 0, 'alpha_only': 0, 'alphanumeric': 0, 'special_chars': 0 } } # Analyze password lengths lengths = [len(pwd) for pwd in self.wordlist] length_counter = Counter(lengths) stats['length_distribution'] = dict(length_counter.most_common(10)) # Analyze character types for pwd in self.wordlist: if pwd.isdigit(): stats['character_types']['numeric_only'] += 1 elif pwd.isalpha(): stats['character_types']['alpha_only'] += 1 elif pwd.isalnum(): stats['character_types']['alphanumeric'] += 1 elif any(not c.isalnum() for c in pwd): stats['character_types']['special_chars'] += 1 # Find common patterns common_passwords = Counter(self.wordlist).most_common(20) stats['common_patterns'] = dict(common_passwords) return stats @staticmethod def leet_speak(password: str) ->
def search(self, pattern: str, case_sensitive: bool = False) -> List[str]: """ Search for passwords matching a pattern Args: pattern: Regex pattern to search for case_sensitive: Whether search is case-sensitive Returns: List of matching passwords """ if not self.loaded: self.load() flags = 0 if case_sensitive else re.IGNORECASE regex = re.compile(pattern, flags) return [pwd for pwd in self.wordlist if regex.search(pwd)] 'duplicates': len(self.wordlist) - len(set(self.wordlist))