#!/bin/bash
# RTExit — Tool Verification Script
# Checks all tools referenced in RTExit skills are installed

RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'

PASS=0
FAIL=0
WARN=0

check() {
    local name="$1"
    local cmd="$2"
    if command -v "$cmd" &>/dev/null 2>&1; then
        echo -e "  ${GREEN}✓${NC} $name"
        ((PASS++))
    else
        echo -e "  ${RED}✗${NC} $name"
        ((FAIL++))
    fi
}

check_path() {
    local name="$1"
    local path="$2"
    if [ -f "$path" ] || [ -d "$path" ]; then
        echo -e "  ${GREEN}✓${NC} $name"
        ((PASS++))
    else
        echo -e "  ${RED}✗${NC} $name"
        ((FAIL++))
    fi
}

check_python() {
    local name="$1"
    local module="$2"
    if python3 -c "import $module" &>/dev/null 2>&1; then
        echo -e "  ${GREEN}✓${NC} $name"
        ((PASS++))
    else
        echo -e "  ${YELLOW}⚠${NC} $name — optional"
        ((WARN++))
    fi
}

echo ""
echo "═══════════════════════════════════════════"
echo "        RTExit Tool Verification v3.0"
echo "═══════════════════════════════════════════"

# ── RECON & OSINT ─────────────────────────────
echo ""
echo -e "${BLUE}[ RECON & OSINT ]${NC}"
check "nmap" "nmap"
check "masscan" "masscan"
check "subfinder" "subfinder"
check "amass" "amass"
check "httpx" "httpx"
check "nuclei" "nuclei"
check "ffuf" "ffuf"
check "gobuster" "gobuster"
check "theHarvester" "theHarvester"
check "shodan" "shodan"
check "gau" "gau"
check "waybackurls" "waybackurls"
check "gowitness" "gowitness"
check "gitleaks" "gitleaks"
check "recon-ng" "recon-ng"
check "fierce" "fierce"
check "dnsrecon" "dnsrecon"
check "dnsenum" "dnsenum"
check "nbtscan" "nbtscan"
check "smbmap" "smbmap"
check "enum4linux" "enum4linux"
check_python "enum4linux-ng" "enum4linux_ng"
check_python "maigret" "maigret"
check_python "holehe" "holehe"
check_python "ghunt" "ghunt"
check_python "spiderfoot" "sflib"
check "h8mail" "h8mail"
check "crosslinked" "crosslinked"

# ── WEB APPLICATION ───────────────────────────
echo ""
echo -e "${BLUE}[ WEB APPLICATION ]${NC}"
check "sqlmap" "sqlmap"
check "ghauri" "ghauri"
check "dalfox" "dalfox"
check "nikto" "nikto"
check "wfuzz" "wfuzz"
check "whatweb" "whatweb"
check "wafw00f" "wafw00f"
check "testssl.sh" "testssl.sh"
check "mitmproxy" "mitmproxy"
check "arjun" "arjun"
check "x8" "x8"
check "smuggler" "smuggler"
check "jwt_tool" "jwt_tool"
check "grpcurl" "grpcurl"
check_python "graphw00f" "graphw00f"
check_python "clairvoyance" "clairvoyance"
check "zap" "zap"
check "interactsh-client" "interactsh-client"

# ── ACTIVE DIRECTORY ──────────────────────────
echo ""
echo -e "${BLUE}[ ACTIVE DIRECTORY ]${NC}"
check "impacket-psexec" "impacket-psexec"
check "impacket-secretsdump" "impacket-secretsdump"
check "impacket-GetUserSPNs" "impacket-GetUserSPNs"
check "impacket-GetNPUsers" "impacket-GetNPUsers"
check "certipy" "certipy"
check "evil-winrm" "evil-winrm"
check "bloodhound-python" "bloodhound-python"
check "kerbrute" "kerbrute"
check "netexec" "netexec"
check "responder" "responder"
check "mitm6" "mitm6"
check "coercer" "coercer"
check "pyrdp-mitm" "pyrdp-mitm"
check_python "donpapi" "DonPAPI"
check_path "NoPac" "/opt/noPac"
check_path "PKINITtools" "/opt/PKINITtools"
check_path "PetitPotam" "/opt/PetitPotam"

