DOS protection.

A DOS attack against this script can block the router completely.
This patch inserts a delay to fix this problem.
This commit is contained in:
Robert Langhammer 2019-11-24 22:22:23 +01:00
parent d553bfc0df
commit 5947228548
1 changed files with 8 additions and 0 deletions

View File

@ -3,8 +3,16 @@
<%
echo -en "Content-Type: text/html\r\n\r\n"
HOSTNAME="$(uci -q get "fff.system.hostname")"
lockfile="/tmp/simple.babelweb.lock"
if [ -e $lockfile ];then
if [ 30 -gt $(( $(date +%s) - $(date -r $lockfile +%s) )) ];then
echo "only one access per minute!!" && exit
fi
fi
data=$(echo "dump" | nc ::1 33123)
touch $lockfile
%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">