metasploit-framework/external/installer-win32/installer.nsi

306 lines
9.2 KiB
Plaintext
Raw Normal View History

; Script generated by the HM NIS Edit Script Wizard.
; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "Metasploit Framework"
!define PRODUCT_VERSION "3.5-beta"
!define PRODUCT_PUBLISHER "Rapid7 LLC"
!define PRODUCT_WEB_SITE "http://www.metasploit.com/framework/support/"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!define PRODUCT_STARTMENU_REGVAL "NSIS:StartMenuDir"
!define NMAP_VERSION "5.30BETA1"
!define PG_VERSION "8.4.5-1"
VIProductVersion "3.5.0.0"
VIAddVersionKey /LANG=1033 "ProductName" "Metasploit Framework"
VIAddVersionKey /LANG=1033 "Comments" "This is the official installer for Metasploit 3"
VIAddVersionKey /LANG=1033 "CompanyName" "Rapid7 LLC"
VIAddVersionKey /LANG=1033 "LegalTrademarks" "Metasploit is a registered trademark of Rapid7 LLC"
VIAddVersionKey /LANG=1033 "LegalCopyright" " Copyright (C) 2003-2010 Rapid7 LLC"
VIAddVersionKey /LANG=1033 "FileDescription" "Metasploit 3 Windows Installer"
VIAddVersionKey /LANG=1033 "FileVersion" "3.5.0.0"
SetCompressor /SOLID lzma
Function LaunchMetasploit
Exec '"$INSTDIR\msfconsole.bat"'
FunctionEnd
; Stolen from http://nsis.sourceforge.net/More_advanced_replace_text_in_file
Function AdvReplaceInFile
Exch $0 ;file to replace in
Exch
Exch $1 ;number to replace after
Exch
Exch 2
Exch $2 ;replace and onwards
Exch 2
Exch 3
Exch $3 ;replace with
Exch 3
Exch 4
Exch $4 ;to replace
Exch 4
Push $5 ;minus count
Push $6 ;universal
Push $7 ;end string
Push $8 ;left string
Push $9 ;right string
Push $R0 ;file1
Push $R1 ;file2
Push $R2 ;read
Push $R3 ;universal
Push $R4 ;count (onwards)
Push $R5 ;count (after)
Push $R6 ;temp file name
GetTempFileName $R6
FileOpen $R1 $0 r ;file to search in
FileOpen $R0 $R6 w ;temp file
StrLen $R3 $4
StrCpy $R4 -1
StrCpy $R5 -1
loop_read:
ClearErrors
FileRead $R1 $R2 ;read line
IfErrors exit
StrCpy $5 0
StrCpy $7 $R2
loop_filter:
IntOp $5 $5 - 1
StrCpy $6 $7 $R3 $5 ;search
StrCmp $6 "" file_write1
StrCmp $6 $4 0 loop_filter
StrCpy $8 $7 $5 ;left part
IntOp $6 $5 + $R3
IntCmp $6 0 is0 not0
is0:
StrCpy $9 ""
Goto done
not0:
StrCpy $9 $7 "" $6 ;right part
done:
StrCpy $7 $8$3$9 ;re-join
IntOp $R4 $R4 + 1
StrCmp $2 all loop_filter
StrCmp $R4 $2 0 file_write2
IntOp $R4 $R4 - 1
IntOp $R5 $R5 + 1
StrCmp $1 all loop_filter
StrCmp $R5 $1 0 file_write1
IntOp $R5 $R5 - 1
Goto file_write2
file_write1:
FileWrite $R0 $7 ;write modified line
Goto loop_read
file_write2:
FileWrite $R0 $R2 ;write unmodified line
Goto loop_read
exit:
FileClose $R0
FileClose $R1
SetDetailsPrint none
Delete $0
Rename $R6 $0
Delete $R6
SetDetailsPrint both
Pop $R6
Pop $R5
Pop $R4
Pop $R3
Pop $R2
Pop $R1
Pop $R0
Pop $9
Pop $8
Pop $7
Pop $6
Pop $5
Pop $0
Pop $1
Pop $2
Pop $3
Pop $4
FunctionEnd
!include "MUI2.nsh"
; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "icons\metasploit.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_TEXT "Launch the Metasploit Framework"
!define MUI_FINISHPAGE_RUN_FUNCTION "LaunchMetasploit"
; Welcome page
!insertmacro MUI_PAGE_WELCOME
; License page
!insertmacro MUI_PAGE_LICENSE "msf3\README"
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Start menu page
var ICONS_GROUP
!define MUI_STARTMENUPAGE_NODISABLE
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "Metasploit 3"
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_STARTMENU_REGVAL}"
!insertmacro MUI_PAGE_STARTMENU Application $ICONS_GROUP
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!insertmacro MUI_PAGE_FINISH
; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES
; Language files
!insertmacro MUI_LANGUAGE "English"
; MUI end ------
RequestExecutionLevel "admin"
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "framework-${PRODUCT_VERSION}.exe"
InstallDir "$PROGRAMFILES\Metasploit\Framework3"
ShowInstDetails show
ShowUnInstDetails show
Section "MainSection" SecCore
SetOutPath $INSTDIR
; don't include the installer directories to avoid infinite recursion
; when building
;File /r /x "installer-*" /x "external" "*"
File /r /x "installer-*" "*"
SectionEnd
Section "Nmap" SecNmap
MessageBox MB_YESNO \
"Would you like to install the Nmap Security Scanner v${NMAP_VERSION}? Nmap is a free and open source \
utility for network exploration and security auditing. The Metasploit \
Framework is able to work with Nmap to provide exploit automation features. \
Nmap is copyright (C) 1996-2010 Insecure.Com LLC. Nmap is a registered \
trademark of Insecure.Com LLC. Nmap is included in this installer with \
the permission of the Nmap Project. Nmap is provided under the GNU Public License, \
not the BSD license which covers most of the Metasploit Framework" /SD IDYES IDNO endNmap
ExecWait '"$INSTDIR\other_installers\nmap-${NMAP_VERSION}-setup.exe"'
endNmap:
Delete "$INSTDIR\other_installers\nmap-${NMAP_VERSION}-setup.exe"
; Regardless of the user's choice about installing nmap, run the nmap
; registry tweaks so we can take advantage of the added socket performance
Exec 'regedt32 /S "$INSTDIR\other_installers\nmap_performance.reg"'
Delete "$INSTDIR\other_installers\nmap_performance.reg"
SectionEnd
Section "PG" SecPG
MessageBox MB_YESNO \
"Would you like to install PostgreSQL? Doing so will let you take \
advantage of Metasploit's database features. \
Either way, support for connecting to a PostgreSQL database will be \
included." /SD IDYES IDNO endPGSQL
ExecWait '"$INSTDIR\other_installers\postgresql-${PG_VERSION}-windows.exe"'
endPGSQL:
Delete "$INSTDIR\other_installers\postgresql-${PG_VERSION}-windows.exe"
SectionEnd
Section "FixupConsoleConfig" SecFixupConsoleConfig
Push "REPLACEME" ; text to be replaced
Push "$INSTDIR" ; replacement
Push all ; replace all occurrences
Push all ; replace all occurrences
Push "$INSTDIR\bin\console.xml"
Call AdvReplaceInFile
SectionEnd
Section "Cleanup" SecCleanup
RMDir /r "$INSTDIR\other_installers"
SectionEnd
Section -AdditionalIcons
SetShellVarContext all
WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
CreateDirectory "$SMPROGRAMS\$ICONS_GROUP"
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Metasploit Console.lnk" "$INSTDIR\msfconsole.bat" '' "$INSTDIR\icons\metasploit.ico" 0
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Metasploit Update.lnk" "$INSTDIR\msfupdate.bat" '' "$INSTDIR\icons\metasploit.ico" 0
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Metasm Shell.lnk" "$INSTDIR\metasm.bat" ''
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\RUBY Shell.lnk" "$INSTDIR\msfirb.bat" '' "$INSTDIR\icons\ruby.ico" 0
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Uninstall.lnk" "$INSTDIR\uninst.exe"
CreateDirectory "$SMPROGRAMS\$ICONS_GROUP\Support"
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Support\Metasploit Online.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
CreateDirectory "$SMPROGRAMS\$ICONS_GROUP\Tools"
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Tools\VNCViewer.lnk" "$INSTDIR\bin\vncviewer.exe"
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Tools\WinVI.lnk" "$INSTDIR\bin\winvi32.exe"
CreateShortCut "$DESKTOP\Metasploit Console.lnk" "$INSTDIR\msfconsole.bat" '' "$INSTDIR\icons\metasploit.ico" 0
CreateShortCut "$DESKTOP\Metasploit Update.lnk" "$INSTDIR\msfupdate.bat" '' "$INSTDIR\icons\metasploit.ico" 0
SectionEnd
Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "${PRODUCT_STARTMENU_REGVAL}" "$ICONS_GROUP"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd
Function un.onUninstSuccess
;HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
FunctionEnd
Function un.onInit
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
Abort
FunctionEnd
Section Uninstall
SetShellVarContext all
ReadRegStr $ICONS_GROUP ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "${PRODUCT_STARTMENU_REGVAL}"
RMDir /r "$INSTDIR"
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
RMDir /r "$SMPROGRAMS\$ICONS_GROUP"
Delete "$DESKTOP\Metasploit Console.lnk"
Delete "$DESKTOP\Metasploit Update.lnk"
System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
SetAutoClose true
SectionEnd