2014-01-19 02:05:04 +01:00
|
|
|
--- netcat-openbsd-1.89.orig/netcat.c
|
|
|
|
+++ netcat-openbsd-1.89/netcat.c
|
2013-09-02 21:53:10 +02:00
|
|
|
@@ -55,6 +55,8 @@
|
|
|
|
#include <limits.h>
|
|
|
|
#include "atomicio.h"
|
|
|
|
|
2014-01-19 02:05:04 +01:00
|
|
|
+#define strlcpy(d,s,n) snprintf((d),(n),"%s",(s))
|
2013-09-02 21:53:10 +02:00
|
|
|
+
|
|
|
|
#ifndef SUN_LEN
|
|
|
|
#define SUN_LEN(su) \
|
|
|
|
(sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path))
|
2014-01-19 02:05:04 +01:00
|
|
|
@@ -549,11 +551,11 @@ local_listen(char *host, char *port, str
|
2013-09-02 21:53:10 +02:00
|
|
|
if ((s = socket(res0->ai_family, res0->ai_socktype,
|
|
|
|
res0->ai_protocol)) < 0)
|
|
|
|
continue;
|
|
|
|
-
|
|
|
|
+ #ifdef SO_REUSEPORT
|
|
|
|
ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof(x));
|
|
|
|
if (ret == -1)
|
|
|
|
err(1, NULL);
|
|
|
|
-
|
|
|
|
+ #endif
|
|
|
|
set_common_sockopts(s);
|
|
|
|
|
|
|
|
if (bind(s, (struct sockaddr *)res0->ai_addr,
|
2014-01-19 02:05:04 +01:00
|
|
|
@@ -719,7 +721,8 @@ build_ports(char *p)
|
2013-09-02 21:53:10 +02:00
|
|
|
char *c;
|
|
|
|
|
|
|
|
for (x = 0; x <= (hi - lo); x++) {
|
|
|
|
- y = (arc4random() & 0xFFFF) % (hi - lo);
|
|
|
|
+ /* use random instead of arc4random */
|
|
|
|
+ y = (random() & 0xFFFF) % (hi - lo);
|
|
|
|
c = portlist[x];
|
|
|
|
portlist[x] = portlist[y];
|
|
|
|
portlist[y] = c;
|
2014-01-19 02:05:04 +01:00
|
|
|
@@ -761,21 +764,25 @@ set_common_sockopts(int s)
|
2013-09-02 21:53:10 +02:00
|
|
|
{
|
|
|
|
int x = 1;
|
|
|
|
|
|
|
|
+#ifdef TCP_MD5SIG
|
|
|
|
if (Sflag) {
|
|
|
|
if (setsockopt(s, IPPROTO_TCP, TCP_MD5SIG,
|
|
|
|
&x, sizeof(x)) == -1)
|
|
|
|
err(1, NULL);
|
|
|
|
}
|
|
|
|
+#endif
|
|
|
|
if (Dflag) {
|
|
|
|
if (setsockopt(s, SOL_SOCKET, SO_DEBUG,
|
|
|
|
&x, sizeof(x)) == -1)
|
|
|
|
err(1, NULL);
|
|
|
|
}
|
|
|
|
+#ifdef SO_JUMBO
|
|
|
|
if (jflag) {
|
|
|
|
if (setsockopt(s, SOL_SOCKET, SO_JUMBO,
|
|
|
|
&x, sizeof(x)) == -1)
|
|
|
|
err(1, NULL);
|
|
|
|
}
|
|
|
|
+#endif
|
|
|
|
if (Tflag != -1) {
|
|
|
|
if (setsockopt(s, IPPROTO_IP, IP_TOS,
|
|
|
|
&Tflag, sizeof(Tflag)) == -1)
|
2014-01-19 02:05:04 +01:00
|
|
|
@@ -816,9 +823,11 @@ help(void)
|
2013-09-02 21:53:10 +02:00
|
|
|
\t-n Suppress name/port resolutions\n\
|
|
|
|
\t-P proxyuser\tUsername for proxy authentication\n\
|
|
|
|
\t-p port\t Specify local port for remote connects\n\
|
|
|
|
- \t-r Randomize remote ports\n\
|
|
|
|
- \t-S Enable the TCP MD5 signature option\n\
|
|
|
|
- \t-s addr\t Local source address\n\
|
|
|
|
+ \t-r Randomize remote ports\n "
|
|
|
|
+#ifdef TCP_MD5SIG
|
|
|
|
+" \t-S Enable the TCP MD5 signature option\n"
|
|
|
|
+#endif
|
|
|
|
+" \t-s addr\t Local source address\n\
|
|
|
|
\t-T ToS\t Set IP Type of Service\n\
|
|
|
|
\t-t Answer TELNET negotiation\n\
|
|
|
|
\t-U Use UNIX domain socket\n\
|