first commit

This commit is contained in:
2026-03-25 06:25:14 -07:00
commit 3601db58bf
7 changed files with 3516 additions and 0 deletions

116
README.md Normal file
View File

@@ -0,0 +1,116 @@
# WiFi Cracking Package
## Complete CAP/PCAP Cracking Workflow with Handshake Verification
### Quick Start
```bash
# 1. Make scripts executable
chmod +x auto_crack.sh scripts/*.sh
# 2. Place your CAP/PCAP files in the input/ directory
mkdir -p input
cp /path/to/your/*.cap input/
cp /path/to/your/*.pcap input/
# 3. Run the automation
./auto_crack.sh
```
### What's Included
- **Main Automation Script** (`auto_crack.sh`) - Complete workflow
- **Handshake Verification** (`scripts/verify_handshakes.sh`) - Pre-cracking validation
- **Wordlist Builder** (`scripts/build_wordlist.sh`) - Smart wordlist generation
- **Cracking Pipeline** (`scripts/crack_pipeline.sh`) - Hashcat automation
- **Custom Rules** (`rules/`) - Password mutation rules
- **Documentation** (`docs/`) - Detailed guides and examples
### Directory Structure
```
wifi_cracking_package/
├── auto_crack.sh # MAIN SCRIPT - Run this
├── README.md # This file
├── scripts/ # All automation scripts
│ ├── verify_handshakes.sh # Handshake validation & statistics
│ ├── build_wordlist.sh # Wordlist generation
│ └── crack_pipeline.sh # Hashcat cracking
├── rules/ # Hashcat rule files
│ ├── custom.rule # Custom password mutations
│ └── best64.rule # Common rule set
├── docs/ # Documentation
│ ├── workflow.md # Complete workflow guide
│ └── troubleshooting.md # Common issues & solutions
└── input/ # PLACE YOUR CAP/PCAP FILES HERE
```
### Features
1. **Smart Handshake Verification** - Validates CAP/PCAP files before cracking
2. **Automated Wordlist Management** - Downloads, combines, and optimizes password lists
3. **Rule-Based Attacks** - Uses hashcat rules for password mutations
4. **Batch Processing** - Handles multiple files automatically
5. **Comprehensive Reporting** - Generates detailed results and statistics
6. **Error Recovery** - Handles failures gracefully with logs
### Workflow Steps
1. **System Check** - Verifies tools and dependencies
2. **Handshake Verification** - Validates capture files (NEW!)
3. **Wordlist Generation** - Builds optimized password lists
4. **CAP/PCAP Conversion** - Converts to hashcat format
5. **Hashcat Cracking** - Runs dictionary + rule attacks
6. **Results Reporting** - Generates comprehensive reports
### Handshake Verification
```bash
# Run verification separately
./scripts/verify_handshakes.sh
# Checks for:
# - Valid EAPOL handshakes (4-way handshake)
# - PMKID captures
# - Capture quality and statistics
# - Network identification (SSID/BSSID)
```
### Installation
```bash
# Install required tools
sudo apt update && sudo apt install -y hashcat hcxtools curl wget tshark
# Or use the auto-install feature in auto_crack.sh
```
### Usage Examples
```bash
# Basic usage
./auto_crack.sh
# Manual step-by-step
./scripts/verify_handshakes.sh
./scripts/build_wordlist.sh
./scripts/crack_pipeline.sh
# Custom wordlists
cp ~/wordlists/rockyou.txt input/wordlists/
cp ~/hashcat/rules/*.rule rules/
```
### Output
- **Cracked Passwords**: `results/all_cracked.txt`
- **Verification Reports**: `verification/handshake_report_*.txt`
- **Process Logs**: `auto_crack.log`
- **Hashcat Potfile**: `results/cracking_potfile.txt`
### Requirements
- Linux environment (WSL2, Ubuntu, Kali Linux)
- Hashcat + hcxtools installed
- 4GB+ RAM, 10GB+ disk space
- CAP/PCAP files with valid WPA/WPA2 handshakes
### Legal Notice
**FOR AUTHORIZED SECURITY TESTING ONLY**
Use only on networks you own or have explicit permission to test.
Comply with all applicable laws and regulations.
### Support
1. Check `auto_crack.log` for errors
2. Run `./scripts/verify_handshakes.sh` to validate captures
3. Ensure CAP/PCAP files contain valid handshakes
4. Verify system has required tools installed

477
auto_crack.sh Normal file
View File

