#!/bin/bash TOOLS_DIR="tools" declare -A tool_scripts declare -A tool_outputs domain="" # Load tool scripts and previous outputs index=1 for tool_script in $(ls "$TOOLS_DIR"/*.sh); do source "$tool_script" tool_name=$(get_tool_name) tool_scripts["$index"]=$tool_script tool_outputs["$index"]="${tool_outputs["$index"]}" index=$((index + 1)) done while true; do if [ -z "$domain" ]; then echo "[D] Add domain or file of domains" echo "[Q] Exit and Print Output" read -p "Enter an option (D/Q): " choice else echo "[T] Choose a tool to execute" echo "[A] Run all tests" echo "[Q] Exit and Print Output" read -p "Enter an option (T/A/Q): " choice fi if [ "$choice" == "D" ] || [ "$choice" == "d" ]; then echo "Choose an option to load domains:" echo "[1] Load domains from domains.txt" echo "[2] Load a single domain" read -p "Enter the number of the option: " load_choice if [ "$load_choice" -eq 1 ]; then if [ -f "domains.txt" ]; then read -p "Do you want to load domains from domains.txt? (y/n): " confirm if [ "$confirm" == "y" ]; then domain=$(cat "domains.txt") echo "Loaded domains from domains.txt." fi else read -p "Enter the path to the domains.txt file: " domains_file if [ -f "$domains_file" ]; then domain=$(cat "$domains_file") echo "Loaded domains from $domains_file." else echo "File not found: $domains_file" fi fi elif [ "$load_choice" -eq 2 ]; then read -p "Enter a single domain: " single_domain domain="$single_domain" echo "Added single domain: $domain" else echo "Invalid option: $load_choice" fi elif [ "$choice" == "T" ] || [ "$choice" == "t" ]; then if [ -z "$domain" ]; then echo "No domain loaded. Please load a domain first." else echo "Available tools:" for number in $(seq 1 ${#tool_scripts[@]}); do source "${tool_scripts[$number]}" tool_name=$(get_tool_name) echo "[$number] $tool_name" done read -p "Enter the number of the tool to execute: " tool_choice if [[ "$tool_choice" =~ ^[0-9]+$ ]] && [ "${tool_scripts[$tool_choice]}" ]; then selected_script="${tool_scripts[$tool_choice]}" source "$selected_script" tool_output=$(execute_tool) tool_outputs["$tool_choice"]="$tool_output" echo "Tool $tool_choice executed." else echo "Invalid tool number: $tool_choice" fi fi elif [ "$choice" == "A" ] || [ "$choice" == "a" ]; then if [ -z "$domain" ]; then echo "No domain loaded. Please load a domain first." else for number in $(seq 1 ${#tool_scripts[@]}); do if [ "${tool_scripts[$number]}" ]; then selected_script="${tool_scripts[$number]}" source "$selected_script" tool_output=$(execute_tool) tool_outputs["$number"]="$tool_output" echo "Tool $number executed." fi done echo -e "\nAll tests executed." fi elif [ "$choice" == "Q" ] || [ "$choice" == "q" ]; then has_output=false for number in $(seq 1 ${#tool_scripts[@]}); do if [ "${tool_outputs["$number"]}" ]; then has_output=true break fi done if [ "$has_output" = true ]; then echo -e "\nResults:" for number in $(seq 1 ${#tool_scripts[@]}); do if [ "${tool_outputs["$number"]}" ]; then echo "Tool $number Output:" echo -e "${tool_outputs["$number"]}" echo "------------------------------------" fi done else echo "No output available." fi exit else echo "Invalid input." fi done