diff --git a/CHANGELOG b/CHANGELOG
index dd15bf5c2..c1ad164c1 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,5 +1,9 @@
# Nmap Changelog ($Id$); -*-text-*-
+o [Ncat] [GH#151] [GH#142] New option --no-shutdown prevents Ncat from shutting
+ down when it reads EOF on stdin. This is the same as traditional netcat's
+ "-d" option. [Adam Saparona]
+
o [NSE] Added ip-https-discover for detecting support for Microsoft's IP over
HTTPS tunneling protocol. [Niklaus Schiess]
diff --git a/ncat/docs/ncat.xml b/ncat/docs/ncat.xml
index e96e6e767..ee159926a 100644
--- a/ncat/docs/ncat.xml
+++ b/ncat/docs/ncat.xml
@@ -775,6 +775,19 @@
+
+
+ (Do not shutdown into half-duplex mode)
+ (Ncat option)
+
+
+ If this option is passed, Ncat will not invoke shutdown on a
+ socket aftering seeing EOF on stdin. This is provided for
+ backward-compatibility with OpenBSD netcat, which exhibits this
+ behavior when executed with its '-d' option.
+
+
+
,
diff --git a/ncat/ncat_core.c b/ncat/ncat_core.c
index bb5afae6b..128228f29 100644
--- a/ncat/ncat_core.c
+++ b/ncat/ncat_core.c
@@ -168,6 +168,7 @@ void options_init(void)
o.keepopen = 0;
o.sendonly = 0;
o.recvonly = 0;
+ o.noshutdown = 0;
o.telnet = 0;
o.linedelay = 0;
o.chat = 0;
diff --git a/ncat/ncat_core.h b/ncat/ncat_core.h
index 197dab46a..dd35770aa 100644
--- a/ncat/ncat_core.h
+++ b/ncat/ncat_core.h
@@ -161,6 +161,7 @@ struct options {
int keepopen;
int sendonly;
int recvonly;
+ int noshutdown;
int telnet;
int linedelay;
int chat;
diff --git a/ncat/ncat_listen.c b/ncat/ncat_listen.c
index 9f51b6858..3bf7e0e3e 100644
--- a/ncat/ncat_listen.c
+++ b/ncat/ncat_listen.c
@@ -393,7 +393,7 @@ static int ncat_listen_stream(int proto)
receiving anything, we can quit here. */
return 0;
}
- shutdown_sockets(SHUT_WR);
+ if (!o.noshutdown) shutdown_sockets(SHUT_WR);
}
if (rc < 0)
return 1;
diff --git a/ncat/ncat_main.c b/ncat/ncat_main.c
index d7fd5a538..7dbf50c84 100644
--- a/ncat/ncat_main.c
+++ b/ncat/ncat_main.c
@@ -286,6 +286,7 @@ int main(int argc, char *argv[])
{"source-port", required_argument, NULL, 'p'},
{"source", required_argument, NULL, 's'},
{"send-only", no_argument, &o.sendonly, 1},
+ {"no-shutdown", no_argument, &o.noshutdown,1},
{"broker", no_argument, NULL, 0},
{"chat", no_argument, NULL, 0},
{"talk", no_argument, NULL, 0},