Created
October 6, 2021 18:54
-
-
Save VictorNS69/eac06bace9d83014ec7368b149bedb4e to your computer and use it in GitHub Desktop.
FakeRedirect server with Python 3
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
#!/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