#!/bin/bash
set -u
ips=(193.134.75.14 193.134.75.15 193.134.75.119 193.134.75.124 193.134.75.128 193.134.75.129 193.134.75.131 193.134.75.132 193.134.75.133 193.134.75.134 193.134.75.150 193.134.75.151 193.134.75.16 193.134.75.160 193.134.75.161 193.134.75.162 193.134.75.163 193.134.75.18 193.134.75.58 193.134.75.71 193.134.75.72 193.134.75.74 193.134.75.75 193.134.75.77 193.134.75.78 193.134.75.83 193.134.75.84 193.134.75.85 193.134.75.86 193.134.74.102)
for ip in "${ips[@]}"; do
  out=$(curl --toadex-no-capture -sk --http1.1 --path-as-is --connect-timeout 3 --max-time 7 --resolve "va.baloise.de:443:$ip" -H 'X-Bug-Bounty: dwbzn' -D - -o /tmp/vax.$$ "https://va.baloise.de/SASBIWS/services/Version?wsdl" 2>/dev/null || true)
  st=$(printf '%s' "$out" | awk 'toupper($1) ~ /^HTTP\// {s=$2} END{print s}')
  loc=$(printf '%s' "$out" | awk 'BEGIN{IGNORECASE=1} /^location:/{sub(/\r$/,"",$0); print substr($0,index($0,":")+2)}' | tail -1)
  srv=$(printf '%s' "$out" | awk 'BEGIN{IGNORECASE=1} /^server:/{sub(/\r$/,"",$0); print substr($0,index($0,":")+2)}' | tail -1)
  sz=$(wc -c </tmp/vax.$$ 2>/dev/null || echo 0)
  sig=$(grep -aEio 'Axis|SAS|Airlock|Misdirected|no Route matched|Unauthorized|Forbidden|Service' /tmp/vax.$$ 2>/dev/null | head -3 | tr '\n' ',' || true)
  printf '%-16s status=%-4s size=%-6s server=%-16s sig=%-30s loc=%s\n' "$ip" "${st:-ERR}" "$sz" "$srv" "$sig" "$loc"
done
rm -f /tmp/vax.$$
