Introduction ============ The step by step instructions in this how-to will help you build a portable build of Ncat(http://nmap.org/ncat/) for the MS Windows platform by means of static linking. Toolkit ======= * Microsoft Visual C++ 2010 Express Edition is fine: http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express * Latest OpenSSL sources from http://www.openssl.org/source/ Note: Tested with openssl-1.0.0d. * Perl Install ActivePerl from activestate.com (free download) http://www.activestate.com/store/activeperl/download/ * Nmap source either from svn or release version. http://nmap.org/download.html Building Ncat portable ====================== 0) Open Nmap solution in Visual Studio from mswin32\nmap.sln and switch the build configuration to Release like so: a)Right click on Solution 'nmap' in the Solution Explorer sidebar and choose "Configuration Manager". b)Ensure that the active solution configuration is Release and then close the Configuration Manager. c)Right click on the ncat project and select "Set as StartUp Project" 1) Open nsock_winconfig.h from the nsock project and paste the following line as the first line after the license comment: #define DISABLE_NSOCK_PCAP This define disables WinPcap since we don't need it for building Ncat. 2) Link Ncat, Nsock, Nbase with static runtime: a)Right click the ncat project and choose "Properties". From "Configuration Properties" click on "C/C++" -> "Code Generation". Switch Runtime Library entry from "Multi-threaded DLL (/MD)" to "Multi-threaded (/MT)". Click "Apply" and "Ok". Do the same for nsock and nbase projects. 3) Build OpenSSL static: a) Extract openssl-x.x.x archive to c:\. b) Create C:\OpenSSL folder for installation. c) Open the Visual Studio 2010 command prompt. d) Change directory to the OpenSSL source directory and issue the following commands: perl Configure --prefix=C:/OpenSSL VC-WIN32 -no-shared ms\do_ms.bat nmake -f ms\nt.mak install e) If all is fine from the above step, copy the required files from "C:\OpenSSL" to the "mswin32\OpenSSL" directory in the Nmap source tree(remove existing include,lib directories): \OpenSSL\include -> mswin32\OpenSSL\include \OpenSSL\lib -> mswin32\OpenSSL\lib 4. Remove wpcap.lib, packet.lib dependencies and add additional lib dependencies user32.lib gdi32.lib to Ncat: This last step might seem weird to you, but OpenSSL uses those GUI/IO libraries as seed for the random generators and possibly other kinky things, as suggested by the linker errors function names when you build without them: 1>libeay32.lib(cryptlib.obj) : error LNK2019: unresolved external symbol __imp__GetUserObjectInformationW@20 referenced in function _OPENSSL_isservice 1>libeay32.lib(cryptlib.obj) : error LNK2019: unresolved external symbol __imp__GetProcessWindowStation@0 referenced in function _OPENSSL_isservice 1>libeay32.lib(cryptlib.obj) : error LNK2019: unresolved external symbol __imp__GetDesktopWindow@0 referenced in function _OPENSSL_isservice 1>libeay32.lib(cryptlib.obj) : error LNK2019: unresolved external symbol __imp__MessageBoxA@16 referenced in function _OPENSSL_showfatal ... 1>libeay32.lib(rand_win.obj) : error LNK2019: unresolved external symbol __imp__GetBitmapBits@12 referenced in function _readscreen a)Right click on "ncat" project and choose "Properties". From "Configuration Properties" choose Linker -> Input. Remove the following libs from "Additional Dependencies": wpcap.lib;packet.lib Append the following new libraries to "Additional Dependencies": user32.lib;gdi32.lib Be careful with the semicolons. 4. Right click on the "ncat" project in Visual Studio and click "Build". Go pet a cat or something for a couple of seconds and then Voila! Ncat portable baby! Questions? ========== nmap-dev insecure.org