import Cookie, os, sys cookie = Cookie.SmartCookie(os.environ.get("HTTP_COOKIE", None)) if (not cookie.has_key('foo')) or (cookie['foo'].value == 'false'): cookie['foo'] = 'true' print 'Status: 302 Moved' print cookie print 'Location: https://scripts.mit.edu/~geofft/' print 'Last-Modified: Tue, 17 Feb 2009 22:18:25 GMT' print 'Content-length: 6\r\n' print '123456\r\n' sys.stdout.flush() print """HTTP/1.1 200 OK Content-Type: text/html Content-Length: 31 This was the injected response.\r\n""" else: cookie['foo'] = 'false' print 'Status: 200 OK' print cookie print 'Cache-Control: private, s-maxage=0, max-age=0, must-revalidate' print 'Last-Modified: Tue, 17 Feb 2009 22:18:25 GMT' print 'Content-Type: text/html\r\n' print 'Reload'