From b840cb03f684edfadd9aad305c00e89dfdb511b9 Mon Sep 17 00:00:00 2001 From: "Paul S. Ferrell" Date: Tue, 6 Oct 2009 14:14:16 -0600 Subject: [PATCH] Finish Makefiles for badmath and tanks. --- badmath/Makefile | 26 ++++++++++++++++++++++++++ badmath/badmath.tce | Bin 0 -> 4492 bytes badmath/fake | 14 ++++++++++++++ badmath/log.run | 3 +++ tanks/Makefile | 4 ++-- tanks/log.run | 3 +++ tanks/report_score.py | 16 ++++++++++++++++ tanks/run | 6 ++++++ tanks/run_tanks.py | 20 ++++++++++++++++++++ 9 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 badmath/Makefile create mode 100644 badmath/badmath.tce create mode 100644 badmath/fake create mode 100755 badmath/log.run create mode 100755 tanks/report_score.py create mode 100644 tanks/run_tanks.py diff --git a/badmath/Makefile b/badmath/Makefile new file mode 100644 index 0000000..ae0b82f --- /dev/null +++ b/badmath/Makefile @@ -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 $*' diff --git a/badmath/badmath.tce b/badmath/badmath.tce new file mode 100644 index 0000000000000000000000000000000000000000..ec0516ab8ef924ae1e2181836425ae9ac0c6e1e6 GIT binary patch literal 4492 zcmV;75p(VziwFSbq{~VG1MNKhciT3S`B{GjY_CJAk!eZ(+NWE$r#8;Vy(G@X>UI0P zt{zB25^H`fN!f9Cw}1Q203ZpHplrXF`1bZVueC{HFf*7L%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ocOLIRYm!Z%;?`y?TYz{S>W8%&=$7#74Q=`|$_g>z$y<`2ZX`KQN zSaDjZ+#E|5WL`-9n%+0)oPW+$DGo@~*_QWe7`Mu*7$V14{-U5UEbX3`h7iszKHR#Z zTDGLP!zxZ}Zs&I~go$t;47Z|$3e}lcG8dCg?6oQL5oTO9Vq#7-)uSn>o}6pcqL}Hz z!lIM#DAAzY4$I?RwMS|9&lwD*wLOYuUQnW)a;H^F6Y=|n&h;RtR~#)sYC|33*>^*!CM;0KSl|Mi5 zKb{ak)$uR!?>}(+j}E)||0Gbg|G&b&|A6*CIO^>GG@!SCvJSr>kNfODKB?RP5FWep zpQnJGEwXQW;eNX6^)AWYf)wikJP&lelyCXvjzO--^XE{AdKnq^dM~H5>HOn#_U5#{ zi0B2^u9uL#nEatY>h;)X<`5R%tUY%L)hYf<3-MjHioyeHNH+a5BxG+7{~Ya9A@;wm zw|^JV&woE!e!(2@`1pT#FdldDzk?1s=%9lRI_RK-4m#+dgAO|Apo0!N=%9lRI_RK- e4m#+dgAO|Apo0!N=%9lR+Tfo6J_bzycmM#Uso!`2 literal 0 HcmV?d00001 diff --git a/badmath/fake b/badmath/fake new file mode 100644 index 0000000..5e3c978 --- /dev/null +++ b/badmath/fake @@ -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 diff --git a/badmath/log.run b/badmath/log.run new file mode 100755 index 0000000..c455835 --- /dev/null +++ b/badmath/log.run @@ -0,0 +1,3 @@ +#! /bin/sh + +exec logger -t badmath diff --git a/tanks/Makefile b/tanks/Makefile index 23fdfc3..cb27c38 100644 --- a/tanks/Makefile +++ b/tanks/Makefile @@ -1,5 +1,5 @@ FAKE = fakeroot -s fake -i fake -INSTALL = $(fake) install +INSTALL = $(FAKE) install -o 100 all: tanks.tce @@ -19,7 +19,7 @@ target: $(INSTALL) -d 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) lib/* target/usr/lib/python2.6/site-packages/tanks/ diff --git a/tanks/log.run b/tanks/log.run index e69de29..c4eff97 100755 --- a/tanks/log.run +++ b/tanks/log.run @@ -0,0 +1,3 @@ +#! /bin/sh + +exec logger -t tanks diff --git a/tanks/report_score.py b/tanks/report_score.py new file mode 100755 index 0000000..32e958e --- /dev/null +++ b/tanks/report_score.py @@ -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) diff --git a/tanks/run b/tanks/run index e69de29..a8157be 100755 --- a/tanks/run +++ b/tanks/run @@ -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 diff --git a/tanks/run_tanks.py b/tanks/run_tanks.py new file mode 100644 index 0000000..4263e15 --- /dev/null +++ b/tanks/run_tanks.py @@ -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' + +