miaopanel
1#!/usr/bin/env bash
2# Inspect WAF settings/rules and recent blocked requests.
3set -uo pipefail
4ENTRY="${1:-ipdduiyy}"
5BASE="http://127.0.0.1:8888/$ENTRY"
6PASS=$(awk -F': ' '/^password:/{print $2}' /www/server/panel/data/initial_password.txt)
7
8curl -s -c /tmp/ck.txt -H 'Content-Type: application/json' -H 'Origin: http://127.0.0.1:8888' \
9 -d "{\"username\":\"admin\",\"password\":\"$PASS\"}" "$BASE/api/v1/auth/login" >/dev/null
10
11echo "== settings =="
12curl -s -b /tmp/ck.txt "$BASE/api/v1/waf/settings"
13echo
14echo "== rules =="
15curl -s -b /tmp/ck.txt "$BASE/api/v1/waf/rules"
16echo
17echo "== status counts (all site logs) =="
18awk '{print $9}' /www/wwwlogs/*/access.log 2>/dev/null | sort | uniq -c | sort -rn | head -12
19echo "== recent non-2xx =="
20grep -hE '" (403|404|429|444|503) ' /www/wwwlogs/*/access.log 2>/dev/null | tail -20
21echo "== suspect patterns =="
22grep -hE '\.(zip|tar\.gz|well-known)' /www/wwwlogs/*/access.log 2>/dev/null | tail -10