# Example with transformer print("\n=== Password Transformer Demo ===") transformer = RockYouTransformer() test_pwd = "password"
@staticmethod def add_suffixes(password: str, suffixes: List[str] = None) -> List[str]: """Add common suffixes""" if suffixes is None: suffixes = ['123', '1234', '!', '@', '2023', '2024'] return [f"{password}{suffix}" for suffix in suffixes]
def get_hash(self, hash_type: str = 'md5') -> Dict[str, str]: """ Generate hashes for passwords Args: hash_type: 'md5', 'sha1', 'sha256' Returns: Dictionary mapping password to hash """ if not self.loaded: self.load() hash_func = getattr(hashlib, hash_type) return {pwd: hash_func(pwd.encode()).hexdigest() for pwd in self.wordlist[:1000]} # Limit for performance
try: # Initialize the wordlist manager rockyou = RockYouWordlist() # Load first 1000 passwords for demo print("Loading first 1000 passwords...") passwords = rockyou.load(max_passwords=1000) print(f"Loaded {len(passwords)} passwords\n") # Get statistics print("=== Statistics ===") stats = rockyou.get_statistics() print(f"Total passwords: {stats['total_passwords']}") print(f"Unique passwords: {stats['unique_passwords']}") print(f"Duplicates: {stats['duplicates']}") print("\nTop 10 password lengths:") for length, count in stats['length_distribution'].items(): print(f" Length {length}: {count} passwords") print("\nCharacter type distribution:") for char_type, count in stats['character_types'].items(): print(f" {char_type}: {count}") print("\nTop 5 most common passwords:") for pwd, count in list(stats['common_patterns'].items())[:5]: print(f" '{pwd}': {count} times") # Search functionality print("\n=== Search Examples ===") print("Passwords containing '123':") matches = rockyou.search(r'123') for pwd in matches[:10]: print(f" {pwd}") print("\nPasswords with repeating characters:") matches = rockyou.search(r'(.)\1\1') # Three identical chars in a row for pwd in matches[:10]: print(f" {pwd}") # Filter by length print("\n=== Filtering ===") medium_passwords = rockyou.filter_by_length(min_len=8, max_len=12) print(f"Passwords with 8-12 characters: {len(medium_passwords)}") # Password hashing print("\n=== Password Hashing (MD5) ===") hashes = rockyou.get_hash('md5') for pwd, hash_val in list(hashes.items())[:5]: print(f" {pwd} -> {hash_val}") # Find similar passwords print("\n=== Similar Password Search ===") similar = rockyou.find_similar("password123", threshold=2) print(f"Passwords similar to 'password123': {similar[:10]}") except FileNotFoundError as e: print(f"Error: {e}") print("\nTo get the RockYou wordlist:") print("1. On Kali Linux: sudo gunzip /usr/share/wordlists/rockyou.txt.gz") print("2. Or download from: https://github.com/brannondorsey/naive-hashcat/releases/download/data/rockyou.txt") class RockYouTransformer: """Transform and mutate passwords from rockyou"""