Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- set -euo pipefail
- URL="${1:-https://yourforum.com/}"
- REQUESTS="${REQUESTS:-15}"
- SLEEP_SECONDS="${SLEEP_SECONDS:-0.4}"
- OUT_DIR="./botguard-diagnose-fixed-$(date +%Y%m%d-%H%M%S)"
- mkdir -p "$OUT_DIR"
- RED=$'\033[31m'
- GREEN=$'\033[32m'
- YELLOW=$'\033[33m'
- BOLD=$'\033[1m'
- RESET=$'\033[0m'
- make_test_url() {
- local base="$1"
- local n="$2"
- local mode="$3"
- local sep="?"
- [[ "$base" == *"?"* ]] && sep="&"
- printf '%s%sbg_diag_fixed=%s_%s_%s' "$base" "$sep" "$mode" "$(date +%s%N)" "$n"
- }
- is_challenge() {
- local body="$1"
- local headers="$2"
- local effective="$3"
- grep -Fqi "Before continuing, please complete the verification check." "$body" && return 0
- grep -Fqi "bot-guard/solve" "$body" && return 0
- grep -Fqi "Verification required" "$body" && return 0
- grep -Eiq '^location: .*/bot-guard([/?#]|$)' "$headers" && return 0
- [[ "$effective" =~ /bot-guard([/?#]|$) ]] && return 0
- return 1
- }
- run_mode() {
- local mode="$1"
- local cookie_args=()
- local jar="$OUT_DIR/${mode}-cookies.txt"
- if [[ "$mode" == "sticky" ]]; then
- cookie_args=(-c "$jar" -b "$jar")
- fi
- echo
- echo "${BOLD}=== Mode: $mode ===${RESET}"
- for i in $(seq 1 "$REQUESTS"); do
- local body="$OUT_DIR/${mode}-body-$i.html"
- local headers="$OUT_DIR/${mode}-headers-$i.txt"
- local test_url
- test_url="$(make_test_url "$URL" "$i" "$mode")"
- local meta
- meta="$(
- curl -sS -L \
- --compressed \
- --max-redirs 5 \
- --connect-timeout 10 \
- --max-time 30 \
- -A "curl-botguard-fixed/1.0 no-js mode-${mode}" \
- -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" \
- -H "Cache-Control: no-cache" \
- -H "Pragma: no-cache" \
- "${cookie_args[@]}" \
- -D "$headers" \
- -o "$body" \
- -w "http=%{http_code} redirects=%{num_redirects} effective=%{url_effective}" \
- "$test_url" 2>&1 || true
- )"
- local effective
- effective="$(sed -n 's/.*effective=//p' <<< "$meta")"
- if is_challenge "$body" "$headers" "$effective"; then
- echo "${RED}${BOLD}[$mode request $i] REAL CHALLENGE DETECTED${RESET} — $meta"
- echo "Body: $body"
- echo "Headers: $headers"
- return 0
- fi
- local js="no"
- grep -Eqi 'bot-guard/collect|ZeeBotGuardConfig|botguard\.js|zee/botguard' "$body" && js="yes"
- echo "${YELLOW}[$mode request $i] no real challenge${RESET} — $meta — normal_botguard_js=$js"
- sleep "$SLEEP_SECONDS"
- done
- echo "${RED}${BOLD}[$mode] no real challenge after $REQUESTS requests${RESET}"
- return 1
- }
- echo "${BOLD}Bot Guard corrected curl diagnostic${RESET}"
- echo "URL: $URL"
- echo "Output: $OUT_DIR"
- set +e
- run_mode "stateless"
- STATELESS=$?
- run_mode "sticky"
- STICKY=$?
- set -e
- echo
- echo "${BOLD}=== Result ===${RESET}"
- if [[ "$STATELESS" -eq 0 || "$STICKY" -eq 0 ]]; then
- echo "${GREEN}A real CAPTCHA/Bot Guard challenge was detected.${RESET}"
- else
- echo "${RED}No real CAPTCHA/Bot Guard challenge detected.${RESET}"
- echo "If Bot Guard is enabled and this route is protected, that still needs investigation."
- fi
Advertisement
Add Comment
Please, Sign In to add comment