diff --git a/badmath/Gyopi.py b/badmath/Gyopi.py index 47cef85..c36bdce 100644 --- a/badmath/Gyopi.py +++ b/badmath/Gyopi.py @@ -40,6 +40,7 @@ class Gyopi(irc.Bot): self._lvl = 0 self._flag.set_flag( self.FLAG_DEFAULT ) + self._tokens = [] self._lastAttempt = {} self._affiliations = {} self._newPuzzle() @@ -62,7 +63,7 @@ class Gyopi(irc.Bot): self.last_tb = '%s %s %s' % (t, v, infostr) print(self.last_tb) - def cmd_join(self, sender, forum, addl): + def cmd_JOIN(self, sender, forum, addl): """On join, announce who has the flag.""" if sender.name() in self.nicks: self._tellFlag(forum) @@ -150,11 +151,11 @@ class Gyopi(irc.Bot): self._tokens[user].remove(token) - def cmd_privmsg(self, sender, forum, addl): + def cmd_PRIVMSG(self, sender, forum, addl): text = addl[0] who = sender.name() if text.startswith('!'): - parts = text[1:].lower().split(' ', 1) + parts = text[1:].split(' ', 1) cmd = parts[0] if len(parts) > 1: args = parts[1] @@ -179,6 +180,7 @@ class Gyopi(irc.Bot): elif cmd.startswith('h'): # Help forum.msg('Goal: Help me with my math homework, FROM ANOTHER DIMENSION!') + forum.msg('Order of operations is always left to right.') #forum.msg('Goal: The current winner gets to control the contest music.') forum.msg('Commands: !help, !flag, !register [TEAM], !solve SOLUTION,!? EQUATION, !ops, !problem, !who') elif cmd.startswith('prob'): @@ -208,11 +210,15 @@ class Gyopi(irc.Bot): # self._giveToken(who, sender) self._saveState() else: - forum.msg('%s: %s != %s' % (who, attempt, answer)) forum.msg('%s: That is not correct.' % who) # Test a simple one op command. elif cmd.startswith('?'): + if not args: + forum.msg('%s: Give me an easier problem, and I\'ll ' + 'give you the answer.' % who) + return + try: tokens = badmath.parse(''.join(args)) except (ValueError) as msg: @@ -253,7 +259,7 @@ if __name__ == '__main__': help='Flag server password') p.add_option('-d', '--path', dest='path', default='/var/lib/badmath', help='Path to where we can store state info.') - p.add_option('-c', '--channel', dest='channel', default='+badmath', + p.add_option('-c', '--channel', dest='channel', default='#badmath', help='Which channel to join') opts, args = p.parse_args() diff --git a/badmath/badmath.tce b/badmath/badmath.tce index ec0516a..fab5817 100644 Binary files a/badmath/badmath.tce and b/badmath/badmath.tce differ diff --git a/badmath/fake b/badmath/fake index 5e3c978..85d3f2c 100644 --- a/badmath/fake +++ b/badmath/fake @@ -10,5 +10,6 @@ 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=87573213,mode=100755,uid=0,gid=0,nlink=1,rdev=0 +dev=16,ino=87573285,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/run b/badmath/run index 4477536..d5c3b2b 100755 --- a/badmath/run +++ b/badmath/run @@ -5,4 +5,4 @@ DATA_PATH=/var/lib/badmath mkdir -p $DATA_PATH -exec envuidgid ctf python3.0 usr/lib/ctf/badmath/Gyopi.py --data=$DATA_PATH +exec envuidgid ctf python3 /usr/lib/ctf/badmath/Gyopi.py --path=$DATA_PATH diff --git a/tanks/Makefile b/tanks/Makefile index cb27c38..b769a30 100644 --- a/tanks/Makefile +++ b/tanks/Makefile @@ -17,9 +17,8 @@ target: $(INSTALL) AI/medium/* target/var/lib/tanks/ai/medium/ $(INSTALL) AI/hard/* target/var/lib/tanks/ai/hard/ - $(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 + $(INSTALL) -d target/usr/lib/www/tanks/ + $(INSTALL) www/* target/usr/lib/www/tanks/ $(INSTALL) -d target/usr/lib/python2.6/site-packages/tanks/ $(INSTALL) lib/* target/usr/lib/python2.6/site-packages/tanks/ diff --git a/tanks/run b/tanks/run index a8157be..8457d0b 100755 --- a/tanks/run +++ b/tanks/run @@ -2,5 +2,7 @@ [ -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 +ln -s /var/lib/tanks /usr/lib/www/tanks/results + +envuidgid ctf python2.6 run_tanks.py /var/lib/tanks/ easy 100 2>&1 & +envuidgid ctf report_score.py 2>&1 diff --git a/tanks/t.py b/tanks/t.py new file mode 100644 index 0000000..7a2285d --- /dev/null +++ b/tanks/t.py @@ -0,0 +1,3 @@ +import sys + +print >> sys.stderr, 'hello' diff --git a/tanks/www/docs.cgi b/tanks/www/docs.cgi index 8ceb4d0..26306e3 100755 --- a/tanks/www/docs.cgi +++ b/tanks/www/docs.cgi @@ -7,7 +7,7 @@ import os import sys try: - from Tanks import Program, setup, conditions, actions, docs + from tanks import Program, setup, conditions, actions, docs except: path = os.getcwd().split('/') path.pop() diff --git a/tanks/www/errors.cgi b/tanks/www/errors.cgi index 1359cc9..f61d2bc 100755 --- a/tanks/www/errors.cgi +++ b/tanks/www/errors.cgi @@ -1,9 +1,10 @@ -#!/usr/bin/python +#!/usr/bin/python3 -print """Content-Type: text/html\n\n""" -print """\n\n""" +print("""Content-Type: text/html\n\n""") +print("""\n\n""") import cgi import cgitb; cgitb.enable() +import sys import os import Config @@ -16,18 +17,17 @@ except: try: from ctf import teams except: - import sys path = '/home/pflarr/repos/gctf/' sys.path.append(path) from ctf import teams teams.build_teams() head = open('head.html').read() % "Error Report" -print head -print open('links.html').read() +print(head) +print(open('links.html').read()) def done(): - print '' + print('') sys.exit(0) fields = cgi.FieldStorage() @@ -38,25 +38,25 @@ if team and passwd and \ path = os.path.join(Config.DATA_PATH, 'errors', quote(team)) if os.path.isfile(path): errors = open(path).readlines() - print '

