diff --git a/analyzer b/analyzer index 7426631..59970d0 100755 --- a/analyzer +++ b/analyzer @@ -26,6 +26,7 @@ export REPORTS_DIR="$ANALYZER_DIR/reports" # Source core source "$LIB_DIR/colors.sh" source "$LIB_DIR/utils.sh" +source "$ENGINE_DIR/discovery.sh" source "$ENGINE_DIR/recon.sh" source "$ENGINE_DIR/ollama-brain.sh" source "$ENGINE_DIR/reporter.sh" @@ -58,7 +59,7 @@ interactive_mode() { echo -e " ${GREEN}1${NC}. Quick Scan — Fast recon + auto-vector selection" echo -e " ${GREEN}2${NC}. Deep Scan — Full recon, all vectors, exhaustive" echo -e " ${GREEN}3${NC}. Custom Scan — Pick your own vectors" - echo -e " ${GREEN}4${NC}. List Vectors — Show all 20 attack vectors" + echo -e " ${GREEN}4${NC}. List Vectors — Show all 21 attack vectors" echo -e " ${GREEN}5${NC}. View Reports — Browse past results" echo -e " ${DIM}q${NC}. Quit" echo '' @@ -102,19 +103,23 @@ quick_scan() { echo -e "\n${BRIGHT_CYAN}${BOLD}═══ QUICK SCAN MODE ═══${NC}\n" # Step 1: Check connectivity - print_step 1 4 "Checking target..." + print_step 1 5 "Checking target..." if ! target_alive "$target"; then print_error "Target unreachable!" exit 1 fi print_ok "Target is alive" - # Step 2: Recon - print_step 2 4 "Reconnaissance" + # Step 2: Discovery — find real URLs, forms, params to attack + print_step 2 5 "Discovering attack surface" + discover_target "$target" + + # Step 3: Recon + print_step 3 5 "Reconnaissance" recon_target "$target" "$report" - # Step 3: Ollama decides - print_step 3 4 "Ollama brain selecting vectors" + # Step 4: Ollama decides + print_step 4 5 "Ollama brain selecting vectors" local decision=$(ollama_decide "$target") echo '' echo -e "${MAGENTA}${ICON_BRAIN} Ollama's Strategy:${NC}" @@ -123,16 +128,16 @@ quick_scan() { local selected=$(parse_decision "$decision") if [ -z "$selected" ]; then - print_warn "Ollama didn't pick specific vectors. Running top 5." - selected="1 2 3 4 5" + print_warn "Ollama didn't pick specific vectors. Running default set." + selected="21 1 2 3 4" # nuclei + sqli + xss + lfi + cmdi fi echo '' print_info "Running vectors: $(echo $selected | tr '\n' ' ')" echo '' - # Step 4: Run vectors - print_step 4 4 "Executing attack vectors" + # Step 5: Run vectors + print_step 5 5 "Executing attack vectors" run_vectors "$target" "$report" $selected # Generate final report @@ -164,8 +169,8 @@ deep_scan() { recon_target "$target" "$report" # Step 3: Run ALL vectors - print_step 3 3 "Running all 20 attack vectors" - local all_vectors=$(seq 1 20 | tr '\n' ' ') + print_step 3 3 "Running all 21 attack vectors" + local all_vectors=$(seq 1 21 | tr '\n' ' ') run_vectors "$target" "$report" $all_vectors # Generate report @@ -257,9 +262,9 @@ run_vectors() { # Map vector names to function names case $num in - 1) func_name="vector_sqli" ;; - 2) func_name="vector_xss" ;; - 3) func_name="vector_lfi" ;; + 1) func_name="vector_sqli_v2" ;; + 2) func_name="vector_xss_v2" ;; + 3) func_name="vector_lfi_v2" ;; 4) func_name="vector_cmdi" ;; 5) func_name="vector_ssrf" ;; 6) func_name="vector_oredir" ;; @@ -277,6 +282,7 @@ run_vectors() { 18) func_name="vector_cors" ;; 19) func_name="vector_race" ;; 20) func_name="vector_nosqli" ;; + 21) func_name="vector_nuclei" ;; esac if declare -f "$func_name" >/dev/null; then diff --git a/engine/discovery.sh b/engine/discovery.sh new file mode 100644 index 0000000..d55a1b5 --- /dev/null +++ b/engine/discovery.sh @@ -0,0 +1,199 @@ +#!/usr/bin/env bash +# The Analyzer v2 — Discovery Engine +# Finds actual URLs, forms, parameters, and endpoints on the target +# This feeds the exploit vectors with real attack surface + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +source "$SCRIPT_DIR/../lib/utils.sh" + +discover_target() { + local target="$1" + local domain=$(get_domain "$target") + local base=$(get_base "$target") + local outfile="$REPORTS_DIR/.${domain}_discovery.txt" + + print_info "Discovering attack surface on $target..." + separator + + local DISCOVERED_URLS="" + local DISCOVERED_FORMS="" + local DISCOVERED_PARAMS="" + local DISCOVERED_ENDPOINTS="" + + # 1. Crawl the homepage for links and forms + print_sub "Crawling homepage for links..." + local page=$(curl -s --connect-timeout 10 --max-time 20 -L "$target" 2>/dev/null) + + if [ -z "$page" ]; then + print_error "Cannot fetch target page" + return 1 + fi + + # Extract all internal links + local links=$(echo "$page" | perl -nle 'while (/href="([^"]+)"/g) { print $1 }' | sort -u) + local internal_links="" + while IFS= read -r link; do + [ -z "$link" ] && continue + # Make absolute + if [[ "$link" == /* ]]; then + link="${base}${link}" + elif [[ "$link" == http* ]]; then + # External link — skip unless same domain + local link_domain=$(echo "$link" | sed 's|https\?://||' | cut -d/ -f1) + [[ "$link_domain" != "$domain" ]] && continue + else + link="${base}/${link}" + fi + internal_links+="$link\n" + DISCOVERED_URLS+="$link\n" + done <<< "$links" + + local url_count=$(echo -e "$DISCOVERED_URLS" | grep -c .) + print_ok "Found $url_count internal URLs" + + # 2. Extract forms + print_sub "Extracting forms..." + local forms=$(echo "$page" | perl -0 -nle 'while (/