Merge branch 'master' of ssh://fozzie/home/neale/projects/ctf

This commit is contained in:
Neale Pickett 2012-06-06 11:36:20 -06:00
commit c6d0fe4f30
13 changed files with 59 additions and 101 deletions

View File

@ -1,7 +1,12 @@
00ADMIN_PKGDIR = $(TARGET)/00admin 00ADMIN_PKGDIR = $(TARGET)/00admin
ifndef PASSWORD
$(error PASSWORD not defined)
endif
00admin-install: 00admin-install:
$(call COPYTREE, packages/00admin/service, $(00ADMIN_PKGDIR)/service) $(call COPYTREE, packages/00admin/service, $(00ADMIN_PKGDIR)/service)
echo "$(PASSWORD)" > $(00ADMIN_PKGDIR)/password
mkdir -p $(00ADMIN_PKGDIR)/sbin mkdir -p $(00ADMIN_PKGDIR)/sbin
cp packages/00admin/sbin/* $(00ADMIN_PKGDIR)/sbin cp packages/00admin/sbin/* $(00ADMIN_PKGDIR)/sbin

View File

@ -2,7 +2,9 @@
exec 2>&1 exec 2>&1
echo 'root:$1$i/EeZyl6$5C6Z8s0ftEdTKFLUli1wP1' | chpasswd --encrypted read password < /opt/00admin/password
printf 'root:%s' "$password" | chpasswd --md5
# Bring up the NIC; this will get us at least a link-local address, and # Bring up the NIC; this will get us at least a link-local address, and
# hopefully a global address with stateless autoconfiguration. # hopefully a global address with stateless autoconfiguration.

View File

@ -17,13 +17,6 @@ set -C
base=${CTF_BASE:-/var/lib/ctf} base=${CTF_BASE:-/var/lib/ctf}
www=${CTF_BASE:-/var/www} www=${CTF_BASE:-/var/www}
if which backup-team >/dev/null 2>&1 ; then
if [ ! -e $base/pass ]; then
echo "\nYou should consider running backup-pass or new-contest."
echo "DBTL Altocumulus™ backup system will not work without it.\n"
fi
fi
mkdir -p $base/teams/names mkdir -p $base/teams/names
mkdir -p $base/teams/colors mkdir -p $base/teams/colors

View File

@ -1,25 +0,0 @@
#! /bin/sh -e
base=${CTF_BASE:-/var/lib/ctf}
www=${CTF_BASE:-/var/www}
pass=$base/pass
img=$www/bkup.png
time=$(date +%s)
output=bkup-${time}.png
if [ ! -e $img -o ! -e $pass ]; then
exit 0
fi
# clean up all other backup images
if ls $www/bkup-*.png >/dev/null 2>&1 ; then
rm $www/bkup-*.png
fi
# This is a tested method.
#(cat $img; tar -cf - $base 2>/dev/null | gzip -c ) > $www/$output
# This is not a tested method.
(cat $img; tar -cvf - $base 2>/dev/null | gzip -c | rc4 3< $pass) > $www/$output
echo $output

View File

@ -1,38 +0,0 @@
#! /bin/sh -e
trap "stty echo; echo ''; echo 'Passfile not written'; exit 42" 1 2 3 15
askpass () {
echo "Password: "
stty -echo
read pass1
echo "Retype password: "
read pass2
stty echo
if [ "${pass1}" = "${pass2}" ]; then
echo "Got it.\n"
return 0
else
echo "Authentication token manipulation error.\n"
return 1
fi
}
base=${CTF_BASE:-/var/lib/ctf}
passfile=$base/pass
if [ -e $passfile ]; then
echo "\nDanger! Danger!\n"
echo "Wipes out current passfile. It's ok as long as note the current"
echo "timestamp ($(date +%s)) and the new pass will be applied on the"
echo "next scoreboard update.\n"
fi
echo "Enter passphrase for backups"
echo "To exit, press ctrl+c"
until askpass; do true; done
echo -e "${pass1}" > $passfile
echo "Passfile written"
stty echo

View File

@ -77,7 +77,10 @@ BEGIN {
tslen = 0 tslen = 0
nteams = 0; nteams = 0;
while (1 == getline) { }
# MAINLOOP
{
time = $1 time = $1
team = $2 team = $2
cat = $3 cat = $3
@ -98,6 +101,7 @@ BEGIN {
points_by_cat_team[cat, team] += points points_by_cat_team[cat, team] += points
} }
END {
output() output()
# Get team colors and names # Get team colors and names
@ -181,6 +185,7 @@ BEGIN {
print " <body>" print " <body>"
print " <h1>Scoreboard</h1>" print " <h1>Scoreboard</h1>"
print " <p id=\"debug\"></p>" print " <p id=\"debug\"></p>"
print " <img src=\"backup.png?" NR "\" alt=\"\" style=\"display: none;\" height=\"1\" width=\"1\">"
print " <table id=\"scoreboard\">" print " <table id=\"scoreboard\">"
print " <tr>" print " <tr>"
print " <th>Overall</th>" print " <th>Overall</th>"

View File

@ -31,6 +31,7 @@ mcp-install: $(MCP_BUILDDIR)/build
$(call COPYTREE, packages/mcp/bin, $(MCP_PKGDIR)/bin) $(call COPYTREE, packages/mcp/bin, $(MCP_PKGDIR)/bin)
cp packages/mcp/src/pointscli $(MCP_PKGDIR)/bin/ cp packages/mcp/src/pointscli $(MCP_PKGDIR)/bin/
cp packages/mcp/src/puzzles.cgi $(MCP_PKGDIR)/bin/ cp packages/mcp/src/puzzles.cgi $(MCP_PKGDIR)/bin/
cp packages/mcp/src/tea $(MCP_PKGDIR)/bin/
cp $(MCP_BUILDDIR)/eris/eris $(MCP_PKGDIR)/bin/ cp $(MCP_BUILDDIR)/eris/eris $(MCP_PKGDIR)/bin/

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

View File

@ -1,14 +1,31 @@
#! /bin/sh #! /bin/sh -e
fn=$2/$3 fn=$2/$3
POINTS=/var/lib/ctf/points.log
SCOREBOARD=/var/www/scoreboard.html
cat $fn >> $POINTS || break WWW=${CTF_BASE:-/var/www}
BASE=${CTF_BASE:-/var/lib/ctf}
OPT=${CTF_BASE:-/opt}
POINTS=$BASE/points.log
BACKUP=$WWW/backup.png
SCOREBOARD=$WWW/scoreboard.html
# Only do this if this score hasn't yet been recorded
if ! cut -d' ' -f2- $POINTS | grep -Fqx "$(cut -d' ' -f2- $fn)"; then
cat $fn >> $POINTS
rm $fn rm $fn
fi
# Render scoreboard
if [ $POINTS -nt $SCOREBOARD ]; then if [ $POINTS -nt $SCOREBOARD ]; then
/opt/mcp/bin/scoreboard < $POINTS > $SCOREBOARD.new && mv $SCOREBOARD.new $SCOREBOARD # Generate new backup
(
cat bkup.png;
tar cvf - $BASE | gzip -c | $OPT/00admin/bin/tea 3< $OPT/00admin/password
) > $BACKUP.new
mv $BACKUP.new $BACKUP
# Render scoreboard
/opt/mcp/bin/scoreboard < $POINTS > $SCOREBOARD.new
mv $SCOREBOARD.new $SCOREBOARD
fi fi

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 B

View File

@ -27,7 +27,6 @@ main(int argc, char *argv[])
char* multicastIP; /* Arg: IP Multicast address */ char* multicastIP; /* Arg: IP Multicast address */
char* multicastPort; /* Arg: Server port */ char* multicastPort; /* Arg: Server port */
char token[100]; char token[100];
size_t tokenlen;
struct addrinfo * multicastAddr; /* Multicast address */ struct addrinfo * multicastAddr; /* Multicast address */
struct addrinfo hints = { 0 }; /* Hints for name lookup */ struct addrinfo hints = { 0 }; /* Hints for name lookup */
struct timeval timeout = { 0 }; struct timeval timeout = { 0 };
@ -44,7 +43,6 @@ main(int argc, char *argv[])
if (NULL == fgets(token, sizeof(token), stdin)) { if (NULL == fgets(token, sizeof(token), stdin)) {
DieWithError("Unable to read token"); DieWithError("Unable to read token");
} }
tokenlen = strlen(token);
/* Resolve destination address for multicast datagrams */ /* Resolve destination address for multicast datagrams */
hints.ai_family = PF_INET6; hints.ai_family = PF_INET6;

View File

@ -1,4 +1,4 @@
CFLAGS = -Wall -Werror CFLAGS = -Wall
LDFLAGS = -static LDFLAGS = -static
TARGETS = printf TARGETS = printf

View File

@ -59,7 +59,7 @@ $(ECMH_BUILDDIR): $(ECMH_CACHE)
router-build: $(ROUTER_BUILDDIR)/ecmh-build router-build: $(ROUTER_BUILDDIR)/ecmh-build
$(ROUTER_BUILDDIR)/ecmh-build: $(ECMH_BUILDDIR) $(ROUTER_BUILDDIR)/ecmh-build: $(ECMH_BUILDDIR)
$(MAKE) -C $(ECMH_BUILDDIR)/src ECMH_VERSION=dbtl-git STRIP=$(STRIP) $(MAKE) -C $(ECMH_BUILDDIR)/src ECMH_VERSION=dbtl-git STRIP=echo
$(MAKE) -C $(ECMH_BUILDDIR)/tools/mtrace6 $(MAKE) -C $(ECMH_BUILDDIR)/tools/mtrace6
touch $@ touch $@