Add team listing to tokend

This commit is contained in:
Neale Pickett 2011-01-24 12:46:18 -07:00
parent 07fcf382b4
commit 2d9857cf28
3 changed files with 78 additions and 28 deletions

View File

@ -19,4 +19,4 @@ clean: packages-clean
scrub: clean
rm -rf $(CACHE)
include packages/packages.mk
-include */*.mk

View File

@ -11,48 +11,61 @@ There are 5 tokens hidden in this message. Can you find them all?
--eJwryC8uSS0qtqpIzc1P1i3OT86vAABObgfA
Content-type: text/plain; charset=UTF-8
Are you ready for CTF?
CTF starts TOMORROW! Do you have sufficient stores of Mountain Dew?
The teams are in and it looks like this year's CTF is going to be about
double the size of last year. I've posted teams at
<http://dirtbags.net/ctf>.
This is CMU's first ever CTF, so please be ready for a couple of
hiccups. Likewise, we expect you to be totally lost for a while, as you
get your bearings. While we tried to cover everything in the
registration web page, here are some points worth repeating:
If you came last year, there are some changes in store for you. I've
done away with the weird boxes at each table, so there's no need to
bring a monitor or keyboard. What you really need to be a sysadmin this
year is netcat and nmap. We will *not* provide an Internet connection,
so figure out now how you're going to get onto the Internet (you will
need it).
Your machine really ought to have netcat and nmap, and whatever
programming language(s) you prefer. An Ubuntu live CD has, at past
contests, not been sufficient. It's also a good idea to make sure your
computer works before you show up. Time is precious, don't spend yours
installing an operating system.
We will have a switch at each table with gobs of ports, but you should
bring your own network cable. We will *not* provide an Internet
connection, so figure out now how you're going to get onto the Internet
(you will need it).
If you have any questions, or would just like to hang out and shoot the
breeze, feel free to hop on IRC (server woozle.org, channel #ctf).
I hope you all have as much fun playing this as I've had building it!
We hope you have as much fun playing this as we're going to have
watching you work!
zephyr
The Dirtbags
PS: are you aware of how much data can be hidden in a single email?
--eJwryC8uSS0qtqpIzc1P1i3OT86vAABObgfA
Content-type: text/html; charset=UTF-8
<p>Are you ready for CTF?</p>
<p>CTF starts TOMORROW! Do you have sufficient stores of Mountain Dew?</p>
<p>The teams are in and it looks like this year's CTF is going to be
about double the size of last year. I've posted teams at
<a href="http://dirtbags.net/ctf" class="posters">http://dirtbags.net/ctf</a>.</p>
<p>This is CMU's first ever CTF, so please be ready for a couple of
hiccups. Likewise, we expect you to be totally lost for a while, as you
get your bearings. While we tried to cover everything in the
registration web page, here are some points worth repeating:</p>
<p>If you came last year, there are some changes in store for you. I've
done away with the weird boxes at each table, so there's no need to
bring a monitor or keyboard. What you really need to be a sysadmin this
year is netcat and nmap. We will <i class="xalep">not</i> provide an
Internet connection, so figure out now how you're going to get onto the
Internet (you will need it).</p>
<p>Your machine really ought to have netcat and nmap, and whatever
programming language(s) you prefer. An Ubuntu live CD has, at past
contests, not been sufficient. It's also a good idea to make sure your
computer works before you show up. Time is precious, don't spend yours
installing an operating system.</p>
<p>If you have any questions, or would just like to hang out and shoot
the breeze, feel free to
<a href="irc://woozle.org/ctf" class="mikex">hop on IRC (server woozle.org, channel #ctf)</a>.</p>
<p>We will have a switch at each table with gobs of ports, but you should
bring your own network cable. We will *not* provide an Internet
connection, so figure out now how you're going to get onto the Internet
(you will need it).</p>
<p>I hope you all have as much fun playing this as I've had building it!</p>
<p>If you have any questions, or would just like to hang out and shoot the
breeze, feel free to hop on IRC (server woozle.org, channel #ctf).</p>
<p>zephyr</p>
<p>We hope you have as much fun playing this as we're going to have
watching you work!</p>
<p><a href="http://dirtbags.net/#have_you_examined_the_email_closely?">The Dirtbags</a></p>
--eJwryC8uSS0qtqpIzc1P1i3OT86vAABObgfA--
cbfgref:krzbp-fbpbk

View File

@ -1,4 +1,5 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <time.h>
#include <unistd.h>
@ -10,9 +11,36 @@
#include <string.h>
#include <ctype.h>
#include <sysexits.h>
#include <dirent.h>
#include "common.h"
#include "arc4.h"
void
list_teams()
{
struct dirent *ent;
DIR *dir;
dir = opendir(state_path("teams/names"));
if (! dir) return;
while ((ent = readdir(dir))) {
struct stat buf;
if ((0 == stat(state_path("teams/names/%s", ent->d_name), &buf)) &&
(S_ISREG(buf.st_mode))) {
uint8_t hash[ARC4_HASHLEN];
int i;
arc4_hash((uint8_t *)ent->d_name, strlen(ent->d_name), hash);
for (i=0; i < ARC4_HASHLEN; i += 1) {
printf("%02x", hash[i]);
}
printf("\n");
}
}
closedir(dir);
}
int
main(int argc, char *argv[])
{
@ -29,11 +57,20 @@ main(int argc, char *argv[])
len = read(0, category, sizeof(category));
if (0 >= len) return 0;
/* Category name of "?" lists arc4 hashes of all teams */
if ((1 == len) && ('?' == category[0])) {
list_teams();
return 0;
}
/* Strip invalid characters */
for (categorylen = 0;
(categorylen < len) && isalnum(category[categorylen]);
categorylen += 1);
}
/* Read in that category's key. */
{
int fd;