Restore angle calculation

This commit is contained in:
Neale Pickett 2010-03-03 11:15:51 -07:00
parent 3cae9d7442
commit 7b406ce67d
34 changed files with 14 additions and 550 deletions

View File

@ -1 +0,0 @@
../10/,binary.png

View File

@ -1 +0,0 @@
../10/,ctf.css

View File

@ -1,76 +0,0 @@
#!/usr/bin/python
import os
import cgi
import cgitb
cgitb.enable(context=10)
if os.environ.has_key('QUERY_STRING'):
os.environ['QUERY_STRING'] = ''
fields = cgi.FieldStorage()
print 'Content-Type: text/html'
print ''
print '''
<html>
<head>
<title>4</title>
<link rel="stylesheet" type="text/css" href=",ctf.css" media="all" />
</head>
<body>
<div id="wrapper">
<div id="content">
<h1>Web Application Challenge 4</h1>
<p>Through some manipulation or interpretation of this CGI script
and the HTML page(s) that it generates, a 10 character key can be
found.</p>
<p><strong>Find the key!</strong></p>
<div class="vertsep"></div>
'''
PRODUCT_NAME = "Unidentifiable garbage"
def purchase_success(quantity):
print '''
<p>Congratulations, your order for %d "%s" has been placed.</p>
''' % (quantity, PRODUCT_NAME)
# key = 765JBo4B54
if fields.has_key('quantity') and fields.has_key('product') and fields['product'].value == PRODUCT_NAME:
product = fields['product'].value
quantity = int(fields['quantity'].value)
purchase_success(quantity)
else:
print '''
<h2>SALE: %s</h2>
<p>Use the order form below to place an order.</p>
<form method="post" action="4.cgi">
How many would you like?
<select name="quantity">
<option value="12">12</option>
<option value="24">24</option>
<option value="48">48</option>
</select>
<br /><br />
<input type="submit" value="Order!" />
<input type="hidden" name="product" value="%s" />
</form>
''' % (PRODUCT_NAME, PRODUCT_NAME)
print '''
</div>
<div id="footer">
<p>Copyright &copy; 2009 LANS, LLC.</p>
</div>
</div>
</body>
</html>
'''

View File

@ -1 +0,0 @@
765JBo4B54

View File

@ -1 +0,0 @@
../10/,binary.png

View File

@ -1 +0,0 @@
../10/,ctf.css

View File

@ -1,89 +0,0 @@
#!/usr/bin/python
import os
import cgi
import cgitb
cgitb.enable(context=10)
if os.environ.has_key('QUERY_STRING'):
os.environ['QUERY_STRING'] = ''
fields = cgi.FieldStorage()
print 'Content-Type: text/html'
print ''
print '''
<html>
<head>
<title>5</title>
<link rel="stylesheet" type="text/css" href=",ctf.css" media="all" />
</head>
<body>
<div id="wrapper">
<div id="content">
<h1>Web Application Challenge 5</h1>
<p>Through some manipulation or interpretation of this CGI script
and the HTML page(s) that it generates, a 10 character key can be
found.</p>
<p><strong>Find the key!</strong></p>
<div class="vertsep"></div>
'''
PRODUCT_NAME = "Alex Brugh"
QUANT_LIMIT = 1
def purchase_success(quantity):
print '''
<p>Congratulations, your order for %d "%s" has been placed.</p>
''' % (quantity, PRODUCT_NAME)
class InvalidQuantityError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
quantity = None
if fields.has_key('quantity') and fields.has_key('product') and fields['product'].value == PRODUCT_NAME:
product = fields['product'].value
try:
quantity = int(fields['quantity'].value)
if quantity > QUANT_LIMIT:
# key = eVkIwHzOok
raise InvalidQuantityError("%d is not a valid quantity (limit %d)" % (quantity, QUANT_LIMIT))
except ValueError:
print '''
<p class="error">There was an error with your order request. Sorry.</p>
'''
quantity = None
if quantity is not None:
purchase_success(quantity)
else:
print '''
<h2>SALE: %s</h2>
<p>Use the order form below to place an order.</p>
<form method="post" action="5.cgi">
<em>Orders for "%s" are limited to 1 per customer.</em>
<br /><br />
<input type="submit" value="Order!" />
<input type="hidden" name="product" value="%s" />
<input type="hidden" name="quantity" value="1" />
</form>
''' % (PRODUCT_NAME, PRODUCT_NAME, PRODUCT_NAME)
print '''
</div>
<div id="footer">
<p>Copyright &copy; 2009 LANS, LLC.</p>
</div>
</div>
</body>
</html>
'''

