Last active
January 20, 2025 09:12
-
-
Save tanaydin/09cb9326305030539991a4d742fc16ff to your computer and use it in GitHub Desktop.
HTTP request handler for the jetbrains tools crackers gateway
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
import json | |
from http.server import HTTPServer, BaseHTTPRequestHandler | |
class ProxyHandler(BaseHTTPRequestHandler): | |
""" | |
HTTP request handler for the jetbrains tools crackers gateway. | |
which locates at https://github.com/kingparks/ | |
Handles GET and POST requests and returning a JSON response indicating paid status. | |
To run: | |
python jetbra_proxy.py | |
open another console and run: | |
export http_proxy='http://localhost:19090' | |
jetbra | |
bonus: Same thing as mitmproxy script.. | |
from mitmproxy import http | |
def request(flow: http.HTTPFlow) -> None: | |
flow.response = http.Response.make( | |
200, # (status code) | |
b'{"isPay": 1}', # (content) | |
{"Content-Type": "application/json"} # (headers) | |
) | |
""" | |
def _send_response(self): | |
"""Send a 200 OK response with JSON payload indicating paid status. | |
Sets appropriate headers and writes the JSON response to the output stream. | |
""" | |
self.send_response(200) | |
self.send_header('Content-Type', 'application/json') | |
self.end_headers() | |
response = {"isPay": 1} | |
self.wfile.write(json.dumps(response).encode()) | |
def do_GET(self): | |
self._send_response() | |
def do_POST(self): | |
self._send_response() | |
def run_server(port=19090): | |
server = HTTPServer(('localhost', port), ProxyHandler) | |
print(f'Starting proxy server on port {port}') | |
server.serve_forever() | |
if __name__ == '__main__': | |
run_server() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment