synapse-registration-bash/registerform.sh

62 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
source config
sendcaptchashort() {
curl --silent -XPOST "$captchouliurl" -H "$HTTP_CONTENT_TYPE" -d "$1" > /dev/null
}
htmlspecialchars() {
echo "$1" | sed -e 's/&/,amp/g' -e 's/"/,quot/g' -e 's/</,lt/g' -e 's/>/,gt/g' | head -n 1
}
registrationpage() {
echo "Content-type: text/html"
echo ""
echo "<html>"
echo "<head>"
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'
echo "<style> body { color:black ; background-image: url('background.jpg'); background-repeat: no-repeat; background-size: cover; } .info { background: white ; margin: 0px; padding: 0px ;} </style>"
echo "</head>"
echo "<body>"
echo "<center>"
echo '<img id="banner" src="banner.png"><br>'
echo "<form action='do-register.sh' method='POST'>"
echo '<table border="0"> <tr> <td>'
echo "<span class='box info'>"
echo "<label for='login'>Login:</label>"
echo "</span>"
echo "</td> <td>"
echo "<input type='text' id='login' name='login'>"
echo "</td> </tr> <tr> <td>"
echo "<span class='box info'>"
echo "<label for='password'>Password:</label>"
echo "</span>"
echo "</td> <td>"
echo "<input type='password' id='password' name='password'>"
echo "</td> </tr> <tr> <td>"
echo "<span class='box info'>"
echo "<label for='passwordagain'>Re-type Password:</label>"
echo "</span>"
echo "</td> <td>"
echo "<input type='password' id='passwordagain' name='passwordagain'>"
echo "<input type='hidden' id='captcha' name='captcha' value='\"$id\"'>"
echo '</td> </tr> </table>'
echo "<input type='submit' value='Submit'>"
echo "</form>"
echo "</center>"
echo "</body>"
echo "</html>"
}
# get post body from captchouli to check if its valid later
data=$(cat)
id=$(htmlspecialchars $(echo "$data" | cut -d '=' -f 2 | cut -d '&' -f 1))
registrationpage
# sends the captcha id to capthouli so it knows it was solved
sendcaptchashort "$data"
exit 0