View File

@ -1 +0,0 @@
eVkIwHzOok

View File

@ -1 +0,0 @@
../10/,binary.png

View File

@ -1 +0,0 @@
../10/,ctf.css

View File

@ -1,72 +0,0 @@
#!/usr/bin/python
import os
import cgi
import cgitb
cgitb.enable(context=10)
#if os.environ.has_key('QUERY_STRING'):
# os.environ['QUERY_STRING'] = ''
fields = cgi.FieldStorage()
import Cookie
c = Cookie.SimpleCookie()
c['key'] = 'QJebByJaKX'
c['content'] = '<p><em>Maybe I should have used sessions...</em></p>'
print 'Content-Type: text/html\n%s\n\n\n' % c
print ''
print '''
<html>
<head>
<title>6</title>
<link rel="stylesheet" type="text/css" href=",ctf.css" media="all" />
<script type="text/javascript">
function readCookie(key) {
var s = key + '=';
var toks = document.cookie.split(';');
for (var i = 0; i < toks.length; i++) {
var tok = toks[i];
while (tok.charAt(0) == ' ') {
tok = tok.substring(1, tok.length);
}
if (tok.indexOf(s) == 0) {
return tok.substring(s.length, tok.length);
}
}
return null;
}
function setContent() {
content = readCookie("content");
document.getElementById("stuff").innerHTML = content.substring(1, content.length-1);
}
window.onload = setContent;
</script>
</head>
<body>
<div id="wrapper">
<div id="content">
<h1>Web Application Challenge 6</h1>
<p>Through some manipulation or interpretation of this CGI script
and the HTML page(s) that it generates, a 10 character key can be
found.</p>
<p><strong>Find the key!</strong></p>
<div class="vertsep"></div>
<div id="stuff"></div>
'''
print '''
</div>
<div id="footer">
<p>Copyright &copy; 2009 LANS, LLC.</p>
</div>
</div>
</body>
</html>
'''

View File

@ -1 +0,0 @@
QJebByJaKX

View File

@ -1 +0,0 @@
../10/,binary.png

View File

@ -1 +0,0 @@
../10/,ctf.css

View File

@ -1,86 +0,0 @@
#!/usr/bin/python
import os
import cgi
import cgitb
cgitb.enable(context=10)
#if os.environ.has_key('QUERY_STRING'):
# os.environ['QUERY_STRING'] = ''
fields = cgi.FieldStorage()
import Cookie
c = Cookie.SimpleCookie(os.environ.get('HTTP_COOKIE', ''))
content = {
'joke1' : '<p>An infinite number of mathematicians walk into a bar. The first one orders a beer. The second orders half a beer. The third, a quarter of a beer. The bartender says <em>You are all idiots!</em> and pours two beers.<p>',
'joke2' : '<p>Two atoms are talking. One of them says <em>I think I lost an electron!</em> and the other says <em>Are you sure?</em> The first replies <em>Yeah, I am positive!</em></p>',
}
if c.has_key('content_name') and c.has_key('content'):
k = c['content_name'].value
try:
c['content'] = content[k]
except KeyError:
c['content'] = '<p><em>key = s4nNlaMScV</em></p>'
else:
c['content_name'] = 'joke1';
c['content'] = content['joke1']
print 'Content-Type: text/html\n%s\n\n\n' % c
print ''
print '''
<html>
<head>
<title>7</title>
<link rel="stylesheet" type="text/css" href=",ctf.css" media="all" />
<script type="text/javascript">
function readCookie(key) {
var s = key + '=';
var toks = document.cookie.split(';');
for (var i = 0; i < toks.length; i++) {
var tok = toks[i];
while (tok.charAt(0) == ' ') {
tok = tok.substring(1, tok.length);
}
if (tok.indexOf(s) == 0) {
return tok.substring(s.length, tok.length);
}
}
return null;
}
function getContent() {
content = readCookie("content");
document.getElementById("stuff").innerHTML = content.substring(1, content.length-1);
}
window.onload = getContent;
</script>
</head>
<body>
<div id="wrapper">
<div id="content">
<h1>Web Application Challenge 7</h1>
<p>Through some manipulation or interpretation of this CGI script
and the HTML page(s) that it generates, a 10 character key can be
found.</p>
<p><strong>Find the key!</strong></p>
<div class="vertsep"></div>
<div id="stuff"></div>
'''
print '''
</div>
<div id="footer">
<p>Copyright &copy; 2009 LANS, LLC.</p>
</div>
</div>
</body>
</html>
'''

