ratelimiting
This commit is contained in:
parent
e3ace52726
commit
5f6b5d86cc
|
|
@ -19,7 +19,8 @@ statuspage() {
|
||||||
echo "<br><br>"
|
echo "<br><br>"
|
||||||
echo "You need to know the animu girls better."
|
echo "You need to know the animu girls better."
|
||||||
echo "<br><br>"
|
echo "<br><br>"
|
||||||
echo "<a href=$registrationurl/registerform.sh>Go back</a>"
|
echo "<a href=$registrationurl/registerform.sh>You have to go back</a>"
|
||||||
|
echo $(date +"%Y-%m-%d %H:%M:%S") "$realip" "$login" failed registration with wrong captcha >> /var/log/register/log
|
||||||
echo "</span>"
|
echo "</span>"
|
||||||
elif [ "$password" != "$retype" ]
|
elif [ "$password" != "$retype" ]
|
||||||
then
|
then
|
||||||
|
|
@ -28,9 +29,10 @@ statuspage() {
|
||||||
echo "<br><br>"
|
echo "<br><br>"
|
||||||
echo "Passwords do not match."
|
echo "Passwords do not match."
|
||||||
echo "<br><br>"
|
echo "<br><br>"
|
||||||
echo "<a href=$registrationurl/registerform.sh>Go back</a>"
|
echo "<a href=$registrationurl/registerform.sh>You have to go back</a>"
|
||||||
|
|
||||||
echo "</span>"
|
echo "</span>"
|
||||||
|
echo $(date +"%Y-%m-%d %H:%M:%S") "$realip" "$login" failed registration with wrong password >> /var/log/register/log
|
||||||
else
|
else
|
||||||
echo "<pre class='info'>"
|
echo "<pre class='info'>"
|
||||||
registerscript
|
registerscript
|
||||||
|
|
@ -40,8 +42,11 @@ statuspage() {
|
||||||
if [[ $regstatus == 0 ]]
|
if [[ $regstatus == 0 ]]
|
||||||
then
|
then
|
||||||
echo "<a href=$elementurl/#/login>Go to Login</a>"
|
echo "<a href=$elementurl/#/login>Go to Login</a>"
|
||||||
|
registercounter
|
||||||
|
echo $(date +"%Y-%m-%d %H:%M:%S") "$realip" "$login" has registered >> /var/log/register/log
|
||||||
else
|
else
|
||||||
echo "<a href=$registrationurl/registerform.sh>Go back</a>"
|
echo "<a href=$registrationurl/registerform.sh>You have to go back</a>"
|
||||||
|
echo $(date +"%Y-%m-%d %H:%M:%S") "$realip" shit is fucked yo >> /var/log/register/log
|
||||||
|
|
||||||
echo "</span>"
|
echo "</span>"
|
||||||
fi
|
fi
|
||||||
|
|
@ -72,17 +77,36 @@ registerscript() {
|
||||||
unset secret
|
unset secret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
registercounter(){
|
||||||
|
date -d '+1 minute' +%s > /tmp/counter
|
||||||
|
}
|
||||||
|
|
||||||
|
ratelimit(){
|
||||||
|
currentstamp=$(date +%s)
|
||||||
|
if [[ "$currentstamp" < $(cat /tmp/counter) ]]
|
||||||
|
then
|
||||||
|
# ratelimit
|
||||||
|
echo $(cat /tmp/counter)+120 | bc > /tmp/counternew
|
||||||
|
mv /tmp/counternew /tmp/counter
|
||||||
|
captcha=false
|
||||||
|
echo $(date +"%Y-%m-%d %H:%M:%S") $realip ratelimiting until $(date +"%Y-%m-%d %H:%M:%S" -d @$(cat /tmp/counter)) >> /var/log/register/log
|
||||||
|
else
|
||||||
|
echo $(date +"%Y-%m-%d %H:%M:%S") $realip noratelimit >> /var/log/register/log
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# receive post data
|
# receive post data
|
||||||
data=$(cat)
|
data=$(cat)
|
||||||
id=$(rawurldecode "$(echo "$data" | cut -d '=' -f 5)")
|
id=$(rawurldecode "$(echo "$data" | cut -d '=' -f 5)" | sed -e 's/"//g')
|
||||||
login=$(rawurldecode "$(echo "$data" | cut -d '=' -f 2 | cut -d '&' -f 1)")
|
login=$(rawurldecode "$(echo "$data" | cut -d '=' -f 2 | cut -d '&' -f 1)")
|
||||||
password=$(rawurldecode "$(echo "$data" | cut -d '=' -f 3 | cut -d '&' -f 1)")
|
password=$(rawurldecode "$(echo "$data" | cut -d '=' -f 3 | cut -d '&' -f 1)")
|
||||||
retype=$(rawurldecode "$(echo "$data" | cut -d '=' -f 4 | cut -d '&' -f 1)")
|
retype=$(rawurldecode "$(echo "$data" | cut -d '=' -f 4 | cut -d '&' -f 1)")
|
||||||
|
|
||||||
# returns true or false depending if user passed or not
|
# returns true or false depending if user passed or not
|
||||||
captcha=$(checkcaptchouli "$id")
|
captcha=$(checkcaptchouli "$id")
|
||||||
|
realip=$(env | grep HTTP_X_FORWARDED_FOR | cut -d '=' -f 2 | cut -d ',' -f 1)
|
||||||
|
|
||||||
|
ratelimit
|
||||||
statuspage
|
statuspage
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue