#!/bin/bash
cd /root/recon
UA='Mozilla/5.0'
echo '== zimbra versions:'
for ip in 108.21.88.132 12.139.121.106 132.226.186.43 150.136.119.18 150.136.222.120 162.243.167.231 104.207.82.57 131.153.221.142; do
  curl -gsk -m 10 -A "$UA" -o /tmp/vz.html "https://$ip/"
  v=$(grep -aoiE 'ZCS[- ]?[0-9]+\.[0-9]+\.[0-9]+[^"<]{0,15}|version[^"<]{0,30}|/zimbra/css[^"]{0,40}' /tmp/vz.html | head -2 | tr '\n' ' ')
  echo "$ip : $v"
  rm -f /tmp/vz.html
done
echo '== freepbx:'
for ip in 107.174.180.147 64.68.151.86 173.224.79.235; do
  curl -gsk -m 10 -A "$UA" -o /tmp/vp.html "https://$ip/admin/config.php" -w "rc:%{http_code} "
  v=$(grep -aoiE 'FreePBX [0-9]+\.[0-9.]+|version[^"<]{0,20}' /tmp/vp.html | head -2 | tr '\n' ' ')
  echo "$ip : $v"
  rm -f /tmp/vp.html
done
echo '== whd:'
for ip in 100.1.41.243 15.197.216.96; do
  curl -gsk -m 12 -A "$UA" -o /tmp/vw.html "https://$ip/helpdesk/" -w "rc:%{http_code} "
  v=$(grep -aoiE 'Web Help Desk[^"<]{0,20}|[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/vw.html | head -3 | tr '\n' ' ')
  echo "$ip : $v"
  rm -f /tmp/vw.html
done
echo '== craft:'
for ip in 159.65.132.103 64.62.135.64; do
  curl -gsk -m 10 -A "$UA" -o /tmp/vc.html "https://$ip/admin/login" -w "rc:%{http_code} "
  v=$(grep -aoiE 'Craft CMS[^"<]{0,20}|v?[0-9]+\.[0-9]+\.[0-9]+' /tmp/vc.html | head -2 | tr '\n' ' ')
  echo "$ip : $v"
  rm -f /tmp/vc.html
done
echo '== ws1 redirect targets:'
for ip in 155.101.195.81 172.109.213.181 172.65.53.87 192.243.19.181; do
  loc=$(curl -gsk -m 10 -A "$UA" -o /dev/null -w '%{redirect_url}' "https://$ip/")
  echo "$ip -> $loc"
done
echo VPDONE