View File

@ -1 +0,0 @@
s4nNlaMScV

View File

@ -1 +0,0 @@
../10/,binary.png

View File

@ -1 +0,0 @@
../10/,ctf.css

View File

@ -1,4 +0,0 @@
<p>An unsigned integer walks into a bar and orders a drink.<br />
The bartender delivers it and says, &quot;Is something wrong?&quot;<br />
The int looks up and replies, &quot;Parity error.&quot;<br />
&quot;Ah,&quot; the bartender replies, &quot;I thought you looked a bit off.&quot;</p>

View File

@ -1,2 +0,0 @@
<p>There are 10 types of people in the world: those who understand binary and those who don't.</p>

View File

@ -1,2 +0,0 @@
<p>Why do programmers confuse Halloween and Christmas?<br /><br />
Because OCT 31 == DEC 25!</p>

View File

@ -1,2 +0,0 @@
<p>Once a programmer drowned in the sea. Many people were at the beach at the time,
but the programmer was shouting &quot;F1! F1!&quot; and nobody understood it.</p>

View File

@ -1,6 +0,0 @@
<p>&quot;Knock, Knock.&quot;<br />
&quot;Who's there?&quot;<br />
<br />
... long pause ...<br />
<br />
&quot;Java.&quot;</p>

View File

