From ee26b2876d16cc9e64ccdf7610737cc130a1e4dc Mon Sep 17 00:00:00 2001 From: "Paul S. Ferrell" Date: Wed, 7 Oct 2009 10:50:18 -0600 Subject: [PATCH] Assorted changes to get my badmath and tanks working on the ctf server. --- badmath/Gyopi.py | 16 +++++++++++----- badmath/badmath.tce | Bin 4492 -> 4574 bytes badmath/fake | 3 ++- badmath/run | 2 +- tanks/Makefile | 5 ++--- tanks/run | 6 ++++-- tanks/t.py | 3 +++ tanks/www/docs.cgi | 2 +- tanks/www/errors.cgi | 34 +++++++++++++++++----------------- tanks/www/submit.cgi | 30 ++++++++++++++++-------------- 10 files changed, 57 insertions(+), 44 deletions(-) create mode 100644 tanks/t.py 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 ec0516ab8ef924ae1e2181836425ae9ac0c6e1e6..fab58178fe612edb15f4cd3e0cf70ed3620983b7 100644 GIT binary patch literal 4574 zcmV<45h3m$iwFPE3*Y%~T zA0^SY8d=gLIk|LO|MmeSB~cRPBz>23AHwT$k_ZAI00IQb+1h;d?9d0;-`(Z^0#yIy z&x66%-q!y1R)1?7zVGk%_g|6S=NIkOt3{I1n2=X-7^chc9%}zD1#5GW#Lw&lPqzP{ zzq{3M?f()W?C*Q_Gy1^O?GG<|t^HpD3i~_hGt31?`*a9e+ekt-=^-IrnArN z2T!;E_D*a6mjS)~-`|IkXGQm)hsSdJZ*6bw?p5r+I~YLx?|&Zl%i;gr{@y$a7?=futNYi68Kn# z;KfeqyEXCY)XiGo!ON7z9rnp#Q7R~8lO)*f+YGzgfV^oUDSdIp2;k%>^E)C;$j(3GVmab-+V zoyK*K7+kSNLAKk;XSslF>F!n( zdqFw|9Hoas@74$IeN78WWF;)+52pB7GPp9@qE{N;upj}FSJygjG)YHk%H~lDDF67E z28B*0p6^j~wWJ9rV0UMWpMUmI3Aw>p97{t9eEfkabc* zQ^5>n0I_Mp0y<}AYFnv2p2YBMO~y{>GRq0apiJJ}?KP6Bg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@@ 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()