python-proxy
python-proxy copied to clipboard
Empty reply from proxy server - even when remote target port is closed
Using the proxy to connect to a remote target, i.e. using curl --socks5 1.2.3.4:1080 targetip:targetport
leads to empty replies (curl: (52) Empty reply from server
), even when the remote target port is closed.
Is this behaviour intended? Can anyone else confirm this?
On a side note, when setting up SSH as Socks Proxy ssh -N -D 0.0.0.0:1080 localhost
it works as expected and the proxy does not answer with an empty reply for closed ports curl: (97) connection to proxy closed
.
Turning on the debug via -d
reveals that refused connections are seemingly not handled gracefully:
Task exception was never retrieved
future: <Task finished name='Task-4' coro=<stream_handler() done, defined at /home/marco/pproxy/lib/python3.11/site-packages/pproxy/server.py:62> exception=ConnectionRefusedError(111, "Connect call failed ('172.20.254.1', 2222)")>
Traceback (most recent call last):
File "/home/marco/pproxy/lib/python3.11/site-packages/pproxy/server.py", line 85, in stream_handler
reader_remote, writer_remote = await roption.open_connection(host_name, port, local_addr, lbind)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/marco/pproxy/lib/python3.11/site-packages/pproxy/server.py", line 223, in open_connection
reader, writer = await asyncio.wait_for(wait, timeout=timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Thus pproxy does not submit the proper response = bytes([0x05, 0x05, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
which leads to clients like curl
to interpret the port as open with an empty response.