Last Modified: Tue, 15 Jan 2019 18:01:58 +0000 ; Created: Tue, 08 Sep 2009 16:58:50 +0000
|I wanted a way to compile Netcat on Windows using MinGW so I could have a version without the GAPING_SECURITY_HOLE option (-e command line option). This helps to avoid the annoyance of anti-virus tools reporting it as a virus/trojan and also gives me a binary I know isn't infected with something.
Doing so on Windows is a real pain since there isn't a straight forward make file for MinGW. It seemed mostly geared at Microsoft VC.
Just copy and paste the following text into a "makewin.cmd" file in the same directory as the source. A good place to get source for Windows is http://joncraton.org/blog/46#comment-14590181 (this also includes a binary for Netcat for Windows but the -e option is still turned on).
I also have a build of Netcat (nc.exe) that you can download here.
You'll need MinGW with gcc (MinGW.org GCC-8.2.0-3) 8.2.0. Modify the paths in the batch script as needed and run it. You should get a nc.exe file if all went well.
@REM Build script to compile Netcat on WIN32 using MinGW @REM @REM Rodney Beede (http://www.rodneybeede.com) @REM @REM 2019-01-15 @REM @REM Tested with gcc (MinGW.org GCC-8.2.0-3) 8.2.0 @REM Adjust PATH so necessary dll's are accessible SET PATH=%PATH%;c:\MinGW\bin SET COMPILER=c:\MinGW\bin\gcc.exe SET LIB_DIR=c:\MinGW\lib @REM not needed? SET COMPILE_OPTIONS=-c -DWIN32 -DNDEBUG -D_CONSOLE -DTELNET SET COMPILE_OPTIONS=-c del *.o del nc.exe "%COMPILER%" %COMPILE_OPTIONS% getopt.c "%COMPILER%" %COMPILE_OPTIONS% doexec.c "%COMPILER%" %COMPILE_OPTIONS% netcat.c @REM Note that the -l libraries MUST come at the very end or linking will fail "%COMPILER%" getopt.o doexec.o netcat.o --output nc.exe -Wl,-L"%LIB_DIR%",-lkernel32,-luser32,-lwinmm,-lws2_32