Finish Makefiles for badmath and tanks.

This commit is contained in:
Paul S. Ferrell 2009-10-06 14:14:16 -06:00
parent 2034591fb6
commit b840cb03f6
9 changed files with 90 additions and 2 deletions

26
badmath/Makefile Normal file
View File

@ -0,0 +1,26 @@
FAKE = fakeroot -s fake -i fake
INSTALL = $(FAKE) install
all: badmath.tce
badmath.tce: target
$(FAKE) sh -c 'cd target && tar -czf - --exclude=placeholder --exclude=*~ .' > $@
target:
$(INSTALL) -d target/usr/lib/ctf/badmath
$(INSTALL) Gyopi.py badmath.py target/usr/lib/ctf/badmath
$(INSTALL) -d target/var/lib/badmath
$(INSTALL) -d target/var/service/badmath
$(INSTALL) run target/var/service/badmath/run
$(INSTALL) -d target/var/service/badmath/log
$(INSTALL) log.run target/var/service/badmath/log/run
clean:
rm -rf target badmath.tce fake
%.pyc: %.py
python3 -c 'import $*'

BIN
badmath/badmath.tce Normal file

Binary file not shown.

14
badmath/fake Normal file
View File

@ -0,0 +1,14 @@
dev=16,ino=87557208,mode=40755,uid=0,gid=0,nlink=2,rdev=0
dev=16,ino=87557227,mode=40755,uid=0,gid=0,nlink=2,rdev=0
dev=16,ino=87557231,mode=40755,uid=0,gid=0,nlink=2,rdev=0
dev=16,ino=87557232,mode=40755,uid=0,gid=0,nlink=2,rdev=0
dev=16,ino=87557233,mode=40755,uid=0,gid=0,nlink=2,rdev=0
dev=16,ino=87557234,mode=40755,uid=0,gid=0,nlink=2,rdev=0
dev=16,ino=87557235,mode=40755,uid=0,gid=0,nlink=2,rdev=0
dev=16,ino=87557237,mode=40755,uid=0,gid=0,nlink=2,rdev=0
dev=16,ino=87557238,mode=40755,uid=0,gid=0,nlink=2,rdev=0
dev=16,ino=87557239,mode=40755,uid=0,gid=0,nlink=2,rdev=0
dev=16,ino=87557240,mode=40755,uid=0,gid=0,nlink=2,rdev=0
dev=16,ino=87573208,mode=100755,uid=0,gid=0,nlink=1,rdev=0
dev=16,ino=87573433,mode=100755,uid=0,gid=0,nlink=1,rdev=0
dev=16,ino=87573456,mode=100755,uid=0,gid=0,nlink=1,rdev=0

3
badmath/log.run Executable file
View File

@ -0,0 +1,3 @@
#! /bin/sh
exec logger -t badmath

View File

@ -1,5 +1,5 @@
FAKE = fakeroot -s fake -i fake FAKE = fakeroot -s fake -i fake
INSTALL = $(fake) install INSTALL = $(FAKE) install -o 100
all: tanks.tce all: tanks.tce
@ -19,7 +19,7 @@ target:
$(INSTALL) -d target/var/lib/www/tanks/ $(INSTALL) -d target/var/lib/www/tanks/
$(INSTALL) www/* target/var/lib/www/tanks/ $(INSTALL) www/* target/var/lib/www/tanks/
# $(FAKE) ln -s target/var/lib/tanks/ target/var/lib/www/data $(FAKE) ln -s target/var/lib/tanks/ target/var/lib/www/data
$(INSTALL) -d target/usr/lib/python2.6/site-packages/tanks/ $(INSTALL) -d target/usr/lib/python2.6/site-packages/tanks/
$(INSTALL) lib/* target/usr/lib/python2.6/site-packages/tanks/ $(INSTALL) lib/* target/usr/lib/python2.6/site-packages/tanks/

View File

@ -0,0 +1,3 @@
#! /bin/sh
exec logger -t tanks

16
tanks/report_score.py Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/python3.0
from ctf.flagd import Flagger
key = 'tanks:::2bac5e912ff2e1ad559b177eb5aeecca'
f = Flagger.Flagger('localhost', key)
while 1:
time.sleep(1)
try:
winner = open('/var/lib/tanks/winner').read()
except:
winner = None
f.set_flag(winner)

View File

@ -0,0 +1,6 @@
#! /bin/sh
[ -f /var/lib/ctf/disabled/tanks ] && exit 0
envuidgid ctf python2.6 run_tanks.py /var/lib/tanks/ easy 100 &
envuidgid ctf report_score.py

20
tanks/run_tanks.py Normal file
View File

@ -0,0 +1,20 @@
import time
from tanks import Pflanzarr
import sys
T = 60*5
try:
while 1:
start = time.time()
p = Pflanzarr(sys.argv[1], sys.argv[2])
p.run(int(sys.argv[3]))
diff = time.time() - start
if diff - T > 0:
time.sleep( diff - T )
except:
print 'Usage: python2.6 run_tanks.py data_dir easy|medium|hard max_turns'