1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-28 18:39:03 +00:00

Selects correct default port for a given proxy type. Closes #1139

This commit is contained in:
nnposter
2018-03-05 01:53:34 +00:00
parent a2c93e87d0
commit 68220585cd
2 changed files with 25 additions and 18 deletions

View File

@@ -1,5 +1,8 @@
#Nmap Changelog ($Id$); -*-text-*-
o [Ncat][GH#1139] Ncat now selects the correct default port for a given proxy
type. [Pavel Zhukov]
o [NSE] memcached-info can now gather information from the UDP memcached
service in addition to the TCP service. The UDP service is frequently used as
a DDoS reflector and amplifier. [Daniel Miller]

View File

@@ -277,7 +277,7 @@ int main(int argc, char *argv[])
struct host_list_node *allow_host_list = NULL;
struct host_list_node *deny_host_list = NULL;
unsigned short proxyport = DEFAULT_PROXY_PORT;
unsigned short proxyport;
int srcport = -1;
char *source = NULL;
@@ -724,24 +724,28 @@ int main(int argc, char *argv[])
if (!o.proxytype)
o.proxytype = Strdup("http");
if (!strcmp(o.proxytype, "http") ||
!strcmp(o.proxytype, "socks4") || !strcmp(o.proxytype, "4") ||
!strcmp(o.proxytype, "socks5") || !strcmp(o.proxytype, "5")) {
/* Parse HTTP/SOCKS proxy address and store it in targetss.
* If the proxy server is given as an IPv6 address (not hostname),
* the port number MUST be specified as well or parsing will break
* (due to the colons in the IPv6 address and host:port separator).
*/
targetaddrs->addrlen = parseproxy(o.proxyaddr,
&targetaddrs->addr.storage, &targetaddrs->addrlen, &proxyport);
if (o.af == AF_INET) {
targetaddrs->addr.in.sin_port = htons(proxyport);
} else { // might modify to else if and test AF_{INET6|UNIX|UNSPEC}
targetaddrs->addr.in6.sin6_port = htons(proxyport);
}
} else {
/* validate proxy type and configure its default port */
if (!strcmp(o.proxytype, "http"))
proxyport = DEFAULT_PROXY_PORT;
else if (!strcmp(o.proxytype, "socks4") || !strcmp(o.proxytype, "4"))
proxyport = DEFAULT_SOCKS4_PORT;
else if (!strcmp(o.proxytype, "socks5") || !strcmp(o.proxytype, "5"))
proxyport = DEFAULT_SOCKS5_PORT;
else
bye("Invalid proxy type \"%s\".", o.proxytype);
/* Parse HTTP/SOCKS proxy address and store it in targetss.
* If the proxy server is given as an IPv6 address (not hostname),
* the port number MUST be specified as well or parsing will break
* (due to the colons in the IPv6 address and host:port separator).
*/
targetaddrs->addrlen = parseproxy(o.proxyaddr,
&targetaddrs->addr.storage, &targetaddrs->addrlen, &proxyport);
if (o.af == AF_INET) {
targetaddrs->addr.in.sin_port = htons(proxyport);
} else { // might modify to else if and test AF_{INET6|UNIX|UNSPEC}
targetaddrs->addr.in6.sin6_port = htons(proxyport);
}
if (o.listen)