#!/usr/bin/env bash # Confirm 429 is counted as throttling, not as malicious traffic. set -uo pipefail ENTRY="${1:-ipdduiyy}" BASE="http://127.0.0.1:8888/$ENTRY" PASS=$(awk -F': ' '/^password:/{print $2}' /www/server/panel/data/initial_password.txt) ORIGIN="http://127.0.0.1:8888" curl -s -c /tmp/ck.txt -H 'Content-Type: application/json' -H "Origin: $ORIGIN" \ -d "{\"username\":\"admin\",\"password\":\"$PASS\"}" "$BASE/api/v1/auth/login" >/dev/null before=$(curl -s -b /tmp/ck.txt "$BASE/api/v1/waf/overview") echo "before: $(echo "$before" | python3 -c "import json,sys;d=json.load(sys.stdin)['data'];print('req',d['requests'],'blocked',d['blocked'],'throttled',d['throttled'])")" seq 1 400 | xargs -P 40 -I{} curl -s -o /dev/null -H 'Host: demo.test' "http://127.0.0.1/t{}" sleep 7 after=$(curl -s -b /tmp/ck.txt "$BASE/api/v1/waf/overview") echo "after: $(echo "$after" | python3 -c "import json,sys;d=json.load(sys.stdin)['data'];print('req',d['requests'],'blocked',d['blocked'],'throttled',d['throttled'])")" echo "events:" curl -s -b /tmp/ck.txt "$BASE/api/v1/waf/events?limit=5" | python3 -c " import json,sys for e in json.load(sys.stdin)['data'][:5]: print(' ', e['status'], e['rule'], e['uri'][:30])"