Skip to content

Commit

Permalink
Add SOCKS5 support for SOCKS5_ATYP_NAME bind address. Closes nmap#2365
Browse files Browse the repository at this point in the history
  • Loading branch information
nnposter authored and mzet- committed Dec 20, 2021
1 parent fcc5654 commit 2ce7e07
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG
Expand Up @@ -3,6 +3,9 @@
o [Ncat] Fix hostname/certificate comparison and matching to handle ASN.1
strings without null terminators, a similar bug to OpenSSL's CVE-2021-3712.

o [Ncat][GH#2365] Added support for SOCKS5 proxies that return bind addresses
as hostnames, instead of IPv4/IPv6 addresses. [pomu0325]

Nmap 7.92 [2021-08-07]

o [Windows] Upgraded Npcap (our Windows raw packet capturing and
Expand Down
10 changes: 9 additions & 1 deletion ncat/ncat_connect.c
Expand Up @@ -660,7 +660,7 @@ static int do_proxy_socks5(void)
size_t addrlen;
char addrstr[INET6_ADDRSTRLEN];
size_t bndaddrlen;
char bndaddr[16 + 2]; /* IPv4/IPv6 address and port */
char bndaddr[SOCKS5_DST_MAXLEN + 2]; /* IPv4/IPv6/hostname and port */
size_t remainderlen;
char* remainder;

Expand Down Expand Up @@ -919,6 +919,14 @@ static int do_proxy_socks5(void)
case SOCKS5_ATYP_IPv6:
bndaddrlen = 16 + 2;
break;
case SOCKS5_ATYP_NAME:
if (socket_buffer_readcount(&stateful_buf, socksbuf, 1) < 0) {
loguser("Error: malformed request response from proxy.\n");
close(sd);
return -1;
}
bndaddrlen = (unsigned char)socksbuf[0] + 2;
break;
default:
loguser("Error: invalid proxy bind address type.\n");
close(sd);
Expand Down

0 comments on commit 2ce7e07

Please sign in to comment.