@ -1,45 +0,0 @@
#!/usr/bin/env python2.6
import os
import sys
import sqlite3
import base64
import stat
# new db
if os.path.exists(',zomg.sqlite3'):
os.remove(',zomg.sqlite3')
db = sqlite3.connect(',zomg.sqlite3')
cur = db.cursor()
# pics table
cur.execute('create table pics(id integer primary key, data blob)')
paths = os.listdir(',pics/')
for path in paths:
f = open(os.path.join(',pics/', path), 'rb')
data = f.read()
f.close()
encoded = base64.encodestring(data)
html = '<img src="data:image/jpg;base64,%s"/>' % encoded
cur.execute('insert into pics(data) values(?)', (html,))
# jokes table
cur.execute('create table jokes(id integer primary key, data text)')
paths = os.listdir(',jokes/')
for path in paths:
f = open(os.path.join(',jokes/', path), 'r')
html = f.read()
f.close()
cur.execute('insert into jokes(data) values(?)', (html,))
# key
cur.execute('create table key(id integer primary key, data text)')
for k in [None, None, None, None, None, 'dmW5f9P54e']:
cur.execute('insert into key(data) values(?)', (k,))
# clean up
db.commit()
cur.close()
db.close()
os.chmod(',zomg.sqlite3', stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

View File

@ -1,150 +0,0 @@
#!/usr/bin/python
import os
import cgi
import cgitb
import sqlite3
cgitb.enable(context=10)
if os.environ.has_key('QUERY_STRING'):
os.environ['QUERY_STRING'] = ''
fields = cgi.FieldStorage()
q = None
if fields.has_key('q'):
q = fields['q'].value
if q is not None:
print 'Content-Type: text/html\n'
try:
db = sqlite3.connect(',zomg.sqlite3')
cur = db.cursor()
cur.execute(q)
results = cur.fetchall()
print '<table>'
for r in results:
print '<tr>'
for thing in r:
print '<td>%s</td>' % thing
print '</tr>'
print '</table>'
except Exception:
print '<p class="error">Invalid query: %s</p>' % q
else:
print 'Content-Type: text/html\n'
print ''
print '''
<html>
<head>
<title>8</title>
<link rel="stylesheet" type="text/css" href=",ctf.css" media="all" />
<script type="text/javascript">
function buildQuery(table_name, result_limit) {
var q = "SELECT * FROM " + table_name + " LIMIT " + result_limit;
return q;
}
function getXHRObject() {
var xhr = null;
try {
xhr = new XMLHttpRequest();
}
catch (ex) {
try {
xhr = new ActiveXObject("msxml2.XMLHTTP");
}
catch (ex) {
alert("Browser does not support AJAX!")
return null;
}
}
return xhr;
}
function sendXHRPost(xhr, url, params) {
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("Content-length", params.length);
xhr.setRequestHeader("Connection", "close");
xhr.send(params)
}
function doQuery(q) {
var xhr = getXHRObject();
if (xhr != null) {
var url = "8.cgi";
var params = "q=" + q;
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
var response = xhr.responseText;
var d = document.getElementById("results");
d.innerHTML = response;
}
}
sendXHRPost(xhr, url, params);
}
}
function submitForm() {
var f = document.getElementById("the_form");
var table_name = f.tname.value;
var result_limit = f.rlimit.value;
var q = buildQuery(table_name, result_limit);
doQuery(q);
return false;
}
</script>
</head>
<body>
<div id="wrapper">
<div id="content">
<h1>Web Application Challenge 8</h1>
<p>Through some manipulation or interpretation of this CGI script
and the HTML page(s) that it generates, a 10 character key can be
found.</p>
<p><strong>Find the key!</strong></p>
<div class="vertsep"></div>
<h2>Database Query Wizard</h2>
<p>Use the form below to retrieve data from the database. Select the
type of data that you would like to view and the number of database
entries to retrieve and then click on the &quot;Query&quot; button.</p>
<form id="the_form" action="" method="POST" onsubmit="return submitForm()">
<br />
Topic: <select name="tname">
<option value="jokes">Jokes</option>
<option value="pics">Pictures</option>
</select>
<br /><br />
# Results: <select name="rlimit">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<br /><br />
<input type="submit" value="Query" />
</form>
<div id="results"></div>
</div>
<div id="footer">
<p>Copyright &copy; 2009 LANS, LLC.</p>
</div>
</div>
</body>
</html>
'''

View File

@ -1 +0,0 @@
dmW5f9P54e

View File

@ -139,7 +139,10 @@ to be in radians, and must be in the range 0 <= angle < 2*pi.
is negative if angle2 leads angle1 (clockwise)..
"""
return (angle2 - angle1) % pi2
ret = (angle2 - angle1) % pi2
if ret > math.pi:
ret -= pi2
return ret
def getDist(point1, point2):
"""Returns the distance between point1 and point2."""

View File

@ -196,11 +196,21 @@ class Pflanzarr:
cgi.escape(tank.deathReason)))
body.write(' </table>\n')
links='''<h3>Tanks</h3>
<ul>
<li><a href="docs.html">Docs</a></li>
<li><a href="results.cgi">Results</a></li>
<li><a href="submit.html">Submit</a></li>
<li><a href="errors.cgi">My Errors</a></li>
</ul>
'''
# Write everything out
html.write(self.gameFilename,
'Tanks round %d' % self.gameNum,
body.getvalue(),
hdr=hdr.getvalue(),
links=links,
onload='start(turns);')