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);