# ── CLOUD ─────────────────────────────────────
echo ""
echo -e "${BLUE}[ CLOUD ]${NC}"
check "aws" "aws"
check "kubectl" "kubectl"
check "pacu" "pacu"
check "roadrecon" "roadrecon"
check "pmapper" "pmapper"
check "prowler" "prowler"
check "stratus" "stratus"
check "teamfiltration" "teamfiltration"
check_python "scoutsuite" "ScoutSuite"
check "kube-hunter" "kube-hunter"
check "cloudlist" "cloudlist"
check "mapcidr" "mapcidr"

# ── PASSWORD & HASHES ─────────────────────────
echo ""
echo -e "${BLUE}[ PASSWORD & HASHES ]${NC}"
check "hashcat" "hashcat"
check "john" "john"
check "hydra" "hydra"
check "medusa" "medusa"
check "cewl" "cewl"
check "crunch" "crunch"
check "cupp" "cupp"
check "pypykatz" "pypykatz"
check_python "patator" "patator"
check "onesixtyone" "onesixtyone"

# ── POST-EXPLOITATION & C2 ────────────────────
echo ""
echo -e "${BLUE}[ POST-EXPLOITATION & C2 ]${NC}"
check "msfconsole" "msfconsole"
check "sliver-client" "sliver-client"
check "chisel" "chisel"
check "ligolo-proxy" "ligolo-proxy"
check "socat" "socat"
check "iodine" "iodine"
check_path "Empire" "/opt/Empire"
check_path "Villain" "/opt/Villain"
check_path "PoshC2" "/opt/PoshC2"
check_path "Atomic Red Team" "/opt/atomic-red-team/atomics"
check_path "Caldera" "/opt/caldera"

# ── NETWORK ───────────────────────────────────
echo ""
echo -e "${BLUE}[ NETWORK ]${NC}"
check "tcpdump" "tcpdump"
check "tshark" "tshark"
check "bettercap" "bettercap"
check "ettercap" "ettercap"
check "dsniff" "dsniff"
check "arpwatch" "arpwatch"
check "netsniff-ng" "netsniff-ng"
check "hping3" "hping3"
check "proxychains4" "proxychains4"
check "macchanger" "macchanger"
check "sslstrip" "sslstrip"

# ── EXPLOITATION ──────────────────────────────
echo ""
echo -e "${BLUE}[ EXPLOITATION ]${NC}"
check "searchsploit" "searchsploit"
check "phpggc" "phpggc"
check "beef-xss" "beef-xss"
check_path "SET" "/opt/setoolkit"
check "gophish" "gophish"
check_path "routersploit" "/opt/routersploit"
check "weevely" "weevely"
check_python "king-phisher" "king_phisher"

# ── BINARY ANALYSIS & RE ──────────────────────
echo ""
echo -e "${BLUE}[ BINARY ANALYSIS & REVERSE ENGINEERING ]${NC}"
check "gdb" "gdb"
check "radare2" "r2"
check "ghidra" "ghidra"
check "binwalk" "binwalk"
check "strings" "strings"
check "ltrace" "ltrace"
check "strace" "strace"
check "pwntools" "pwn"
check "floss" "floss"
check "objdump" "objdump"

# ── FUZZING ───────────────────────────────────
echo ""
echo -e "${BLUE}[ FUZZING ]${NC}"
check "afl-fuzz" "afl-fuzz"
check "radamsa" "radamsa"
check_python "boofuzz" "boofuzz"

