if cache_file.exists(): print(f"[✓] Using cached: cache_file") return cache_file
WORDLISTS = "10k_most_common": "url": f"SECLISTS_BASE_URL/Common-Credentials/10k-most-common.txt", "description": "10,000 most common passwords", , "500_worst": "url": f"SECLISTS_BASE_URL/500-worst-passwords.txt", "description": "500 worst passwords", , "rockyou_20": "url": f"SECLISTS_BASE_URL/RockYou-20.txt", "description": "Top 20 from RockYou leak", , "xato_10k": "url": f"SECLISTS_BASE_URL/xato-net-10-million-passwords-10000.txt", "description": "Xato 10k most common", , "linkedin": "url": f"SECLISTS_BASE_URL/LinkedIn-common-passwords.txt", "description": "LinkedIn leak common passwords", , Download & Cache Management ---------------------------------------------------------------------- def download_wordlist(name: str, cache_dir: Path) -> Path: """Download wordlist to cache directory, return local path.""" if name not in WORDLISTS: raise ValueError(f"Unknown wordlist: name. Choose from list(WORDLISTS.keys())") seclists password
try: resp = requests.get(url, timeout=15) resp.raise_for_status() cache_file.write_bytes(resp.content) print(f"[✓] Saved to cache_file") return cache_file except Exception as e: raise RuntimeError(f"Failed to download name: e") def load_passwords(name: str, cache_dir: Path = DEFAULT_CACHE_DIR) -> List[str]: """Return list of passwords (stripped, non-empty).""" path = download_wordlist(name, cache_dir) passwords = [] with open(path, "r", encoding="utf-8", errors="ignore") as f: for line in f: pwd = line.strip() if pwd: passwords.append(pwd) return passwords Search / Filter / Sample ---------------------------------------------------------------------- def filter_passwords( passwords: List[str], min_len: Optional[int] = None, max_len: Optional[int] = None, pattern: Optional[str] = None, only_digits: bool = False, only_alpha: bool = False, only_lower: bool = False, only_upper: bool = False, exclude_special: bool = False, must_contain: Optional[str] = None, ) -> List[str]: """Apply various filters to password list.""" result = passwords if cache_file
info = WORDLISTS[name] url = info["url"] cache_file = cache_dir / f"name.txt" 000 most common passwords"
if args.verbose: print(f"[*] Loaded len(all_passwords) passwords from 'args.list'")
# Cache directory if args.no_cache_dir and not args.cache_dir: print("Error: --no-cache-dir requires --cache-dir to be set", file=sys.stderr) sys.exit(1) cache_dir = args.cache_dir if args.cache_dir else DEFAULT_CACHE_DIR
if args.search: filtered = search_passwords(filtered, args.search, args.case_sensitive) if args.verbose: print(f"[*] After substring search 'args.search': len(filtered) passwords")