Your latest errors:' - print '

' + print('

Your latest errors:') + print('

') if errors: - print '
\n'.join(errors) + print('
\n'.join(errors)) else: - print 'There were no errors.' - print '
' + print('There were no errors.') + print('
') else: - print '

No error file found.' + print('

No error file found.') done() if team and team not in teams.teams: - print '

Invalid team.' + print('

Invalid team.') if team and team in teams.teams and passwd != teams.teams[team][0]: - print '

Invalid password.' + print('

Invalid password.') -print ''' +print('''

Error report request: @@ -64,6 +64,6 @@ print ''' Password:
-
''' +''') done() diff --git a/tanks/www/submit.cgi b/tanks/www/submit.cgi index 9d57907..5dad944 100755 --- a/tanks/www/submit.cgi +++ b/tanks/www/submit.cgi @@ -1,8 +1,11 @@ -#!/usr/bin/python +#!/usr/bin/python3 +print("Content-Type: text/html\n\n") +print("""\n\n""") import cgi import cgitb; cgitb.enable() import os +import sys import Config @@ -14,21 +17,18 @@ except: try: from ctf import teams except: - import sys path = '/home/pflarr/repos/gctf/' sys.path.append(path) from ctf import teams teams.build_teams() -print """Content-Type: text/html\n\n""" -print """\n\n""" head = open('head.html').read() % "Submission Results" -print head -print "

Results

" -print open('links.html').read() +print(head) +print("

Results

") +print(open('links.html').read()) def done(): - print '' + print('') sys.exit(0) fields = cgi.FieldStorage() @@ -36,21 +36,23 @@ team = fields.getfirst('team', '').strip() passwd = fields.getfirst('passwd', '').strip() code = fields.getfirst('code', '') if not team: - print '

No team specified'; done() + print('

No team specified'); done() elif not passwd: - print '

No password given'; done() + print('

No password given'); done() elif not code: - print '

No program given.'; done() + print('

No program given.'); done() if team not in teams.teams: - print '

Team is not registered.'; done() + print('

Team is not registered.'); done() if passwd != teams.teams[team][0]: - print '

Invalid password.'; done() + print('

Invalid password.'); done() -path = os.path.join(Config.DATA_PATH, 'ai/players', encode(team) ) +path = os.path.join(Config.DATA_PATH, 'ai/players', quote(team) ) file = open(path, 'w') file.write(code) file.close() +print("

Submission Successful") + done()