From 23ee017b951b299e874f2079103e27e98bcac867 Mon Sep 17 00:00:00 2001 From: dmiller Date: Mon, 8 Jul 2019 16:12:08 +0000 Subject: [PATCH] Check for WSL and warn, suggest native Windows build of Nmap. --- nmap.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/nmap.cc b/nmap.cc index 9b1662726..6c4d32f62 100644 --- a/nmap.cc +++ b/nmap.cc @@ -197,6 +197,11 @@ #endif #define DNET_VERSION VERSION +#ifdef LINUX +/* Check for Windows Subsystem for Linux (WSL) */ +#include +#endif + #include #include #include @@ -1815,6 +1820,18 @@ int nmap_main(int argc, char *argv[]) { struct sockaddr_storage ss; size_t sslen; +#ifdef LINUX + /* Check for WSL and warn that things may not go well. */ + struct utsname uts; + if (!uname(&uts)) { + if (strstr(uts.release, "Microsoft") != NULL) { + error("Warning: %s may not work correctly on Windows Subsystem for Linux.\n" + "For best performance and accuracy, use the native Windows build from %s/download.html#windows.", + NMAP_NAME, NMAP_URL); + } + } +#endif + now = time(NULL); local_time = localtime(&now);