first commit
This commit is contained in:
156
scripts/build_wordlist.sh
Normal file
156
scripts/build_wordlist.sh
Normal 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
294
scripts/crack_pipeline.sh
Normal 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 "$@"
|
||||
358
scripts/verify_handshakes.sh
Normal file
358
scripts/verify_handshakes.sh
Normal 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 "$@"
|
||||
Reference in New Issue
Block a user