Seclists Password Portable Direct

if args.verbose: print(f"[*] Loaded len(all_passwords) passwords from 'args.list'")

def search_passwords(passwords: List[str], query: str, case_sensitive: bool = False) -> List[str]: """Simple substring search.""" if not case_sensitive: query = query.lower() return [p for p in passwords if query in p.lower()] return [p for p in passwords if query in p] Export ---------------------------------------------------------------------- def export_results(passwords: List[str], output_file: Path, fmt: str = "txt"): """Export to txt, json, or csv.""" output_file.parent.mkdir(parents=True, exist_ok=True) if fmt == "txt": output_file.write_text("\n".join(passwords), encoding="utf-8") elif fmt == "json": json.dump(passwords, output_file.open("w", encoding="utf-8"), indent=2) elif fmt == "csv": import csv with open(output_file, "w", newline="", encoding="utf-8") as f: writer = csv.writer(f) writer.writerow(["password"]) writer.writerows([[p] for p in passwords]) else: raise ValueError(f"Unsupported format: fmt") print(f"[✓] Exported len(passwords) passwords to output_file") ---------------------------------------------------------------------- CLI ---------------------------------------------------------------------- def main(): parser = argparse.ArgumentParser( description="SecLists Password Tool – fetch, filter, search, and sample common passwords." ) parser.add_argument( "--list", "-l", choices=list(WORDLISTS.keys()), default=DEFAULT_WORDLIST, help=f"Wordlist to use (default: DEFAULT_WORDLIST)" ) parser.add_argument( "--search", "-s", help="Substring search (case-insensitive by default)" ) parser.add_argument( "--case-sensitive", action="store_true", help="Make --search case-sensitive" ) parser.add_argument( "--pattern", "-p", help="Regex pattern to match" ) parser.add_argument( "--min-len", type=int, help="Minimum password length" ) parser.add_argument( "--max-len", type=int, help="Maximum password length" ) parser.add_argument( "--only-digits", action="store_true", help="Only numeric passwords" ) parser.add_argument( "--only-alpha", action="store_true", help="Only alphabetic passwords" ) parser.add_argument( "--only-lower", action="store_true", help="Only lowercase letters" ) parser.add_argument( "--only-upper", action="store_true", help="Only uppercase letters" ) parser.add_argument( "--exclude-special", action="store_true", help="Exclude any non-alphanumeric characters" ) parser.add_argument( "--must-contain", help="Must contain this substring" ) parser.add_argument( "--sample", "-n", type=int, help="Randomly sample N passwords (after filters)" ) parser.add_argument( "--output", "-o", type=Path, help="Export results to file (txt, json, csv based on extension or --format)" ) parser.add_argument( "--format", choices=["txt", "json", "csv"], help="Export format (default from file extension or txt)" ) parser.add_argument( "--no-cache-dir", action="store_true", help="Do not use default cache (specify custom via --cache-dir)" ) parser.add_argument( "--cache-dir", type=Path, help="Custom cache directory" ) parser.add_argument( "--stats", action="store_true", help="Show statistics of selected passwords" ) parser.add_argument( "--verbose", action="store_true", help="Show additional info" ) seclists password

# Sampling if args.sample: if args.sample > len(filtered): print(f"Warning: sample size args.sample > available (len(filtered)). Using all.", file=sys.stderr) result = filtered else: result = sample_passwords(filtered, args.sample, unique=True) else: result = filtered if args