Wordlist Rockyou ((exclusive)) -
class RockYouWordlist: """ Feature for managing and analyzing the RockYou wordlist """
def load(self, max_passwords: Optional[int] = None) -> List[str]: """ Load the wordlist into memory Args: max_passwords: Limit number of passwords to load (for testing) Returns: List of passwords """ passwords = [] # Handle gzipped files if self.filepath.endswith('.gz'): open_func = gzip.open mode = 'rt' else: open_func = open mode = 'r', encoding='latin-1' try: with open_func(self.filepath, mode, encoding='latin-1', errors='ignore') as f: for i, line in enumerate(f): if max_passwords and i >= max_passwords: break password = line.strip() if password: # Skip empty lines passwords.append(password) except TypeError: # Fallback for older Python versions with open_func(self.filepath, 'rt', encoding='latin-1', errors='ignore') as f: for i, line in enumerate(f): if max_passwords and i >= max_passwords: break password = line.strip() if password: passwords.append(password) self.wordlist = passwords self.loaded = True return passwords
def find_similar(self, target_password: str, threshold: int = 2) -> List[str]: """ Find similar passwords using Levenshtein distance Args: target_password: Password to compare against threshold: Maximum edit distance Returns: List of similar passwords """ if not self.loaded: self.load() def levenshtein(s1: str, s2: str) -> int: if len(s1) < len(s2): return levenshtein(s2, s1) if len(s2) == 0: return len(s1) previous_row = range(len(s2) + 1) for i, c1 in enumerate(s1): current_row = [i + 1] for j, c2 in enumerate(s2): insertions = previous_row[j + 1] + 1 deletions = current_row[j] + 1 substitutions = previous_row[j] + (c1 != c2) current_row.append(min(insertions, deletions, substitutions)) previous_row = current_row return previous_row[-1] similar = [] for pwd in self.wordlist[:10000]: # Limit for performance distance = levenshtein(target_password, pwd) if distance <= threshold: similar.append(pwd) return similar def demo_rockyou_feature(): """Demonstrate the RockYou wordlist feature""" wordlist rockyou
@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 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] max_passwords: Optional[int] = None) ->
def __init__(self, filepath: Optional[str] = None): """ Initialize the RockYou wordlist manager Args: filepath: Path to rockyou.txt or rockyou.txt.gz file """ self.filepath = self._find_wordlist(filepath) if filepath else self._find_wordlist() self.wordlist = None self.loaded = False def _find_wordlist(self, filepath: Optional[str] = None) -> str: """Find the rockyou wordlist file""" if filepath and os.path.exists(filepath): return filepath for path in self.COMMON_PATHS: expanded_path = os.path.expanduser(path) if os.path.exists(expanded_path): return expanded_path raise FileNotFoundError( "RockYou wordlist not found. Please provide the correct path. " "On Kali Linux: sudo gunzip /usr/share/wordlists/rockyou.txt.gz" )
# Common paths where rockyou might be located COMMON_PATHS = [ "/usr/share/wordlists/rockyou.txt", "/usr/share/wordlists/rockyou.txt.gz", "./wordlists/rockyou.txt", "./rockyou.txt", "~/rockyou.txt" ] encoding='latin-1' try: with open_func(self.filepath
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