AUTONOMY DIRECTORATE

๐Ÿ  Main

๐Ÿงช Interactive Apps

๐Ÿ“ฐ News

๐Ÿ›ก๏ธ PQ Crypta Proxy

๐Ÿ‘ค Account

โŸจ QUANTUM ERROR PORTAL โŸฉ

Navigate the Error Dimensions

PQ Crypta Logo

Script Viewer

Red Team Suite › 04_rate_limit.sh

04_rate_limit.sh 33 lines
1 #!/bin/bash
2 # Rate limiting test - burst requests to trigger throttle
3 SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4 source "$SCRIPT_DIR/../config.sh"
5 OUT="$OUT/rate_limit"
6 mkdir -p "$OUT"
7
8 echo '=== RATE LIMITING TESTS ===' | tee "$OUT/summary.txt"
9 echo 'Sending 40 rapid requests to / ...' | tee -a "$OUT/summary.txt"
10
11 declare -A counts
12 for i in $(seq 1 40); do
13 code=$(curl -sk -o /dev/null -w '%{http_code}' --max-time 5 "$TARGET/")
14 counts[$code]=$(( ${counts[$code]:-0} + 1 ))
15 done
16
17 for code in "${!counts[@]}"; do
18 echo " HTTP $code: ${counts[$code]} times" | tee -a "$OUT/summary.txt"
19 done
20
21 echo '' | tee -a "$OUT/summary.txt"
22 echo 'Sending 20 rapid POST to API /encrypt ...' | tee -a "$OUT/summary.txt"
23 declare -A acounts
24 for i in $(seq 1 20); do
25 code=$(curl -sk -o /dev/null -w '%{http_code}' --max-time 5 -X POST -H 'Content-Type: application/json' -d '{"data":"test","algorithm":"classical"}' "$API_TARGET/encrypt")
26 acounts[$code]=$(( ${acounts[$code]:-0} + 1 ))
27 done
28 for code in "${!acounts[@]}"; do
29 echo " HTTP $code: ${acounts[$code]} times" | tee -a "$OUT/summary.txt"
30 done
31
32 cat "$OUT/summary.txt"
33