Skip to content

Instantly share code, notes, and snippets.

@VictorNS69
Created October 6, 2021 18:54
Show Gist options
  • Save VictorNS69/eac06bace9d83014ec7368b149bedb4e to your computer and use it in GitHub Desktop.
Save VictorNS69/eac06bace9d83014ec7368b149bedb4e to your computer and use it in GitHub Desktop.
FakeRedirect server with Python 3
#!/usr/bin/env python3
from http.server import HTTPServer, BaseHTTPRequestHandler
# Open netcat on port 6969
# nc -lvnp 6969
REDIRECT_URL = f"http://localhost:6969"
LISTENER_PORT = 8080
class FakeRedirect(BaseHTTPRequestHandler):
def do_GET(self):
print(f"Path: {self.path}")
self.send_response(302) # 302 - Found
new_path = f"{REDIRECT_URL}{self.path}"
self.send_header('Location', new_path)
self.end_headers()
print("Starting FakeRedirect server")
HTTPServer(("", LISTENER_PORT), FakeRedirect).serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment