From f0f053433f0541e3b3eb1572b077e1bc0348b578 Mon Sep 17 00:00:00 2001 From: fyodor Date: Sat, 11 Aug 2007 04:31:34 +0000 Subject: [PATCH] merge soc07 r4959:4963 - Added a script that automatically sets the version on nmap.rc and nmap.nsi --- mswin32/Makefile | 4 +- mswin32/nmap.rc | 9 +- mswin32/nsis/Nmap.nsi | 338 +++++++++++++++++++------------------- mswin32/version-update.sh | 108 ++++++++++++ 4 files changed, 283 insertions(+), 176 deletions(-) create mode 100755 mswin32/version-update.sh diff --git a/mswin32/Makefile b/mswin32/Makefile index 052c9fcbb..5c78d512f 100644 --- a/mswin32/Makefile +++ b/mswin32/Makefile @@ -1,11 +1,13 @@ -MAKENSIS=/c/apps/NSIS/makensis.exe +MAKENSIS="/c/apps/NSIS/makensis.exe" VCEXPRESS="/c/Program Files/Microsoft Visual Studio 8/Common7/IDE/VCExpress.exe" export NMAP_VERSION := $(shell grep '^\#[ \t]*define[ \t]\+NMAP_VERSION' ../nmap.h | sed -e 's/.*"\(.*\)".*/\1/' -e 'q') +export NMAP_NUM_VERSION := $(shell grep '^\#[ \t]*define[ \t]\+NMAP_NUM_VERSION' ../nmap.h | sed -e 's/.*"\(.*\)".*/\1/' -e 'q') LOGLOC=c:nmapbuild.log NSE_FILES = scripts/script.db scripts/*.nse winbuild: # VCExpress.exe is devenv.com with the commercial Visual Studio suite instead of VC++ Express + @./version-update.sh $(NMAP_VERSION) $(NMAP_NUM_VERSION) $(VCEXPRESS) nmap.sln /build release /log $(LOGLOC) $(MAKENSIS) winpcap/winpcap-nmap.nsi rm -rf nmap-$(NMAP_VERSION) diff --git a/mswin32/nmap.rc b/mswin32/nmap.rc index 409ecc7d4..269388800 100644 --- a/mswin32/nmap.rc +++ b/mswin32/nmap.rc @@ -1,4 +1,4 @@ -//Microsoft Developer Studio generated resource script. + //Microsoft Developer Studio generated resource script. // // edited // @@ -12,8 +12,7 @@ // VS_VERSION_INFO VERSIONINFO - FILEVERSION 4,02,0,7 - PRODUCTVERSION 4,00,0,0 +FILEVERSION 4,21,0,5 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x21L @@ -28,16 +27,14 @@ BEGIN BEGIN BLOCK "040904b0" BEGIN - VALUE "Comments", "\0" VALUE "CompanyName", "Insecure.Org\0" VALUE "FileDescription", "Nmap\0" - VALUE "FileVersion", "4.20ALPAHA7\0" + VALUE "FileVersion", "4.21ALPHA5\0" VALUE "InternalName", "Nmap\0" VALUE "LegalCopyright", "Copyright (c) Insecure.Com LLC (fyodor@insecure.org)\0" VALUE "LegalTrademarks", "NMAP\0" VALUE "OriginalFilename", "nmap.exe\0" VALUE "ProductName", "Nmap\0" - VALUE "ProductVersion", "4.X\0" END END BLOCK "VarFileInfo" diff --git a/mswin32/nsis/Nmap.nsi b/mswin32/nsis/Nmap.nsi index 0f48eba19..e027489f4 100644 --- a/mswin32/nsis/Nmap.nsi +++ b/mswin32/nsis/Nmap.nsi @@ -1,169 +1,169 @@ -;Nmap Installer -;Started by Bo Jiang @ 08/26/2005 06:07PM - -;-------------------------------- -;Include Modern UI - - !include "MUI.nsh" - !include "AddToPath.nsh" - -;-------------------------------- -;General - - ;Name and file - Name "Nmap" - OutFile "NmapInstaller.exe" - - ;Default installation folder - InstallDir "$PROGRAMFILES\Nmap" - - ;Get installation folder from registry if available - InstallDirRegKey HKCU "Software\Nmap" "" - - VIProductVersion 4.2.0.7 - VIAddVersionKey /LANG=1033 "FileVersion" "4.20ALPHA7" - VIAddVersionKey /LANG=1033 "ProductName" "Nmap" - VIAddVersionKey /LANG=1033 "CompanyName" "Insecure.org" - VIAddVersionKey /LANG=1033 "InternalName" "NmapInstaller.exe" - VIAddVersionKey /LANG=1033 "LegalCopyright" "Copyright (c) Insecure.Com LLC (fyodor@insecure.org)" - VIAddVersionKey /LANG=1033 "LegalTrademark" "NMAP" - VIAddVersionKey /LANG=1033 "FileDescription" "Nmap installer" - -;-------------------------------- -;Interface Settings - - !define MUI_ABORTWARNING - -;-------------------------------- -;Pages - -; !insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt" - !insertmacro MUI_PAGE_LICENSE "..\..\COPYING" - !insertmacro MUI_PAGE_COMPONENTS - !insertmacro MUI_PAGE_DIRECTORY - !insertmacro MUI_PAGE_INSTFILES - - !insertmacro MUI_UNPAGE_CONFIRM - !insertmacro MUI_UNPAGE_INSTFILES - -;-------------------------------- -;Languages - - !insertmacro MUI_LANGUAGE "English" - -;-------------------------------- -;Installer Sections - -Section "Nmap Core Files" SecCore - - SetOutPath "$INSTDIR" - RMDir /r $PROGRAMFILES\Nmap - - SetOverwrite on - File ..\..\CHANGELOG - File ..\..\COPYING - File ..\..\nmap-mac-prefixes - File ..\..\nmap-os-fingerprints - File ..\..\nmap-os-db - File ..\..\nmap-protocols - File ..\..\nmap-rpc - File ..\..\nmap-service-probes - File ..\..\nmap-services - File ..\Release\nmap.exe - File ..\..\docs\nmap.xsl - File ..\nmap_performance.reg - File ..\..\README-WIN32 - File /r ..\..\scripts - File ..\icon1.ico - - ;Store installation folder - WriteRegStr HKCU "Software\Nmap" "" $INSTDIR - - ;Create uninstaller - WriteUninstaller "$INSTDIR\Uninstall.exe" - - ; Register Nmap with add/remove programs - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Nmap" "DisplayName" "Nmap 4.20ALPHA7" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Nmap" "UninstallString" '"$INSTDIR\uninstall.exe"' - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Nmap" "DisplayIcon" '"$INSTDIR\icon1.ico"' - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Nmap" "NoModify" 1 - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Nmap" "NoRepair" 1 -SectionEnd - -Section "Register Nmap Path" SecRegisterPath - PUSH $INSTDIR - Call AddToPath -SectionEnd - -Section "WinPcap 4.0" SecWinPcap - File ..\winpcap\winpcap-nmap-4.0.exe - Exec '"$INSTDIR\winpcap-nmap-4.0.exe"' - Delete "$INSTDIR\winpcap-nmap-4.0.exe" -SectionEnd - -Section "Network Performance Improvements (Registry Changes)" SecPerfRegistryMods - File ..\nmap_performance.reg - Exec 'regedt32 /S "$INSTDIR\nmap_performance.reg"' -SectionEnd - -;-------------------------------- -;Descriptions - - ;Component strings - LangString DESC_SecCore ${LANG_ENGLISH} "Installs Nmap executables and script files" - LangString DESC_SecRegisterPath ${LANG_ENGLISH} "Registers Nmap path to System path so you can execute it from any directory" - LangString DESC_SecWinPcap ${LANG_ENGLISH} "Installs WinPcap 4.0 (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." - - ;Assign language strings to sections - !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN - !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} $(DESC_SecCore) - !insertmacro MUI_DESCRIPTION_TEXT ${SecWinPcap} $(DESC_SecWinPcap) - !insertmacro MUI_DESCRIPTION_TEXT ${SecRegisterPath} $(DESC_SecRegisterPath) - !insertmacro MUI_DESCRIPTION_TEXT ${SecPerfRegistryMods} $(DESC_SecPerfRegistryMods) - !insertmacro MUI_FUNCTION_DESCRIPTION_END -;-------------------------------- -;Uninstaller Section - -Section "Uninstall" - - SetDetailsPrint textonly - DetailPrint "Uninstalling Files..." - SetDetailsPrint listonly - - IfFileExists $INSTDIR\nmap.exe nmap_installed - MessageBox MB_YESNO "It does not appear that Nmap is installed in the directory '$INSTDIR'.$\r$\nContinue anyway (not recommended)?" IDYES nmap_installed - Abort "Uninstall aborted by user" - - nmap_installed: - Delete "$INSTDIR\CHANGELOG" - Delete "$INSTDIR\COPYING" - Delete "$INSTDIR\nmap-mac-prefixes" - Delete "$INSTDIR\nmap-os-fingerprints" - Delete "$INSTDIR\nmap-os-db" - Delete "$INSTDIR\nmap-protocols" - Delete "$INSTDIR\nmap-rpc" - Delete "$INSTDIR\nmap-service-probes" - Delete "$INSTDIR\nmap-services" - Delete "$INSTDIR\nmap.exe" - Delete "$INSTDIR\nmap.xsl" - Delete "$INSTDIR\nmap_performance.reg" - Delete "$INSTDIR\README-WIN32" - Delete "$INSTDIR\icon1.ico" - - Delete "$INSTDIR\Uninstall.exe" - - RMDir /r $PROGRAMFILES\Nmap - - SetDetailsPrint textonly - DetailPrint "Deleting Registry Keys..." - SetDetailsPrint listonly - DeleteRegKey /ifempty HKCU "Software\Nmap" - DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Nmap" - SetDetailsPrint textonly - DetailPrint "Unregistering Nmap Path..." - Push $INSTDIR - Call un.RemoveFromPath - - SetDetailsPrint both -SectionEnd \ No newline at end of file +;Nmap Installer +;Started by Bo Jiang @ 08/26/2005 06:07PM + +;-------------------------------- +;Include Modern UI + + !include "MUI.nsh" + !include "AddToPath.nsh" + +;-------------------------------- +;General + + ;Name and file + Name "Nmap" + OutFile "NmapInstaller.exe" + + ;Default installation folder + InstallDir "$PROGRAMFILES\Nmap" + + ;Get installation folder from registry if available + InstallDirRegKey HKCU "Software\Nmap" "" + + VIProductVersion "4.21.0.5" + VIAddVersionKey /LANG=1033 "FileVersion" "4.21ALPHA5" + VIAddVersionKey /LANG=1033 "ProductName" "Nmap" + VIAddVersionKey /LANG=1033 "CompanyName" "Insecure.org" + VIAddVersionKey /LANG=1033 "InternalName" "NmapInstaller.exe" + VIAddVersionKey /LANG=1033 "LegalCopyright" "Copyright (c) Insecure.Com LLC (fyodor@insecure.org)" + VIAddVersionKey /LANG=1033 "LegalTrademark" "NMAP" + VIAddVersionKey /LANG=1033 "FileDescription" "Nmap installer" + +;-------------------------------- +;Interface Settings + + !define MUI_ABORTWARNING + +;-------------------------------- +;Pages + +; !insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt" + !insertmacro MUI_PAGE_LICENSE "..\..\COPYING" + !insertmacro MUI_PAGE_COMPONENTS + !insertmacro MUI_PAGE_DIRECTORY + !insertmacro MUI_PAGE_INSTFILES + + !insertmacro MUI_UNPAGE_CONFIRM + !insertmacro MUI_UNPAGE_INSTFILES + +;-------------------------------- +;Languages + + !insertmacro MUI_LANGUAGE "English" + +;-------------------------------- +;Installer Sections + +Section "Nmap Core Files" SecCore + + SetOutPath "$INSTDIR" + RMDir /r $PROGRAMFILES\Nmap + + SetOverwrite on + File ..\..\CHANGELOG + File ..\..\COPYING + File ..\..\nmap-mac-prefixes + File ..\..\nmap-os-fingerprints + File ..\..\nmap-os-db + File ..\..\nmap-protocols + File ..\..\nmap-rpc + File ..\..\nmap-service-probes + File ..\..\nmap-services + File ..\Release\nmap.exe + File ..\..\docs\nmap.xsl + File ..\nmap_performance.reg + File ..\..\README-WIN32 + File /r ..\..\scripts + File ..\icon1.ico + + ;Store installation folder + WriteRegStr HKCU "Software\Nmap" "" $INSTDIR + + ;Create uninstaller + WriteUninstaller "$INSTDIR\Uninstall.exe" + + ; Register Nmap with add/remove programs + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Nmap" "DisplayName" "Nmap 4.20ALPHA7" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Nmap" "UninstallString" '"$INSTDIR\uninstall.exe"' + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Nmap" "DisplayIcon" '"$INSTDIR\icon1.ico"' + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Nmap" "NoModify" 1 + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Nmap" "NoRepair" 1 +SectionEnd + +Section "Register Nmap Path" SecRegisterPath + PUSH $INSTDIR + Call AddToPath +SectionEnd + +Section "WinPcap 4.0" SecWinPcap + File ..\winpcap\winpcap-nmap-4.0.exe + Exec '"$INSTDIR\winpcap-nmap-4.0.exe"' + Delete "$INSTDIR\winpcap-nmap-4.0.exe" +SectionEnd + +Section "Network Performance Improvements (Registry Changes)" SecPerfRegistryMods + File ..\nmap_performance.reg + Exec 'regedt32 /S "$INSTDIR\nmap_performance.reg"' +SectionEnd + +;-------------------------------- +;Descriptions + + ;Component strings + LangString DESC_SecCore ${LANG_ENGLISH} "Installs Nmap executables and script files" + LangString DESC_SecRegisterPath ${LANG_ENGLISH} "Registers Nmap path to System path so you can execute it from any directory" + LangString DESC_SecWinPcap ${LANG_ENGLISH} "Installs WinPcap 4.0 (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." + + ;Assign language strings to sections + !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN + !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} $(DESC_SecCore) + !insertmacro MUI_DESCRIPTION_TEXT ${SecWinPcap} $(DESC_SecWinPcap) + !insertmacro MUI_DESCRIPTION_TEXT ${SecRegisterPath} $(DESC_SecRegisterPath) + !insertmacro MUI_DESCRIPTION_TEXT ${SecPerfRegistryMods} $(DESC_SecPerfRegistryMods) + !insertmacro MUI_FUNCTION_DESCRIPTION_END +;-------------------------------- +;Uninstaller Section + +Section "Uninstall" + + SetDetailsPrint textonly + DetailPrint "Uninstalling Files..." + SetDetailsPrint listonly + + IfFileExists $INSTDIR\nmap.exe nmap_installed + MessageBox MB_YESNO "It does not appear that Nmap is installed in the directory '$INSTDIR'.$\r$\nContinue anyway (not recommended)?" IDYES nmap_installed + Abort "Uninstall aborted by user" + + nmap_installed: + Delete "$INSTDIR\CHANGELOG" + Delete "$INSTDIR\COPYING" + Delete "$INSTDIR\nmap-mac-prefixes" + Delete "$INSTDIR\nmap-os-fingerprints" + Delete "$INSTDIR\nmap-os-db" + Delete "$INSTDIR\nmap-protocols" + Delete "$INSTDIR\nmap-rpc" + Delete "$INSTDIR\nmap-service-probes" + Delete "$INSTDIR\nmap-services" + Delete "$INSTDIR\nmap.exe" + Delete "$INSTDIR\nmap.xsl" + Delete "$INSTDIR\nmap_performance.reg" + Delete "$INSTDIR\README-WIN32" + Delete "$INSTDIR\icon1.ico" + + Delete "$INSTDIR\Uninstall.exe" + + RMDir /r $PROGRAMFILES\Nmap + + SetDetailsPrint textonly + DetailPrint "Deleting Registry Keys..." + SetDetailsPrint listonly + DeleteRegKey /ifempty HKCU "Software\Nmap" + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Nmap" + SetDetailsPrint textonly + DetailPrint "Unregistering Nmap Path..." + Push $INSTDIR + Call un.RemoveFromPath + + SetDetailsPrint both +SectionEnd diff --git a/mswin32/version-update.sh b/mswin32/version-update.sh new file mode 100755 index 000000000..8cdb36f4f --- /dev/null +++ b/mswin32/version-update.sh @@ -0,0 +1,108 @@ +#!/bin/sh + +#-------------------------------------------# +# Nmap windows build version update script # +# # +# From the version in nmap.h this script # +# updates both nmap.rc and nmap.nsi which # +# in turn updates nmap.exe and # +# nmapinstall.exe # +# # +#-------------------------------------------# + +# Eddie Bell 2007 + +NMAP_RC="./nmap.rc" +NMAP_NSIS="./nsis/Nmap.nsi" +NMAP_TMP="./.nmap-version.tmp" + +# make sure all the files we need +# are available + +if [ -z $1 ] || [ -z $2 ] + then + echo "$0 <#-version>" + exit 1 +fi + +NMAP_VERSION=$1 +NMAP_NUM_VERSION=$2 + +if [ ! -f $NMAP_RC ] + then + echo "Cannot access $NMAP_RC" + exit 1 +fi + +if [ ! -f $NMAP_NSIS ] + then + echo "Cannot access $NMAP_NSIS" + exit 1 +fi + +: > $NMAP_TMP + +# make the substitutions for nmap.rc +# Note we have to do it this strange way using head and tail because +# bash's 'read' automatically removes whitespace which messes up the +# files indentation + +i=1 +max=`wc -l $NMAP_RC | awk '{print $1}'` +echo "$0: updating $NMAP_RC ($max)" + +while : + do + line=`head -n $i $NMAP_RC | tail -n 1` + i=`expr $i + 1` + + if [ -n "`echo $line | grep 'VALUE "FileVersion"'`" ] + then + echo " VALUE \"FileVersion\", \"$NMAP_VERSION\\0\"" >> $NMAP_TMP + elif [ -n "`echo $line | grep 'FILEVERSION'`" ] + then + echo "FILEVERSION `echo $NMAP_NUM_VERSION | tr '.' ','`" >> $NMAP_TMP + else + echo "$line" >> $NMAP_TMP + fi + + if [ $i -gt $max ] + then + break + fi +done + +mv $NMAP_TMP $NMAP_RC +touch $NMAP_TMP + + +# make the substitutions for Nmap.nsi + +i=1 +max=`wc -l $NMAP_NSIS | awk '{print $1}'` +echo "$0: updating $NMAP_NSIS ($max)" + +while : + do + line=`head -n $i $NMAP_NSIS | tail -n 1` + i=`expr $i + 1` + + if [ -n "`echo $line | grep 'VIProductVersion'`" ] + then + echo " VIProductVersion \"$NMAP_NUM_VERSION\"" >> $NMAP_TMP + elif [ -n "`echo $line | grep 'VIAddVersionKey /LANG=1033 "FileVersion"'`" ] + then + echo " VIAddVersionKey /LANG=1033 \"FileVersion\" \"$NMAP_VERSION\"" >> $NMAP_TMP + else + echo "$line" >> $NMAP_TMP + fi + + if [ $i -gt $max ] + then + break + fi +done + +mv $NMAP_TMP $NMAP_NSIS +echo "$0: set nmap.rc and nmap.nsi to $NMAP_VERSION ($NMAP_NUM_VERSION)" +exit 0