Advertisement
Deerenaros

base http server with injection

May 6th, 2015
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.03 KB | None | 0 0
  1. import time
  2. import urllib2
  3. import BaseHTTPServer
  4.  
  5.  
  6. HOST_NAME = 'example.net' # !!!REMEMBER TO CHANGE THIS!!!
  7. PORT_NUMBER = 80 # Maybe set this to 9000.
  8.  
  9.  
  10. class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
  11.     def do_HEAD(s):
  12.         s.send_response(200)
  13.         s.send_header("Content-type", "text/html")
  14.         s.end_headers()
  15.     def do_GET(s):
  16.         """Respond to a GET request."""
  17.         s.send_response(200)
  18.         s.send_header("Content-type", "text/html")
  19.         s.end_headers()
  20.         content = urllib.open(s.path)
  21.         # insert banner or donate-bunner to content here!
  22.         s.wfile.write(content)
  23.  
  24. if __name__ == '__main__':
  25.     server_class = BaseHTTPServer.HTTPServer
  26.     httpd = server_class((HOST_NAME, PORT_NUMBER), MyHandler)
  27.     print time.asctime(), "Server Starts - %s:%s" % (HOST_NAME, PORT_NUMBER)
  28.     try:
  29.         httpd.serve_forever()
  30.     except KeyboardInterrupt:
  31.         pass
  32.     httpd.server_close()
  33.     print time.asctime(), "Server Stops - %s:%s" % (HOST_NAME, PORT_NUMBER)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement