#!/bin/bash # Wordlist Builder Script # Downloads, processes, and creates master wordlist for hashcat cracking set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" WORKSPACE_DIR="$(dirname "$SCRIPT_DIR")" WORDLIST_DIR="$WORKSPACE_DIR/wordlists" TEMP_DIR="$WORKSPACE_DIR/temp" # Create directories mkdir -p "$WORDLIST_DIR" "$TEMP_DIR" echo "==========================================" echo "Wordlist Builder for Hashcat Cracking" echo "==========================================" # Function to download wordlist download_wordlist() { local url="$1" local filename="$2" echo "Downloading: $filename" if command -v wget &> /dev/null; then wget -q --show-progress -O "$TEMP_DIR/$filename" "$url" elif command -v curl &> /dev/null; then curl -s -L "$url" -o "$TEMP_DIR/$filename" else echo "Error: Neither wget nor curl found. Please install one of them." exit 1 fi } # Function to process and clean wordlist clean_wordlist() { local input_file="$1" local output_file="$2" echo "Cleaning: $(basename "$input_file")" # Remove non-printable characters, convert to lowercase, sort, remove duplicates iconv -f utf-8 -t utf-8//IGNORE "$input_file" | \ tr -cd '\11\12\15\40-\176' | \ tr '[:upper:]' '[:lower:]' | \ sort -u | \ grep -v '^$' > "$output_file" echo " → Cleaned: $(wc -l < "$output_file") lines" } # List of wordlist sources (common breached password lists) WORDLIST_SOURCES=( "https://raw.githubusercontent.com/danielmiessler/SecLists/master/Passwords/Leaked-Databases/rockyou.txt" "https://raw.githubusercontent.com/danielmiessler/SecLists/master/Passwords/Common-Credentials/10-million-password-list-top-1000000.txt" "https://raw.githubusercontent.com/danielmiessler/SecLists/master/Passwords/Common-Credentials/10k-most-common.txt" "https://raw.githubusercontent.com/danielmiessler/SecLists/master/Passwords/darkweb2017-top10000.txt" "https://raw.githubusercontent.com/danielmiessler/SecLists/master/Passwords/xato-net-10-million-passwords-1000000.txt" "https://raw.githubusercontent.com/berzerk0/Probable-Wordlists/master/Real-Passwords/Top12Thousand-probable-v2.txt" ) echo "Step 1: Downloading wordlists..." for url in "${WORDLIST_SOURCES[@]}"; do filename=$(basename "$url") if [ ! -f "$TEMP_DIR/$filename" ]; then download_wordlist "$url" "$filename" else echo "Already exists: $filename" fi done echo "" echo "Step 2: Cleaning and processing wordlists..." CLEANED_FILES=() for file in "$TEMP_DIR"/*.txt; do if [ -f "$file" ]; then clean_filename="clean_$(basename "$file")" clean_wordlist "$file" "$WORDLIST_DIR/$clean_filename" CLEANED_FILES+=("$WORDLIST_DIR/$clean_filename") fi done echo "" echo "Step 3: Creating master wordlist..." MASTER_WORDLIST="$WORDLIST_DIR/master_wordlist.txt" # Combine all cleaned wordlists cat "${CLEANED_FILES[@]}" | sort -u > "$MASTER_WORDLIST.tmp" # Remove passwords that are too short or too long (WPA/WPA2 typically 8-63 chars) echo "Filtering by length (8-63 characters)..." grep -E '^.{8,63}$' "$MASTER_WORDLIST.tmp" > "$MASTER_WORDLIST" # Clean up rm -f "$MASTER_WORDLIST.tmp" echo "" echo "Step 4: Generating custom wordlists with Crunch..." if command -v crunch &> /dev/null; then # Generate common pattern wordlists echo "Generating common patterns..." # 8-12 character lowercase crunch 8 12 -t @@@@@@@@ -o "$WORDLIST_DIR/crunch_lower_8-12.txt" 2>/dev/null || true # Common substitutions (leet speak) echo "password" > "$TEMP_DIR/base.txt" echo "admin" >> "$TEMP_DIR/base.txt" echo "welcome" >> "$TEMP_DIR/base.txt" echo "123456" >> "$TEMP_DIR/base.txt" # Create rule file for common substitutions cat > "$TEMP_DIR/leet.rule" << 'EOF' : l u c s$ sa@ so0 si1 se3 sa4 sh5 sg6 st7 sb8 sg9 EOF # Apply rules to base words if command -v hashcat &> /dev/null; then hashcat --stdout "$TEMP_DIR/base.txt" -r "$TEMP_DIR/leet.rule" > "$WORDLIST_DIR/leet_variations.txt" 2>/dev/null || true fi else echo "Crunch not installed. Skipping pattern generation." fi echo "" echo "Step 5: Final statistics..." TOTAL_LINES=$(wc -l < "$MASTER_WORDLIST") TOTAL_SIZE=$(du -h "$MASTER_WORDLIST" | cut -f1) echo "==========================================" echo "Wordlist Creation Complete!" echo "==========================================" echo "Master wordlist: $MASTER_WORDLIST" echo "Total entries: $TOTAL_LINES" echo "File size: $TOTAL_SIZE" echo "" echo "Additional wordlists available in: $WORDLIST_DIR/" ls -la "$WORDLIST_DIR"/*.txt | head -10 echo "" echo "Place your CAP/PCAP files in: $WORKSPACE_DIR/input/" echo "Then run the cracking script to begin."