#!/bin/bash # Set this variable to "true" to enable debug mode DEBUG_MODE="false" get_tool_name() { echo "HTTP Status Check" } get_tool_description() { echo "Check HTTP and HTTPS status of a domain" } execute_tool() { result="" if [ -n "$domain" ]; then if [[ "$domain" == *$'\n'* ]]; then for single_domain in $domain; do process_domain "$single_domain" done else process_domain "$domain" fi else result="No domains specified." fi echo -e "$result" } process_domain() { local single_domain="$1" result+="\e[1mDomain:\e[0m $single_domain\n" http_response=$(curl -sIL --max-time 10 "http://$single_domain" | grep -i "HTTP/1.1") if [ -n "$http_response" ]; then result+="\e[1mHTTP:\e[0m \e[32mPass\e[0m\n" else https_response=$(curl -sIL --max-time 10 "https://$single_domain" | grep -i "HTTP/1.1") if [ -n "$https_response" ]; then if [[ "$https_response" == *"301 Moved Permanently"* ]]; then https_redirect=$(echo "$https_response" | awk '{print $3}') https_status=$(curl -sIL --max-time 10 "$https_redirect" | grep -i "HTTP/1.1") if [ -n "$https_status" ] && [[ "$https_status" == *"200 OK"* ]]; then result+="\e[1mHTTP/HTTPS:\e[0m \e[32mhttps forced\e[0m\n" else result+="\e[1mHTTP/HTTPS:\e[0m \e[31mhttps not forced\e[0m\n" fi else result+="\e[1mHTTP/HTTPS:\e[0m \e[31mhttps failed\e[0m\n" fi else result+="\e[1mHTTP/HTTPS:\e[0m \e[31mFailed\e[0m\n" fi fi if [ "$DEBUG_MODE" == "true" ]; then echo -e "\n\e[1mDebug Info:\e[0m" curl -IL --max-time 10 "http://$single_domain" fi }