These steps will compile an executable (default: nc.exe) on a Windows 10 machine. This build will enable the “-e” command line option (also known as “GAPING_SECURITY_HOLE”). The “-e” option allows you to pass a command into NetCat; example:
I discovered that MobaXterm for Windows has the nc (netcat) command, as well as many other Unix commands, like ls, ps, and kill. I wholeheartedly recommend MobaXterm, especially if you are familiar with both Unix and DOS. For me, there was nothing to install; it's just one executable that opens a terminal window in Windows that accepts many. Example: 5) NC as a proxy. NC can also be used as a proxy with a simple command. Let’s take an example, $ ncat -l 8080 ncat 192.168.1.200 80. Now all the connections coming to our server on port 8080 will be automatically redirected to 192.168.1.200 server on port 80.
The caveat for Windows 10 is that Window’s Defender detects nc.exe as being “malware” and deletes it. Therefore beware the git repo we use here does have a compiled version. If you have Windows Defender active this file will likely be deleted. When you compile a new nc.exe it too will likely be deleted.
Window Defender Workaround
You have two easy options to get around Window Defender.
Disable Windows Defender while you use netcat or;
Before you compile edit a source file. There are numerous areas, especially in netcat.c where status messages (such as at line 381) are sent as output to a terminal. If you change the message, then compile, you will change the hash of the file. Windows Defender seems to be largely tied to file hashes.
Let’s Build NetCat
Netcat Commands List
It is useful if you are using an account with elevated permissions.
1) Download the Windows NetCat source code. 2) Download MinGW
3) Configure MinGW 3a) If the MinGW “Installation Manager” does not auto-start after the installation of MinGW has completed run it:
Start>MinGW Installation Manager
4) From the MinGW Installation Manager I needed to select the following plugins: 4a) mingw32-developer-toolkit 4b) mingw32-base 4c) mingw32-gcc-g++ 4d) mingw32-gcc-objc 4e) mysys-base
5) Apply the selected plugins:
Installation > Apply Changes
6) Make sure your PATH system variable includes a reference to the MinGW DLLs. 6a) The default path is:
C:MinGWbin
6b) Start > Control Panel > Advanced Settings > Environment Variables 6c) Select “Path” from “User variables for [your user name]”. 6d) Select Edit… 6e) Add the path the the DLL folder (default: c:MinGWbin). 6f) Apply Changes / Close Control Panel Windows 6g) Restart Windows
7) Verify the gcc compiler is includes references to the DLL path. 7a) Open CMD and type:
gcc -print-search-dirs
7b) Amoung other things you should see references to /mingw32/bin
8) Still in CMD navigate to the folder which holds the NetCat source files. 8a) Run makewin.cmd 8b) You may get the following error:
As long as there are no other errors (not talking about warnings) you should be fine. What happens is the default makewin.cmd script attempts to copy the newly complied nc.exe file into your system32 folder (which if you get this error cannot be done because that folder is protected). This error can be ignored as you have the compiled binary in the folder you are currently in.