Created
April 4, 2020 02:34
-
-
Save pennz/c95c3759d8da066603c576b86daa53dd to your computer and use it in GitHub Desktop.
tproxy patch for netcat v1.10 GNU commutiy version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- a/netcat.c 2018-01-11 22:13:14.000000000 +0000 | |
+++ b/netcat.c 2020-04-04 01:24:53.000042333 +0000 | |
@@ -81,6 +81,10 @@ | |
#include <fcntl.h> /* O_WRONLY et al */ | |
#include <unistd.h> | |
+/* quick hack to make it working without patched kernel source, | |
+ for https://sourceforge.net/projects/nc110/files/community%20releases/ */ | |
+#define IP_TRANSPARENT 19 | |
+ | |
/* handy stuff: */ | |
#define SA struct sockaddr /* socket overgeneralization braindeath */ | |
#define SAI struct sockaddr_in /* ... whoever came up with this model */ | |
@@ -196,6 +199,7 @@ | |
USHORT o_random = 0; | |
USHORT o_udpmode = 0; | |
USHORT o_verbose = 0; | |
+USHORT o_transparent = 0; | |
USHORT o_holler_stderr = 1; | |
unsigned int o_wait = 0; | |
USHORT o_zero = 0; | |
@@ -814,6 +818,13 @@ | |
if (rr == -1) | |
holler ("nnetfd reuseport failed"); /* ??? */ | |
#endif | |
+ if (o_transparent) { | |
+ x = 1; | |
+ rr = setsockopt(nnetfd, SOL_IP, IP_TRANSPARENT, &x, sizeof(x)); | |
+ if (rr == -1) { | |
+ holler("nnetfd set transparent failed"); | |
+ } | |
+ } | |
#if 0 | |
/* If you want to screw with RCVBUF/SNDBUF, do it here. Liudvikas Bukys at | |
Rochester sent this example, which would involve YET MORE options and is | |
@@ -1832,6 +1843,7 @@ | |
-t answer TELNET negotiation"); | |
#endif | |
holler ("\ | |
+ -T set IP_TRANSPARENT for the socket\n\ | |
-u UDP mode\n\ | |
-v verbose [use twice to be more verbose]\n\ | |
-w secs timeout for connects and final net reads\n\ | |
@@ -1974,7 +1986,7 @@ | |
/* If your shitbox doesn't have getopt, step into the nineties already. */ | |
/* optarg, optind = next-argv-component [i.e. flag arg]; optopt = last-char */ | |
- while ((x = getopt (argc, argv, "46abc:e:g:G:hi:lno:p:q:rs:tuvw:z")) != EOF) { | |
+ while ((x = getopt (argc, argv, "46abc:e:g:G:hi:lno:p:q:rs:tTuvw:z")) != EOF) { | |
/* Debug (("in go: x now %c, optarg %x optind %d", x, optarg, optind)) */ | |
switch (x) { | |
#ifdef INET6 | |
@@ -2029,6 +2041,8 @@ | |
if (! o_interval) | |
bail ("invalid interval time %s", optarg); | |
break; | |
+ case 'T': /* numeric-only, no DNS lookups */ | |
+ o_transparent = 1; break; | |
case 'l': /* listen mode */ | |
o_listen++; break; | |
case 'n': /* numeric-only, no DNS lookups */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Orignial Patch can be found at the related kernel doc page.
This one is for the nc source code in https://sourceforge.net/projects/nc110/files/community%20releases/ .