Advertisement
opexxx

Compile Netcat on Windows using MinGW

Jan 27th, 2015
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.85 KB | None | 0 0
  1.  
  2. Compile Netcat on Windows using MinGW
  3. 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.
  4.  
  5. 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.
  6.  
  7. 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 that you can download here. In addition you can find other sites that provide mirrors at http://www.thaoh.net/Tools/Netcat/
  8.  
  9. You'll need MinGW with gcc version 3.4.5 (I used MinGW 5.1.4. Modify the paths in the batch script as needed and run it. You should get a nc.exe file if all went well. If not feel free to drop me an e-mail at website2008+netcat -AT_NOSPAM- rodneybeede _D0t_ com.
  10.  
  11. @REM    Build script to compile Netcat on WIN32 using MinGW
  12. @REM
  13. @REM    Rodney Beede    (http://www.rodneybeede.com)
  14. @REM
  15. @REM    2009-09-02
  16. @REM
  17. @REM    Tested with gcc 3.4.5 and MinGW version 5.1.4
  18.  
  19. SET COMPILER=c:\MinGW\bin\gcc.exe
  20. SET LIB_DIR=c:\MinGW\lib
  21.  
  22. @REM    not needed? SET COMPILE_OPTIONS=-c -DWIN32 -DNDEBUG -D_CONSOLE -DTELNET
  23. SET COMPILE_OPTIONS=-c
  24.  
  25. del *.o
  26. del nc.exe
  27.  
  28. "%COMPILER%" %COMPILE_OPTIONS% getopt.c
  29.  
  30. "%COMPILER%" %COMPILE_OPTIONS% doexec.c
  31.  
  32. "%COMPILER%" %COMPILE_OPTIONS% netcat.c
  33.  
  34. @REM Note that the -l libraries MUST come at the very end or linking will fail
  35. "%COMPILER%" getopt.o doexec.o netcat.o --output nc.exe -Wl,-L"%LIB_DIR%",-lkernel32,-luser32,-lwinmm,-lws2_32
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement