109 lines
2.7 KiB
Bash
109 lines
2.7 KiB
Bash
#!/bin/bash
|
|
# utils/test_zapret.sh - Test utility for checking DPI bypass
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd .. && pwd)"
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m'
|
|
|
|
print_green() { echo -e "${GREEN}$1${NC}"; }
|
|
print_red() { echo -e "${RED}$1${NC}"; }
|
|
print_yellow(){ echo -e "${YELLOW}$1${NC}"; }
|
|
|
|
test_website() {
|
|
local url="$1"
|
|
local name="$2"
|
|
local timeout=10
|
|
local result
|
|
|
|
result=$(curl -o /dev/null -s -w "%{http_code}" --max-time "$timeout" -L "$url" 2>/dev/null)
|
|
|
|
if [[ "$result" == "200" ]] || [[ "$result" == "301" ]] || [[ "$result" == "302" ]]; then
|
|
print_green " [OK] $name ($url) - HTTP $result"
|
|
return 0
|
|
elif [[ -z "$result" ]]; then
|
|
print_red " [FAIL] $name ($url) - No response"
|
|
return 1
|
|
else
|
|
print_red " [FAIL] $name ($url) - HTTP $result"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
standard_tests() {
|
|
echo "[*] Standard tests - checking common sites..."
|
|
echo ""
|
|
|
|
local targets_file="$SCRIPT_DIR/utils/targets.txt"
|
|
if [[ ! -f "$targets_file" ]]; then
|
|
targets_file="/dev/stdin"
|
|
echo "ytimg.com"
|
|
echo "discord.com"
|
|
echo "discordapp.com"
|
|
echo "youtube.com"
|
|
echo "googlevideo.com"
|
|
fi
|
|
|
|
local total=0
|
|
local passed=0
|
|
|
|
while IFS= read -r line || [[ -n "$line" ]]; do
|
|
[[ -z "$line" ]] && continue
|
|
[[ "$line" =~ ^# ]] && continue
|
|
total=$((total + 1))
|
|
if test_website "https://$line" "$line"; then
|
|
passed=$((passed + 1))
|
|
fi
|
|
done < "$targets_file"
|
|
|
|
echo ""
|
|
echo "Results: $passed/$passed passed"
|
|
if [[ "$passed" -eq "$total" ]]; then
|
|
print_green "All tests passed!"
|
|
else
|
|
print_yellow "Some tests failed. Try a different strategy."
|
|
fi
|
|
}
|
|
|
|
dpi_checkers() {
|
|
echo "[*] DPI checkers - checking various endpoints..."
|
|
echo ""
|
|
|
|
local endpoints=(
|
|
"https://1.1.1.1|Cloudflare"
|
|
"https://8.8.8.8|Google DNS"
|
|
"https://check-host.net|Check-Host"
|
|
)
|
|
|
|
for entry in "${endpoints[@]}"; do
|
|
IFS='|' read -r url name <<< "$entry"
|
|
test_website "$url" "$name"
|
|
done
|
|
|
|
echo ""
|
|
echo "[*] Checking if TCP timestamps are enabled..."
|
|
if [[ -r /proc/sys/net/ipv4/tcp_timestamps ]]; then
|
|
local val
|
|
val=$(cat /proc/sys/net/ipv4/tcp_timestamps)
|
|
if [[ "$val" == "1" ]]; then
|
|
print_green " [OK] tcp_timestamps = 1"
|
|
else
|
|
print_red " [WARN] tcp_timestamps = $val (should be 1)"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
case "${1:-standard}" in
|
|
standard)
|
|
standard_tests
|
|
;;
|
|
dpi)
|
|
dpi_checkers
|
|
;;
|
|
*)
|
|
echo "Usage: $0 [standard|dpi]"
|
|
exit 1
|
|
;;
|
|
esac
|