From aff9f2deea702e757904855c1d37ea24bc27d08c Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Mon, 4 Feb 2013 22:34:45 -0700 Subject: [PATCH] Possibly functional register.cgi for tf5 --- packages/mcp/www/register.cgi | 26 ++++++++++++++------------ packages/mcp/www/register.html | 14 +++++++++----- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/packages/mcp/www/register.cgi b/packages/mcp/www/register.cgi index 1330bb7..3737158 100755 --- a/packages/mcp/www/register.cgi +++ b/packages/mcp/www/register.cgi @@ -1,7 +1,12 @@ #! /bin/sh -e -team=$(echo "$QUERY_STRING" | sed -n s'/.*team=\([^&]*\).*/\1/p') -team=$(busybox httpd -d "$team" || echo "$team") +param () { + 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 <Team Registration EOF -if [ ! -w $CTF_BASE/www ] || [ ! -w $CTF_BASE/state/teams ]; then - echo "

It looks like the server isn't set up for self-registrations." - echo "Go talk to someone at the head table to register your team.

" +if ! grep -q $h $CTF_BASE/state/teams/assigned.txt; then + echo "

That token has not been assigned.

" +elif [ -f $CTF_BASE/state/teams/names/$h ]; then + echo "

That token has already been named.

" else - echo "

Team name: $team

" - echo -n "
"
-    if $CTF_BASE/mcp/bin/addteam "$team"; then
-        echo "

Write this hash down. You will use it to claim points.

" - else - echo "Oops, something broke. Better call Neale." - fi + printf "%s" "$t" > $CTF_BASE/state/teams/names/$h + echo "

Okay, your team has been named and you may begin using your token!

" fi + cat < diff --git a/packages/mcp/www/register.html b/packages/mcp/www/register.html index 96257e6..ec3948a 100644 --- a/packages/mcp/www/register.html +++ b/packages/mcp/www/register.html @@ -7,14 +7,18 @@

Team Registration

- Please register a team for yourself during this training. This - team is just for the training portion; it will not be the team you - play on during the exercise. + Before you can use a token, you must choose a team name. + You can only do this once per token, + so make sure it's the team name you actually want. + Staff are unable to make changes to team names.

+ + +
- - + +