#!/bin/bash
echo "=== IIS 8.5 + La Pradera + Marina Deep Probe ==="
echo "Started: $(date)"

# VUCE IIS 8.5 deeper
echo "========== vuceregulaciones-admin.mincex.gob.cu =========="
echo "--- More IIS paths ---"
for path in "/web.config" "/elmah.axd" "/trace.axd" "/iisstart.htm" "/aspnet_client/" "/Scripts/" "/Content/" "/bundles/" "/App_Data/" "/bin/" "/Views/" "/Areas/" "/api/" "/api/values" "/api/account" "/api/token" "/odata/" "/signalr/" "/signalr/hubs" "/_layouts/" "/webresource.axd" "/scriptresource.axd" "/handler.ashx" "/WebResource.axd" "/favicon.ico" "/Error.aspx" "/Login.aspx" "/Account/Login" "/Account/Register" "/Home/" "/Admin/" "/swagger/"; do
  status=$(proxychains4 -q curl -ks -o /dev/null -w "%{http_code}|%{size_download}|%{content_type}" --connect-timeout 10 -m 15 "https://vuceregulaciones-admin.mincex.gob.cu${path}" 2>/dev/null)
  code=$(echo $status | cut -d'|' -f1)
  size=$(echo $status | cut -d'|' -f2)
  ctype=$(echo $status | cut -d'|' -f3)
  if [ "$code" != "000" ]; then
    echo "  [$code] $path (${size}B) $ctype"
  fi
done

echo ""
echo "--- Login page full content ---"
proxychains4 -q curl -ks --connect-timeout 15 -m 30 "https://vuceregulaciones-admin.mincex.gob.cu/Default.aspx?ReturnUrl=%2f" 2>/dev/null | head -c 3000
echo ""

# Try HTTP (might bypass some restrictions)
echo ""
echo "--- HTTP check ---"
proxychains4 -q curl -ksI --connect-timeout 10 -m 15 "http://vuceregulaciones-admin.mincex.gob.cu/" 2>/dev/null | head -10

# CIS La Pradera medical tourism
echo ""
echo "========== cislapradera.com Deep =========="
echo "--- Subdomains ---"
for sub in "api" "admin" "booking" "reservas" "mail" "webmail" "portal" "pacientes" "patients" "medicos" "doctors" "consulta" "citas"; do
  status=$(proxychains4 -q curl -ks -o /dev/null -w "%{http_code}|%{size_download}" --connect-timeout 8 -m 12 "https://${sub}.cislapradera.com/" 2>/dev/null)
  code=$(echo $status | cut -d'|' -f1)
  if [ "$code" != "000" ]; then
    echo "  [$code] ${sub}.cislapradera.com"
  fi
done

echo ""
echo "--- Main site paths ---"
for path in "/api" "/api/v1" "/services" "/treatments" "/doctors" "/contact" "/prices" "/booking" "/login" "/admin" "/portal" "/robots.txt" "/sitemap.xml" "/.well-known/"; do
  status=$(proxychains4 -q curl -ks -o /dev/null -w "%{http_code}|%{size_download}" --connect-timeout 8 -m 12 "https://www.cislapradera.com${path}" 2>/dev/null)
  code=$(echo $status | cut -d'|' -f1)
  size=$(echo $status | cut -d'|' -f2)
  if [ "$code" != "000" ] && [ "$code" != "404" ]; then
    echo "  [$code] $path (${size}B)"
  fi
done

# Marinas Gaviota
echo ""
echo "========== marinasgaviotasa.com Deep =========="
echo "--- Subdomains ---"
for sub in "api" "apihoteles" "apitransfer" "admin" "booking" "reservas" "mail" "cdn"; do
  status=$(proxychains4 -q curl -ks -o /dev/null -w "%{http_code}|%{size_download}" --connect-timeout 8 -m 12 "https://${sub}.marinasgaviotasa.com/" 2>/dev/null)
  code=$(echo $status | cut -d'|' -f1)
  size=$(echo $status | cut -d'|' -f2)
  if [ "$code" != "000" ]; then
    echo "  [$code] ${sub}.marinasgaviotasa.com (${size}B)"
  fi
done

echo ""
echo "--- JS bundle analysis ---"
html=$(proxychains4 -q curl -ks --connect-timeout 15 -m 30 "https://www.marinasgaviotasa.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 60 "https://www.marinasgaviotasa.com/${mainjs}" > /tmp/marinas-main.js 2>/dev/null
  echo "Size: $(wc -c < /tmp/marinas-main.js) bytes"
  echo "--- API URLs ---"
  grep -oP 'https?://[a-zA-Z0-9._/-]+' /tmp/marinas-main.js | sort -u
fi

# Gaviota-grupo.com Drupal deeper
echo ""
echo "========== gaviota-grupo.com Drupal =========="
for path in "/user/login" "/user/1" "/admin" "/node/1" "/node/2" "/node/3" "/rss.xml" "/robots.txt" "/CHANGELOG.txt" "/update.php" "/install.php" "/sites/default/files/" "/misc/drupal.js" "/modules/" "/profiles/" "/includes/" "/xmlrpc.php" "/?q=user" "/?q=admin"; do
  status=$(proxychains4 -q curl -ks -o /dev/null -w "%{http_code}|%{size_download}" --connect-timeout 8 -m 12 "https://www.gaviota-grupo.com${path}" 2>/dev/null)
  code=$(echo $status | cut -d'|' -f1)
  size=$(echo $status | cut -d'|' -f2)
  if [ "$code" != "000" ] && [ "$code" != "404" ]; then
    echo "  [$code] $path (${size}B)"
    if [ "$code" = "200" ] && [ "$size" -lt 3000 ] && [ "$size" -gt 10 ]; then
      proxychains4 -q curl -ks --connect-timeout 8 -m 12 "https://www.gaviota-grupo.com${path}" 2>/dev/null | head -c 300
      echo ""
    fi
  fi
done

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