# ── FORENSICS ─────────────────────────────────
echo ""
echo -e "${BLUE}[ FORENSICS ]${NC}"
check "foremost" "foremost"
check "dc3dd" "dc3dd"
check "testdisk" "testdisk"
check "bulk_extractor" "bulk_extractor"
check "exiftool" "exiftool"
check "vol" "vol"
check_path "volatility3" "/opt/volatility3"

# ── STEGANOGRAPHY ─────────────────────────────
echo ""
echo -e "${BLUE}[ STEGANOGRAPHY ]${NC}"
check "steghide" "steghide"
check "zsteg" "zsteg"
check "stegsolve" "stegsolve"
check "binwalk" "binwalk"
check "exiftool" "exiftool"
check_python "stegoveritas" "stegoveritas"

# ── MOBILE ────────────────────────────────────
echo ""
echo -e "${BLUE}[ MOBILE ]${NC}"
check "apktool" "apktool"
check "jadx" "jadx"
check "frida" "frida"
check "objection" "objection"
check "apkleaks" "apkleaks"
check "dex2jar" "dex2jar"
check_python "drozer" "drozer"
check "adb" "adb"
check "peirates" "peirates"
check "ScareCrow" "ScareCrow"
check "adb" "adb"

# ── CONTAINER & KUBERNETES ────────────────────
echo ""
echo -e "${BLUE}[ CONTAINER & KUBERNETES ]${NC}"
check "cdk" "cdk"
check "deepce" "deepce"
check "botb" "botb"
check "trivy" "trivy"
check "dive" "dive"
check "kubectl" "kubectl"
check "kube-hunter" "kube-hunter"
check_path "peirates" "/opt/peirates"

# ── EVASION & PAYLOAD GENERATION ─────────────
echo ""
echo -e "${BLUE}[ EVASION & PAYLOAD GENERATION ]${NC}"
check_path "Veil" "/opt/Veil"
check_path "macro_pack" "/opt/macro_pack"
check_path "Donut" "/opt/godonuts"
check_path "ScareCrow" "/opt/ScareCrow"
check "msfvenom" "msfvenom"
check_path "electronegativity" "/usr/local/bin/electronegativity"

# ── AI/LLM SECURITY ───────────────────────────
echo ""
echo -e "${BLUE}[ AI/LLM SECURITY ]${NC}"
check_python "garak" "garak"
check "promptfoo" "promptfoo"

# ── VOIP & HARDWARE ───────────────────────────
echo ""
echo -e "${BLUE}[ VOIP & HARDWARE/IOT ]${NC}"
check_path "sipvicious" "/opt/sipvicious"
check "rtpbreak" "rtpbreak"
check "pjsua" "pjsua"
check "openocd" "openocd"
check "flashrom" "flashrom"
check "avrdude" "avrdude"
check_path "ucsniff" "/opt/ucsniff"

# ── OSINT SPECIALIZED ─────────────────────────
echo ""
echo -e "${BLUE}[ OSINT SPECIALIZED ]${NC}"
check "interactsh-client" "interactsh-client"
check "chaos" "chaos"
check "cloudlist" "cloudlist"
check_python "h8mail" "h8mail"

# ── SUMMARY ───────────────────────────────────
echo ""
echo "═══════════════════════════════════════════"
echo -e "  ${GREEN}✓ Passed: $PASS${NC}  |  ${RED}✗ Failed: $FAIL${NC}  |  ${YELLOW}⚠ Warnings: $WARN${NC}"
TOTAL=$((PASS + FAIL))
PCT=$((PASS * 100 / TOTAL))
echo -e "  Coverage: ${GREEN}$PCT%${NC} ($PASS/$TOTAL tools)"
echo "═══════════════════════════════════════════"
echo ""

if [ $FAIL -gt 0 ]; then
    echo -e "${YELLOW}Tip: Some tools install on first use. Run: apt-get install <tool> or pip3 install <tool>${NC}"
fi
