2011-02-07 22:38:13 -07:00
|
|
|
#! /bin/sh
|
|
|
|
|
2012-07-22 17:14:06 -06:00
|
|
|
STATE=$CTF_BASE/state
|
2011-02-07 22:38:13 -07:00
|
|
|
|
2012-07-22 17:14:06 -06:00
|
|
|
echo -n "Team hash: "
|
2011-02-09 15:31:15 -07:00
|
|
|
read -r teamhash
|
2011-02-07 22:38:13 -07:00
|
|
|
|
2012-07-22 17:14:06 -06:00
|
|
|
if ! [ -f $STATE/teams/names/"$teamhash" ]; then
|
2011-02-07 22:38:13 -07:00
|
|
|
echo 'No such team.'
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2012-07-22 17:14:06 -06:00
|
|
|
cd $STATE/rlyeh
|
2011-02-07 22:38:13 -07:00
|
|
|
|
|
|
|
if [ -f $teamhash ]; then
|
|
|
|
now=$(date +%s)
|
|
|
|
ts=$(stat -c %Y $teamhash)
|
|
|
|
d=$(expr $now - $ts)
|
|
|
|
if [ $d -lt 60 ]; then
|
|
|
|
echo 'You are trying to connect too fast.'
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
else
|
2011-02-09 15:31:15 -07:00
|
|
|
echo 1 > $teamhash
|
2011-02-07 22:38:13 -07:00
|
|
|
fi
|
|
|
|
read level < $teamhash
|
|
|
|
|
|
|
|
(
|
|
|
|
if ! flock -n 8; then
|
|
|
|
echo 'Your team is already logged in.'
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Your team is on level $level."
|
|
|
|
echo
|
|
|
|
|
2011-02-09 15:31:15 -07:00
|
|
|
if setuidgid nobody rlyeh $level; then
|
2012-07-22 17:14:06 -06:00
|
|
|
arc4 $CTF_BASE/packages/rlyeh/tokens/rlyeh/enc.key < $$CTF_BASE/state/rlyeh/tokens.txt
|
2011-02-09 15:31:15 -07:00
|
|
|
echo
|
2011-02-07 22:38:13 -07:00
|
|
|
expr $level + 1 > $teamhash
|
|
|
|
else
|
|
|
|
touch $teamhash
|
|
|
|
fi
|
|
|
|
) 8<$teamhash
|