[Python] Python Residential Proxy

Discussão em 'Python' iniciado por Stack, Agosto 5, 2025.

  1. Stack

    Stack Membro Participativo

    Here is my problem I managed to redirect the traffic via a python script which listens on port 80 of the pc the problem is when I want to access from outside the residence the client's proxy server so I am looking for a way to do not open ports like packetStream does

    class ProxyHandler(http.server.SimpleHTTPRequestHandler):
    def do_CONNECT(self):
    self.send_response(200, "Connection reussi")
    self.send_header("Proxy-agent", "Python Proxy")
    self.end_headers()

    with self.connect_to_target() as target_client:
    self.exchange_loop(self.connection, target_client)

    def connect_to_target(self):
    target_host, target_port = self.path.split(":")
    target_port = int(target_port)

    target_client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    target_client.connect((target_host, target_port))
    return target_client

    def exchange_loop(self, client, remote):
    while True:
    data = client.recv(4096)
    if not data:
    break
    remote.sendall(data)

    client.close()
    remote.close()


    def on_exit():
    # Code à exécuter avant la sortie du programme
    #sendState(False)
    print("Le programme est en train de se terminer.")


    # Enregistrement de la fonction on_exit pour être appelée à la sortie du programme
    atexit.register(on_exit)

    if __name__ == "__main__":
    handler = ProxyHandler
    with socketserver.ThreadingTCPServer(("localhost", PORT), handler) as httpd:
    #sendState(True)
    print(f"HTTP Proxy server is running on http://localhost:{PORT}")
    httpd.serve_forever()

    Continue reading...

Compartilhe esta Página