#!/bin/bash
echo "=== Guajiritos Network - Extended Domain Probe ==="
echo "Started: $(date)"

# New domains from SSL SAN
domains=(
  "marinasmarlin.com"
  "feriascuba.com"
  "tradicionalesdelos50.com"
  "gracielatravel.com"
  "wetransp.com"
  "guajitech.com"
  "elguajirito.com"
  "guajirito.com"
  "grupoelguajirito.com"
  "legendariosdelguajirito.com"
  "agenciaparadiso.com"
)

for domain in "${domains[@]}"; do
  echo ""
  echo "========== $domain =========="

  # DNS
  dig +short "$domain" A 2>/dev/null | head -3
  dig +short "www.$domain" A 2>/dev/null | head -3

  # Main site
  echo "--- www ---"
  status=$(proxychains4 -q curl -ks -o /dev/null -w "%{http_code}|%{size_download}" --connect-timeout 10 -m 20 "https://www.$domain/" 2>/dev/null)
  code=$(echo $status | cut -d'|' -f1)
  size=$(echo $status | cut -d'|' -f2)
  echo "  [$code] www.$domain (${size}B)"
  if [ "$code" = "200" ]; then
    title=$(proxychains4 -q curl -ks --connect-timeout 10 -m 20 "https://www.$domain/" 2>/dev/null | grep -oP '<title>[^<]+</title>' | head -1)
    echo "  Title: $title"
  fi

  # Key subdomains
  for sub in "api" "admin" "apihoteles" "apitransfer" "apiautos" "apiexperiencias" "apiseg" "apicustom" "cdn" "mail" "booking"; do
    status=$(proxychains4 -q curl -ks -o /dev/null -w "%{http_code}|%{size_download}" --connect-timeout 6 -m 10 "https://${sub}.${domain}/" 2>/dev/null)
    code=$(echo $status | cut -d'|' -f1)
    size=$(echo $status | cut -d'|' -f2)
    if [ "$code" != "000" ]; then
      echo "  [$code] ${sub}.${domain} (${size}B)"
      if [ "$code" = "200" ] && [ "$size" -lt 200 ]; then
        proxychains4 -q curl -ks --connect-timeout 6 -m 10 "https://${sub}.${domain}/" 2>/dev/null | head -c 200
        echo ""
      fi
    fi
  done
done

# Dump Marinas Marlin more deeply if found
echo ""
echo "========== Marinas Marlin Deep =========="
status=$(proxychains4 -q curl -ks -o /dev/null -w "%{http_code}|%{size_download}" --connect-timeout 10 -m 20 "https://www.marinasmarlin.com/" 2>/dev/null)
code=$(echo $status | cut -d'|' -f1)
if [ "$code" = "200" ]; then
  echo "Site is UP"
  proxychains4 -q curl -ks --connect-timeout 10 -m 20 "https://www.marinasmarlin.com/" 2>/dev/null | head -c 500
  echo ""
  # JS analysis
  html=$(proxychains4 -q curl -ks --connect-timeout 15 -m 30 "https://www.marinasmarlin.com/" 2>/dev/null)
  mainjs=$(echo "$html" | grep -oP 'src="([^"]*main[^"]*\.js)"' | head -1 | grep -oP '"[^"]*"' | tr -d '"')
  if [ -n "$mainjs" ]; then
    echo "Main JS: $mainjs"
    proxychains4 -q curl -ks --connect-timeout 15 -m 30 "https://www.marinasmarlin.com/${mainjs}" 2>/dev/null | grep -oP 'https?://[a-zA-Z0-9._/-]+' | sort -u
  fi
fi

echo ""
echo "Completed: $(date)"
