#!/bin/bash
# Mass light check: does /f5-oauth2/v1/userinfo exist on alive F5 hosts?
# Presence of OAuth error JSON => OAuth Authorization Server configured => CVE-2026-94127 config candidate
cd /root/recon
chk() {
  h=$1
  out=$(curl -sk -m 8 -A 'Mozilla/5.0' -o /tmp/f5_$h.txt -w '%{http_code}' "https://$h/f5-oauth2/v1/userinfo" 2>/dev/null)
  body=$(head -c 80 /tmp/f5_$h.txt 2>/dev/null | tr '\n' ' ')
  [ "$out" != "000" ] && [ -n "$body" ] && echo "$h $out $body"
  rm -f /tmp/f5_$h.txt
}
export -f chk
awk '{print $1}' f5_resp.tsv | xargs -P16 -I{} bash -c 'chk {}' | tee f5_userinfo_hits.txt
echo "done; candidates: $(wc -l < f5_userinfo_hits.txt)"
