summaryrefslogtreecommitdiff
path: root/repo/netcat/0006-udp-scan-timeout.patch
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2022-06-15 23:15:23 +0100
committerdavidovski <david@davidovski.xyz>2022-06-15 23:15:23 +0100
commite4a392b4e1e547c9569abdd1f08ec51da3dc4562 (patch)
treef23f62b3d309e332dd1d37b4c6ff5addc2c65453 /repo/netcat/0006-udp-scan-timeout.patch
parente17a6ad453835a5c7d8a277c625688750a62e28d (diff)
added netcat
Diffstat (limited to 'repo/netcat/0006-udp-scan-timeout.patch')
-rw-r--r--repo/netcat/0006-udp-scan-timeout.patch60
1 files changed, 60 insertions, 0 deletions
diff --git a/repo/netcat/0006-udp-scan-timeout.patch b/repo/netcat/0006-udp-scan-timeout.patch
new file mode 100644
index 0000000..799acc6
--- /dev/null
+++ b/repo/netcat/0006-udp-scan-timeout.patch
@@ -0,0 +1,60 @@
+From: Aron Xu <aron@debian.org>
+Date: Mon, 13 Feb 2012 15:29:37 +0800
+Subject: udp scan timeout
+
+---
+ netcat.c | 25 ++++++++++++++++---------
+ 1 file changed, 16 insertions(+), 9 deletions(-)
+
+diff --git a/netcat.c b/netcat.c
+index f971893..9ab507a 100644
+--- a/netcat.c
++++ b/netcat.c
+@@ -117,6 +117,8 @@
+ #define CONNECTION_FAILED 1
+ #define CONNECTION_TIMEOUT 2
+
++#define UDP_SCAN_TIMEOUT 3 /* Seconds */
++
+ /* Command Line Options */
+ int Cflag = 0; /* CRLF line-ending */
+ int dflag; /* detached, no stdin */
+@@ -525,7 +527,7 @@ main(int argc, char *argv[])
+ continue;
+
+ ret = 0;
+- if (vflag || zflag) {
++ if (vflag) {
+ /* For UDP, make sure we are connected. */
+ if (uflag) {
+ if (udptest(s) == -1) {
+@@ -1298,15 +1300,20 @@ build_ports(char *p)
+ int
+ udptest(int s)
+ {
+- int i, ret;
+-
+- for (i = 0; i <= 3; i++) {
+- if (write(s, "X", 1) == 1)
+- ret = 1;
+- else
+- ret = -1;
++ int i, t;
++
++ if ((write(s, "X", 1) != 1) ||
++ ((write(s, "X", 1) != 1) && (errno == ECONNREFUSED)))
++ return -1;
++
++ /* Give the remote host some time to reply. */
++ for (i = 0, t = (timeout == -1) ? UDP_SCAN_TIMEOUT : (timeout / 1000);
++ i < t; i++) {
++ sleep(1);
++ if ((write(s, "X", 1) != 1) && (errno == ECONNREFUSED))
++ return -1;
+ }
+- return (ret);
++ return 1;
+ }
+
+ void
+--