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

Closed
wants to merge 3 commits into from

Conversation

@pomu0325
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:
image

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

nmap/ncat/ncat_connect.c

Lines 915 to 923 in b0bd277

switch (socksbuf[3]) {
case SOCKS5_ATYP_IPv4:
bndaddrlen = 4 + 2;
break;
case SOCKS5_ATYP_IPv6:
bndaddrlen = 16 + 2;
break;
default:
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");
close(sd);
return -1;
}
bndaddrlen = (unsigned char) socksbuf[0] + 2;
Copy link
Author

@pomu0325 pomu0325 Sep 10, 2021

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.

@nnposter
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!

@nmap-bot nmap-bot closed this in 972ed6b Oct 10, 2021
@pomu0325 pomu0325 deleted the ncat/support-SOCKS5_ATYP_NAME branch Oct 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants