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

ncat: Support domain name response from socks5 proxy #2365

wants to merge 3 commits into from


Copy link

@pomu0325 pomu0325 commented Sep 10, 2021

Some socks5 proxy server returns 3: Domain Name as an Address Type value.
Here is an example of response packet:

But current ncat implementation does not support this type and ends up with "Error: invalid proxy bind address type":


Lines 915 to 923 in b0bd277

switch (socksbuf[3]) {
case SOCKS5_ATYP_IPv4:
bndaddrlen = 4 + 2;
case SOCKS5_ATYP_IPv6:
bndaddrlen = 16 + 2;
loguser("Error: invalid proxy bind address type.\n");

This kind of response is described in RFC1928, so should be supported.

if (socket_buffer_readcount(&stateful_buf, socksbuf, 1) < 0) {
loguser("Error: number of octets of domain name missing.\n");
return -1;
bndaddrlen = (unsigned char) socksbuf[0] + 2;
Copy link

@pomu0325 pomu0325 Sep 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in RFC1928,

the address field contains a fully-qualified domain name. The first
octet of the address field contains the number of octets of name that
follow, there is no terminating NUL octet.

Copy link

@nnposter nnposter commented Sep 12, 2021

I definitely want to review this enhancement but I am out of pocket for the next few weeks. Stay tuned.

Copy link

@nnposter nnposter left a comment

The code looks good. It has been committed as r38294.
Thank you for contributing to Nmap!

@pomu0325 pomu0325 deleted the ncat/support-SOCKS5_ATYP_NAME branch Oct 10, 2021
mzet- pushed a commit to mzet-/Nmap-for-Pen-Testers that referenced this issue Dec 20, 2021
@nmap nmap deleted a comment Apr 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants