diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..14ab94c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +SOURCES/nmap-ncat-7.50.tar.bz2 +SOURCES/nmap-purified-6.40.tar.bz2 diff --git a/.nmap.metadata b/.nmap.metadata new file mode 100644 index 0000000..6ec65cb --- /dev/null +++ b/.nmap.metadata @@ -0,0 +1,2 @@ +8e84bfeeacaaf80dd8bbff351d6e893642b1b533 SOURCES/nmap-ncat-7.50.tar.bz2 +58cd84e04fae5a64b091f0ed4ab9e024b7494177 SOURCES/nmap-purified-6.40.tar.bz2 diff --git a/README.md b/README.md deleted file mode 100644 index 0e7897f..0000000 --- a/README.md +++ /dev/null @@ -1,5 +0,0 @@ -The master branch has no content - -Look at the c7 branch if you are working with CentOS-7, or the c4/c5/c6 branch for CentOS-4, 5 or 6 - -If you find this file in a distro specific branch, it means that no content has been checked in yet diff --git a/SOURCES/ncat_reg_stdin.diff b/SOURCES/ncat_reg_stdin.diff new file mode 100644 index 0000000..e6034b2 --- /dev/null +++ b/SOURCES/ncat_reg_stdin.diff @@ -0,0 +1,12 @@ +diff -up nmap-6.01/ncat/ncat_main.c.noepoll nmap-6.01/ncat/ncat_main.c +--- nmap-6.01/ncat/ncat_main.c.noepoll 2013-01-04 12:50:18.670295473 +0100 ++++ nmap-6.01/ncat/ncat_main.c 2013-01-04 12:50:18.692295660 +0100 +@@ -280,6 +280,8 @@ int main(int argc, char *argv[]) + #ifdef WIN32 + windows_init(); + #endif ++ ++ nsock_set_default_engine("select"); + + while (1) { + /* handle command line arguments */ diff --git a/SOURCES/nmap-4.03-mktemp.patch b/SOURCES/nmap-4.03-mktemp.patch new file mode 100644 index 0000000..68baffe --- /dev/null +++ b/SOURCES/nmap-4.03-mktemp.patch @@ -0,0 +1,23 @@ +--- nmap-4.03/shtool.mktemp 2006-05-10 13:09:34.000000000 +0200 ++++ nmap-4.03/shtool 2006-05-10 13:13:58.000000000 +0200 +@@ -579,15 +579,11 @@ + else + tmpdir="/tmp" + fi +- tmpdir="$tmpdir/.shtool.$$" +- ( umask 077 +- rm -rf "$tmpdir" >/dev/null 2>&1 || true +- mkdir "$tmpdir" >/dev/null 2>&1 +- if [ $? -ne 0 ]; then +- echo "$msgprefix:Error: failed to create temporary directory \`$tmpdir'" 1>&2 +- exit 1 +- fi +- ) ++ tmpdir=`mktemp -p $tmpdir -d` ++ if [ $? -ne 0 ]; then ++ echo "$msgprefix:Error: failed to create temporary directory \`$tmpdir'" 1>&2 ++ exit 1 ++ fi + + # create (implicitly) secure temporary file + tmpfile="$tmpdir/shtool.tmp" diff --git a/SOURCES/nmap-4.52-noms.patch b/SOURCES/nmap-4.52-noms.patch new file mode 100644 index 0000000..2161715 --- /dev/null +++ b/SOURCES/nmap-4.52-noms.patch @@ -0,0 +1,24 @@ +diff -up nmap-4.90RC1/docs/nmap.1.noms nmap-4.90RC1/docs/nmap.1 +--- nmap-4.90RC1/docs/nmap.1.noms 2009-06-25 01:12:51.000000000 +0200 ++++ nmap-4.90RC1/docs/nmap.1 2009-07-16 09:58:22.090769947 +0200 +@@ -282,7 +282,7 @@ Nmap 4\&.90RC1 ( http://nmap\&.org ) + Usage: nmap [Scan Type(s)] [Options] {target specification} + TARGET SPECIFICATION: + Can pass hostnames, IP addresses, networks, etc\&. +- Ex: scanme\&.nmap\&.org, microsoft\&.com/24, 192\&.168\&.0\&.1; 10\&.0\&.0\-255\&.1\-254 ++ Ex: scanme\&.nmap\&.org, 192\&.168\&.0\&.1; 10\&.0\&.0\-255\&.1\-254 + \-iL : Input from list of hosts/networks + \-iR : Choose random targets + \-\-exclude : Exclude hosts/networks +diff -up nmap-4.90RC1/docs/nmap.usage.txt.noms nmap-4.90RC1/docs/nmap.usage.txt +--- nmap-4.90RC1/docs/nmap.usage.txt.noms 2009-06-25 01:12:51.000000000 +0200 ++++ nmap-4.90RC1/docs/nmap.usage.txt 2009-07-16 09:56:24.758078049 +0200 +@@ -2,7 +2,7 @@ Nmap 4.90RC1 ( http://nmap.org ) + Usage: nmap [Scan Type(s)] [Options] {target specification} + TARGET SPECIFICATION: + Can pass hostnames, IP addresses, networks, etc. +- Ex: scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254 ++ Ex: scanme.nmap.org, 192.168.0.1; 10.0.0-255.1-254 + -iL : Input from list of hosts/networks + -iR : Choose random targets + --exclude : Exclude hosts/networks diff --git a/SOURCES/nmap-6.25-displayerror.patch b/SOURCES/nmap-6.25-displayerror.patch new file mode 100644 index 0000000..6b59845 --- /dev/null +++ b/SOURCES/nmap-6.25-displayerror.patch @@ -0,0 +1,17 @@ +diff -up nmap-6.25/zenmap/zenmapGUI/App.py.displayerror nmap-6.25/zenmap/zenmapGUI/App.py +--- nmap-6.25/zenmap/zenmapGUI/App.py.displayerror 2013-05-23 15:11:46.595569883 +0200 ++++ nmap-6.25/zenmap/zenmapGUI/App.py 2013-05-23 15:12:44.786049525 +0200 +@@ -116,7 +116,12 @@ except Exception: + # startup scripts, and for some reason the first connection (the one that + # caused the launch) is rejected. But somehow subsequent connections work + # fine! So if the import fails, try one more time. +- import gtk ++ try: ++ import gtk ++ except Exception, e: ++ print >> sys.stderr, 'Error:', str(e) ++ sys.exit(1) ++ + warnings.resetwarnings() + + from zenmapGUI.higwidgets.higdialogs import HIGAlertDialog diff --git a/SOURCES/nmap-6.40-add_eproto_handler.patch b/SOURCES/nmap-6.40-add_eproto_handler.patch new file mode 100644 index 0000000..3de4b87 --- /dev/null +++ b/SOURCES/nmap-6.40-add_eproto_handler.patch @@ -0,0 +1,12 @@ +diff --git a/nsock/src/nsock_core.c b/nsock/src/nsock_core.c +index ec38cad..1261c83 100644 +--- a/nsock/src/nsock_core.c ++++ b/nsock/src/nsock_core.c +@@ -350,6 +350,7 @@ void handle_connect_result(mspool *ms, msevent *nse, enum nse_status status) { + case ETIMEDOUT: + case EHOSTDOWN: + case ECONNRESET: ++ case EPROTO: + #ifdef WIN32 + case WSAEADDRINUSE: + case WSAEADDRNOTAVAIL: diff --git a/SOURCES/nmap-6.40-allresolve.patch b/SOURCES/nmap-6.40-allresolve.patch new file mode 100644 index 0000000..2a19139 --- /dev/null +++ b/SOURCES/nmap-6.40-allresolve.patch @@ -0,0 +1,480 @@ +diff -up nmap-6.40/ncat/ncat_connect.c.allresolve nmap-6.40/ncat/ncat_connect.c +--- nmap-6.40/ncat/ncat_connect.c.allresolve 2015-07-07 09:47:11.527409563 +0200 ++++ nmap-6.40/ncat/ncat_connect.c 2015-07-07 09:47:11.529409551 +0200 +@@ -165,6 +165,7 @@ static struct conn_state cs = { + 0 + }; + ++static void try_nsock_connect(nsock_pool nsp, struct sockaddr_list *conn_addr); + static void connect_handler(nsock_pool nsp, nsock_event evt, void *data); + static void post_connect(nsock_pool nsp, nsock_iod iod); + static void read_stdin_handler(nsock_pool nsp, nsock_event evt, void *data); +@@ -586,7 +587,7 @@ int ncat_connect(void) + + if (o.af != AF_INET) + bye("Sorry, -g can only currently be used with IPv4."); +- ipopts = buildsrcrte(targetss.in.sin_addr, o.srcrtes, o.numsrcrtes, o.srcrteptr, &ipoptslen); ++ ipopts = buildsrcrte(targetaddrs->addr.in.sin_addr, o.srcrtes, o.numsrcrtes, o.srcrteptr, &ipoptslen); + + nsi_set_ipoptions(cs.sock_nsi, ipopts, ipoptslen); + free(ipopts); /* Nsock has its own copy */ +@@ -596,49 +597,18 @@ int ncat_connect(void) + if (o.af == AF_UNIX) { + if (o.proto == IPPROTO_UDP) { + nsock_connect_unixsock_datagram(mypool, cs.sock_nsi, connect_handler, NULL, +- &targetss.sockaddr, +- SUN_LEN((struct sockaddr_un *)&targetss.sockaddr)); ++ &targetaddrs->addr.sockaddr, ++ SUN_LEN((struct sockaddr_un *)&targetaddrs->addr.sockaddr)); + } else { + nsock_connect_unixsock_stream(mypool, cs.sock_nsi, connect_handler, o.conntimeout, +- NULL, &targetss.sockaddr, +- SUN_LEN((struct sockaddr_un *)&targetss.sockaddr)); ++ NULL, &targetaddrs->addr.sockaddr, ++ SUN_LEN((struct sockaddr_un *)&targetaddrs->addr.sockaddr)); + } + } else + #endif +- if (o.proto == IPPROTO_UDP) { +- nsock_connect_udp(mypool, cs.sock_nsi, connect_handler, +- NULL, &targetss.sockaddr, targetsslen, +- inet_port(&targetss)); +- } +-#ifdef HAVE_OPENSSL +- else if (o.proto == IPPROTO_SCTP && o.ssl) { +- nsock_connect_ssl(mypool, cs.sock_nsi, connect_handler, +- o.conntimeout, NULL, +- &targetss.sockaddr, targetsslen, +- IPPROTO_SCTP, inet_port(&targetss), +- NULL); +- } +-#endif +- else if (o.proto == IPPROTO_SCTP) { +- nsock_connect_sctp(mypool, cs.sock_nsi, connect_handler, +- o.conntimeout, NULL, +- &targetss.sockaddr, targetsslen, +- inet_port(&targetss)); +- } +-#ifdef HAVE_OPENSSL +- else if (o.ssl) { +- nsock_connect_ssl(mypool, cs.sock_nsi, connect_handler, +- o.conntimeout, NULL, +- &targetss.sockaddr, targetsslen, +- IPPROTO_TCP, inet_port(&targetss), +- NULL); +- } +-#endif +- else { +- nsock_connect_tcp(mypool, cs.sock_nsi, connect_handler, +- o.conntimeout, NULL, +- &targetss.sockaddr, targetsslen, +- inet_port(&targetss)); ++ { ++ /* Add connection to first resolved address. */ ++ try_nsock_connect(mypool, targetaddrs); + } + } else { + /* A proxy connection. */ +@@ -665,8 +635,8 @@ int ncat_connect(void) + socket_buffer_init(&stateful_buf, connect_socket); + + if (o.verbose) { +- loguser("Connected to proxy %s:%hu\n", inet_socktop(&targetss), +- inet_port(&targetss)); ++ loguser("Connected to proxy %s:%hu\n", inet_socktop(&targetaddrs->addr), ++ inet_port(&targetaddrs->addr)); + } + + /* Fill the socks4_data struct */ +@@ -716,6 +686,8 @@ int ncat_connect(void) + /* connect */ + rc = nsock_loop(mypool, -1); + ++ free_sockaddr_list(targetaddrs); ++ + if (o.verbose) { + struct timeval end_time; + double time; +@@ -739,19 +711,73 @@ int ncat_connect(void) + return rc == NSOCK_LOOP_ERROR ? 1 : 0; + } + ++static void try_nsock_connect(nsock_pool nsp, struct sockaddr_list *conn_addr) ++{ ++ if (o.proto == IPPROTO_UDP) { ++ nsock_connect_udp(nsp, cs.sock_nsi, connect_handler, (void *)conn_addr->next, ++ &conn_addr->addr.sockaddr, conn_addr->addrlen, ++ inet_port(&conn_addr->addr)); ++ } ++#ifdef HAVE_OPENSSL ++ else if (o.proto == IPPROTO_SCTP && o.ssl) { ++ nsock_connect_ssl(nsp, cs.sock_nsi, connect_handler, ++ o.conntimeout, (void *)conn_addr->next, ++ &conn_addr->addr.sockaddr, conn_addr->addrlen, ++ IPPROTO_SCTP, inet_port(&conn_addr->addr), ++ NULL); ++ } ++#endif ++ else if (o.proto == IPPROTO_SCTP) { ++ nsock_connect_sctp(nsp, cs.sock_nsi, connect_handler, ++ o.conntimeout, (void *)conn_addr->next, ++ &conn_addr->addr.sockaddr, conn_addr->addrlen, ++ inet_port(&conn_addr->addr)); ++ } ++#ifdef HAVE_OPENSSL ++ else if (o.ssl) { ++ nsock_connect_ssl(nsp, cs.sock_nsi, connect_handler, ++ o.conntimeout, (void *)conn_addr->next, ++ &conn_addr->addr.sockaddr, conn_addr->addrlen, ++ IPPROTO_TCP, inet_port(&conn_addr->addr), ++ NULL); ++ } ++#endif ++ else { ++ nsock_connect_tcp(nsp, cs.sock_nsi, connect_handler, ++ o.conntimeout, (void *)conn_addr->next, ++ &conn_addr->addr.sockaddr, conn_addr->addrlen, ++ inet_port(&conn_addr->addr)); ++ } ++} ++ + static void connect_handler(nsock_pool nsp, nsock_event evt, void *data) + { + enum nse_status status = nse_status(evt); + enum nse_type type = nse_type(evt); ++ struct sockaddr_list *next_addr = (struct sockaddr_list *)data; + + ncat_assert(type == NSE_TYPE_CONNECT || type == NSE_TYPE_CONNECT_SSL); + +- if (status == NSE_STATUS_ERROR) { +- loguser("%s.\n", socket_strerror(nse_errorcode(evt))); +- exit(1); +- } else if (status == NSE_STATUS_TIMEOUT) { +- loguser("%s.\n", socket_strerror(ETIMEDOUT)); +- exit(1); ++ if (status == NSE_STATUS_ERROR || status == NSE_STATUS_TIMEOUT) { ++ int errcode = (status == NSE_STATUS_TIMEOUT)?ETIMEDOUT:nse_errorcode(evt); ++ /* If there are more resolved addresses, try connecting to next one */ ++ if (next_addr != NULL) { ++ if (o.verbose) { ++ union sockaddr_u peer; ++ zmem(&peer, sizeof(peer.storage)); ++ nsi_getlastcommunicationinfo(cs.sock_nsi, NULL, NULL, NULL, ++ &peer.sockaddr, sizeof(peer.storage)); ++ loguser("Connection to %s failed: %s.\n", inet_socktop(&peer), socket_strerror(errcode)); ++ loguser("Trying next address...\n"); ++ } ++ try_nsock_connect(nsp, next_addr); ++ return; ++ } ++ else { ++ free_sockaddr_list(targetaddrs); ++ loguser("%s.\n", socket_strerror(errcode)); ++ exit(1); ++ } + } else { + ncat_assert(status == NSE_STATUS_SUCCESS); + } +diff -up nmap-6.40/ncat/ncat_core.c.allresolve nmap-6.40/ncat/ncat_core.c +--- nmap-6.40/ncat/ncat_core.c.allresolve 2013-07-29 00:08:48.000000000 +0200 ++++ nmap-6.40/ncat/ncat_core.c 2015-07-07 09:47:11.529409551 +0200 +@@ -147,8 +147,7 @@ int num_listenaddrs = 0; + union sockaddr_u srcaddr; + size_t srcaddrlen; + +-union sockaddr_u targetss; +-size_t targetsslen; ++struct sockaddr_list *targetaddrs; + + union sockaddr_u httpconnect, socksconnect; + size_t httpconnectlen, socksconnectlen; +@@ -211,19 +210,23 @@ void options_init(void) + #endif + } + +-/* Internal helper for resolve and resolve_numeric. addl_flags is ored into +- hints.ai_flags, so you can add AI_NUMERICHOST. */ ++/* Internal helper for resolve and resolve_numeric. ++ addl_flags is ored into hints.ai_flags, so you can add AI_NUMERICHOST. ++ sl is a pointer to first element of sockaddr linked list, which is always ++ statically allocated. Next list elements are dynamically allocated. ++ If multiple_addrs is false then only first address is returned. */ + static int resolve_internal(const char *hostname, unsigned short port, +- struct sockaddr_storage *ss, size_t *sslen, int af, int addl_flags) ++ struct sockaddr_list *sl, int af, int addl_flags, int multiple_addrs) + { + struct addrinfo hints; + struct addrinfo *result; ++ struct addrinfo *next; ++ struct sockaddr_list **item_ptr = &sl; ++ struct sockaddr_list *new_item; + char portbuf[16]; + int rc; + + ncat_assert(hostname != NULL); +- ncat_assert(ss != NULL); +- ncat_assert(sslen != NULL); + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = af; +@@ -240,8 +243,19 @@ static int resolve_internal(const char * + if (result == NULL) + return EAI_NONAME; + ncat_assert(result->ai_addrlen > 0 && result->ai_addrlen <= (int) sizeof(struct sockaddr_storage)); +- *sslen = result->ai_addrlen; +- memcpy(ss, result->ai_addr, *sslen); ++ for (next = result; next != NULL; next = next->ai_next) { ++ if (*item_ptr == NULL) ++ { ++ *item_ptr = (struct sockaddr_list *)safe_malloc(sizeof(struct sockaddr_list)); ++ (**item_ptr).next = NULL; ++ } ++ new_item = *item_ptr; ++ new_item->addrlen = next->ai_addrlen; ++ memcpy(&new_item->addr.storage, next->ai_addr, next->ai_addrlen); ++ if (!multiple_addrs) ++ break; ++ item_ptr = &new_item->next; ++ } + freeaddrinfo(result); + + return 0; +@@ -260,12 +274,42 @@ int resolve(const char *hostname, unsign + struct sockaddr_storage *ss, size_t *sslen, int af) + { + int flags; ++ struct sockaddr_list sl; ++ int result; + + flags = 0; + if (o.nodns) + flags |= AI_NUMERICHOST; + +- return resolve_internal(hostname, port, ss, sslen, af, flags); ++ result = resolve_internal(hostname, port, &sl, af, flags, 0); ++ *ss = sl.addr.storage; ++ *sslen = sl.addrlen; ++ return result; ++} ++ ++/* Resolves the given hostname or IP address with getaddrinfo, and stores ++ all results into a linked list. ++ The rest of the behavior is same as resolve(). */ ++int resolve_multi(const char *hostname, unsigned short port, ++ struct sockaddr_list *sl, int af) ++{ ++ int flags; ++ ++ flags = 0; ++ if (o.nodns) ++ flags |= AI_NUMERICHOST; ++ ++ return resolve_internal(hostname, port, sl, af, flags, 1); ++} ++ ++void free_sockaddr_list(struct sockaddr_list *sl) ++{ ++ struct sockaddr_list *current, *next = sl; ++ while (next != NULL) { ++ current = next; ++ next = current->next; ++ free(current); ++ } + } + + int fdinfo_close(struct fdinfo *fdn) +diff -up nmap-6.40/ncat/ncat_core.h.allresolve nmap-6.40/ncat/ncat_core.h +--- nmap-6.40/ncat/ncat_core.h.allresolve 2013-07-29 00:08:48.000000000 +0200 ++++ nmap-6.40/ncat/ncat_core.h 2015-07-07 09:47:11.529409551 +0200 +@@ -130,14 +130,20 @@ + a IPV4 INADDR_ANY and a IPV6 in6addr_any at most or a user defined address */ + #define NUM_LISTEN_ADDRS 2 + ++/* Structure to store a linked list of resolved addresses. */ ++struct sockaddr_list { ++ union sockaddr_u addr; ++ size_t addrlen; ++ struct sockaddr_list* next; ++}; ++ + extern union sockaddr_u listenaddrs[NUM_LISTEN_ADDRS]; + extern int num_listenaddrs; + + extern union sockaddr_u srcaddr; + extern size_t srcaddrlen; + +-extern union sockaddr_u targetss; +-extern size_t targetsslen; ++extern struct sockaddr_list *targetaddrs; + + extern union sockaddr_u httpconnect, socksconnect; + extern size_t httpconnectlen, socksconnectlen; +@@ -223,6 +229,14 @@ void options_init(void); + int resolve(const char *hostname, unsigned short port, + struct sockaddr_storage *ss, size_t *sslen, int af); + ++/* Resolves the given hostname or IP address with getaddrinfo, and stores ++ all results into a linked list. ++ The rest of behavior is same as resolve(). */ ++int resolve_multi(const char *hostname, unsigned short port, ++ struct sockaddr_list *sl, int af); ++ ++void free_sockaddr_list(struct sockaddr_list *sl); ++ + int fdinfo_close(struct fdinfo *fdn); + int fdinfo_recv(struct fdinfo *fdn, char *buf, size_t size); + int fdinfo_send(struct fdinfo *fdn, const char *buf, size_t size); +diff -up nmap-6.40/ncat/ncat_main.c.allresolve nmap-6.40/ncat/ncat_main.c +--- nmap-6.40/ncat/ncat_main.c.allresolve 2015-07-07 09:47:11.519409609 +0200 ++++ nmap-6.40/ncat/ncat_main.c 2015-07-07 09:50:12.924358800 +0200 +@@ -648,15 +648,17 @@ int main(int argc, char *argv[]) + } + #endif /* HAVE_SYS_UN_H */ + ++ targetaddrs = (struct sockaddr_list *)safe_zalloc(sizeof(struct sockaddr_list)); ++ + /* Will be AF_INET or AF_INET6 or AF_UNIX when valid */ +- memset(&targetss.storage, 0, sizeof(targetss.storage)); +- targetss.storage.ss_family = AF_UNSPEC; +- httpconnect.storage = socksconnect.storage = srcaddr.storage = targetss.storage; ++ memset(&srcaddr.storage, 0, sizeof(srcaddr.storage)); ++ srcaddr.storage.ss_family = AF_UNSPEC; ++ targetaddrs->addr.storage = httpconnect.storage = socksconnect.storage = srcaddr.storage; + + /* Clear the listenaddrs array */ + int i; + for (i = 0; i < NUM_LISTEN_ADDRS; i++) { +- listenaddrs[i].storage = targetss.storage; ++ listenaddrs[i].storage = srcaddr.storage; + } + + if (proxyaddr) { +@@ -739,10 +741,10 @@ int main(int argc, char *argv[]) + } else { + #if HAVE_SYS_UN_H + if (o.af == AF_UNIX) { +- memset(&targetss.storage, 0, sizeof(struct sockaddr_un)); +- targetss.un.sun_family = AF_UNIX; +- strncpy(targetss.un.sun_path, argv[optind], sizeof(targetss.un.sun_path)); +- targetsslen = SUN_LEN(&targetss.un); ++ memset(&targetaddrs->addr.storage, 0, sizeof(struct sockaddr_un)); ++ targetaddrs->addr.un.sun_family = AF_UNIX; ++ strncpy(targetaddrs->addr.un.sun_path, argv[optind], sizeof(targetaddrs->addr.un.sun_path)); ++ targetaddrs->addrlen = SUN_LEN(&targetaddrs->addr.un); + o.target = argv[optind]; + optind++; + } else +@@ -753,7 +755,7 @@ int main(int argc, char *argv[]) + + o.target = argv[optind]; + /* resolve hostname */ +- rc = resolve(o.target, 0, &targetss.storage, &targetsslen, o.af); ++ rc = resolve_multi(o.target, 0, targetaddrs, o.af); + if (rc != 0) + bye("Could not resolve hostname \"%s\": %s.", o.target, gai_strerror(rc)); + optind++; +@@ -789,21 +791,26 @@ int main(int argc, char *argv[]) + o.portno = (unsigned short) long_port; + } + +- if (targetss.storage.ss_family == AF_INET) +- targetss.in.sin_port = htons(o.portno); ++ struct sockaddr_list *targetaddrs_item = targetaddrs; ++ while (targetaddrs_item != NULL) ++ { ++ if (targetaddrs_item->addr.storage.ss_family == AF_INET) ++ targetaddrs_item->addr.in.sin_port = htons(o.portno); + #ifdef HAVE_IPV6 +- else if (targetss.storage.ss_family == AF_INET6) +- targetss.in6.sin6_port = htons(o.portno); ++ else if (targetaddrs_item->addr.storage.ss_family == AF_INET6) ++ targetaddrs_item->addr.in6.sin6_port = htons(o.portno); + #endif + #if HAVE_SYS_UN_H +- /* If we use Unix domain sockets, we have to count with them. */ +- else if (targetss.storage.ss_family == AF_UNIX) +- ; /* Do nothing. */ ++ /* If we use Unix domain sockets, we have to count with them. */ ++ else if (targetaddrs_item->addr.storage.ss_family == AF_UNIX) ++ ; /* Do nothing. */ + #endif +- else if (targetss.storage.ss_family == AF_UNSPEC) +- ; /* Leave unspecified. */ +- else +- bye("Unknown address family %d.", targetss.storage.ss_family); ++ else if (targetaddrs_item->addr.storage.ss_family == AF_UNSPEC) ++ ; /* Leave unspecified. */ ++ else ++ bye("Unknown address family %d.", targetaddrs_item->addr.storage.ss_family); ++ targetaddrs_item = targetaddrs_item->next; ++ } + + if (srcport != -1) { + if (o.listen) { +@@ -815,7 +822,7 @@ int main(int argc, char *argv[]) + /* We have a source port but not an explicit source address; + fill in an unspecified address of the same family as the + target. */ +- srcaddr.storage.ss_family = targetss.storage.ss_family; ++ srcaddr.storage.ss_family = targetaddrs->addr.storage.ss_family; + if (srcaddr.storage.ss_family == AF_INET) + srcaddr.in.sin_addr.s_addr = INADDR_ANY; + else if (srcaddr.storage.ss_family == AF_INET6) +@@ -834,17 +841,17 @@ int main(int argc, char *argv[]) + * need to reverse these address structures to avoid any further confusion + */ + if (httpconnect.storage.ss_family != AF_UNSPEC) { +- union sockaddr_u tmp = targetss; +- size_t tmplen = targetsslen; +- targetss = httpconnect; +- targetsslen = httpconnectlen; ++ union sockaddr_u tmp = targetaddrs->addr; ++ size_t tmplen = targetaddrs->addrlen; ++ targetaddrs->addr = httpconnect; ++ targetaddrs->addrlen = httpconnectlen; + httpconnect = tmp; + httpconnectlen = tmplen; + } else if (socksconnect.storage.ss_family != AF_UNSPEC) { +- union sockaddr_u tmp = targetss; +- size_t tmplen = targetsslen; +- targetss = socksconnect; +- targetsslen = socksconnectlen; ++ union sockaddr_u tmp = targetaddrs->addr; ++ size_t tmplen = targetaddrs->addrlen; ++ targetaddrs->addr = socksconnect; ++ targetaddrs->addrlen = socksconnectlen; + socksconnect = tmp; + socksconnectlen = tmplen; + } +@@ -926,8 +933,8 @@ static int ncat_listen_mode(void) + bye("/bin/sh is not executable, so `-c' won't work."); + #endif + +- if (targetss.storage.ss_family != AF_UNSPEC) { +- listenaddrs[num_listenaddrs++] = targetss; ++ if (targetaddrs->addr.storage.ss_family != AF_UNSPEC) { ++ listenaddrs[num_listenaddrs++] = targetaddrs->addr; + } else { + size_t ss_len; + int rc; +diff -up nmap-6.40/ncat/util.c.allresolve nmap-6.40/ncat/util.c +--- nmap-6.40/ncat/util.c.allresolve 2013-07-29 00:08:48.000000000 +0200 ++++ nmap-6.40/ncat/util.c 2015-07-07 09:47:11.530409546 +0200 +@@ -470,7 +470,7 @@ int do_connect(int type) + /* We need a socket that can be inherited by child processes in + ncat_exec_win.c, for --exec and --sh-exec. inheritable_socket is from + nbase. */ +- sock = inheritable_socket(targetss.storage.ss_family, type, 0); ++ sock = inheritable_socket(targetaddrs->addr.storage.ss_family, type, 0); + + if (srcaddr.storage.ss_family != AF_UNSPEC) { + size_t sa_len; +@@ -487,7 +487,7 @@ int do_connect(int type) + } + + if (sock != -1) { +- if (connect(sock, &targetss.sockaddr, (int) targetsslen) != -1) ++ if (connect(sock, &targetaddrs->addr.sockaddr, (int) targetaddrs->addrlen) != -1) + return sock; + else if (socket_errno() == EINPROGRESS || socket_errno() == EAGAIN) + return sock; diff --git a/SOURCES/nmap-6.40-logdebug.patch b/SOURCES/nmap-6.40-logdebug.patch new file mode 100644 index 0000000..b0b99c2 --- /dev/null +++ b/SOURCES/nmap-6.40-logdebug.patch @@ -0,0 +1,33 @@ +diff -up nmap-6.40/ncat/ncat_connect.c.logdebug nmap-6.40/ncat/ncat_connect.c +--- nmap-6.40/ncat/ncat_connect.c.logdebug 2013-08-08 16:49:23.541312607 +0200 ++++ nmap-6.40/ncat/ncat_connect.c 2013-08-08 16:50:07.311943322 +0200 +@@ -420,7 +420,8 @@ static int do_proxy_http(void) + goto bail; + } + code = http_parse_status_line_code(status_line); +- logdebug("Proxy returned status code %d.\n", code); ++ if (o.debug) ++ logdebug("Proxy returned status code %d.\n", code); + free(status_line); + status_line = NULL; + if (http_read_header(&sockbuf, &header) != 0) { +@@ -461,7 +462,8 @@ static int do_proxy_http(void) + http_challenge_free(&challenge); + goto bail; + } +- logdebug("Reconnection header:\n%s", request); ++ if (o.debug) ++ logdebug("Reconnection header:\n%s", request); + if (send(sd, request, n, 0) < 0) { + loguser("Error sending proxy request: %s.\n", socket_strerror(socket_errno())); + free(request); +@@ -478,7 +480,8 @@ static int do_proxy_http(void) + goto bail; + } + code = http_parse_status_line_code(status_line); +- logdebug("Proxy returned status code %d.\n", code); ++ if (o.debug) ++ logdebug("Proxy returned status code %d.\n", code); + free(status_line); + status_line = NULL; + if (http_read_header(&sockbuf, &header) != 0) { diff --git a/SOURCES/nmap-6.40-mantypo.patch b/SOURCES/nmap-6.40-mantypo.patch new file mode 100644 index 0000000..b5dd2ae --- /dev/null +++ b/SOURCES/nmap-6.40-mantypo.patch @@ -0,0 +1,33 @@ +diff -up nmap-6.40/docs/nmap.1.mantypo nmap-6.40/docs/nmap.1 +--- nmap-6.40/docs/nmap.1.mantypo 2013-08-09 18:09:13.569139528 +0200 ++++ nmap-6.40/docs/nmap.1 2013-08-09 18:09:24.616044416 +0200 +@@ -174,7 +174,7 @@ SCRIPT SCAN: + \-\-script\-trace: Show all data sent and received + \-\-script\-updatedb: Update the script database\&. + \-\-script\-help=: Show help about scripts\&. +- is a comma separted list of script\-files or ++ is a comma separated list of script\-files or + script\-categories\&. + OS DETECTION: + \-O: Enable OS detection +diff -up nmap-6.40/nping/docs/nping.1.mantypo nmap-6.40/nping/docs/nping.1 +--- nmap-6.40/nping/docs/nping.1.mantypo 2013-08-09 18:09:37.655932148 +0200 ++++ nmap-6.40/nping/docs/nping.1 2013-08-09 18:09:49.382831186 +0200 +@@ -1425,7 +1425,7 @@ The following paragraphs describe the di + .RS 4 + This option tells Nping to run as an Echo client\&. + \fIpassphrase\fR +-is a sequence of ASCII characters that is used used to generate the cryptographic keys needed for encryption and authentication in a given session\&. The passphrase should be a secret that is also known by the server, and it may contain any number of printable ASCII characters\&. Passphrases that contain whitespace or special characters must be enclosed in double quotes\&. ++is a sequence of ASCII characters that is used to generate the cryptographic keys needed for encryption and authentication in a given session\&. The passphrase should be a secret that is also known by the server, and it may contain any number of printable ASCII characters\&. Passphrases that contain whitespace or special characters must be enclosed in double quotes\&. + .sp + When running Nping as an Echo client, most options from the regular raw probe modes apply\&. The client may be configured to send specific probes using flags like + \fB\-\-tcp\fR, +@@ -1441,7 +1441,7 @@ or + .RS 4 + This option tells Nping to run as an Echo server\&. + \fIpassphrase\fR +-is a sequence of ASCII characters that is used used to generate the cryptographic keys needed for encryption and authentication in a given session\&. The passphrase should be a secret that is also known by the clients, and it may contain any number of printable ASCII characters\&. Passphrases that contain whitespace or special characters must be enclosed in double quotes\&. Note that although it is not recommended, it is possible to use empty passphrases, supplying ++is a sequence of ASCII characters that is used to generate the cryptographic keys needed for encryption and authentication in a given session\&. The passphrase should be a secret that is also known by the clients, and it may contain any number of printable ASCII characters\&. Passphrases that contain whitespace or special characters must be enclosed in double quotes\&. Note that although it is not recommended, it is possible to use empty passphrases, supplying + \fB\-\-echo\-server ""\fR\&. However, if what you want is to set up an open Echo server, it is better to use option + \fB\-\-no\-crypto\fR\&. See below for details\&. + .RE diff --git a/SOURCES/nmap-6.40-ncat_7.50.patch b/SOURCES/nmap-6.40-ncat_7.50.patch new file mode 100644 index 0000000..d4963c4 --- /dev/null +++ b/SOURCES/nmap-6.40-ncat_7.50.patch @@ -0,0 +1,258 @@ +diff --git a/ncat/ncat_connect.c b/ncat/ncat_connect.c +index a420126..048dc46 100644 +--- a/ncat/ncat_connect.c ++++ b/ncat/ncat_connect.c +@@ -265,20 +265,20 @@ static void connect_report(nsock_iod nsi) + union sockaddr_u peer; + zmem(&peer, sizeof(peer.storage)); + +- nsock_iod_get_communication_info(nsi, NULL, NULL, NULL, &peer.sockaddr, ++ nsi_getlastcommunicationinfo(nsi, NULL, NULL, NULL, &peer.sockaddr, + sizeof(peer.storage)); + if (o.verbose) { + #ifdef HAVE_OPENSSL +- if (nsock_iod_check_ssl(nsi)) { ++ if (nsi_checkssl(nsi)) { + X509 *cert; + X509_NAME *subject; + char digest_buf[SHA1_STRING_LENGTH + 1]; + char *fp; + + loguser("SSL connection to %s:%d.", inet_socktop(&peer), +- nsock_iod_get_peerport(nsi)); ++ nsi_peerport(nsi)); + +- cert = SSL_get_peer_certificate((SSL *)nsock_iod_get_ssl(nsi)); ++ cert = SSL_get_peer_certificate((SSL *)nsi_getssl(nsi)); + ncat_assert(cert != NULL); + + subject = X509_get_subject_name(cert); +@@ -303,7 +303,7 @@ static void connect_report(nsock_iod nsi) + else + #endif + loguser("Connected to %s:%d.\n", inet_socktop(&peer), +- nsock_iod_get_peerport(nsi)); ++ nsi_peerport(nsi)); + } + #else + #if HAVE_SYS_UN_H +@@ -312,7 +312,7 @@ static void connect_report(nsock_iod nsi) + else + #endif + loguser("Connected to %s:%d.\n", inet_socktop(&peer), +- nsock_iod_get_peerport(nsi)); ++ nsi_peerport(nsi)); + #endif + } + } +@@ -892,32 +892,32 @@ int ncat_connect(void) + nsock_set_default_engine("select"); + + /* Create an nsock pool */ +- if ((mypool = nsock_pool_new(NULL)) == NULL) ++ if ((mypool = nsp_new(NULL)) == NULL) + bye("Failed to create nsock_pool."); + + if (o.debug >= 6) +- nsock_set_loglevel(NSOCK_LOG_DBG_ALL); ++ nsock_set_loglevel(mypool, NSOCK_LOG_DBG_ALL); + else if (o.debug >= 3) +- nsock_set_loglevel(NSOCK_LOG_DBG); ++ nsock_set_loglevel(mypool, NSOCK_LOG_DBG); + else if (o.debug >= 1) +- nsock_set_loglevel(NSOCK_LOG_INFO); ++ nsock_set_loglevel(mypool, NSOCK_LOG_INFO); + else +- nsock_set_loglevel(NSOCK_LOG_ERROR); ++ nsock_set_loglevel(mypool, NSOCK_LOG_ERROR); + + /* Allow connections to broadcast addresses. */ + nsock_pool_set_broadcast(mypool, 1); + + #ifdef HAVE_OPENSSL +- set_ssl_ctx_options((SSL_CTX *) nsock_pool_ssl_init(mypool, 0)); ++ set_ssl_ctx_options((SSL_CTX *) nsock_pool_ssl_init(mypool)); + #endif + + if (!o.proxytype) { + /* A non-proxy connection. Create an iod for a new socket. */ +- cs.sock_nsi = nsock_iod_new(mypool, NULL); ++ cs.sock_nsi = nsi_new(mypool, NULL); + if (cs.sock_nsi == NULL) + bye("Failed to create nsock_iod."); + +- if (nsock_iod_set_hostname(cs.sock_nsi, o.target) == -1) ++ if (nsi_set_hostname(cs.sock_nsi, o.target) == -1) + bye("Failed to set hostname on iod."); + + #if HAVE_SYS_UN_H +@@ -945,7 +945,7 @@ int ncat_connect(void) + strncpy(srcaddr.un.sun_path, tmp_name, sizeof(srcaddr.un.sun_path)); + free (tmp_name); + } +- nsock_iod_set_localaddr(cs.sock_nsi, &srcaddr.storage, ++ nsi_set_localaddr(cs.sock_nsi, &srcaddr.storage, + SUN_LEN((struct sockaddr_un *)&srcaddr.storage)); + + if (o.verbose) +@@ -957,23 +957,23 @@ int ncat_connect(void) + case AF_UNSPEC: + break; + case AF_INET: +- nsock_iod_set_localaddr(cs.sock_nsi, &srcaddr.storage, ++ nsi_set_localaddr(cs.sock_nsi, &srcaddr.storage, + sizeof(srcaddr.in)); + break; + #ifdef AF_INET6 + case AF_INET6: +- nsock_iod_set_localaddr(cs.sock_nsi, &srcaddr.storage, ++ nsi_set_localaddr(cs.sock_nsi, &srcaddr.storage, + sizeof(srcaddr.in6)); + break; + #endif + #if HAVE_SYS_UN_H + case AF_UNIX: +- nsock_iod_set_localaddr(cs.sock_nsi, &srcaddr.storage, ++ nsi_set_localaddr(cs.sock_nsi, &srcaddr.storage, + SUN_LEN((struct sockaddr_un *)&srcaddr.storage)); + break; + #endif + default: +- nsock_iod_set_localaddr(cs.sock_nsi, &srcaddr.storage, ++ nsi_set_localaddr(cs.sock_nsi, &srcaddr.storage, + sizeof(srcaddr.storage)); + break; + } +@@ -986,7 +986,7 @@ int ncat_connect(void) + bye("Sorry, -g can only currently be used with IPv4."); + ipopts = buildsrcrte(targetaddrs->addr.in.sin_addr, o.srcrtes, o.numsrcrtes, o.srcrteptr, &ipoptslen); + +- nsock_iod_set_ipoptions(cs.sock_nsi, ipopts, ipoptslen); ++ nsi_set_ipoptions(cs.sock_nsi, ipopts, ipoptslen); + free(ipopts); /* Nsock has its own copy */ + } + +@@ -1029,10 +1029,10 @@ int ncat_connect(void) + + /* Once the proxy negotiation is done, Nsock takes control of the + socket. */ +- cs.sock_nsi = nsock_iod_new2(mypool, connect_socket, NULL); ++ cs.sock_nsi = nsi_new2(mypool, connect_socket, NULL); + + /* Create IOD for nsp->stdin */ +- if ((cs.stdin_nsi = nsock_iod_new2(mypool, 0, NULL)) == NULL) ++ if ((cs.stdin_nsi = nsi_new2(mypool, 0, NULL)) == NULL) + bye("Failed to create stdin nsiod."); + + post_connect(mypool, cs.sock_nsi); +@@ -1049,8 +1049,8 @@ int ncat_connect(void) + gettimeofday(&end_time, NULL); + time = TIMEVAL_MSEC_SUBTRACT(end_time, start_time) / 1000.0; + loguser("%lu bytes sent, %lu bytes received in %.2f seconds.\n", +- nsock_iod_get_write_count(cs.sock_nsi), +- nsock_iod_get_read_count(cs.sock_nsi), time); ++ nsi_get_write_count(cs.sock_nsi), ++ nsi_get_read_count(cs.sock_nsi), time); + } + + #if HAVE_SYS_UN_H +@@ -1061,7 +1061,7 @@ int ncat_connect(void) + } + #endif + +- nsock_pool_delete(mypool); ++ nsp_delete(mypool); + + return rc == NSOCK_LOOP_ERROR ? 1 : 0; + } +@@ -1127,7 +1127,7 @@ static void connect_handler(nsock_pool nsp, nsock_event evt, void *data) + if (o.verbose) { + union sockaddr_u peer; + zmem(&peer, sizeof(peer.storage)); +- nsock_iod_get_communication_info(cs.sock_nsi, NULL, NULL, NULL, ++ nsi_getlastcommunicationinfo(cs.sock_nsi, NULL, NULL, NULL, + &peer.sockaddr, sizeof(peer.storage)); + loguser("Connection to %s failed: %s.\n", inet_socktop(&peer), socket_strerror(errcode)); + loguser("Trying next address...\n"); +@@ -1146,10 +1146,10 @@ static void connect_handler(nsock_pool nsp, nsock_event evt, void *data) + } + + #ifdef HAVE_OPENSSL +- if (nsock_iod_check_ssl(cs.sock_nsi)) { ++ if (nsi_checkssl(cs.sock_nsi)) { + /* Check the domain name. ssl_post_connect_check prints an + error message if appropriate. */ +- if (!ssl_post_connect_check((SSL *)nsock_iod_get_ssl(cs.sock_nsi), o.target)) ++ if (!ssl_post_connect_check((SSL *)nsi_getssl(cs.sock_nsi), o.target)) + bye("Certificate verification error."); + } + #endif +@@ -1160,7 +1160,7 @@ static void connect_handler(nsock_pool nsp, nsock_event evt, void *data) + } + + /* Create IOD for nsp->stdin */ +- if ((cs.stdin_nsi = nsock_iod_new2(nsp, 0, NULL)) == NULL) ++ if ((cs.stdin_nsi = nsi_new2(nsp, 0, NULL)) == NULL) + bye("Failed to create stdin nsiod."); + + post_connect(nsp, nse_iod(evt)); +@@ -1174,9 +1174,9 @@ static void post_connect(nsock_pool nsp, nsock_iod iod) + if (o.cmdexec) { + struct fdinfo info; + +- info.fd = nsock_iod_get_sd(iod); ++ info.fd = nsi_getsd(iod); + #ifdef HAVE_OPENSSL +- info.ssl = (SSL *)nsock_iod_get_ssl(iod); ++ info.ssl = (SSL *)nsi_getssl(iod); + #endif + /* Convert Nsock's non-blocking socket to an ordinary blocking one. It's + possible for a program to write fast enough that it will get an +@@ -1217,7 +1217,7 @@ static void read_stdin_handler(nsock_pool nsp, nsock_event evt, void *data) + + if (status == NSE_STATUS_EOF) { + if (!o.noshutdown) +- shutdown(nsock_iod_get_sd(cs.sock_nsi), SHUT_WR); ++ shutdown(nsi_getsd(cs.sock_nsi), SHUT_WR); + /* In --send-only mode or non-TCP mode, exit after EOF on stdin. */ + if (o.proto != IPPROTO_TCP || (o.proto == IPPROTO_TCP && o.sendonly)) + nsock_loop_quit(nsp); +@@ -1288,7 +1288,7 @@ static void read_socket_handler(nsock_pool nsp, nsock_event evt, void *data) + ncat_delay_timer(o.linedelay); + + if (o.telnet) +- dotelnet(nsock_iod_get_sd(nse_iod(evt)), (unsigned char *) buf, nbytes); ++ dotelnet(nsi_getsd(nse_iod(evt)), (unsigned char *) buf, nbytes); + + /* Write socket data to stdout */ + Write(STDOUT_FILENO, buf, nbytes); +diff --git a/ncat/util.h b/ncat/util.h +index 63f4c6f..f81d577 100644 +--- a/ncat/util.h ++++ b/ncat/util.h +@@ -175,6 +175,8 @@ do { \ + + void die(char *); + ++#define NORETURN __attribute__((noreturn)) ++ + NORETURN void bye(const char *, ...) + __attribute__ ((format (printf, 1, 2))); + +diff --git a/ncat/ncat_connect.c b/ncat/ncat_connect.c +index 048dc46..8680278 100644 +--- a/ncat/ncat_connect.c ++++ b/ncat/ncat_connect.c +@@ -905,10 +905,10 @@ int ncat_connect(void) + nsock_set_loglevel(mypool, NSOCK_LOG_ERROR); + + /* Allow connections to broadcast addresses. */ +- nsock_pool_set_broadcast(mypool, 1); ++ nsp_setbroadcast(mypool, 1); + + #ifdef HAVE_OPENSSL +- set_ssl_ctx_options((SSL_CTX *) nsock_pool_ssl_init(mypool)); ++ set_ssl_ctx_options((SSL_CTX *) nsp_ssl_init(mypool)); + #endif + + if (!o.proxytype) { diff --git a/SOURCES/nmap-6.40-ncat_early_error_reporting.patch b/SOURCES/nmap-6.40-ncat_early_error_reporting.patch new file mode 100644 index 0000000..74fe9d1 --- /dev/null +++ b/SOURCES/nmap-6.40-ncat_early_error_reporting.patch @@ -0,0 +1,19 @@ +diff --git a/nsock/src/nsock_core.c b/nsock/src/nsock_core.c +index ec38cad..aac2c1b 100644 +--- a/nsock/src/nsock_core.c ++++ b/nsock/src/nsock_core.c +@@ -1230,6 +1230,14 @@ void nsp_add_event(mspool *nsp, msevent *nse) { + assert(0); + break; /* unreached */ + } ++ ++ /* It can happen that the event already completed. In which case we can ++ * * already deliver it, even though we're probably not inside nsock_loop(). */ ++ if (nse->event_done) { ++ msevent_dispatch_and_delete(nsp, nse, 1); ++ update_first_events(nse); ++ ++ } + } + + /* An event has been completed and the handler is about to be called. This diff --git a/SOURCES/nmap-6.40-ncat_memleak.patch b/SOURCES/nmap-6.40-ncat_memleak.patch new file mode 100644 index 0000000..420d4c0 --- /dev/null +++ b/SOURCES/nmap-6.40-ncat_memleak.patch @@ -0,0 +1,200 @@ +diff --git a/ncat/ncat_connect.c b/ncat/ncat_connect.c +index d8c73ab1b..5695800a3 100644 +--- a/ncat/ncat_connect.c ++++ b/ncat/ncat_connect.c +@@ -1049,7 +1049,10 @@ int ncat_connect(void) + } + + if (connect_socket == -1) ++ { ++ nsp_delete(mypool); + return 1; ++ } + /* Clear out whatever is left in the socket buffer which may be + already sent by proxy server along with http response headers. */ + //line = socket_buffer_remainder(&stateful_buf, &n); +--- a/ncat/ncat.h ++++ b/ncat/ncat.h +@@ -177,13 +177,13 @@ + + struct socks5_connect { + char ver; +- char nmethods; ++ unsigned char nmethods; + char methods[3]; + } __attribute__((packed)); + + struct socks5_auth { +- char ver; // must be always 1 +- char data[SOCKS_BUFF_SIZE]; ++ char ver; // must be always 1 ++ unsigned char data[SOCKS_BUFF_SIZE]; + } __attribute__((packed)); + + struct socks5_request { +@@ -263,6 +263,12 @@ + #define SOCKS5_ATYP_NAME 3 + #define SOCKS5_ATYP_IPv6 4 + ++#define SOCKS5_USR_MAXLEN 255 ++#define SOCKS5_PWD_MAXLEN 255 ++ ++#if SOCKS_BUFF_SIZE < (1 + SOCKS5_USR_MAXLEN) + (1 + SOCKS5_PWD_MAXLEN) ++#error SOCKS_BUFF_SIZE is defined too small to handle SOCKS5 authentication ++#endif + + /* Length of IPv6 address */ + #ifndef INET6_ADDRSTRLEN +--- a/ncat/ncat_connect.c ++++ b/ncat/ncat_connect.c +@@ -664,9 +664,8 @@ + int sd,len,lenfqdn; + struct socks5_request socks5msg2; + struct socks5_auth socks5auth; +- char *proxy_auth; +- char *username; +- char *password; ++ char *uptr, *pptr; ++ size_t authlen, ulen, plen; + + sd = do_connect(SOCK_STREAM); + if (sd == -1) { +@@ -683,17 +682,13 @@ + + zmem(&socks5msg,sizeof(socks5msg)); + socks5msg.ver = SOCKS5_VERSION; +- socks5msg.nmethods = 1; +- socks5msg.methods[0] = SOCKS5_AUTH_NONE; +- len = 3; ++ socks5msg.nmethods = 0; ++ socks5msg.methods[socks5msg.nmethods++] = SOCKS5_AUTH_NONE; + +- if (o.proxy_auth){ +- socks5msg.nmethods ++; +- socks5msg.methods[1] = SOCKS5_AUTH_USERPASS; +- len ++; +- } ++ if (o.proxy_auth) ++ socks5msg.methods[socks5msg.nmethods++] = SOCKS5_AUTH_USERPASS; + +- if (send(sd, (char *) &socks5msg, len, 0) < 0) { ++ if (send(sd, (char *)&socks5msg, offsetof(struct socks5_connect, methods) + socks5msg.nmethods, 0) < 0) { + loguser("Error: proxy request: %s.\n", socket_strerror(socket_errno())); + close(sd); + return -1; +@@ -706,46 +701,47 @@ + return -1; + } + +- if (socksbuf[0] != 5){ ++ if (socksbuf[0] != SOCKS5_VERSION) { + loguser("Error: got wrong server version in response.\n"); + close(sd); + return -1; + } + +- switch(socksbuf[1]) { ++ switch((unsigned char)socksbuf[1]) { + case SOCKS5_AUTH_NONE: + if (o.verbose) + loguser("No authentication needed.\n"); + break; + +- case SOCKS5_AUTH_GSSAPI: +- loguser("GSSAPI authentication method not supported.\n"); +- close(sd); +- return -1; +- + case SOCKS5_AUTH_USERPASS: + if (o.verbose) + loguser("Doing username and password authentication.\n"); + + if(!o.proxy_auth){ +- loguser("Error: proxy requested to do authentication, but no credentials were provided.\n"); ++ /* Proxy must not select a method not offered by the client */ ++ loguser("Error: proxy selected invalid authentication method.\n"); + close(sd); + return -1; + } + +- if (strlen(o.proxy_auth) > SOCKS_BUFF_SIZE-2){ +- loguser("Error: username and password are too long to fit into buffer.\n"); ++ /* Split up the proxy auth argument. */ ++ uptr = o.proxy_auth; ++ pptr = strchr(o.proxy_auth, ':'); ++ if (pptr == NULL) { ++ loguser("Error: invalid username:password combo.\n"); + close(sd); + return -1; + } + +- /* Split up the proxy auth argument. */ +- proxy_auth = Strdup(o.proxy_auth); +- username = strtok(proxy_auth, ":"); +- password = strtok(NULL, ":"); +- if (password == NULL || username == NULL) { +- free(proxy_auth); +- loguser("Error: empty username or password.\n"); ++ ulen = (pptr++) - uptr; ++ plen = strlen(pptr); ++ if (ulen > SOCKS5_USR_MAXLEN) { ++ loguser("Error: username length exceeds %d.\n", SOCKS5_USR_MAXLEN); ++ close(sd); ++ return -1; ++ } ++ if (plen > SOCKS5_PWD_MAXLEN) { ++ loguser("Error: password length exceeds %d.\n", SOCKS5_PWD_MAXLEN); + close(sd); + return -1; + } +@@ -766,15 +762,16 @@ + */ + + socks5auth.ver = 1; +- socks5auth.data[0] = strlen(username); +- memcpy(socks5auth.data+1,username,strlen(username)); +- len = 2 + strlen(username); // (version + strlen) + username ++ authlen = 0; ++ socks5auth.data[authlen++] = ulen; ++ memcpy(socks5auth.data + authlen, uptr, ulen); ++ authlen += ulen; + +- socks5auth.data[len-1]=strlen(password); +- memcpy(socks5auth.data+len,password,strlen(password)); +- len += 1 + strlen(password); ++ socks5auth.data[authlen++] = plen; ++ memcpy(socks5auth.data + authlen, pptr, plen); ++ authlen += plen; + +- if (send(sd, (char *) &socks5auth, len, 0) < 0) { ++ if (send(sd, (char *) &socks5auth, offsetof(struct socks5_auth, data) + authlen, 0) < 0) { + loguser("Error: sending proxy authentication.\n"); + close(sd); + return -1; +@@ -794,8 +791,14 @@ + + break; + ++ case SOCKS5_AUTH_FAILED: ++ loguser("Error: no acceptable authentication method proposed.\n"); ++ close(sd); ++ return -1; ++ + default: +- loguser("Error - can't choose any authentication method.\n"); ++ /* Proxy must not select a method not offered by the client */ ++ loguser("Error: proxy selected invalid authentication method.\n"); + close(sd); + return -1; + } +@@ -832,6 +835,10 @@ + socks5msg2.dst[0]=lenfqdn; + memcpy(socks5msg2.dst+1,o.target,lenfqdn); + len = 1 + lenfqdn; ++ break; ++ ++ default: // this shall not happen ++ ncat_assert(0); + } + + memcpy(socks5msg2.dst+len, &proxyport, sizeof(proxyport)); diff --git a/SOURCES/nmap-6.40-trancated_dns.patch b/SOURCES/nmap-6.40-trancated_dns.patch new file mode 100644 index 0000000..c773551 --- /dev/null +++ b/SOURCES/nmap-6.40-trancated_dns.patch @@ -0,0 +1,179 @@ +diff -up nmap-5.51/nmap_dns.cc.tcpdns nmap-5.51/nmap_dns.cc +--- a/nmap_dns.cc 2011-01-21 01:04:16.000000000 +0100 ++++ b/nmap_dns.cc 2016-10-26 11:04:49.057723356 +0200 +@@ -677,9 +677,9 @@ static void read_evt_handler(nsock_pool + + packet_id = buf[1] + (buf[0] << 8); + +- // Check that this is a response, standard query, and that no truncation was performed ++ // Check that this is a response, standard query + // 0xFA == 11111010 (we're not concerned with AA or RD bits) +- if ((buf[2] & 0xFA) != 0x80) return; ++ if ((buf[2] & 0xF8) != 0x80) return; + + // Check that the zero field is all zeros and there is no error condition. + // We don't care if recursion is available or not since we might be querying +@@ -715,7 +715,8 @@ static void read_evt_handler(nsock_pool + return; + } + +- if (queries <= 0 || answers <= 0) return; ++ bool processing_successful = false; ++// if (queries <= 0 || answers <= 0) return; + + curbuf = 12; + +@@ -732,7 +733,7 @@ static void read_evt_handler(nsock_pool + + // We're now at the ANSWER section + +- for (i=0; i= TRACE_DEBUG_LEVEL) log_write(LOG_STDOUT, "mass_rdns: OK MATCHED <%s> to <%s>\n", inet_ntoa(ia), outbuf); + output_summary(); + stat_ok++; +@@ -771,15 +772,26 @@ static void read_evt_handler(nsock_pool + if (ia.s_addr == 0) return; + + if (o.debugging >= TRACE_DEBUG_LEVEL) log_write(LOG_STDOUT, "mass_rdns: CNAME found for <%s>\n", inet_ntoa(ia)); +- process_result(ia.s_addr, NULL, ACTION_CNAME_LIST, packet_id); ++ processing_successful = process_result(ia.s_addr, NULL, ACTION_SYSTEM_RESOLVE, packet_id); + } else { + if (rdlen < 0 || rdlen + curbuf >= buflen) return; + curbuf += rdlen; + } + +- if (curbuf >= buflen) return; ++ if (curbuf >= buflen) break;//return; + } + ++ if (!processing_successful) { ++ if ((buf[2] & 0x02)) { //truncated ++ u32 discard = 0; ++ process_result(discard, NULL, ACTION_SYSTEM_RESOLVE, packet_id); ++ } ++ else { ++ if (o.debugging >= TRACE_DEBUG_LEVEL) { ++ log_write(LOG_STDOUT, "mass_rdns: Unable to process the response\n"); ++ } ++ } ++ } + } + + +@@ -1225,20 +1237,20 @@ static void nmap_mass_rdns_core(Target * + + nsp_delete(dnspool); + +- if (cname_reqs.size() && o.debugging) +- log_write(LOG_STDOUT, "Performing system-dns for %d domain names that use CNAMEs\n", (int) cname_reqs.size()); ++ if (deferred_reqs.size() && o.debugging) ++ log_write(LOG_STDOUT, "Performing system-dns for %d domain names that were deferred\n", (int) deferred_reqs.size()); + +- if (cname_reqs.size()) { +- Snprintf(spmobuf, sizeof(spmobuf), "System CNAME DNS resolution of %u host%s.", (unsigned) cname_reqs.size(), cname_reqs.size()-1 ? "s" : ""); ++ if (deferred_reqs.size()) { ++ Snprintf(spmobuf, sizeof(spmobuf), "System DNS resolution of %u host%s.", (unsigned) deferred_reqs.size(), deferred_reqs.size()-1 ? "s" : ""); + SPM = new ScanProgressMeter(spmobuf); + +- for(i=0, reqI = cname_reqs.begin(); reqI != cname_reqs.end(); reqI++, i++) { ++ for(i=0, reqI = deferred_reqs.begin(); reqI != deferred_reqs.end(); reqI++, i++) { + struct sockaddr_storage ss; + size_t sslen; + char hostname[MAXHOSTNAMELEN + 1] = ""; + + if (keyWasPressed()) +- SPM->printStats((double) i / cname_reqs.size(), NULL); ++ SPM->printStats((double) i / deferred_reqs.size(), NULL); + + tpreq = *reqI; + +diff --git a/nmap_dns.cc b/nmap_dns.cc +index 9a72336..e01230c 100644 +--- a/nmap_dns.cc ++++ b/nmap_dns.cc +@@ -309,7 +309,7 @@ struct host_elem { + + static std::list servs; + static std::list new_reqs; +-static std::list cname_reqs; ++static std::list deferred_reqs; + static int total_reqs; + static nsock_pool dnspool=NULL; + +diff --git a/nmap_dns.cc b/nmap_dns.cc +index e01230c..540d39d 100644 +--- a/nmap_dns.cc ++++ b/nmap_dns.cc +@@ -327,12 +327,13 @@ static ScanProgressMeter *SPM; + + //------------------- Prototypes and macros --------------------- + ++static void read_evt_handler(nsock_pool, nsock_event, void *); + static void put_dns_packet_on_wire(request *req); + static const char *lookup_etchosts(u32 ip); + static void addto_etchosts(u32 ip, const char *hname); + + #define ACTION_FINISHED 0 +-#define ACTION_CNAME_LIST 1 ++#define ACTION_SYSTEM_RESOLVE 1 + #define ACTION_TIMEOUT 2 + + //------------------- Misc code --------------------- +diff --git a/nmap_dns.cc b/nmap_dns.cc +index 540d39d..e0c6f6c 100644 +--- a/nmap_dns.cc ++++ b/nmap_dns.cc +@@ -1240,7 +1240,7 @@ static void nmap_mass_rdns_core(Target **targets, int num_targets) { + + connect_dns_servers(); + +- cname_reqs.clear(); ++ deferred_reqs.clear(); + + read_timeout_index = MIN(sizeof(read_timeouts)/sizeof(read_timeouts[0]), servs.size()) - 1; + +diff --git a/nmap_dns.cc b/nmap_dns.cc +index 9363614..815b3a4 100644 +--- a/nmap_dns.cc ++++ b/nmap_dns.cc +@@ -558,7 +558,7 @@ static int process_result(u32 ia, char *result, int action, u16 id) { + if (ia != 0 && tpreq->targ->v4host().s_addr != ia) + continue; + +- if (action == ACTION_CNAME_LIST || action == ACTION_FINISHED) { ++ if (action == ACTION_SYSTEM_RESOLVE || action == ACTION_FINISHED) { + servI->capacity += CAPACITY_UP_STEP; + check_capacities(&*servI); + +@@ -572,7 +572,7 @@ static int process_result(u32 ia, char *result, int action, u16 id) { + + total_reqs--; + +- if (action == ACTION_CNAME_LIST) cname_reqs.push_back(tpreq); ++ if (action == ACTION_SYSTEM_RESOLVE) deferred_reqs.push_back(tpreq); + if (action == ACTION_FINISHED) delete tpreq; + } else { + memcpy(&tpreq->timeout, nsock_gettimeofday(), sizeof(struct timeval)); +diff --git a/nmap_dns.cc b/nmap_dns.cc +index 815b3a4..f00ac18 100644 +--- a/nmap_dns.cc ++++ b/nmap_dns.cc +@@ -1302,7 +1302,7 @@ static void nmap_mass_rdns_core(Target **targets, int num_targets) { + delete SPM; + } + +- cname_reqs.clear(); ++ deferred_reqs.clear(); + + } + diff --git a/SOURCES/zenmap-621887-workaround.patch b/SOURCES/zenmap-621887-workaround.patch new file mode 100644 index 0000000..74a9578 --- /dev/null +++ b/SOURCES/zenmap-621887-workaround.patch @@ -0,0 +1,12 @@ +diff -up nmap-5.50/zenmap/zenmapGUI/App.py.bz637403 nmap-5.50/zenmap/zenmapGUI/App.py +--- nmap-5.50/zenmap/zenmapGUI/App.py.bz637403 2011-01-21 01:04:51.000000000 +0100 ++++ nmap-5.50/zenmap/zenmapGUI/App.py 2011-02-07 13:01:36.275314680 +0100 +@@ -179,7 +179,7 @@ def install_excepthook(): + # produces a warning, but the lack of a display eventually causes a + # segmentation fault. See http://live.gnome.org/PyGTK/WhatsNew210. + import warnings +- warnings.filterwarnings("error", module = "gtk") ++ warnings.filterwarnings("error", module = "gtk", append=True) + import gtk + warnings.resetwarnings() + diff --git a/SOURCES/zenmap-root.consoleapps b/SOURCES/zenmap-root.consoleapps new file mode 100644 index 0000000..7fa8b7d --- /dev/null +++ b/SOURCES/zenmap-root.consoleapps @@ -0,0 +1,4 @@ +USER=root +PROGRAM=/usr/bin/zenmap +SESSION=true +FALLBACK=true diff --git a/SOURCES/zenmap-root.pamd b/SOURCES/zenmap-root.pamd new file mode 100644 index 0000000..a3d8388 --- /dev/null +++ b/SOURCES/zenmap-root.pamd @@ -0,0 +1,4 @@ +#%PAM-1.0 +auth include config-util +account include config-util +session include config-util diff --git a/SOURCES/zenmap.desktop b/SOURCES/zenmap.desktop new file mode 100644 index 0000000..53f7894 --- /dev/null +++ b/SOURCES/zenmap.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Name=Zenmap +GenericName=Nmap Security Scanner +Comment=GUI frontend for Nmap security/port scanner +Version=1.0 +TryExec=zenmap-root +Exec=zenmap-root +Icon=zenmap +Terminal=false +Type=Application +Categories=System;Security;GTK; diff --git a/SPECS/nmap.spec b/SPECS/nmap.spec new file mode 100644 index 0000000..6824572 --- /dev/null +++ b/SPECS/nmap.spec @@ -0,0 +1,735 @@ +#TODO: stop using local copy of libdnet, once system distributed version supports sctp (grep sctp /usr/include/dnet.h) +Summary: Network exploration tool and security scanner +Name: nmap +Epoch: 2 +Version: 6.40 +## We rebase ncat on newer version to have compatibility with nc +## For doing this few upstream patches must be reverted +## https://bugzilla.redhat.com/1460249 +%global ncat_version 7.50 +#global prerelease %{nil} +Release: 13%{?dist} +# nmap is GPLv2 +# zenmap is GPLv2 and LGPLv2+ (zenmap/higwidgets) and GPLv2+ (zenmap/radialnet) +# libdnet-stripped is BSD (advertising clause rescinded by the Univ. of California in 1999) with some parts as Public Domain (crc32) +License: GPLv2 and LGPLv2+ and GPLv2+ and BSD +Group: Applications/System +Requires: %{name}-ncat = %{epoch}:%{version}-%{release} +# to make our life easier, we use upstream tarball, but we remove budled libraries first +# that way it's easier to keep an eye on licensing and crypto export restrictions +# VER=%{version}; tar xjf nmap-${VER}.tar.bz2; rm -rf nmap-${VER}/{libpcap,libpcre,macosx,mswin32}; tar cjf nmap-purified-${VER}.tar.bz2 nmap-${VER} +#Source0: http://nmap.org/dist/%{name}-%{version}%{?prerelease}.tar.bz2 +Source0: %{name}-purified-%{version}%{?prerelease}.tar.bz2 + +%if "%{ncat_version}" != "%{version}" +# VER=%{ncat_version}; tar xjf nmap-${VER}.tar.bz2; cd nmap-${VER}; tar cjf nmap-ncat-${VER}.tar.bz2 ncat +Source4: %{name}-ncat-%{ncat_version}.tar.bz2 +%endif + +Source1: zenmap.desktop +Source2: zenmap-root.pamd +Source3: zenmap-root.consoleapps + + +#prevent possible race condition for shtool, rhbz#158996 +Patch1: nmap-4.03-mktemp.patch + +#don't suggest to scan microsoft +Patch2: nmap-4.52-noms.patch + +# rhbz#637403, workaround for rhbz#621887=gnome#623965 +Patch4: zenmap-621887-workaround.patch + +# upstream provided patch for rhbz#845005, not yet in upstream repository +Patch5: ncat_reg_stdin.diff +Patch6: nmap-6.25-displayerror.patch +Patch7: nmap-6.40-mantypo.patch + +# not upstream yet, rhbz#1134412 +Patch8: nmap-6.40-logdebug.patch + +# sent upstream, for nmap <= 6.49, rhbz#1192143 +Patch9: nmap-6.40-allresolve.patch + +# https://bugzilla.redhat.com/1390326 +# backported upstream +Patch10: nmap-6.40-trancated_dns.patch + +%if "%{ncat_version}" != "%{version}" +Patch11: nmap-6.40-ncat_%{ncat_version}.patch +Patch12: nmap-6.40-ncat_memleak.patch +%endif +Patch13: nmap-6.40-add_eproto_handler.patch +Patch14: nmap-6.40-ncat_early_error_reporting.patch + +URL: http://nmap.org/ +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +BuildRequires: openssl-devel, gtk2-devel, lua-devel, libpcap-devel, pcre-devel +BuildRequires: desktop-file-utils, dos2unix +BuildRequires: libtool, automake, autoconf, gettext-devel + +# exception granted in FPC ticket 255 +Provides: bundled(lua) = 5.2 + +%define pixmap_srcdir zenmap/share/pixmaps + +%description +Nmap is a utility for network exploration or security auditing. It supports +ping scanning (determine which hosts are up), many port scanning techniques +(determine what services the hosts are offering), and TCP/IP fingerprinting +(remote host operating system identification). Nmap also offers flexible target +and port specification, decoy scanning, determination of TCP sequence +predictability characteristics, reverse-identd scanning, and more. In addition +to the classic command-line nmap executable, the Nmap suite includes a flexible +data transfer, redirection, and debugging tool (netcat utility ncat), a utility +for comparing scan results (ndiff), and a packet generation and response analysis +tool (nping). + +%package frontend +Summary: The GTK+ front end for nmap +Group: Applications/System +Requires: nmap = %{epoch}:%{version} gtk2 python >= 2.5 pygtk2 usermode +BuildRequires: python >= 2.5 python-devel pygtk2-devel libpng-devel +BuildArch: noarch +%description frontend +This package includes zenmap, a GTK+ front end for nmap. The nmap package must +be installed before installing nmap front end. + +%package ncat +Group: Applications/System +Summary: Nmap's Netcat replacement +Obsoletes: nc < 1.109.20120711-2 +Provides: nc +%description ncat +Ncat is a feature packed networking utility which will read and +write data across a network from the command line. It uses both +TCP and UDP for communication and is designed to be a reliable +back-end tool to instantly provide network connectivity to other +applications and users. Ncat will not only work with IPv4 and IPv6 +but provides the user with a virtually limitless number of potential +uses. + + +%prep +%setup -q -n %{name}-%{version}%{?prerelease} + +%if "%{ncat_version}" != "%{version}" +# Replace ncat sources if needed +rm -rf ncat +tar -xf %{SOURCE4} +%endif + +%patch1 -p1 -b .mktemp +%patch2 -p1 -b .noms +%patch4 -p1 -b .bz637403 +%patch5 -p1 -b .ncat_reg_stdin +%patch6 -p1 -b .displayerror +%patch7 -p1 -b .mantypo +%patch10 -p1 -b .dns_resolve + + +%if "%{ncat_version}" != "%{version}" +# Patch for newer/older ncat +%patch11 -p1 -b .ncatrebase +%patch12 -p1 -b .memleak +%else +# Patches which were accepted upstream and not needed in rebased version +%patch8 -p1 -b .logdebug +%patch9 -p1 -b .allresolve +%endif + +%patch14 -p1 -b .errorreporting +%patch13 -p1 -b .eproto + +#be sure we're not using tarballed copies of some libraries, +#we remove them when creating our own tarball, just check they are not present +[ -z "$(ls -d 2>/dev/null libpcap libpcre macosx mswin32)" ] || exit 1 + +# for aarch64 support, not needed with autotools 2.69+ +for f in acinclude.m4 configure.ac nping/configure.ac +do + sed -i -e 's/\(AC_DEFINE([^,)]*\))/\1, 1, [Description])/' -e 's/\(AC_DEFINE([^,]*,[^,)]*\))/\1, [Description])/' $f +done +autoreconf -I . -fiv --no-recursive +cd nping; autoreconf -I .. -fiv --no-recursive; cd .. + + +#fix locale dir +mv zenmap/share/zenmap/locale zenmap/share +sed -i -e "s|^locale_dir =.*$|locale_dir = os.path.join('share','locale')|" \ + -e 's|join(self.install_data, data_dir)|join(self.install_data, "share")|' zenmap/setup.py +sed -i 's|^LOCALE_DIR = .*|LOCALE_DIR = join(prefix, "share", "locale")|' zenmap/zenmapCore/Paths.py + +%build +export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing" +export CXXFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing" +%configure --with-libpcap=/usr --without-nmap-update +make %{?_smp_mflags} + +#fix man page (rhbz#813734) +sed -i 's/-md/-mf/' nping/docs/nping.1 + +%install +rm -rf $RPM_BUILD_ROOT + +#prevent stripping - replace strip command with 'true' +make DESTDIR=$RPM_BUILD_ROOT STRIP=true install +rm -f $RPM_BUILD_ROOT%{_bindir}/uninstall_zenmap + +#do not include certificate bundle (#734389) +rm -f $RPM_BUILD_ROOT%{_datadir}/ncat/ca-bundle.crt +rmdir $RPM_BUILD_ROOT%{_datadir}/ncat + +#use consolehelper +rm -f $RPM_BUILD_ROOT%{_datadir}/applications/zenmap*.desktop +rm -f $RPM_BUILD_ROOT%{_datadir}/zenmap/su-to-zenmap.sh +ln -s consolehelper $RPM_BUILD_ROOT%{_bindir}/zenmap-root +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/pam.d \ + $RPM_BUILD_ROOT%{_sysconfdir}/security/console.apps +install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/pam.d/zenmap-root +install -m 0644 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/security/console.apps/zenmap-root + +cp docs/zenmap.1 $RPM_BUILD_ROOT%{_mandir}/man1/ +gzip $RPM_BUILD_ROOT%{_mandir}/man1/* || : +pushd $RPM_BUILD_ROOT%{_mandir}/man1 +ln -s zenmap.1.gz nmapfe.1.gz +ln -s zenmap.1.gz xnmap.1.gz +popd + +#we provide 'nc' replacement +ln -s ncat.1.gz $RPM_BUILD_ROOT%{_mandir}/man1/nc.1.gz +ln -s ncat $RPM_BUILD_ROOT%{_bindir}/nc + +desktop-file-install --vendor nmap \ + --dir $RPM_BUILD_ROOT%{_datadir}/applications \ + --add-category X-Red-Hat-Base \ + %{SOURCE1}; + +#for .desktop and app icon +mkdir -p $RPM_BUILD_ROOT%{_datadir}/icons/hicolor/256x256/apps +ln -s ../../../../zenmap/pixmaps/zenmap.png $RPM_BUILD_ROOT%{_datadir}/icons/hicolor/256x256/apps + +# fix end-of-line +pushd $RPM_BUILD_ROOT +for fe in ./%{python_sitelib}/zenmapCore/Paths.py +do + dos2unix <$fe >$fe.new + touch -r $fe $fe.new + mv -f $fe.new $fe +done +popd + +%find_lang nmap --with-man +%find_lang zenmap + +%post frontend +touch --no-create %{_datadir}/icons/hicolor &>/dev/null || : + +%postun frontend +if [ $1 -eq 0 ] ; then + touch --no-create %{_datadir}/icons/hicolor &>/dev/null + gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : +fi + +%posttrans frontend +gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : + +%clean +rm -rf $RPM_BUILD_ROOT + +%files -f nmap.lang +%defattr(-,root,root) +%doc COPYING* +%doc docs/README +%doc docs/nmap.usage.txt +%{_bindir}/nmap +%{_bindir}/ndiff +%{_bindir}/nping +%{_mandir}/man1/ndiff.1.gz +%{_mandir}/man1/nmap.1.gz +%{_mandir}/man1/nping.1.gz +%{_datadir}/nmap + +%files ncat +%defattr(-,root,root) +%doc COPYING ncat/docs/AUTHORS ncat/docs/README ncat/docs/THANKS ncat/docs/examples +%{_bindir}/nc +%{_bindir}/ncat +%{_mandir}/man1/nc.1.gz +%{_mandir}/man1/ncat.1.gz + +%files frontend -f zenmap.lang +%defattr(-,root,root) +%config(noreplace) %{_sysconfdir}/pam.d/zenmap-root +%config(noreplace) %{_sysconfdir}/security/console.apps/zenmap-root +%{_bindir}/zenmap-root +%{_bindir}/zenmap +%{_bindir}/nmapfe +%{_bindir}/xnmap +%{python_sitelib}/* +%{_datadir}/applications/nmap-zenmap.desktop +%{_datadir}/icons/hicolor/* +%{_datadir}/zenmap +%{_mandir}/man1/zenmap.1.gz +%{_mandir}/man1/nmapfe.1.gz +%{_mandir}/man1/xnmap.1.gz + +%changelog +* Wed Nov 8 2017 Pavel Zhukov - 2:6.40-13 +- Resolves: #1436402 - nc from nmap ncat crash if ipv6 disabled + +* Fri Oct 20 2017 Pavel Zhukov - 2:6.40-12 +- Add eproto to list of hanled errnos + +* Fri Sep 08 2017 Pavel Zhukov - 2:6.40-11 +- Related: ##1460249 - Replace memleak patch with one provided by upstream + +* Mon Aug 21 2017 Pavel Zhukov - 2:6.40-10 +- Related: #1460249 - Fix memory leaks (covscan errors) + +* Thu Aug 17 2017 Pavel Zhukov - 2:6.40-9 +- Resolves: #1460249, #1436402, #1317924, #1379008 - Rebase ncat on 7.50 + +* Wed Aug 16 2017 Pavel Zhukov - 2:6.40-8 +- Resolves: #1390326 - Failback to system resolver for truncated dns replies + +* Thu Jul 30 2015 Michal Hlavinka - 2:6.40-7 +- explicitely disable modules we don't want to build to have consistent results (#1246453) + +* Tue Jul 07 2015 Michal Hlavinka - 2:6.40-6 +- fix coverity found issue (#1192143) + +* Fri Jul 03 2015 Michal Hlavinka - 2:6.40-5 +- ncat should try to connect to all resolved addresses, not only the first one (#1192143) +- do not print debug messages during normal use (#1134412) + +* Fri Jan 24 2014 Daniel Mach - 2:6.40-4 +- Mass rebuild 2014-01-24 + +* Fri Dec 27 2013 Daniel Mach - 2:6.40-3 +- Mass rebuild 2013-12-27 + +* Fri Aug 09 2013 Michal Hlavinka - 2:6.40-2 +- fix man page typos + +* Tue Jul 30 2013 Michal Hlavinka - 2:6.40-1 +- nmap udpated to 6.40 + +* Wed Jul 24 2013 Michal Hlavinka - 2:6.25-10.20130624svn +- fix release tag + +* Wed Jul 24 2013 Michal Hlavinka - 2:6.25-10 +- remove bundled libraries from source tarball + +* Mon Jul 22 2013 Michal Hlavinka - 2:6.25-9.20130624svn +- spec cleanup + +* Tue Jul 02 2013 Michal Hlavinka - 2:6.25-8.20130624svn +- ncat should support UNIX sockets correctly, drop wrapper with socat + +* Tue Jul 02 2013 Michal Hlavinka - 2:6.25-7.20130624svn +- allow -i timeout in listen mode + +* Mon Jun 24 2013 Michal Hlavinka - 2:6.25-6.20130624svn +- use svn snapshot that contains all necessary UDP patches + +* Fri May 24 2013 Michal Hlavinka - 2:6.25-5 +- fix man page typo + +* Thu May 23 2013 Michal Hlavinka - 2:6.25-4 +- zenamp: fix icon symlink (#957381) + +* Thu May 23 2013 Michal Hlavinka - 2:6.25-3 +- zenmap: do not traceback when there si no display, just exit nicely (#958240) + +* Thu Mar 28 2013 Michal Hlavinka - 2:6.25-2 +- fix aarch64 support (#926241) + +* Fri Mar 08 2013 Michal Hlavinka - 2:6.25-1 +- nmap updated to 6.25 + +* Thu Feb 14 2013 Fedora Release Engineering - 2:6.01-11 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Fri Jan 04 2013 Michal Hlavinka - 2:6.01-10 +- use select as default nsock engine + +* Thu Nov 29 2012 Michal Hlavinka - 2:6.01-9 +- do not use strict aliasing + +* Thu Nov 29 2012 Michal Hlavinka - 2:6.01-8 +- call shutdown also in listen mode + +* Tue Oct 02 2012 Petr Šabata - 2:6.01-7 +- Move the socat dependency to the ncat subpackage (#858733) + +* Wed Sep 19 2012 Michal Hlavinka - 2:6.01-6 +- shutdown socket on EOF (#845075) + +* Mon Aug 13 2012 Michal Hlavinka - 2:6.01-5 +- ncat did not work when file was used as input (#845005) + +* Tue Jul 24 2012 Michal Hlavinka - 2:6.01-4 +- add nc wrapper with socat as a fallback for unix sockets + +* Fri Jul 20 2012 Fedora Release Engineering - 2:6.01-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Wed Jul 18 2012 Michal Hlavinka - 2:6.01-2 +- provide ncat in extra package as replacement for nc + +* Mon Jun 18 2012 Michal Hlavinka - 2:6.01-1 +- nmap updated to 6.01 + +* Tue Jun 05 2012 Michal Hlavinka - 2:6.00-2 +- prevent stripping binaries + +* Tue Jun 05 2012 Michal Hlavinka - 2:6.00-1 +- updated to 6.00 + +* Wed Mar 14 2012 Michal Hlavinka - 2:5.61-0.1.TEST5 +- updated to 5.61TEST5 + +* Fri Feb 10 2012 Petr Pisar - 2:5.51-5 +- Rebuild against PCRE 8.30 + +* Fri Feb 10 2012 Petr Pisar - 2:5.51-4 +- Rebuild against PCRE 8.30 + +* Fri Jan 13 2012 Fedora Release Engineering - 2:5.51-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Thu Dec 08 2011 Michal Hlavinka - 2:5.51-2 +- do not use bundled certificates, use only system ones (#734389) + +* Mon Feb 14 2011 Michal Hlavinka - 2:5.51-1 +- nmap updated to 5.51 + +* Tue Feb 08 2011 Fedora Release Engineering - 2:5.50-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Mon Feb 07 2011 Michal Hlavinka - 2:5.50-1 +- updated to 5.50 + +* Tue Oct 05 2010 Michal Hlavinka - 2:5.21-10 +- add workaround for zenmap crash (#637403) + +* Wed Sep 29 2010 jkeating - 2:5.21-9 +- Rebuilt for gcc bug 634757 + +* Fri Sep 17 2010 Michal Hlavinka - 2:5.21-8 +- fix location of ja man page (#632104) + +* Thu Aug 19 2010 Michal Hlavinka - 2:5.21-7 +- update icon cache only after gui install + +* Wed Aug 11 2010 Michal Hlavinka - 2:5.21-6 +- update icon cache after package install + +* Wed Jul 21 2010 David Malcolm - 2:5.21-5 +- Rebuilt for https://fedoraproject.org/wiki/Features/Python_2.7/MassRebuild + +* Mon Jun 21 2010 Michal Hlavinka - 2:5.21-4 +- build -frontend as noarch + +* Fri Jun 18 2010 Michal Hlavinka - 2:5.21-3 +- fix multilib issue + +* Fri Apr 30 2010 Ville Skyttä - 2:5.21-2 +- Mark localized man pages with %%lang. + +* Mon Feb 01 2010 Michal Hlavinka - 2:5.21-1 +- updated to 5.21 + +* Tue Jan 12 2010 Michal Hlavinka - 2:5.00-6 +- use sqlite3 (instead of sqlite2) + +* Tue Dec 01 2009 Michal Hlavinka - 2:5.00-5 +- spec cleanup + +* Mon Nov 02 2009 Michal Hlavinka - 2:5.00-4 +- spec cleanup + +* Fri Aug 21 2009 Tomas Mraz - 2:5.00-3 +- rebuilt with new openssl + +* Sat Jul 25 2009 Fedora Release Engineering - 2:5.00-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Fri Jul 17 2009 Michal Hlavinka - 2:5.0-1 +- updated to 5.0 + +* Wed Jul 15 2009 Michal Hlavinka - 2:4.90-0.RC1 +- updated to 4.90RC1 + +* Thu Jun 18 2009 Michal Hlavinka - 2:4.85-0.BETA10 +- updated to 4.85beta10 + +* Wed Feb 25 2009 Fedora Release Engineering - 2:4.76-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + +* Sat Jan 17 2009 Tomas Mraz - 2:4.76-3 +- rebuild with new openssl + +* Mon Dec 15 2008 Michal Hlavinka - 2:4.77-2 +- bump release for rebuild + +* Mon Dec 15 2008 Michal Hlavinka - 2:4.76-1 +- new upstream version 4.76 +- use consolehelper for root auth + +* Sat Nov 29 2008 Ignacio Vazquez-Abrams - 2:4.68-4 +- Rebuild for Python 2.6 + +* Mon Aug 11 2008 Tom "spot" Callaway - 2:4.68-3 +- add missing BuildRequires to use system libs rather than local copies +- really fix license tag + +* Mon Aug 11 2008 Tom "spot" Callaway - 2:4.68-2 +- fix license tag + +* Thu Jul 24 2008 Tomas Smetana - 2:4.68-1 +- new upstream version + +* Mon May 12 2008 Tomas Smetana - 2:4.62-1 +- new upstream version + +* Mon Feb 04 2008 Tomas Smetana - 2:4.53-1 +- new upstream version + +* Mon Jan 07 2008 Tomas Smetana - 2:4.52-2 +- bump release because of build error + +* Mon Jan 07 2008 Tomas Smetana - 2:4.52-1 +- new upstream version + +* Wed Dec 05 2007 Tomas Smetana - 2:4.20-6.1 +- rebuild + +* Wed Aug 22 2007 Harald Hoyer - 2:4.20-6 +- changed license tag + +* Fri Mar 23 2007 Harald Hoyer - 2:4.20-5 +- fixed changelog versions + +* Thu Mar 15 2007 Karsten Hopp 2:4.20-4 +- rebuild with current gtk2 to add png support (#232013) + +* Tue Feb 27 2007 Harald Hoyer - 2:4.20-3 +- specfile cleanup +- fixed Florian La Roche's patch + +* Tue Jan 30 2007 Florian La Roche - 2:4.20-2 +- do not strip away debuginfo + +* Tue Jan 09 2007 Florian La Roche - 2:4.20-1 +- version 4.20 + +* Wed Jul 12 2006 Jesse Keating - 2:4.11-1.1 +- rebuild + +* Tue Jun 27 2006 Harald Hoyer - 2:4.11-1 +- version 4.11 + +* Wed May 17 2006 Harald Hoyer 4.03-2 +- added more build requirements (bug #191932) + +* Wed May 10 2006 Karsten Hopp 4.03-1 +- update to 4.03, this fixes #184286 +- remove duplicate menu entry in 'Internet' (#183056) +- fix possible tmpdir race condition during build (#158996) + +* Fri Feb 10 2006 Jesse Keating - 2:4.00-1.2 +- bump again for double-long bug on ppc(64) + +* Tue Feb 07 2006 Jesse Keating - 2:4.00-1.1 +- rebuilt for new gcc4.1 snapshot and glibc changes + +* Thu Feb 02 2006 Harald Hoyer - 2:4.00-1 +- version 4.00 + +* Mon Dec 19 2005 Harald Hoyer - 2:3.95-1 +- version 3.95 + +* Fri Dec 09 2005 Jesse Keating +- rebuilt + +* Fri Nov 11 2005 Harald Hoyer - 2:3.93-3 +- fixed wrong __attribute__ test + +* Thu Nov 10 2005 Tomas Mraz - 2:3.93-2 +- rebuilt against new openssl + +* Tue Sep 13 2005 Harald Hoyer - 2:3.93-1 +- version 3.93 + +* Wed Aug 03 2005 Harald Hoyer - 2:3.81-4 +- removed references how to scan microsoft.com (bz #164962) +- finally got rid of gtk+-devel dependency + +* Thu Apr 21 2005 Harald Hoyer - 2:3.81-3 +- removed gtk+ requirement + +* Thu Apr 21 2005 Harald Hoyer - 2:3.81-2 +- fixed desktop file and added icons (bug #149157) + +* Wed Mar 02 2005 Harald Hoyer - 2:3.81-1 +- version 3.81 + +* Wed Feb 02 2005 Harald Hoyer - 2:3.78-2 +- evil port of nmapfe to gtk2 + +* Fri Dec 17 2004 Harald Hoyer - 2:3.78-1 +- version 3.78 + +* Mon Sep 13 2004 Harald Hoyer - 2:3.70-1 +- version 3.70 + +* Tue Jul 13 2004 Harald Hoyer - 2:3.55-1 +- new version + +* Tue Jun 15 2004 Elliot Lee +- rebuilt + +* Fri Feb 13 2004 Elliot Lee +- rebuilt + +* Thu Jan 29 2004 Harald Hoyer - 2:3.50-2 +- added BuildRequires: openssl-devel, gtk+-devel, pcre-devel, libpcap + +* Thu Jan 22 2004 Harald Hoyer - 2:3.50-1 +- version 3.50 + +* Wed Oct 8 2003 Harald Hoyer 2:3.48-1 +- version 3.48 + +* Tue Sep 23 2003 Florian La Roche +- allow disabling frontend if gtk1 is not available + +* Wed Jul 30 2003 Harald Hoyer 2:3.30-1 +- version 3.30 + +* Wed Jun 04 2003 Elliot Lee +- rebuilt + +* Mon May 26 2003 Harald Hoyer 2:3.27-1 +- version 3.27 + +* Mon May 12 2003 Harald Hoyer 2:3.20-2 +- changed macro comments to double %% for changelog entries + +* Mon Apr 14 2003 Harald Hoyer 2:3.20-1 +- version 3.2 + +* Wed Jan 22 2003 Tim Powers +- rebuilt + +* Thu Jan 9 2003 Harald Hoyer 3.0-3 +- nmap-3.00-nowarn.patch added + +* Mon Nov 18 2002 Tim Powers +- rebuild on all arches +- remove old desktop file from $$RPM_BUILD_ROOT so rpm won't complain + +* Thu Aug 1 2002 Harald Hoyer +- version 3.0 + +* Mon Jul 29 2002 Harald Hoyer 2.99.2-1 +- bumped version + +* Fri Jul 26 2002 Harald Hoyer 2.99.1-2 +- bumped version to 2.99RC1 + +* Fri Jul 19 2002 Florian La Roche +- add an epoch + +* Mon Jul 1 2002 Harald Hoyer 2.54.36-1 +- removed desktop file +- removed "BETA" name from version +- update to BETA36 + +* Fri Jun 21 2002 Tim Powers +- automated rebuild + +* Sun May 26 2002 Tim Powers +- automated rebuild + +* Wed May 22 2002 Harald Hoyer 2.54BETA34-1 +- update to 2.54BETA34 + +* Mon Mar 25 2002 Harald Hoyer +- more recent version (#61490) + +* Mon Jul 23 2001 Harald Hoyer +- buildprereq for nmap-frontend (#49644) + +* Sun Jul 22 2001 Heikki Korpela +- buildrequire gtk+ + +* Tue Jul 10 2001 Tim Powers +- fix bugs in desktop file (#48341) + +* Wed May 16 2001 Tim Powers +- updated to 2.54BETA22 + +* Mon Nov 20 2000 Tim Powers +- rebuilt to fix bad dir perms + +* Fri Nov 3 2000 Tim Powers +- fixed nmapdatadir in the install section, forgot lto include + $RPM_BUILD_ROOT in the path + +* Thu Nov 2 2000 Tim Powers +- update to nmap-2.54BETA7 to possibly fix bug #20199 +- use the desktop file provided by the package instead of using my own +- patches in previous version are depreciated. Included in SRPM for + reference only + +* Mon Jul 24 2000 Prospector +- rebuilt + +* Mon Jul 10 2000 Tim Powers +- rebuilt + +* Wed Jun 28 2000 Tim Powers +- rebuilt package + +* Thu Jun 8 2000 Tim Powers +- fixed man pages so that they are in an FHS compliant location +- use %%makeinstall +- use predefined RPM macros wherever possible + +* Tue May 16 2000 Tim Powers +- updated to 2.53 +- using applnk now +- use %%configure, and %%{_prefix} where possible +- removed redundant defines at top of spec file + +* Mon Dec 13 1999 Tim Powers +- based on origional spec file from + http://www.insecure.org/nmap/index.html#download +- general cleanups, removed lots of commenrts since it madethe spec hard to + read +- changed group to Applications/System +- quiet setup +- no need to create dirs in the install section, "make + prefix=$RPM_BUILD_ROOT&{prefix} install" does this. +- using defined %%{prefix}, %%{version} etc. for easier/quicker maint. +- added docs +- gzip man pages +- strip after files have been installed into buildroot +- created separate package for the frontend so that Gtk+ isn't needed for the + CLI nmap +- not using -f in files section anymore, no need for it since there aren't that + many files/dirs +- added desktop entry for gnome + +* Sun Jan 10 1999 Fyodor +- Merged in spec file sent in by Ian Macdonald + +* Tue Dec 29 1998 Fyodor +- Made some changes, and merged in another .spec file sent in + by Oren Tirosh + +* Mon Dec 21 1998 Riku Meskanen +- initial build for RH 5.x