diff --git a/docs/nmap-install.xml b/docs/nmap-install.xml index 4611880dc..55dd0f8aa 100644 --- a/docs/nmap-install.xml +++ b/docs/nmap-install.xml @@ -788,7 +788,7 @@ specific release). Most Nmap users choose this option since it is so easy. Another advantage of the self-installer is that it provides the option to install the Zenmap GUI and other tools. Simply run the installer file and let it walk you through panels for choosing an install path and installing Npcap. The installer was created with the open-source Nullsoft Scriptable +url="http://nsis.sourceforge.io/Main_Page">Nullsoft Scriptable Install System. After it completes, read for instructions on executing Nmap on the command-line or through Zenmap. @@ -807,24 +807,18 @@ graphical interface is included, so you need to run download and install a superior command shell such as those included with the free CygwinCygwin -system available from . Here are the step-by-step instructions for installing and executing the Nmap .zip binaries. +system available from . Here are the step-by-step instructions for installing and executing the Nmap .zip binaries. Installing the Nmap zip binaries Download the .zip binaries from . -Uncompress the zip file into the directory you want +Extract the zip file into the directory you want Nmap to reside in. An example would be C:\Program Files. A directory called nmap-version should be created, which includes -the Nmap executable and data files. Microsoft Windows XP and later -includes zip extraction—just right-click on the file in -Explorer. If you do not have a Zip -decompression program, there is one (called unzip) in Cygwin described -above, or you can download the open-source and free 7-Zip utility. Commercial -alternatives are WinZip and -PKZIP. +the Nmap executable and data files. + For improved performance, apply the Nmap Registry changes discussed previously. @@ -838,9 +832,9 @@ the latest version from . Due to the way Nmap is compiled, it requires the -Microsoft Visual C++ 2013 Redistributable Package of runtime +Microsoft Visual C++ Redistributable Package of runtime components. Many systems already have this installed from other -packages, but you should run vcredist_x86.exe +packages, but you should run VC_redist.x86.exe from the zip file just in case you need it. Pass the option to run these installers in quiet (non interactive) mode. @@ -857,10 +851,9 @@ given in . Most Windows users prefer to use the Nmap binary self-installer, but compilation from source code is an option, particularly if you plan to help with Nmap development. Compilation requires -Microsoft Visual C++ 2013, which is part of their commercial Visual Studio -suite. Any of the Visual Studio 2013 editions should work, including the free - -Visual C++ 2013 Express. +Microsoft Visual C++ 2019, which is part of their commercial Visual Studio +suite. Any of the Visual Studio 2019 editions should work, including the free +Visual Studio 2019 Community. Some of Nmap's dependencies on Windows are inconvenient to build. For @@ -893,7 +886,7 @@ point to the alternate directory. Uncompress the source code file you just downloaded. The source code directory and the nmap-mswin32-aux must be in the same parent directory. -Recent releases of the free Cygwin distributionCygwin can handle both the .tar.bz2 and .tgz formats. Use the command tar xvjf nmap-version.tar.bz2 or tar xvzf nmap-version.tgz, respectively. Alternatively, the common WinZip application can decompress these files. +Recent releases of the free Cygwin distributionCygwin can handle both the .tar.bz2 and .tgz formats. Use the command tar xvjf nmap-version.tar.bz2 or tar xvzf nmap-version.tgz, respectively. Alternatively, the common WinZip application can decompress these files. Open Visual Studio and the Nmap solution file (nmap-version/mswin32/nmap.sln). @@ -977,18 +970,12 @@ the program menu tree, the simplest approach is to choose Start If you execute Nmap frequently, you can add the Nmap directory -(c:\Program Files (x86)\Nmap by default on -Windows 7) to your command execution path. The exact place -to set this varies by Windows platform. On my Windows XP box, which -installs Nmap in c:\Program Files\Nmap, I do the -following: +(c:\Program Files (x86)\Nmap by default) to your command execution path: + -From the desktop, right click on My -Computer and then click properties. - -In the System Properties window, click the -Advanced tab. + Open the System Properties window to the Advanced tab by running SystemPropertiesAdvanced.exe. + Click the Environment Variables button. @@ -1000,9 +987,9 @@ Choose Path from the System variables section, then hit edit. -Add a semi-colon and then your Nmap directory (e.g. c:\Program Files\Nmap) to the end of the value. +Add a semi-colon and then your Nmap directory (e.g. c:\Program Files (x86)\Nmap) to the end of the value. -Open a new DOS window and you should be able to execute a +Open a new command prompt and you should be able to execute a command such as nmap scanme.nmap.org from any directory. diff --git a/mswin32/Makefile b/mswin32/Makefile index de452d049..1dc48ac63 100644 --- a/mswin32/Makefile +++ b/mswin32/Makefile @@ -1,4 +1,4 @@ -MAKENSIS=C:/Program Files (x86)/NSIS-strlen/makensis.exe +MAKENSIS=C:/Program Files (x86)/NSIS/makensis.exe SIGNTOOL := $(shell reg query "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Microsoft SDKs\\Windows\\v10.0" /v "InstallationFolder" | egrep InstallationFolder | cut -d ' ' -f13- | sed 's%\\%/%g' | tr -d '\r\n' | sed 's%$$%bin/x86/signtool.exe%') NMAPDIR=.. NMAPDIR_WIN=$(shell echo '$(NMAPDIR)' | sed 's|/cygdrive/\(.\)|\1:|;s|/|\\|g') @@ -49,7 +49,6 @@ stage-common: $(NMAPDIR)/CHANGELOG $(NMAPDIR)/LICENSE $(NMAPDIR)/nmap-mac-prefix cp -r $(NMAPDIR)/docs/licenses nmap-$(NMAP_VERSION)/ rm -rf nmap-$(NMAP_VERSION)/licenses/.svn cp VC_redist.x86.exe nmap-$(NMAP_VERSION) - #cp $(NMAP_MSWIN32_AUX)/vcredist2008_x86.exe nmap-$(NMAP_VERSION) cp $(NMAPDIR)/ncat/$(VCCONFIG)/ncat.exe nmap-$(NMAP_VERSION) cp $(NMAPDIR)/ncat/$(VCCONFIG)/ca-bundle.crt nmap-$(NMAP_VERSION) cp $(NMAPDIR)/nping/$(VCCONFIG)/nping.exe nmap-$(NMAP_VERSION) @@ -79,10 +78,21 @@ sign-files: nmap-$(NMAP_VERSION)-oem/nmap.exe nmap-$(NMAP_VERSION)/nmap.exe nmap "$(SIGNTOOL)" $(SIGNTOOL_ARGS) $^ touch sign-files -NSIS_COMMON_ARGS = "/DVERSION=$(NMAP_VERSION)" "/DNUM_VERSION=$(NMAP_NUM_VERSION)" "/DNPCAP_VERSION=$(NPCAP_VERSION)" '/DSIGNTOOL_CMD="$(SIGNTOOL)" $(SIGNTOOL_ARGS)' +NSIS_COMMON_ARGS = "/DVERSION=$(NMAP_VERSION)" "/DNUM_VERSION=$(NMAP_NUM_VERSION)" "/DNPCAP_VERSION=$(NPCAP_VERSION)" bundle-nsis: sign-files - "$(MAKENSIS)" $(NSIS_COMMON_ARGS) "/DNMAP_NAME=$(NMAP_NAME)" nmap-$(NMAP_VERSION)/Nmap.nsi - "$(MAKENSIS)" $(NSIS_COMMON_ARGS) "/DNMAP_NAME=$(NMAP_OEM_NAME)" "/DNMAP_OEM=1" nmap-$(NMAP_VERSION)/Nmap.nsi + rm -f nmap-$(NMAP_VERSION)*/tempinstaller.exe nmap-$(NMAP_VERSION)*/Uninstall.exe + # Make the uninstallers + "$(MAKENSIS)" /DINNER $(NSIS_COMMON_ARGS) "/DNMAP_NAME=$(NMAP_NAME)" nsis/Nmap.nsi + nmap-$(NMAP_VERSION)/tempinstaller.exe || test $$? -eq 2 + test -f nmap-$(NMAP_VERSION)/Uninstall.exe + "$(MAKENSIS)" /DINNER $(NSIS_COMMON_ARGS) "/DNMAP_NAME=$(NMAP_OEM_NAME)" "/DNMAP_OEM=1" nsis/Nmap.nsi + nmap-$(NMAP_VERSION)-oem/tempinstaller.exe || test $$? -eq 2 + test -f nmap-$(NMAP_VERSION)-oem/Uninstall.exe + # Sign uninstallers + "$(SIGNTOOL)" $(SIGNTOOL_ARGS) nmap-$(NMAP_VERSION)/Uninstall.exe nmap-$(NMAP_VERSION)-oem/Uninstall.exe + # Now build the installers + "$(MAKENSIS)" $(NSIS_COMMON_ARGS) "/DNMAP_NAME=$(NMAP_NAME)" nsis/Nmap.nsi + "$(MAKENSIS)" $(NSIS_COMMON_ARGS) "/DNMAP_NAME=$(NMAP_OEM_NAME)" "/DNMAP_OEM=1" nsis/Nmap.nsi "$(SIGNTOOL)" $(SIGNTOOL_ARGS) nmap-$(NMAP_VERSION)-setup.exe nmap-$(NMAP_VERSION)-oem-setup.exe bundle-zip: bundle-zip-public bundle-zip-oem @@ -107,7 +117,6 @@ bundle-zip-main: sign-files nmap-$(NMAP_VERSION)${OEM_SUFFIX}/py2exe/\* \ nmap-$(NMAP_VERSION)${OEM_SUFFIX}/COPYING_HIGWIDGETS \ nmap-$(NMAP_VERSION)${OEM_SUFFIX}/w9xpopen.exe \ - nmap-$(NMAP_VERSION)${OEM_SUFFIX}/vcredist2008_x86.exe \ nmap-$(NMAP_VERSION)${OEM_SUFFIX}/ndiff.exe \ nmap-$(NMAP_VERSION)${OEM_SUFFIX}/Uninstall.exe \ nmap-$(NMAP_VERSION)${OEM_SUFFIX}/icon1.ico \ diff --git a/mswin32/nsis/Nmap.nsi b/mswin32/nsis/Nmap.nsi index f384f4654..dbc481e46 100644 --- a/mswin32/nsis/Nmap.nsi +++ b/mswin32/nsis/Nmap.nsi @@ -27,7 +27,7 @@ !define STAGE_DIR ..\nmap-${VERSION} !ifdef NMAP_OEM -!include "..\..\nmap-build\nmap-oem.nsh" +!include "..\..\..\nmap-build\nmap-oem.nsh" !define STAGE_DIR_OEM ${STAGE_DIR}-oem !else !define STAGE_DIR_OEM ${STAGE_DIR} @@ -45,39 +45,19 @@ ;General ;Name and file Name "${NMAP_NAME}" - -;-------------------------------- -; Sign the uninstaller -; http://nsis.sourceforge.net/Signing_an_Uninstaller + Unicode true !ifdef INNER + # Write an uninstaller only !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES !echo "Inner invocation" ; just to see what's going on - OutFile "$%TEMP%\tempinstaller.exe" ; not really important where this is + OutFile "${STAGE_DIR_OEM}\tempinstaller.exe" ; Ensure we don't confuse these SetCompress off ; for speed RequestExecutionLevel user !else !echo "Outer invocation" - ; Call makensis again, defining INNER. This writes an installer for us which, when - ; it is invoked, will just write the uninstaller to some location, and then exit. - ; Be sure to substitute the name of this script here. - - !system `"${NSISDIR}\makensis.exe" /DINNER Nmap.nsi` = 0 - - ; So now run that installer we just created as %TEMP%\tempinstaller.exe. Since it - ; calls quit the return value isn't zero. - - !system "$\"$%TEMP%\tempinstaller.exe$\"" = 2 - - ; That will have written an uninstaller binary for us. Now we sign it with your - ; favourite code signing tool. - - ;!system "icacls.exe $\"$%TEMP%\Uninstall.exe$\" /grant $\"$%USER%$\":M" - !system `copy /b "$%TEMP%\Uninstall.exe" "${STAGE_DIR_OEM}\Uninstall.exe"` - !system `${SIGNTOOL_CMD} "${STAGE_DIR_OEM}\Uninstall.exe"` = 0 - ; Good. Now we can carry on writing the real installer. OutFile ${STAGE_DIR_OEM}-setup.exe @@ -132,7 +112,6 @@ !ifndef NMAP_OEM Var zenmapset -Var vcredist2008set !endif Var addremoveset Var vcredistset @@ -308,7 +287,7 @@ Section "Zenmap (GUI Frontend)" SecZenmap File /r ${STAGE_DIR}\share File /r ${STAGE_DIR}\py2exe StrCpy $zenmapset "true" - Call vcredist2008installer + Call vcredistinstaller Call create_uninstaller SectionEnd @@ -319,7 +298,7 @@ Section "Ndiff (Scan comparison tool)" SecNdiff File ${STAGE_DIR}\NDIFF_README File ${STAGE_DIR}\python27.dll File /r ${STAGE_DIR}\py2exe - Call vcredist2008installer + Call vcredistinstaller Call create_uninstaller SectionEnd !endif @@ -341,13 +320,19 @@ Section "Nping (Packet generator)" SecNping Call create_uninstaller SectionEnd -!macro VCRuntimeInstalled _a _b _t _f +# Custom LogicLib test macro +!macro _VCRedistInstalled _a _b _t _f SetRegView 32 ReadRegStr $0 HKLM "SOFTWARE\Microsoft\VisualStudio\${VCREDISTVER}\VC\Runtimes\${NMAP_ARCH}" "Installed" StrCmp $0 "1" `${_t}` `${_f}` !macroend +# add dummy parameters for our test +!define VCRedistInstalled `"" VCRedistInstalled ""` + Function vcredistinstaller - StrCmp $vcredistset "" 0 vcredist_done + ${If} $vcredistset != "" + Return + ${EndIf} StrCpy $vcredistset "true" ;Check if VC++ runtimes are already installed. ;This version creates a registry key that makes it easy to check whether a version (not necessarily the @@ -371,42 +356,6 @@ Function vcredistinstaller ${EndIf} FunctionEnd -!ifndef NMAP_OEM -Function vcredist2008installer - StrCmp $vcredist2008set "" 0 vcredist2008_done - StrCpy $vcredist2008set "true" - ;Check if VC++ 2008 runtimes are already installed. - ;NOTE Both the UID in the registry key and the DisplayName string must be updated here (and below) - ;whenever the Redistributable package is upgraded: - ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{9BE518E6-ECC6-35A9-88E4-87755C07200F}" "DisplayName" - StrCmp $0 "Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.6161" vcredist2008_done vcredist2008_check_wow6432node - ;On x64 systems we need to check the Wow6432Node registry key instead - vcredist2008_check_wow6432node: - ReadRegStr $0 HKLM "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{9BE518E6-ECC6-35A9-88E4-87755C07200F}" "DisplayName" - StrCmp $0 "Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.6161" vcredist2008_done vcredist2008_silent_install - ;If VC++ 2008 runtimes are not installed... - vcredist2008_silent_install: - DetailPrint "Installing Microsoft Visual C++ 2008 Redistributable" - SetOutPath $PLUGINSDIR - File ${STAGE_DIR}\vcredist2008_x86.exe - ExecWait '"$PLUGINSDIR\vcredist2008_x86.exe" /q' $0 - ;Check for successful installation of our 2008 version of vcredist_x86.exe... - ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{9BE518E6-ECC6-35A9-88E4-87755C07200F}" "DisplayName" - StrCmp $0 "Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.6161" vcredist2008_success vcredist2008_not_present_check_wow6432node - vcredist2008_not_present_check_wow6432node: - ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{9BE518E6-ECC6-35A9-88E4-87755C07200F}" "DisplayName" - StrCmp $0 "Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.6161" vcredist2008_success vcredist2008_not_present - vcredist2008_not_present: - DetailPrint "Microsoft Visual C++ 2008 Redistributable failed to install" - MessageBox MB_OK "Microsoft Visual C++ 2008 Redistributable Package (x86) failed to install. Please ensure your system meets the minimum requirements before running the installer again." - Goto vcredist2008_done - vcredist2008_success: - Delete "$PLUGINSDIR\vcredist2008_x86.exe" - DetailPrint "Microsoft Visual C++ 2008 Redistributable was successfully installed" - vcredist2008_done: -FunctionEnd -!endif - Function create_uninstaller StrCmp $addremoveset "" 0 skipaddremove ; Register Nmap with add/remove programs @@ -450,7 +399,9 @@ Function .onInit ; the installer. This is better than processing a command line option as it means ; this entire code path is not present in the final (real) installer. - WriteUninstaller "$%TEMP%\Uninstall.exe" + ${GetParent} "$EXEPATH" $0 + MessageBox MB_OK "Writing '$0\Uninstall.exe'" + WriteUninstaller "$0\Uninstall.exe" Quit ; just bail out quickly when running the "inner" installer !endif @@ -491,7 +442,7 @@ FunctionEnd LangString DESC_SecNpcap ${LANG_ENGLISH} "Installs Npcap ${NPCAP_VERSION} (required for most Nmap scans unless it is already installed)" LangString DESC_SecPerfRegistryMods ${LANG_ENGLISH} "Modifies Windows registry values to improve TCP connect scan performance. Recommended." !ifndef NMAP_OEM - LangString DESC_SecZenmap ${LANG_ENGLISH} "Installs Zenmap, the official Nmap graphical user interface, and Visual C++ 2008 runtime components. Recommended." + LangString DESC_SecZenmap ${LANG_ENGLISH} "Installs Zenmap, the official Nmap graphical user interface. Recommended." LangString DESC_SecNdiff ${LANG_ENGLISH} "Installs Ndiff, a tool for comparing Nmap XML files." !endif LangString DESC_SecNcat ${LANG_ENGLISH} "Installs Ncat, Nmap's Netcat replacement."