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
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 wordlist rockyou
@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_statistics(self) ->
def filter_by_length(self, min_len: int = 0, max_len: Optional[int] = None) -> List[str]: """Filter passwords by length""" if not self.loaded: self.load() return [pwd for pwd in self.wordlist if len(pwd) >= min_len and (max_len is None or len(pwd) <= max_len)] 'duplicates': len(self.wordlist) - len(set(self.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 __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" )
def stream(self) -> Iterator[str]: """ Stream passwords without loading all into memory Yields: Passwords one by one """ if self.filepath.endswith('.gz'): with gzip.open(self.filepath, 'rt', encoding='latin-1', errors='ignore') as f: for line in f: password = line.strip() if password: yield password else: with open(self.filepath, 'r', encoding='latin-1', errors='ignore') as f: for line in f: password = line.strip() if password: yield password
|
© 2025 TraceMyIP.org All Rights Reserved.
TraceMyIP® is a registered trademark of TraceMyIP, LLC
Use of TraceMyIP.org constitutes acceptance of Terms of Service. |