#!/bin/bash source config statuspage() { echo "Content-type: text/html" echo "" echo "" echo "" echo '' echo "" echo "" echo "" echo "
" echo '
' if [ "$captcha" != "true" ] then echo "" echo "Registration failed, chud." echo "

" echo "You need to know the animu girls better." echo "

" echo "You have to go back" echo $(date +"%Y-%m-%d %H:%M:%S") "$realip" "$login" failed registration with wrong captcha >> /var/log/register/log echo "
" elif [ "$password" != "$retype" ] then echo "" echo "Registration failed, chud." echo "

" echo "Passwords do not match." echo "

" echo "You have to go back" echo "
" echo $(date +"%Y-%m-%d %H:%M:%S") "$realip" "$login" failed registration with wrong password >> /var/log/register/log else echo "
"
		registerscript
		echo "
" echo "
" echo "" if [[ $regstatus == 0 ]] then echo "Go to Login" registercounter echo $(date +"%Y-%m-%d %H:%M:%S") "$realip" "$login" has registered >> /var/log/register/log else echo "You have to go back" echo $(date +"%Y-%m-%d %H:%M:%S") "$realip" shit is fucked yo >> /var/log/register/log echo "" fi fi echo "
" echo "" echo "" } rawurldecode() { # All escape characters must be encoded, we can replace %NN with \xNN and pass the lot to printf -b, # which will decode hex printf -v REPLY '%b' "${1//%/\\x}" echo "${REPLY}" } checkcaptchouli() { curl --silent -XPOST --data "captchouli-id=$1" "$captchouliurl/status" } registerscript() { # contains the secret variable with the shared secret thing for synapse source ~/.secret # script from synapse.. should have curled the api but i did not want to deal with the nonces ~/register_new_matrix_user.py -u "$login" -p "$password" --no-admin -k "$secret" "$synapse_admin_api" regstatus=$? 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 data=$(cat) id=$(rawurldecode "$(echo "$data" | cut -d '=' -f 5)" | sed -e 's/"//g') login=$(rawurldecode "$(echo "$data" | cut -d '=' -f 2 | 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)") # returns true or false depending if user passed or not captcha=$(checkcaptchouli "$id") realip=$(env | grep HTTP_X_FORWARDED_FOR | cut -d '=' -f 2 | cut -d ',' -f 1) ratelimit statuspage exit 0