Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty reply from proxy server - even when remote target port is closed #169

Open
t3chn0m4g3 opened this issue Aug 31, 2023 · 1 comment
Open

Comments

@t3chn0m4g3
Copy link

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.

@t3chn0m4g3
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant