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

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.

Comment on lines +920 to +925
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

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.

@nnposter
Copy link

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

Choose a reason for hiding this comment

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

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 October 10, 2021 02:58
mzet- pushed a commit to mzet-/Nmap-for-Pen-Testers that referenced this pull request 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants