Building Ncat Portable for Windows


I used to use telnet for testing if the firewall working properly in the office. Telnet is good for simple test, but when comes to testing a large number of destination IP and ports it will be very time consuming. After searching on the Internet I found Netcat, a tool for testing connection. It is build-in in most Linux OS but not on Windows. So I found Ncat here as part of the Nmap for Windows by, but too bad that it won’t execute on some Windows as it requires Microsoft Visual C++ Redistributable Package installed.

A Ncat portable is an alternative, but the website only provided a beta version of Ncat 5.59BETA1, and require you to compile your own if you would like a newer version.

They did provide a documentation on how to compile Ncat with static linking library, but if you follow the steps you will encounter a few problems which you have to troubleshoot yourselves.

So here is my steps on compiling Ncat portable after I had gone through all the trouble.If you are someone who can edit the documentation on, please do that for me as I don’t want to get an extra account for just editing the document :)

If you want to avoid the trouble to compile, you can download the Ncat which I compiled here, however use it at your own risk as I might have inject some malware inside :)

Building Ncat Portable for Windows


The following steps has been tested using the following environment:


  1. First, follow all steps on the original documentation at till you copied the resulted static libs and include files from “C:\OpenSSL” to the “mswin32\OpenSSL” directory in the Nmap source tree in step 5. Below is a screenshot of the original documentation in case it is edited at the time you read this article.
    Building Ncat Portable
  2. Assuming that everything went fine till now, you’re about 7 steps away from building Ncat portable.
    1. Open Nmap solution in Visual Studio from mswin32\nmap.sln and switch the build configuration to “Ncat Static” like so:
      1. Right click on Solution “nmap” in the Solution Explorer sidebar and choose “Configuration Manager“.
      2. Switch the active solution configuration to “Ncat Static“. Check the “Build” check box for project “liblua“. Make sure that the nsock, nbase and ncat projects have switched to the “Static” configuration also. Then close the “Configuration Manager”.
      3. Right click on the ncat project and select “Set as StartUp Project“.
    2. Right click on the “nsock” project in Visual Studio and click “Properties“. In “Configuration Properties” > “General” > “C/C++” > “General“, in “Additional Include Directories“, add path “..\mswin32\OpenSSL\include
    3. Right click on the “ncat” project in Visual Studio and click “Properties“. In “Configuration Properties” > “General” > “C/C++” > “General“, in “Additional Include Directories“, add path “..\mswin32\OpenSSL\include” and “..\liblua
    4. Right click on the “ncat” project in Visual Studio and click “Properties“. In “Configuration Properties” > “General” > “Linker” > “General“, in “Additional Library Directories“, add path “..\mswin32\OpenSSL\lib
    5. Expand the “ncat” project, double click the file “ncat_ssl.c” and comment out the line “#include <openssl/applink.c>
    6. Right click on the “liblua” project in Visual Studio and click “Properties“. In “Configuration Properties” > “General” > “C/C++” > “Code Generation“, set “Runtime Library” to “Multi-threaded DLL (/MD)
    7. Right click on the “ncat” project in Visual Studio and click “Build“. Alternatively you can press the F7 key to start building.

One response to “Building Ncat Portable for Windows

  1. Some things:

    a. It is expected OpenSSL libs and includes to be in a directory called “nmap-mswin32-aux” in parallel with nmap top directory. So you have for example C:\nmap-build and C:\nmap-mswin32-aux\OpenSSL\include. . . This also makes unnecessary to add new lib and include paths to solutions.

    b. Liblua’s problem is already reported and should be solved in svn snapshots of nmap. If you’re using 6.47 release it’s necessary to add the path as you have done.

    c. Instead of editing ncat_ssl.c, applink.c should be located also within openssl headers dir, you can download it from here (that’s official nmap dependency repo).

    d. Step 6 has an error, you should change liblua’s runtime library from “Multi-threaded DLL (/MD)” to “Multithreaded (/MT)”.

    e. Should test static ncat ssl capability, since I compiled it using your guide and it has no ssl at all. Not sure about the problem, but it’s clear it runs on plain text even with –ssl switch on.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s