Skip to content

Commit

Permalink
Mandatory use of square-bracket notation for literal IPv6 proxy address
Browse files Browse the repository at this point in the history
Closes nmap#1441
  • Loading branch information
nnposter committed Feb 23, 2019
1 parent dbed133 commit 504e9d7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#Nmap Changelog ($Id$); -*-text-*-

o [ncat][GH#1441] To avoid confusion and to support default proxy ports,
option --proxy now requires a literal IPv6 address to be specified using
square-bracket notation, such as --proxy [2001:db8::123]:456. [nnposter]

o [ncat][GH#1214][GH#1230][GH#1439] New ncat option provides control over
whether proxy destinations are resolved by the remote proxy server or
locally, by Ncat itself. See option --proxy-dns. [nnposter]
Expand Down
6 changes: 4 additions & 2 deletions ncat/docs/ncat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,10 @@
using the protocol specified by <option>--proxy-type</option>.</para>

<para>If no port is specified, the proxy protocol's well-known port is used (1080 for
SOCKS and 3128 for HTTP). However, when specifying an IPv6 HTTP proxy server using
the IP address rather than the hostname, the port number MUST be specified as well.
SOCKS and 3128 for HTTP). When specifying an IPv6 HTTP proxy server
using the IP address rather than the hostname, the square-bracket
notation (for example [2001:db8::1]:8080) MUST be used to separate
the port from the IPv6 address.
If the proxy requires authentication, use <option>--proxy-auth</option>.</para>
</listitem>
</varlistentry>
Expand Down
13 changes: 11 additions & 2 deletions ncat/ncat_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,21 @@ static int ncat_listen_mode(void);
static size_t parseproxy(char *str, struct sockaddr_storage *ss,
size_t *sslen, unsigned short *portno)
{
char *p = strrchr(str, ':');
char *p = str;
char *q;
long pno;
int rc;

if (p != NULL) {
if (*p == '[') {
p = strchr(p, ']');
if (p == NULL)
bye("Invalid proxy IPv6 address \"%s\".", str);
++str;
*p++ = '\0';
}

p = strchr(p, ':');
if (p != NULL && strchr(p + 1, ':') == NULL) {
*p++ = '\0';
pno = strtol(p, &q, 10);
if (pno < 1 || pno > 0xFFFF || *q)
Expand Down

0 comments on commit 504e9d7

Please sign in to comment.