diff --git a/.gitignore b/.gitignore index 15953f7..dd4952d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *~ *.pyc *.dat +*.swp passwd target/ puzzler/ diff --git a/badmath/Flagger.py b/badmath/Flagger.py deleted file mode 100644 index 8722ea1..0000000 --- a/badmath/Flagger.py +++ /dev/null @@ -1,31 +0,0 @@ -import asynchat -import asyncore -import socket - -class Flagger(asynchat.async_chat): - """Connection to flagd""" - - def __init__(self, addr, auth): - asynchat.async_chat.__init__(self) - self.create_socket(socket.AF_INET, socket.SOCK_STREAM) - self.connect((addr, 6668)) - self.push(auth + b'\n') - self.flag = None - - def handle_read(self): - msg = self.recv(4096) - raise ValueError("Flagger died: %r" % msg) - - def handle_error(self): - # If we lose the connection to flagd, nobody can score any - # points. Terminate everything. - asyncore.close_all() - asynchat.async_chat.handle_error(self) - - def set_flag(self, team): - if team: - eteam = team.encode('utf-8') - else: - eteam = b'' - self.push(eteam + b'\n') - self.flag = team 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.state b/badmath/badmath.state deleted file mode 100644 index 43d3747..0000000 Binary files a/badmath/badmath.state and /dev/null differ diff --git a/badmath/badmath.tce b/badmath/badmath.tce new file mode 100644 index 0000000..ec0516a Binary files /dev/null and b/badmath/badmath.tce differ 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/ctf/teams.py b/ctf/teams.py index 4f73799..29ed25b 100755 --- a/ctf/teams.py +++ b/ctf/teams.py @@ -3,7 +3,11 @@ import fcntl import time import os -from urllib.parse import quote, unquote +# python 2 compatibility +try: + from urllib.parse import quote, unquote +except: + from urllib import quote, unquote from . import config house = config.get('global', 'house_team') @@ -14,7 +18,6 @@ teams = {} built = 0 def build_teams(): global teams, built - if not os.path.exists(passwdfn): return if os.path.getmtime(passwdfn) <= built: diff --git a/puzzles/webapp/2/2.cgi b/puzzles/webapp/2/2.cgi index 2f7249c..3e9b6cd 100755 --- a/puzzles/webapp/2/2.cgi +++ b/puzzles/webapp/2/2.cgi @@ -34,7 +34,7 @@ if (fields.has_key('num')): ''' % int(fields['num'].value) print ''' -
diff --git a/puzzles/webapp/3/3.cgi b/puzzles/webapp/3/3.cgi index 0ac4e73..63f495b 100755 --- a/puzzles/webapp/3/3.cgi +++ b/puzzles/webapp/3/3.cgi @@ -47,7 +47,7 @@ else:Use the order form below to place an order.
-