@@ -0,0 +1,477 @@
#!/bin/bash
# Auto-Crack Master Script
# Complete automation for CAP/PCAP cracking workflow
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WORKSPACE_DIR="$SCRIPT_DIR"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Configuration
INPUT_DIR="$WORKSPACE_DIR/input"
CONVERTED_DIR="$WORKSPACE_DIR/converted"
WORDLIST_DIR="$WORKSPACE_DIR/wordlists"
RULES_DIR="$WORKSPACE_DIR/rules"
RESULTS_DIR="$WORKSPACE_DIR/results"
SCRIPTS_DIR="$WORKSPACE_DIR/scripts"
VERIFY_DIR="$WORKSPACE_DIR/verification"
LOG_FILE="$WORKSPACE_DIR/auto_crack.log"
# Function to print colored messages
print_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Function to log messages
log_message() {
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
echo "[$timestamp] $1" >> "$LOG_FILE"
echo "$1"
}
# Function to check system requirements
check_requirements() {
log_message "Checking system requirements..."
# Check if running in WSL
if grep -q Microsoft /proc/version 2>/dev/null; then
print_info "Running in WSL environment"
fi
# Check for required tools
local required_tools=("hashcat" "hcxpcapngtool" "curl" "wget" "sort" "uniq")
local missing_tools=()
for tool in "${required_tools[@]}"; do
if ! command -v "$tool" &> /dev/null; then
missing_tools+=("$tool")
fi
done
if [ ${#missing_tools[@]} -gt 0 ]; then
print_error "Missing required tools: ${missing_tools[*]}"
print_info "Attempting to install missing tools..."
# Try to install tools
if command -v apt &> /dev/null; then
sudo apt update && sudo apt install -y hashcat hcxtools curl wget coreutils
else
print_error "Cannot install tools automatically. Please install manually:"
print_error " sudo apt install hashcat hcxtools curl wget"
exit 1
fi
fi
print_success "All system requirements satisfied"
}
# Function to setup workspace
setup_workspace() {
log_message "Setting up workspace directories..."
# Create all necessary directories
mkdir -p "$INPUT_DIR" "$CONVERTED_DIR" "$WORDLIST_DIR" "$RULES_DIR" "$RESULTS_DIR" "$SCRIPTS_DIR" "$VERIFY_DIR"
# Create default rule if none exists
if [ ! -f "$RULES_DIR/custom.rule" ]; then
log_message "Creating default rule file..."
cp "$WORKSPACE_DIR/rules/custom.rule" "$RULES_DIR/" 2>/dev/null || true
fi
print_success "Workspace setup complete"
}
# Function to verify handshakes
verify_handshakes() {
log_message "Verifying handshakes in CAP/PCAP files..."
# Check for capture files
local capture_files=($(find "$INPUT_DIR" -type f \( -name "*.cap" -o -name "*.pcap" -o -name "*.pcapng" \) 2>/dev/null))
if [ ${#capture_files[@]} -eq 0 ]; then
print_warning "No CAP/PCAP files found to verify"
return 1
fi
print_info "Found ${#capture_files[@]} capture file(s) for verification"
# Run verification script if available
if [ -f "$SCRIPTS_DIR/verify_handshakes.sh" ]; then
chmod +x "$SCRIPTS_DIR/verify_handshakes.sh"
print_info "Running detailed handshake verification..."
"$SCRIPTS_DIR/verify_handshakes.sh"
local verify_status=$?
if [ $verify_status -eq 0 ]; then
print_success "Handshake verification complete"
return 0
else
print_warning "Handshake verification found issues"
return 1
fi
else
# Basic verification using hcxpcapngtool
print_info "Running basic handshake check..."
local valid_count=0
for capture_file in "${capture_files[@]}"; do
local filename=$(basename "$capture_file")
# Quick check for handshakes
local check_output=$(hcxpcapngtool -v "$capture_file" 2>&1 | grep -E "(EAPOL pairs|PMKID)" || true)
if echo "$check_output" | grep -q "EAPOL pairs: [1-9]" || echo "$check_output" | grep -q "PMKID(s): [1-9]"; then
print_success "$filename: Valid handshake found"
valid_count=$((valid_count + 1))
else
print_warning "$filename: No valid handshake"
fi
done
echo ""
print_info "Handshake verification summary:"
print_info " Total files: ${#capture_files[@]}"
print_info " Files with handshakes: $valid_count"
print_info " Files without handshakes: $((${#capture_files[@]} - valid_count))"
if [ $valid_count -eq 0 ]; then
print_error "No valid handshakes found in any file!"
print_info "Recapture is required before cracking can proceed."
return 1
elif [ $valid_count -lt ${#capture_files[@]} ]; then
print_warning "Some files are missing handshakes."
print_info "Consider recapturing or proceed with available handshakes."
return 0
else
print_success "All files have valid handshakes!"
return 0
fi
fi
}
# Function to build wordlists
build_wordlists() {
log_message "Building wordlists..."
# Check if wordlists already exist
local wordlist_count=$(find "$WORDLIST_DIR" -name "*.txt" -type f | wc -l)
if [ "$wordlist_count" -lt 3 ]; then
print_info "Wordlists not found or insufficient. Building..."
# Run the wordlist builder script if it exists
if [ -f "$SCRIPTS_DIR/build_wordlist.sh" ]; then
chmod +x "$SCRIPTS_DIR/build_wordlist.sh"
cd "$WORKSPACE_DIR"
"$SCRIPTS_DIR/build_wordlist.sh"
else
# Create a basic wordlist
print_info "Creating basic wordlist..."
cat > "$WORDLIST_DIR/basic_wordlist.txt" << 'EOF'
password
12345678
admin
welcome
qwerty
letmein
monkey
dragon
baseball
football
1234567890
password1
admin123
welcome1
qwerty123
EOF
# Download rockyou if possible
if command -v wget &> /dev/null; then
print_info "Downloading rockyou wordlist..."
wget -q -O "$WORDLIST_DIR/rockyou.txt.gz" "https://github.com/brannondorsey/naive-hashcat/releases/download/data/rockyou.txt.gz" 2>/dev/null || true
if [ -f "$WORDLIST_DIR/rockyou.txt.gz" ]; then
gunzip -f "$WORDLIST_DIR/rockyou.txt.gz" 2>/dev/null || true
fi
fi
fi
else
print_info "Using existing wordlists ($wordlist_count found)"
fi
# Create master wordlist by combining all wordlists
print_info "Creating master wordlist..."
find "$WORDLIST_DIR" -name "*.txt" -type f -exec cat {} \; | \
sort -u | \
grep -E '^.{8,63}$' > "$WORDLIST_DIR/master_wordlist.txt" 2>/dev/null || true
local master_count=$(wc -l < "$WORDLIST_DIR/master_wordlist.txt" 2>/dev/null || echo 0)
print_success "Wordlists built: $master_count entries in master wordlist"
}
# Function to process CAP/PCAP files
process_captures() {
log_message "Processing CAP/PCAP files..."
# Check for input files
local input_files=$(find "$INPUT_DIR" -type f \( -name "*.cap" -o -name "*.pcap" -o -name "*.pcapng" \) | wc -l)
if [ "$input_files" -eq 0 ]; then
print_warning "No CAP/PCAP files found in $INPUT_DIR/"
print_info "Please place your capture files in the input/ directory"
print_info "You can add files and run this script again"
return 1
fi
print_info "Found $input_files capture file(s)"
# Convert each capture file
local converted_count=0
find "$INPUT_DIR" -type f \( -name "*.cap" -o -name "*.pcap" -o -name "*.pcapng" \) | while read -r capture_file; do
local filename=$(basename "$capture_file")
local output_file="$CONVERTED_DIR/${filename%.*}.hc22000"
# Skip if already converted
if [ -f "$output_file" ]; then
print_info "Already converted: $filename"
continue
fi
print_info "Converting: $filename"
# Convert using hcxpcapngtool
if hcxpcapngtool -o "$output_file" "$capture_file" 2>/dev/null; then
print_success "Converted: $filename$(basename "$output_file")"
converted_count=$((converted_count + 1))
else
print_warning "Failed to convert: $filename (may not contain valid handshake)"
rm -f "$output_file" 2>/dev/null || true
fi
done
print_success "Conversion complete: $converted_count file(s) converted"
return 0
}
# Function to run cracking
run_cracking() {
log_message "Starting cracking process..."
# Check for hash files
local hash_files=($(find "$CONVERTED_DIR" -name "*.hc22000" -type f))
if [ ${#hash_files[@]} -eq 0 ]; then
print_error "No hash files found to crack"
print_info "Run conversion step first or check input files"
return 1
fi
print_info "Found ${#hash_files[@]} hash file(s) to crack"
# Select wordlist
local wordlist="$WORDLIST_DIR/master_wordlist.txt"
if [ ! -f "$wordlist" ]; then
wordlist=$(find "$WORDLIST_DIR" -name "*.txt" -type f | head -1)
fi
if [ ! -f "$wordlist" ]; then
print_error "No wordlist found"
return 1
fi
local wordlist_size=$(wc -l < "$wordlist" 2>/dev/null || echo 0)
print_info "Using wordlist: $(basename "$wordlist") ($wordlist_size entries)"
# Select rule
local rule_file=$(find "$RULES_DIR" -name "*.rule" -type f | head -1)
if [ ! -f "$rule_file" ]; then
print_warning "No rule file found, using straight dictionary attack"
rule_option=""
else
print_info "Using rule: $(basename "$rule_file")"
rule_option="-r $rule_file"
fi
# Crack each hash file
local cracked_count=0
for hash_file in "${hash_files[@]}"; do
local hash_filename=$(basename "$hash_file")
local output_file="$RESULTS_DIR/${hash_filename%.*}_cracked.txt"
print_info "Cracking: $hash_filename"
# Run hashcat
hashcat -m 22000 "$hash_file" "$wordlist" $rule_option \
--force \
--potfile-path="$RESULTS_DIR/potfile.txt" \
--outfile="$output_file" \
--outfile-format=2 2>&1 | tee -a "$LOG_FILE" | grep -E "(Status|Recovered|Progress)" || true
# Check if cracked
if hashcat --show -m 22000 "$hash_file" 2>/dev/null | grep -q .; then
print_success "CRACKED: $hash_filename"
cracked_count=$((cracked_count + 1))
# Save cracked passwords
hashcat --show -m 22000 "$hash_file" 2>/dev/null >> "$RESULTS_DIR/all_cracked.txt"
else
print_warning "NOT CRACKED: $hash_filename"
fi
echo ""
done
print_success "Cracking complete: $cracked_count/${#hash_files[@]} files cracked"
# Show summary
if [ -f "$RESULTS_DIR/all_cracked.txt" ]; then
echo ""
echo "=========================================="
echo "CRACKED PASSWORDS SUMMARY"
echo "=========================================="
cat "$RESULTS_DIR/all_cracked.txt"
echo "=========================================="
fi
return 0
}
# Function to generate report
generate_report() {
log_message "Generating final report..."
local report_file="$RESULTS_DIR/cracking_report_$(date +%Y%m%d_%H%M%S).txt"
cat > "$report_file" << EOF
CAP/PCAP Cracking Report
========================
Generated: $(date)
Workspace: $WORKSPACE_DIR
INPUT FILES
-----------
$(find "$INPUT_DIR" -type f \( -name "*.cap" -o -name "*.pcap" -o -name "*.pcapng" \) -exec basename {} \; | sort | sed 's/^/ /')
CONVERTED HASH FILES
--------------------
$(find "$CONVERTED_DIR" -name "*.hc22000" -type f -exec basename {} \; | sort | sed 's/^/ /')
WORDLIST STATISTICS
-------------------
Master wordlist: $(wc -l < "$WORDLIST_DIR/master_wordlist.txt" 2>/dev/null || echo "N/A") entries
Total wordlists: $(find "$WORDLIST_DIR" -name "*.txt" -type f | wc -l) files
CRACKING RESULTS
----------------
$(if [ -f "$RESULTS_DIR/all_cracked.txt" ]; then
echo "Cracked passwords:"
cat "$RESULTS_DIR/all_cracked.txt" | sed 's/^/ /'
else
echo "No passwords cracked"
fi)
HASHCAT POTFILE ENTRIES
-----------------------
$(if [ -f "$RESULTS_DIR/potfile.txt" ]; then
cat "$RESULTS_DIR/potfile.txt" | sed 's/^/ /'
else
echo "No potfile entries"
fi)
LOG FILE
--------
$LOG_FILE
EOF
print_success "Report generated: $report_file"
# Display report summary
echo ""
echo "=========================================="
echo "REPORT SUMMARY"
echo "=========================================="
tail -20 "$report_file"
}
# Main function
main() {
echo ""
echo "=========================================="
echo "AUTO-CRACK CAP/PCAP WORKFLOW"
echo "=========================================="
echo ""
# Initialize log
echo "Auto-Crack started at $(date)" > "$LOG_FILE"
# Step 1: Check requirements
check_requirements
# Step 2: Setup workspace
setup_workspace
# Step 3: Build wordlists
build_wordlists
# Step 4: Verify handshakes
if verify_handshakes; then
print_info "Handshake verification passed. Proceeding with cracking..."
# Step 5: Process captures
if process_captures; then
# Step 6: Run cracking
run_cracking
# Step 7: Generate report
generate_report
else
print_warning "No capture files to process"
print_info "Please add CAP/PCAP files to: $INPUT_DIR/"
print_info "Then run this script again"
fi
else
print_error "Handshake verification failed!"
print_info "Some files may not contain valid handshakes."
print_info "You can:"
print_info "1. Recapture handshakes and try again"
print_info "2. Run with --force to attempt cracking anyway"
print_info "3. Check verification reports in: $VERIFY_DIR/"
fi
echo ""
echo "=========================================="
echo "WORKFLOW COMPLETE"
echo "=========================================="
echo ""
echo "Next steps:"
echo "1. Add more CAP/PCAP files to: $INPUT_DIR/"
echo "2. Add custom wordlists to: $WORDLIST_DIR/"
echo "3. Add custom rules to: $RULES_DIR/"
echo "4. Run this script again to process new files"
echo ""
echo "Results available in: $RESULTS_DIR/"
echo "Log file: $LOG_FILE"
echo ""
}
# Run main function
main "$@"

2008
rules/best64.rule Normal file

File diff suppressed because it is too large Load Diff

107
rules/custom.rule Normal file
View File

@@ -0,0 +1,107 @@
# Custom hashcat rules for WPA/WPA2 cracking
# Common password mutations and transformations
# Basic transformations
:
l
u
c
C
t
T
r
R
d
f
p
{
}
$
^
[
]
D
x
O
i
o
# Leet speak substitutions
sa@
so0
si1
se3
sa4
sh5
sg6
st7
sb8
sg9
# Append numbers
$0 $1 $2 $3 $4 $5 $6 $7 $8 $9
$0 $1 $2 $3 $4 $5 $6 $7 $8 $9 $0 $1 $2 $3 $4 $5 $6 $7 $8 $9
$0 $1 $12 $123 $1234 $12345 $123456 $1234567 $12345678 $123456789
# Prepend numbers
^0 ^1 ^2 ^3 ^4 ^5 ^6 ^7 ^8 ^9
^0 ^1 ^12 ^123 ^1234 ^12345 ^123456 ^1234567 ^12345678 ^123456789
# Common suffixes
$! $$ $% $&
$! $$ $% $& $* $- $+ $. $/ $: $; $= $? $@ $[ $\ $] $^ $_ $` ${ $| $} $~
# Common prefixes
^! ^$ ^% ^&
^! ^$ ^% ^& ^* ^- ^+ ^. ^/ ^: ^; ^= ^? ^@ ^[ ^\ ^] ^^ ^_ ^` ^{ ^| ^} ^~
# Year suffixes
$2019 $2020 $2021 $2022 $2023 $2024 $2025
$19 $20 $21 $22 $23 $24 $25
# Double and reverse
d
f
p
{
}
r
# Capitalization patterns
c
C
t
T
# Toggle case
t
T
# Duplicate
d
f
p
# Special character insertions
i0!
i1@
i2#
i3$
i4%
i5^
i6&
i7*
i8(
i9)
# Common password patterns
$password
$admin
$welcome
$123456
$qwerty
$letmein
# Month and day suffixes
$01 $02 $03 $04 $05 $06 $07 $08 $09 $10 $11 $12
$jan $feb $mar $apr $may $jun $jul $aug $sep $oct $nov $dec

156
scripts/build_wordlist.sh Normal file
View File

@@ -0,0 +1,156 @@
#!/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."

294
scripts/crack_pipeline.sh Normal file
View File

@@ -0,0 +1,294 @@
#!/bin/bash
# Hashcat Cracking Pipeline for CAP/PCAP files
# Automated workflow for WPA/WPA2 handshake cracking
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WORKSPACE_DIR="$(dirname "$SCRIPT_DIR")"
# Configuration
INPUT_DIR="$WORKSPACE_DIR/input"
CONVERTED_DIR="$WORKSPACE_DIR/converted"
WORDLIST_DIR="$WORKSPACE_DIR/wordlists"
RULES_DIR="$WORKSPACE_DIR/rules"
RESULTS_DIR="$WORKSPACE_DIR/results"
LOG_DIR="$WORKSPACE_DIR/results/logs"
# Hashcat settings
HASHCAT_MODE="22000" # WPA/WPA2 PMKID/EAPOL
POTFILE="$RESULTS_DIR/cracking_potfile.txt"
HASHCAT_OPTIONS="--force --potfile-path=$POTFILE --outfile-format=2"
# Create directories
mkdir -p "$INPUT_DIR" "$CONVERTED_DIR" "$RESULTS_DIR" "$LOG_DIR"
echo "=========================================="
echo "Hashcat Cracking Pipeline"
echo "=========================================="
echo "Input directory: $INPUT_DIR"
echo "Converted directory: $CONVERTED_DIR"
echo "Results directory: $RESULTS_DIR"
echo ""
# Function to check if tools are installed
check_tools() {
echo "Checking required tools..."
local missing_tools=()
for tool in hashcat hcxpcapngtool; do
if ! command -v "$tool" &> /dev/null; then
missing_tools+=("$tool")
fi
done
if [ ${#missing_tools[@]} -gt 0 ]; then
echo "Error: Missing required tools: ${missing_tools[*]}"
echo "Please install them with: sudo apt install hashcat hcxtools"
exit 1
fi
echo "✓ All tools are available"
}
# Function to convert CAP/PCAP to hashcat format
convert_captures() {
echo ""
echo "Step 1: Converting CAP/PCAP files to hashcat format..."
local converted_count=0
# Find all CAP/PCAP files
find "$INPUT_DIR" -type f \( -name "*.cap" -o -name "*.pcap" -o -name "*.pcapng" \) | while read -r capture_file; do
local filename=$(basename "$capture_file")
local output_file="$CONVERTED_DIR/${filename%.*}.hc22000"
# Skip if already converted
if [ -f "$output_file" ]; then
echo " Already converted: $filename"
continue
fi
echo " Converting: $filename"
# Convert using hcxpcapngtool
if hcxpcapngtool -o "$output_file" "$capture_file" 2>/dev/null; then
echo " → Success: $(basename "$output_file")"
converted_count=$((converted_count + 1))
else
echo " → Failed: $filename (may not contain valid handshake)"
rm -f "$output_file" 2>/dev/null || true
fi
done
echo " Total converted: $converted_count files"
}
# Function to select wordlist
select_wordlist() {
echo ""
echo "Step 2: Selecting wordlist..."
local wordlists=("$WORDLIST_DIR"/*.txt)
if [ ${#wordlists[@]} -eq 0 ] || [ ! -f "${wordlists[0]}" ]; then
echo " No wordlists found in $WORDLIST_DIR/"
echo " Creating default wordlist..."
# Create a simple default wordlist
cat > "$WORDLIST_DIR/default_wordlist.txt" << 'EOF'
password
12345678
admin
welcome
qwerty
letmein
monkey
dragon
baseball
football
EOF
echo "$WORDLIST_DIR/default_wordlist.txt"
return
fi
# Use master wordlist if available
if [ -f "$WORDLIST_DIR/master_wordlist.txt" ]; then
echo " Using: master_wordlist.txt"
echo "$WORDLIST_DIR/master_wordlist.txt"
return
fi
# Use the largest wordlist
local largest_wordlist=""
local largest_size=0
for wordlist in "${wordlists[@]}"; do
local size=$(wc -l < "$wordlist" 2>/dev/null || echo 0)
if [ "$size" -gt "$largest_size" ]; then
largest_size=$size
largest_wordlist="$wordlist"
fi
done
echo " Using: $(basename "$largest_wordlist") ($largest_size entries)"
echo "$largest_wordlist"
}
# Function to select rules
select_rules() {
echo ""
echo "Step 3: Selecting rules..."
local rules=("$RULES_DIR"/*.rule)
if [ ${#rules[@]} -eq 0 ] || [ ! -f "${rules[0]}" ]; then
echo " No rule files found in $RULES_DIR/"
echo " Using default rules..."
# Create a simple default rule
cat > "$RULES_DIR/default.rule" << 'EOF'
:
l
u
c
$0 $1 $2 $3 $4 $5 $6 $7 $8 $9
$! $$ $%
^! ^$ ^%
sa@
so0
si1
se3
EOF
echo "$RULES_DIR/default.rule"
return
fi
# Return all rule files
for rule in "${rules[@]}"; do
echo " Available: $(basename "$rule")"
done
# Return the first rule for now (can be enhanced to use multiple)
echo "${rules[0]}"
}
# Function to run hashcat cracking
run_cracking() {
local hash_file="$1"
local wordlist="$2"
local rule_file="$3"
local hash_filename=$(basename "$hash_file")
local output_file="$RESULTS_DIR/${hash_filename%.*}_cracked.txt"
local log_file="$LOG_DIR/${hash_filename%.*}_$(date +%Y%m%d_%H%M%S).log"
echo ""
echo "Cracking: $hash_filename"
echo " Wordlist: $(basename "$wordlist")"
echo " Rule: $(basename "$rule_file")"
echo " Output: $(basename "$output_file")"
# Build hashcat command
local hashcat_cmd="hashcat -m $HASHCAT_MODE $HASHCAT_OPTIONS"
hashcat_cmd="$hashcat_cmd --outfile=\"$output_file\""
hashcat_cmd="$hashcat_cmd \"$hash_file\" \"$wordlist\" -r \"$rule_file\""
echo " Command: hashcat -m $HASHCAT_MODE ... -r $(basename "$rule_file")"
# Run hashcat
eval "$hashcat_cmd" 2>&1 | tee "$log_file"
# Check if any passwords were cracked
if hashcat --show -m "$HASHCAT_MODE" "$hash_file" 2>/dev/null | grep -q .; then
echo " ✓ Success: Password(s) found!"
hashcat --show -m "$HASHCAT_MODE" "$hash_file" 2>/dev/null | tail -5
else
echo " ✗ No passwords found with this wordlist/rule"
fi
}
# Function to display results
show_results() {
echo ""
echo "=========================================="
echo "Cracking Results Summary"
echo "=========================================="
local cracked_files=0
local total_files=0
# Count hash files
for hash_file in "$CONVERTED_DIR"/*.hc22000; do
if [ -f "$hash_file" ]; then
total_files=$((total_files + 1))
if hashcat --show -m "$HASHCAT_MODE" "$hash_file" 2>/dev/null | grep -q .; then
cracked_files=$((cracked_files + 1))
echo "$(basename "$hash_file"): CRACKED"
hashcat --show -m "$HASHCAT_MODE" "$hash_file" 2>/dev/null | while read -r line; do
echo " $line"
done
else
echo "$(basename "$hash_file"): NOT CRACKED"
fi
fi
done
echo ""
echo "Summary: $cracked_files/$total_files files cracked"
if [ "$cracked_files" -gt 0 ]; then
echo ""
echo "Cracked passwords saved in:"
find "$RESULTS_DIR" -name "*_cracked.txt" -type f | while read -r file; do
echo " $file"
done
fi
}
# Main execution
main() {
check_tools
# Convert CAP/PCAP files
convert_captures
# Check if we have any hash files to crack
local hash_files=("$CONVERTED_DIR"/*.hc22000)
if [ ${#hash_files[@]} -eq 0 ] || [ ! -f "${hash_files[0]}" ]; then
echo ""
echo "No hash files found in $CONVERTED_DIR/"
echo "Please place CAP/PCAP files in $INPUT_DIR/ and run again."
exit 1
fi
# Select wordlist and rules
local wordlist=$(select_wordlist)
local rule_file=$(select_rules)
echo ""
echo "Step 4: Starting cracking process..."
echo "=========================================="
# Crack each hash file
for hash_file in "${hash_files[@]}"; do
if [ -f "$hash_file" ]; then
run_cracking "$hash_file" "$wordlist" "$rule_file"
fi
done
# Show results
show_results
echo ""
echo "Pipeline complete! Check $RESULTS_DIR/ for detailed results."
echo "Logs available in: $LOG_DIR/"
}
# Run main function
main "$@"

View File

@@ -0,0 +1,358 @@
#!/bin/bash
# Handshake Verification and Statistics Script
# Analyzes CAP/PCAP files for valid WPA/WPA2 handshakes before cracking
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WORKSPACE_DIR="$(dirname "$SCRIPT_DIR")"
# Configuration
INPUT_DIR="$WORKSPACE_DIR/input"
CONVERTED_DIR="$WORKSPACE_DIR/converted"
RESULTS_DIR="$WORKSPACE_DIR/results"
VERIFY_DIR="$WORKSPACE_DIR/verification"
REPORT_FILE="$VERIFY_DIR/handshake_report_$(date +%Y%m%d_%H%M%S).txt"
# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Create directories
mkdir -p "$VERIFY_DIR" "$RESULTS_DIR"
# Function to print colored messages
print_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Function to check if tools are available
check_tools() {
local tools=("hcxpcapngtool" "tshark" "capinfos")
local missing=()
for tool in "${tools[@]}"; do
if ! command -v "$tool" &> /dev/null; then
missing+=("$tool")
fi
done
if [ ${#missing[@]} -gt 0 ]; then
print_warning "Missing tools: ${missing[*]}"
print_info "Some verification features may be limited"
return 1
fi
return 0
}
# Function to analyze CAP/PCAP file with hcxpcapngtool
analyze_with_hcxpcapngtool() {
local input_file="$1"
local output_file="$2"
print_info "Analyzing: $(basename "$input_file")"
# Run hcxpcapngtool with verbose output
local analysis_output
analysis_output=$(hcxpcapngtool -v "$input_file" 2>&1 || true)
# Extract key information
local handshake_count=$(echo "$analysis_output" | grep -c "EAPOL pairs" || echo "0")
local pmkid_count=$(echo "$analysis_output" | grep -c "PMKID(s)" || echo "0")
local valid_handshake="NO"
if [ "$handshake_count" -gt 0 ] || [ "$pmkid_count" -gt 0 ]; then
valid_handshake="YES"
fi
# Save detailed analysis
echo "=== Analysis of $(basename "$input_file") ===" > "$output_file"
echo "File: $input_file" >> "$output_file"
echo "Size: $(du -h "$input_file" | cut -f1)" >> "$output_file"
echo "Analysis Time: $(date)" >> "$output_file"
echo "" >> "$output_file"
echo "$analysis_output" >> "$output_file"
# Return summary
echo "$valid_handshake:$handshake_count:$pmkid_count"
}
# Function to analyze with tshark (Wireshark)
analyze_with_tshark() {
local input_file="$1"
local output_file="$2"
print_info "Running packet analysis with tshark..."
# Check for EAPOL packets (WPA handshake)
local eapol_count=$(tshark -r "$input_file" -Y "eapol" 2>/dev/null | wc -l || echo "0")
# Check for beacon frames to identify networks
local beacon_info=$(tshark -r "$input_file" -Y "wlan.fc.type_subtype == 0x0008" -T fields -e wlan.sa -e wlan.ssid 2>/dev/null | head -5 || echo "No beacon frames")
# Get packet count and duration
local packet_count=$(capinfos -c "$input_file" 2>/dev/null | grep "Number of packets" | cut -d: -f2 | tr -d ' ' || echo "N/A")
local duration=$(capinfos -a "$input_file" 2>/dev/null | grep "Capture duration" | cut -d: -f2 | tr -d ' ' || echo "N/A")
# Append to output file
echo "" >> "$output_file"
echo "=== Wireshark Analysis ===" >> "$output_file"
echo "Total packets: $packet_count" >> "$output_file"
echo "Capture duration: $duration" >> "$output_file"
echo "EAPOL packets (handshake): $eapol_count" >> "$output_file"
echo "Beacon frames (networks):" >> "$output_file"
echo "$beacon_info" >> "$output_file"
echo "$eapol_count"
}
# Function to generate summary report
generate_summary_report() {
local summary_file="$1"
shift
local files=("$@")
print_info "Generating summary report..."
cat > "$summary_file" << 'EOF'
HANDSHAKE VERIFICATION REPORT
=============================
Generated: $(date)
SUMMARY
-------
EOF
local total_files=0
local valid_files=0
local total_handshakes=0
local total_pmkids=0
for file in "${files[@]}"; do
if [ -f "$file" ]; then
total_files=$((total_files + 1))
# Get analysis results
local analysis_file="$VERIFY_DIR/$(basename "$file").analysis.txt"
if [ -f "$analysis_file" ]; then
local valid_line=$(grep -E "^YES:|^NO:" "$analysis_file" | head -1)
if [[ "$valid_line" == YES:* ]]; then
valid_files=$((valid_files + 1))
IFS=':' read -r valid handshakes pmkids <<< "$valid_line"
total_handshakes=$((total_handshakes + handshakes))
total_pmkids=$((total_pmkids + pmkids))
fi
fi
fi
done
cat >> "$summary_file" << EOF
Statistics:
- Total files analyzed: $total_files
- Files with valid handshakes: $valid_files
- Total EAPOL pairs found: $total_handshakes
- Total PMKIDs found: $total_pmkids
RECOMMENDATIONS
---------------
EOF
if [ "$valid_files" -eq 0 ]; then
cat >> "$summary_file" << EOF
❌ NO VALID HANDSHAKES FOUND
- None of the capture files contain valid WPA/WPA2 handshakes
- Recapture is required before cracking can proceed
- Ensure you capture the 4-way handshake or PMKID
EOF
elif [ "$valid_files" -lt "$total_files" ]; then
cat >> "$summary_file" << EOF
⚠️ PARTIAL HANDSHAKES FOUND
- $valid_files out of $total_files files contain handshakes
- Consider recapturing missing handshakes
- Proceed with cracking for files that have handshakes
EOF
else
cat >> "$summary_file" << EOF
✅ ALL FILES HAVE VALID HANDSHAKES
- All $total_files files contain handshakes
- Ready for cracking
- Total handshake material: $total_handshakes EAPOL pairs, $total_pmkids PMKIDs
EOF
fi
cat >> "$summary_file" << EOF
DETAILED ANALYSIS
-----------------
EOF
for file in "${files[@]}"; do
if [ -f "$file" ]; then
local analysis_file="$VERIFY_DIR/$(basename "$file").analysis.txt"
if [ -f "$analysis_file" ]; then
echo "" >> "$summary_file"
echo "File: $(basename "$file")" >> "$summary_file"
grep -E "^(EAPOL pairs|PMKID|YES:|NO:)" "$analysis_file" | head -5 >> "$summary_file"
fi
fi
done
cat >> "$summary_file" << EOF
NEXT STEPS
----------
1. Files with handshakes will be converted to hashcat format
2. Conversion output: $CONVERTED_DIR/
3. Run cracking with: ./auto_crack.sh or ./scripts/crack_pipeline.sh
Report saved: $summary_file
EOF
}
# Function to display quick statistics
display_quick_stats() {
local files=("$@")
echo ""
echo "=========================================="
echo "QUICK HANDSHAKE STATISTICS"
echo "=========================================="
local file_count=0
local valid_count=0
for file in "${files[@]}"; do
if [ -f "$file" ]; then
file_count=$((file_count + 1))
local filename=$(basename "$file")
# Quick check with hcxpcapngtool
local quick_check=$(hcxpcapngtool -v "$file" 2>&1 | grep -E "(EAPOL pairs|PMKID)" || true)
if echo "$quick_check" | grep -q "EAPOL pairs: [1-9]" || echo "$quick_check" | grep -q "PMKID(s): [1-9]"; then
echo -e "${GREEN}${NC} $filename: VALID handshake found"
valid_count=$((valid_count + 1))
# Extract counts
local eapol=$(echo "$quick_check" | grep "EAPOL pairs" | grep -o '[0-9]*' || echo "0")
local pmkid=$(echo "$quick_check" | grep "PMKID(s)" | grep -o '[0-9]*' || echo "0")
echo " EAPOL pairs: $eapol, PMKIDs: $pmkid"
else
echo -e "${RED}${NC} $filename: NO valid handshake"
fi
fi
done
echo ""
echo "Summary: $valid_count/$file_count files have valid handshakes"
if [ "$valid_count" -eq 0 ]; then
echo -e "${RED}❌ No valid handshakes found. Recapture required.${NC}"
return 1
elif [ "$valid_count" -lt "$file_count" ]; then
echo -e "${YELLOW}⚠️ Some files missing handshakes. Consider recapturing.${NC}"
return 0
else
echo -e "${GREEN}✅ All files have valid handshakes. Ready for cracking.${NC}"
return 0
fi
}
# Main function
main() {
echo ""
echo "=========================================="
echo "HANDSHAKE VERIFICATION & STATISTICS"
echo "=========================================="
# Check for tools
check_tools
# Find CAP/PCAP files
local capture_files=()
while IFS= read -r -d $'\0' file; do
capture_files+=("$file")
done < <(find "$INPUT_DIR" -type f \( -name "*.cap" -o -name "*.pcap" -o -name "*.pcapng" \) -print0)
if [ ${#capture_files[@]} -eq 0 ]; then
print_error "No CAP/PCAP files found in $INPUT_DIR/"
print_info "Please place capture files in the input directory"
exit 1
fi
print_info "Found ${#capture_files[@]} capture file(s)"
# Display quick statistics
display_quick_stats "${capture_files[@]}"
local quick_status=$?
echo ""
print_info "Running detailed analysis..."
# Analyze each file
local analysis_results=()
for capture_file in "${capture_files[@]}"; do
local analysis_file="$VERIFY_DIR/$(basename "$capture_file").analysis.txt"
local result=$(analyze_with_hcxpcapngtool "$capture_file" "$analysis_file")
# Also run tshark analysis if available
if command -v tshark &> /dev/null; then
analyze_with_tshark "$capture_file" "$analysis_file"
fi
analysis_results+=("$result")
# Display result
IFS=':' read -r valid handshakes pmkids <<< "$result"
if [ "$valid" = "YES" ]; then
print_success "$(basename "$capture_file"): $handshakes EAPOL pairs, $pmkids PMKIDs"
else
print_warning "$(basename "$capture_file"): No valid handshake"
fi
done
# Generate comprehensive report
generate_summary_report "$REPORT_FILE" "${capture_files[@]}"
echo ""
echo "=========================================="
echo "ANALYSIS COMPLETE"
echo "=========================================="
echo ""
echo "Detailed reports saved in: $VERIFY_DIR/"
echo "Summary report: $REPORT_FILE"
echo ""
# Recommendation
if [ $quick_status -eq 1 ]; then
print_error "RECOMMENDATION: Recapture handshakes before cracking"
else
print_success "RECOMMENDATION: Proceed with cracking"
print_info "Run: ./auto_crack.sh or place files in input/ and run main script"
fi
echo ""
print_info "Next: Files with valid handshakes will be automatically converted"
print_info " during the cracking workflow."
}
# Run main function
main "$@"