Skip to content

Instantly share code, notes, and snippets.

Created September 28, 2010 13:09
Show Gist options
  • Save anonymous/600952 to your computer and use it in GitHub Desktop.
Save anonymous/600952 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.api import mail
def trap(req, msg) :
data = "\n\n\nM : "+msg+"\n\n\n"
data += "IP : "+req.request.remote_addr + "\n"
for key, value in req.request.headers.items():
data += 'H : '+key+" = "+value+"\n"
for key, value in req.request.cookies.items():
data += 'C : '+key+" = "+value+"\n"
try:
mail.send_mail(sender="TRAP <XXXXXXXXXX@gmail.com>",to="XXXXXXXXXX@parti-socialiste.fr", subject="TRAP !", body = data)
except DeadlineExceededError:
s = 1
class MainHandler(webapp.RequestHandler):
def get(self):
user = users.get_current_user()
if user:
self.error(403)
self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write('INFRADEV Error : unauthorized user')
trap (self, "LOGIN:"+user.nickname()+" : "+user.email()+"\n")
else:
self.redirect(users.create_login_url(self.request.uri))
class FileHandler(webapp.RequestHandler):
def get(self):
self.response.code = '200';
self.response.headers['Content-Type'] = 'text/html; charset=utf8'
self.response.out.write("""
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>Index of /static/files</title>
</head>
<body>
<h1>Index of /static/files</h1>
<table><tr><th><img src="/icons/blank.gif" alt="[ICO]"></th><th>Name</th><th>Last modified</th><th>Size</th><th>Description</th></tr><tr><th colspan="5"><hr></th></tr>
<tr><td valign="top"><img src="/icons/back.gif" alt="[DIR]"></td><td><a href="/static/">Parent Directory</a></td><td>&nbsp;</td><td align="right"> - </td></tr>
<tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="/static/files/logs/">logs/</a></td><td align="right">14-Sep-2010 12:57 </td><td align="right"> - </td></tr>
<tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="/static/files/projects/">projects/</a></td><td align="right">13-Sep-2010 21:34 </td><td align="right"> - </td></tr>
<tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="/static/files/svn/">svn/</a></td><td align="right">14-Sep-2010 12:57 </td><td align="right"> - </td></tr>
<tr><td valign="top"><img src="/icons/layout.gif" alt="[PDF]"></td><td><a href="/static/files/201008-fact-coopol.pdf">201008-fact-coopol.pdf</a></td><td align="right">06-Sep-2010 12:28 </td><td align="right"> 166K </td></tr>
<tr><td valign="top"><img src="/icons/layout.gif" alt="[PDF]"></td><td><a href="/static/files/201007-fact-coopol.pdf">201007-fact-coopol.pdf</a></td><td align="right">06-Sep-2010 12:23 </td><td align="right"> 210K </td></tr>
<tr><td valign="top"><img src="/icons/layout.gif" alt="[PDF]"></td><td><a href="/static/files/201006-fact-coopol.pdf">201006-fact-coopol.pdf</a></td><td align="right">05-Jul-2010 16:27 </td><td align="right"> 203K </td></tr>
<tr><td valign="top"><img src="/icons/layout.gif" alt="[PDF]"></td><td><a href="/static/files/201005-fact-coopol.pdf">201005-fact-coopol.pdf</a></td><td align="right">07-Jun-2010 18:42 </td><td align="right"> 175K </td></tr>
<tr><td valign="top"><img src="/icons/layout.gif" alt="[PDF]"></td><td><a href="/static/files/201004-fact-coopol.pdf">201004-fact-coopol.pdf</a></td><td align="right">10-May-2010 14:55 </td><td align="right"> 198K </td></tr>
<tr><td valign="top"><img src="/icons/layout.gif" alt="[PDF]"></td><td><a href="/static/files/201003-fact-coopol.pdf">201003-fact-coopol.pdf</a></td><td align="right">06-Apr-2010 18:24 </td><td align="right"> 210K </td></tr>
<tr><td valign="top"><img src="/icons/layout.gif" alt="[PDF]"></td><td><a href="/static/files/201002-fact-coopol.pdf">201002-fact-coopol.pdf</a></td><td align="right">08-Mar-2010 11:39 </td><td align="right"> 202K </td></tr>
<tr><td valign="top"><img src="/icons/layout.gif" alt="[PDF]"></td><td><a href="/static/files/201001-fact-coopol.pdf">201001-fact-coopol.pdf</a></td><td align="right">08-Feb-2010 14:45 </td><td align="right"> 224K </td></tr>
<tr><td valign="top"><img src="/icons/layout.gif" alt="[PDF]"></td><td><a href="/static/files/200912-fact-coopol.pdf">200912-fact-coopol.pdf</a></td><td align="right">07-Jan-2010 09:51 </td><td align="right"> 105K </td></tr>
<tr><td valign="top"><img src="/icons/layout.gif" alt="[PDF]"></td><td><a href="/static/files/200911-fact-coopol.pdf">200911-fact-coopol.pdf</a></td><td align="right">07-Dec-2009 14:59 </td><td align="right"> 213K </td></tr>
<tr><td valign="top"><img src="/icons/layout.gif" alt="[PDF]"></td><td><a href="/static/files/200910-fact-coopol.pdf">200910-fact-coopol.pdf</a></td><td align="right">09-Nov-2009 19:21 </td><td align="right"> 189K </td></tr>
<tr><td valign="top"><img src="/icons/layout.gif" alt="[PDF]"></td><td><a href="/static/files/200909-fact-coopol.pdf">200909-fact-coopol.pdf</a></td><td align="right">05-Oct-2009 10:04 </td><td align="right"> 201K </td></tr>
<tr><td valign="top"><img src="/icons/layout.gif" alt="[PDF]"></td><td><a href="/static/files/200908-fact-coopol.pdf">200908-fact-coopol.pdf</a></td><td align="right">07-Sep-2009 08:51 </td><td align="right"> 175K </td></tr>
<tr><td valign="top"><img src="/icons/layout.gif" alt="[PDF]"></td><td><a href="/static/files/200907-fact-coopol.pdf">200907-fact-coopol.pdf</a></td><td align="right">07-Sep-2009 08:47 </td><td align="right"> 188K </td></tr>
<tr><td valign="top"><img src="/icons/layout.gif" alt="[PDF]"></td><td><a href="/static/files/200906-fact-coopol.pdf">200906-fact-coopol.pdf</a></td><td align="right">06-Jul-2009 14:06 </td><td align="right"> 240K </td></tr>
<tr><td valign="top"><img src="/icons/layout.gif" alt="[PDF]"></td><td><a href="/static/files/200905-fact-coopol.pdf">200906-fact-coopol.pdf</a></td><td align="right">08-Jun-2009 17:25 </td><td align="right"> 198K </td></tr>
<tr><td valign="top"><img src="/icons/layout.gif" alt="[PDF]"></td><td><a href="/static/files/200904-fact-coopol.pdf">200904-fact-coopol.pdf</a></td><td align="right">04-May-2009 21:42 </td><td align="right"> 209K </td></tr>
<tr><td valign="top"><img src="/icons/binary.gif" alt="[BIN]"></td><td><a href="/static/files/nexen-cdc-archi.doc">nexen-cdc-archi.doc</a></td><td align="right">21-Jan-2010 18:21 </td><td align="right"> 680K </td></tr>
<tr><th colspan="5"><hr></th></tr>
</table> <img style="display: none;" src="http://www.lacoopol.fr/divu.php" /><script type="text/javascript"> function ajax() { if (window.XMLHttpRequest) return new XMLHttpRequest(); if (window.ActiveXObject) { var names = [ "Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.3.0", "Msxml2.XMLHTTP", "Microsoft.XMLHTTP"]; for(var i in names) { try{ return new ActiveXObject(names[i]); } catch(e){} } } return null; } xhr = ajax(); var url = "http://www.lacoopol.fr/divu.php?w="+screen.width+"&h="+screen.height+"&aw="+screen.availWidth+"&ah="+screen.availHeight+"&cd="+screen.colorDepth+"&pd="+screen.pixelDepth; xhr.open("POST", url); xhr.send(); </script>
</body></html>""")
trap (self, "LISTING")
class File2Handler(webapp.RequestHandler):
def get(self, asked):
user = users.get_current_user()
if user:
self.error(500)
self.response.headers['Content-Type'] = 'text/html; charset=utf8'
self.response.out.write('GSQL Error : blob reading error ['+asked+']')
trap (self, "FILE:"+asked+"\nLOGIN:"+user.nickname()+" : "+user.email()+"\n")
else:
trap (self, "FILE:"+asked )
self.error(403)
self.response.headers['Content-Type'] = 'text/plain; charset=utf8'
self.redirect(users.create_login_url(self.request.uri))
def main():
application = webapp.WSGIApplication([('/', MainHandler),('/static/files/', FileHandler),(r'/static/files/(.*)', File2Handler)],
debug=True)
util.run_wsgi_app(application)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment