2011-03-08 23:06:21 -07:00
|
|
|
#! /bin/sh -e
|
|
|
|
|
2013-02-04 22:34:45 -07:00
|
|
|
param () {
|
|
|
|
ret=$(echo "$QUERY_STRING" | tr '=&' ' \n' | awk -v "k=$1" '($1==k) {print $2;}')
|
|
|
|
ret=$(busybox httpd -d "$ret" || echo "$ret")
|
2013-02-05 23:03:10 -07:00
|
|
|
echo "$ret"
|
2013-02-04 22:34:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
team=$(param n)
|
|
|
|
hash=$(param h | tr -dc 0-9a-f)
|
2011-03-08 23:06:21 -07:00
|
|
|
|
|
|
|
cat <<EOF
|
|
|
|
Content-type: text/html
|
|
|
|
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Team Registration</title>
|
|
|
|
<link rel="stylesheet" href="ctf.css" type="text/css">
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h1>Team Registration</h1>
|
|
|
|
EOF
|
|
|
|
|
2013-02-05 23:07:35 -07:00
|
|
|
if [ -z "$hash" ] || [ -z "$team" ]; then
|
|
|
|
echo "<p>Empty field, cannot complete request</p>"
|
2013-02-06 00:02:08 -07:00
|
|
|
elif ! grep -q " $hash$" $CTF_BASE/state/teams/assigned.txt; then
|
2013-02-05 23:06:45 -07:00
|
|
|
echo "<p>That hash has not been assigned.</p>"
|
2013-02-05 23:03:10 -07:00
|
|
|
elif [ -f $CTF_BASE/state/teams/names/$hash ]; then
|
2013-02-05 23:06:45 -07:00
|
|
|
echo "<p>That hash has already been registered.</p>"
|
2011-03-08 23:06:21 -07:00
|
|
|
else
|
2013-02-05 23:06:45 -07:00
|
|
|
printf "%s" "$team" > $CTF_BASE/state/teams/names/$hash
|
|
|
|
echo "<p>Okay, your team has been named and you may begin using your hash!</p>"
|
2011-03-08 23:06:21 -07:00
|
|
|
fi
|
2013-02-04 22:34:45 -07:00
|
|
|
|
2011-03-08 23:06:21 -07:00
|
|
|
cat <<EOF
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
EOF
|