Possibly functional register.cgi for tf5

This commit is contained in:
Neale Pickett 2013-02-04 22:34:45 -07:00
parent 36940a98cb
commit 4fdbbf04fb
2 changed files with 23 additions and 17 deletions

View File

@ -1,7 +1,12 @@
#! /bin/sh -e #! /bin/sh -e
team=$(echo "$QUERY_STRING" | sed -n s'/.*team=\([^&]*\).*/\1/p') param () {
team=$(busybox httpd -d "$team" || echo "$team") ret=$(echo "$QUERY_STRING" | tr '=&' ' \n' | awk -v "k=$1" '($1==k) {print $2;}')
ret=$(busybox httpd -d "$ret" || echo "$ret")
}
team=$(param n)
hash=$(param h | tr -dc 0-9a-f)
cat <<EOF cat <<EOF
Content-type: text/html Content-type: text/html
@ -16,18 +21,15 @@ Content-type: text/html
<h1>Team Registration</h1> <h1>Team Registration</h1>
EOF EOF
if [ ! -w $CTF_BASE/www ] || [ ! -w $CTF_BASE/state/teams ]; then if ! grep -q $h $CTF_BASE/state/teams/assigned.txt; then
echo "<p>It looks like the server isn't set up for self-registrations." echo "<p>That token has not been assigned.</p>"
echo "Go talk to someone at the head table to register your team.</p>" elif [ -f $CTF_BASE/state/teams/names/$h ]; then
echo "<p>That token has already been named.</p>"
else else
echo "<p>Team name: $team</p>" printf "%s" "$t" > $CTF_BASE/state/teams/names/$h
echo -n "<pre>" echo "<p>Okay, your team has been named and you may begin using your token!</p>"
if $CTF_BASE/mcp/bin/addteam "$team"; then
echo "</pre><p>Write this hash down. You will use it to claim points.</p>"
else
echo "Oops, something broke. Better call Neale.</pre>"
fi
fi fi
cat <<EOF cat <<EOF
</body> </body>
</html> </html>

View File

@ -7,14 +7,18 @@
<body> <body>
<h1>Team Registration</h1> <h1>Team Registration</h1>
<p> <p>
Please register a team for yourself during this training. This Before you can use a token, you must choose a team name.
team is just for the training portion; it will not be the team you You can only do this once per token,
play on during the exercise. so make sure it's the team name you actually want.
Staff are unable to make changes to team names.
</p> </p>
<form method="get" action="register.cgi"> <form method="get" action="register.cgi">
<label>Team Hash (Token):</label>
<input type="text" name="h">
<br>
<label>Team Name:</label> <label>Team Name:</label>
<input type="text" name="team"> <input type="text" name="n">
<br>
<input type="submit" value="Register"> <input type="submit" value="Register">
</form> </form>
</body> </body>