pollev / python-websocket-proxy Goto Github PK
View Code? Open in Web Editor NEWPython3 Websocket AND http proxy
Python3 Websocket AND http proxy
After adding the certificates to the browser it gets a bit further, but as soon as it tunnels a websocket messages it crashes and closes the connection:
py websocket_http_proxy.py
started https intercept proxy server at 127.0.0.1 (port 9999)
Initiating websocket handshake
127.0.0.1 - - [24/Jan/2024 16:26:28] "GET / HTTP/1.1" 101 -
127.0.0.1 - - [24/Jan/2024 16:26:28] websocket connected
127.0.0.1 - - [24/Jan/2024 16:26:28] Connecting to remote websocket wss://@@@@@@@@@@@/
127.0.0.1 - - [24/Jan/2024 16:26:28] Starting thread to forward server messages to the client
CLIENT: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Exception in thread Thread-9 (forward_to_client):
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\threading.py", line 1045, in _bootstrap_inner
self.run()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\threading.py", line 982, in run
self._target(*self._args, **self._kwargs)
File "C:@@@@@@@@@@@\websocket_http_proxy.py", line 625, in forward_to_client
message = str(proxy_obj.remote_websocket.recv())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users@@@\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\websocket_core.py", line 388, in recv
opcode, data = self.recv_data()
^^^^^^^^^^^^^^^^
File "C:\Users@@@\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\websocket_core.py", line 416, in recv_data
opcode, frame = self.recv_data_frame(control_frame)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users@@@\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\websocket_core.py", line 437, in recv_data_frame
frame = self.recv_frame()
^^^^^^^^^^^^^^^^^
File "C:\Users@@@\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\websocket_core.py", line 478, in recv_frame
return self.frame_buffer.recv_frame()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users@@@\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\websocket_abnf.py", line 363, in recv_frame
self.recv_header()
File "C:\Users@@@\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\websocket_abnf.py", line 319, in recv_header
header = self.recv_strict(2)
^^^^^^^^^^^^^^^^^^^
File "C:\Users@@@\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\websocket_abnf.py", line 398, in recv_strict
bytes = self.recv(min(16384, shortage))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users@@@\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\websocket_core.py", line 563, in _recv
return recv(self.sock, bufsize)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users@@@\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\websocket_socket.py", line 129, in recv
raise WebSocketConnectionClosedException("Connection to remote host was lost.")
websocket._exceptions.WebSocketConnectionClosedException: Connection to remote host was lost.
Is this something on my side, something else I'm missing or whats going on?
Is this project dead? I just get issues trying to run it:
Exception occurred during processing of request from ('127.0.0.1', 52432)
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\socketserver.py", line 691, in process_request_thread
self.finish_request(request, client_address)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\socketserver.py", line 361, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\@@@@@\websocket_http_proxy.py", line 81, in init
BaseHTTPRequestHandler.init(self, *args, **kwargs)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\socketserver.py", line 755, in init
self.handle()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\http\server.py", line 436, in handle
self.handle_one_request()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\http\server.py", line 424, in handle_one_request
method()
File "C:\Users\@@@@@\websocket_http_proxy.py", line 85, in do_CONNECT
self.connect_intercept()
File "C:\Users\@@@@@\websocket_http_proxy.py", line 109, in connect_intercept
self.connection = ssl_settings.wrap_socket(self.connection, server_side=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\ssl.py", line 517, in wrap_socket
return self.sslsocket_class._create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\ssl.py", line 1108, in _create
self.do_handshake()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\ssl.py", line 1383, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: SSLV3_ALERT_BAD_CERTIFICATE] sslv3 alert bad certificate (_ssl.c:1006)
Set up the certs just like setup_https_intercept.sh said, works without the certs but cant seem to intercept the websocket then.
hi
how to modify response of tagret server, before sent end user
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.