Skip to content

Instantly share code, notes, and snippets.

@KG7x

KG7x/block_q3dd Secret

Last active September 19, 2020 18:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KG7x/27873277bb3c3e3230a2c09bc5e36af4 to your computer and use it in GitHub Desktop.
Save KG7x/27873277bb3c3e3230a2c09bc5e36af4 to your computer and use it in GitHub Desktop.
q3 engine getstatus ddos filter
#!/bin/bash
function numcommas () {
local S="${1//[^,]/}"
echo ${#S}
}
PORTS=${1:-27960}
NUMPORTS=$(($(numcommas ${PORTS}) + 1))
HITS=$((${2:-5} * ${NUMPORTS}))
SECONDS=${3:-2}
iptables -N quake3_ddos
iptables -A quake3_ddos -m u32 ! --u32 "0x1c=0xffffffff" -j ACCEPT
iptables -A quake3_ddos -m u32 --u32 "0x20=0x67657473&&0x24=0x74617475&&0x25&0xff=0x73" -m recent --name getstatus --set
iptables -A quake3_ddos -m recent --update --name getstatus --hitcount ${HITS} --seconds ${SECONDS} -j DROP
iptables -A quake3_ddos -j ACCEPT
if [ ${NUMPORTS} -eq 1 ]; then
iptables -I INPUT -p udp --dport ${PORTS} -j quake3_ddos
else
iptables -I INPUT -m multiport -p udp --dports ${PORTS} -j quake3_ddos
fi
@KG7x
Copy link
Author

KG7x commented Jul 7, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment