Home page logo

Personal tools

Nmap/Ncat Portable

From SecWiki
Jump to: navigation, search

Building Ncat Portable for Windows

The step by step instructions in this section will guide you through the process of building a portable version of Ncat for the MS Windows platform by means of static linking. The resulted binary, ncat.exe, can then be transported and executed by itself, with no runtime dependencies, across all versions of Microsoft Windows starting from Windows XP to Windows 7.

Before you proceed with building a static version of Ncat, we strongly recommend building a normal, dynamic build of Ncat first, just to get the hang of it or spot building issues that might not pertain to building a static version. Details on how you can achieve that can be found at http://nmap.org/install/.

Now that you've successfully build Ncat with dynamic linking, let's proceed building Ncat Portable for Windows.

First of all, tools of the trade:

  • Microsoft Visual C++ 2010
 Express Edition is fine:
 Note: Tested with openssl-1.0.0d.
  • Perl (needed for building OpenSSl)
 Install ActivePerl from activestate.com (free download)
  • Nmap source either from svn or a released version greater then nmap-5.59BETA1

Next step is to build the OpenSSL library you just downloaded statically:

  1. Extract openssl-x.x.x archive to c:\.
  2. Create c:\OpenSSL folder for installation.
  3. Open the Visual Studio 2010 command prompt.
    To do this, click Start, point to All Programs, point to Microsoft Visual Studio 2010, point to Visual Studio Tools, and then click Visual Studio 2010 Command Prompt.
  4. Change directory to the OpenSSL source directory and issue the following commands:
    perl Configure --prefix=C:/OpenSSL VC-WIN32 -no-shared
    nmake -f ms\nt.mak install
  5. If all is fine from the above step, copy the resulted static libs and include files from "C:\OpenSSL" to the "mswin32\OpenSSL" directory in the Nmap source tree. Remove the existing include\ and lib\ directories:
    c:\OpenSSL\include   -> nmap\mswin32\OpenSSL\include
    c:\OpenSSL\lib       -> nmap\mswin32\OpenSSL\lib

Assuming that everything went fine till now, you're about two 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" and then close the Configuration Manager. Make sure that the nsock, nbase and ncat projects have switched to the "Static" configuration also.
    3. Right click on the ncat project and select "Set as StartUp Project".
  2. Right click on the "ncat" project in Visual Studio and click "Build". Alternatively you can press the F7 key to start building.

That's it, Ncat should be compiling by now. Wait for the build process to finish and then you can find the resulted Ncat Portable static binary ncat.exe in your nmap directory in ncat\Release. You can take it outside of the build directory and use it as a standalone exe either on your system or any other machine running one of the Microsoft Windows versions supported.

If you're having trouble or questions regarding the steps outlined in this document, feel free to e-mail nmap-dev <at> insecure.org.

Known problem

If you found this error at compilation:

'openssl/applink.c': No such file or directory

or the resulting exe fails to open sockets:

ncat -l 8000

setsockopt: No error

You might try to use the exact 5.59BETA1 version of source code from this link: http://nmap.org/dist/nmap-5.59BETA1.tgz

[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]