Guest User

Untitled

a guest
May 28th, 2026
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.41 KB | Source Code | 0 0
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3.  
  4. URL="${1:-https://yourforum.com/}"
  5. REQUESTS="${REQUESTS:-15}"
  6. SLEEP_SECONDS="${SLEEP_SECONDS:-0.4}"
  7.  
  8. OUT_DIR="./botguard-diagnose-fixed-$(date +%Y%m%d-%H%M%S)"
  9. mkdir -p "$OUT_DIR"
  10.  
  11. RED=$'\033[31m'
  12. GREEN=$'\033[32m'
  13. YELLOW=$'\033[33m'
  14. BOLD=$'\033[1m'
  15. RESET=$'\033[0m'
  16.  
  17. make_test_url() {
  18.     local base="$1"
  19.     local n="$2"
  20.     local mode="$3"
  21.     local sep="?"
  22.  
  23.     [[ "$base" == *"?"* ]] && sep="&"
  24.     printf '%s%sbg_diag_fixed=%s_%s_%s' "$base" "$sep" "$mode" "$(date +%s%N)" "$n"
  25. }
  26.  
  27. is_challenge() {
  28.     local body="$1"
  29.     local headers="$2"
  30.     local effective="$3"
  31.  
  32.     grep -Fqi "Before continuing, please complete the verification check." "$body" && return 0
  33.     grep -Fqi "bot-guard/solve" "$body" && return 0
  34.     grep -Fqi "Verification required" "$body" && return 0
  35.     grep -Eiq '^location: .*/bot-guard([/?#]|$)' "$headers" && return 0
  36.     [[ "$effective" =~ /bot-guard([/?#]|$) ]] && return 0
  37.  
  38.     return 1
  39. }
  40.  
  41. run_mode() {
  42.     local mode="$1"
  43.     local cookie_args=()
  44.     local jar="$OUT_DIR/${mode}-cookies.txt"
  45.  
  46.     if [[ "$mode" == "sticky" ]]; then
  47.         cookie_args=(-c "$jar" -b "$jar")
  48.     fi
  49.  
  50.     echo
  51.     echo "${BOLD}=== Mode: $mode ===${RESET}"
  52.  
  53.     for i in $(seq 1 "$REQUESTS"); do
  54.         local body="$OUT_DIR/${mode}-body-$i.html"
  55.         local headers="$OUT_DIR/${mode}-headers-$i.txt"
  56.         local test_url
  57.         test_url="$(make_test_url "$URL" "$i" "$mode")"
  58.  
  59.         local meta
  60.         meta="$(
  61.            curl -sS -L \
  62.                --compressed \
  63.                --max-redirs 5 \
  64.                --connect-timeout 10 \
  65.                --max-time 30 \
  66.                -A "curl-botguard-fixed/1.0 no-js mode-${mode}" \
  67.                -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" \
  68.                -H "Cache-Control: no-cache" \
  69.                -H "Pragma: no-cache" \
  70.                "${cookie_args[@]}" \
  71.                -D "$headers" \
  72.                -o "$body" \
  73.                -w "http=%{http_code} redirects=%{num_redirects} effective=%{url_effective}" \
  74.                "$test_url" 2>&1 || true
  75.        )"
  76.  
  77.         local effective
  78.         effective="$(sed -n 's/.*effective=//p' <<< "$meta")"
  79.  
  80.         if is_challenge "$body" "$headers" "$effective"; then
  81.             echo "${RED}${BOLD}[$mode request $i] REAL CHALLENGE DETECTED${RESET} — $meta"
  82.             echo "Body:    $body"
  83.             echo "Headers: $headers"
  84.             return 0
  85.         fi
  86.  
  87.         local js="no"
  88.         grep -Eqi 'bot-guard/collect|ZeeBotGuardConfig|botguard\.js|zee/botguard' "$body" && js="yes"
  89.  
  90.         echo "${YELLOW}[$mode request $i] no real challenge${RESET} — $meta — normal_botguard_js=$js"
  91.         sleep "$SLEEP_SECONDS"
  92.     done
  93.  
  94.     echo "${RED}${BOLD}[$mode] no real challenge after $REQUESTS requests${RESET}"
  95.     return 1
  96. }
  97.  
  98. echo "${BOLD}Bot Guard corrected curl diagnostic${RESET}"
  99. echo "URL: $URL"
  100. echo "Output: $OUT_DIR"
  101.  
  102. set +e
  103. run_mode "stateless"
  104. STATELESS=$?
  105.  
  106. run_mode "sticky"
  107. STICKY=$?
  108. set -e
  109.  
  110. echo
  111. echo "${BOLD}=== Result ===${RESET}"
  112.  
  113. if [[ "$STATELESS" -eq 0 || "$STICKY" -eq 0 ]]; then
  114.     echo "${GREEN}A real CAPTCHA/Bot Guard challenge was detected.${RESET}"
  115. else
  116.     echo "${RED}No real CAPTCHA/Bot Guard challenge detected.${RESET}"
  117.     echo "If Bot Guard is enabled and this route is protected, that still needs investigation."
  118. fi
Advertisement
Add Comment
Please, Sign In to add comment