#!/bin/bash
cd /root/recon
# real F5 = sig f5 + server header BigIP, junk-filtered
awk -F'\t' '{n=gsub(/,/,",",$5)} index($5,"f5")>0 && n<4 && tolower($3) ~ /bigip/ {print $1}' hitsB.tsv | sort -u > f5_real.txt
wc -l f5_real.txt
chk() {
  h=$1
  out=$(curl -sk -m 8 -A 'Mozilla/5.0' -o /tmp/f5c_$h.txt -w '%{http_code}' "https://$h/f5-oauth2/v1/userinfo" 2>/dev/null)
  body=$(head -c 90 /tmp/f5c_$h.txt 2>/dev/null | tr '\n' ' ')
  { [ "$out" != "000" ] && [ "$out" != "404" ]; } && echo "$h $out $body"
  rm -f /tmp/f5c_$h.txt
}
export -f chk
cat f5_real.txt | xargs -P24 -I{} bash -c 'chk {}' > f5_ui2.txt 2>&1
echo "candidates(non-404): $(wc -l < f5_ui2.txt)"
grep -ai 'oauth\|invalid_request\|access_token\|{"error"' f5_ui2.txt | head -20
echo F5DONE
