2009-10-07 10:50:18 -06:00
|
|
|
#!/usr/bin/python3
|
2009-10-06 11:50:21 -06:00
|
|
|
|
2009-10-07 10:50:18 -06:00
|
|
|
print("Content-Type: text/html\n\n")
|
|
|
|
print("""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN">\n\n""")
|
2009-10-06 11:50:21 -06:00
|
|
|
import cgi
|
|
|
|
import cgitb; cgitb.enable()
|
|
|
|
import os
|
2009-10-07 10:50:18 -06:00
|
|
|
import sys
|
2009-10-06 11:50:21 -06:00
|
|
|
|
2009-10-06 12:47:36 -06:00
|
|
|
import Config
|
|
|
|
|
2009-10-06 11:50:21 -06:00
|
|
|
try:
|
|
|
|
from urllib.parse import quote
|
|
|
|
except:
|
|
|
|
from urllib import quote
|
|
|
|
|
|
|
|
try:
|
|
|
|
from ctf import teams
|
|
|
|
except:
|
|
|
|
path = '/home/pflarr/repos/gctf/'
|
|
|
|
sys.path.append(path)
|
|
|
|
from ctf import teams
|
2009-10-06 12:47:36 -06:00
|
|
|
teams.build_teams()
|
2009-10-06 11:50:21 -06:00
|
|
|
|
|
|
|
head = open('head.html').read() % "Submission Results"
|
2009-10-07 10:50:18 -06:00
|
|
|
print(head)
|
|
|
|
print("<H1>Results</H1>")
|
|
|
|
print(open('links.html').read())
|
2009-10-06 11:50:21 -06:00
|
|
|
|
|
|
|
def done():
|
2009-10-07 10:50:18 -06:00
|
|
|
print('</body></html>')
|
2009-10-06 11:50:21 -06:00
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
fields = cgi.FieldStorage()
|
|
|
|
team = fields.getfirst('team', '').strip()
|
|
|
|
passwd = fields.getfirst('passwd', '').strip()
|
|
|
|
code = fields.getfirst('code', '')
|
|
|
|
if not team:
|
2009-10-07 10:50:18 -06:00
|
|
|
print('<p>No team specified'); done()
|
2009-10-06 11:50:21 -06:00
|
|
|
elif not passwd:
|
2009-10-07 10:50:18 -06:00
|
|
|
print('<p>No password given'); done()
|
2009-10-06 11:50:21 -06:00
|
|
|
elif not code:
|
2009-10-07 10:50:18 -06:00
|
|
|
print('<p>No program given.'); done()
|
2009-10-06 11:50:21 -06:00
|
|
|
|
|
|
|
if team not in teams.teams:
|
2009-10-07 10:50:18 -06:00
|
|
|
print('<p>Team is not registered.'); done()
|
2009-10-06 11:50:21 -06:00
|
|
|
|
|
|
|
if passwd != teams.teams[team][0]:
|
2009-10-07 10:50:18 -06:00
|
|
|
print('<p>Invalid password.'); done()
|
2009-10-06 11:50:21 -06:00
|
|
|
|
2009-10-07 10:50:18 -06:00
|
|
|
path = os.path.join(Config.DATA_PATH, 'ai/players', quote(team) )
|
2009-10-06 11:50:21 -06:00
|
|
|
file = open(path, 'w')
|
|
|
|
file.write(code)
|
|
|
|
file.close()
|
|
|
|
|
2009-10-07 10:50:18 -06:00
|
|
|
print("<P>Submission Successful")
|
|
|
|
|
2009-10-06 11:50:21 -06:00
|
|
|
done()
|