1; 2; ettercap -- NSIS script for the windows installer 3; 4; Copyright (C) ALoR 5; 6; This program is free software; you can redistribute it and/or modify 7; it under the terms of the GNU General Public License as published by 8; the Free Software Foundation; either version 2 of the License, or 9; (at your option) any later version. 10; 11; This program is distributed in the hope that it will be useful, 12; but WITHOUT ANY WARRANTY; without even the implied warranty of 13; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14; GNU General Public License for more details. 15; 16; You should have received a copy of the GNU General Public License 17; along with this program; if not, write to the Free Software 18; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19; 20; 21; NOTE: this .NSI script is designed for NSIS v2.0+ 22 23;-------------------------------- 24;Version Information 25 26!define VER_MAJOR 0 27!define VER_MINOR 7 28!define VER_REVISION 3 29 30!define VER_DISPLAY "0.7.3" 31 32;-------------------------------- 33;Include Modern UI 34 35 !include "MUI.nsh" 36 37;-------------------------------- 38;General 39 40 ;Name and file 41 Name "Ettercap NG" 42 Caption "Ettercap ${VER_DISPLAY} Setup" 43 OutFile "ettercap-NG-${VER_DISPLAY}-win32.exe" 44 45 ;Default installation folder 46 InstallDir "$PROGRAMFILES\EttercapNG" 47 48 ;Get installation folder from registry if available 49 InstallDirRegKey HKCU "Software\ettercap_ng" "" 50 51;-------------------------------- 52;Compiler settings 53 54 SetCompressor lzma 55 SetDatablockOptimize on 56 CRCCheck on 57 ShowInstDetails show ; (can be show to have them shown, or nevershow to disable) 58 ShowUnInstDetails show ; (can be show to have them shown, or nevershow to disable) 59 SetDateSave on ; (can be on to have files restored to their orginal date) 60 61;-------------------------------- 62;Variables 63 64 Var MUI_TEMP 65 Var STARTMENU_FOLDER 66 Var CHECKFAILED 67 Var DOCUMENTATION 68 ; window handlers 69 Var NEXTBUTTON 70 Var BACKBUTTON 71 Var CANCELBUTTON 72 73;-------------------------------- 74;Interface Configuration 75 76 !define MUI_ICON "eNG.ico" 77 !define MUI_HEADERIMAGE 78 !define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\win.bmp" 79 !define MUI_CUSTOMFUNCTION_ABORT UserAbort 80 !define MUI_ABORTWARNING_TEXT "Do you want to exit the Ettercap NG setup ?" 81 !define MUI_COMPONENTSPAGE_SMALLDESC 82 83;-------------------------------- 84;Reserve Files 85 86 ;These files should be inserted before other files in the data block 87 88 ReserveFile "eNG-radiobuttons.ini" 89 ReserveFile "eNG-message.ini" 90 !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS 91 92;-------------------------------- 93;Pages 94 95 ; welcome 96 !define MUI_WELCOMEPAGE_TITLE "Welcome to the Ettercap NG ${VER_DISPLAY} Setup Wizard" 97 !define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of Ettercap NG ${VER_DISPLAY}, the next generation of the popular ettercap sniffer.\r\n\r\nEttercap NG includes a new Modern GTK User Interface, plugin support, support for multiple MITM attack at the same time and a more structured core.\r\n\r\n" 98 !insertmacro MUI_PAGE_WELCOME 99 100 ; check for the correct windows version 101 Page custom CheckWindowsVersion 102 103 ; license 104 !insertmacro MUI_PAGE_LICENSE "LICENSE.txt" 105 106 ; check for the presence of winpcap 107 Page custom CheckWinpcap 108 109 ; already installed, what to do ? 110 Page custom PageReinstall PageLeaveReinstall 111 112 ; components 113 !insertmacro MUI_PAGE_COMPONENTS 114 115 ; directory 116 !insertmacro MUI_PAGE_DIRECTORY 117 118 ; start menu 119 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU" 120 !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\ettercap_ng" 121 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" 122 !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER 123 124 ; install 125 !insertmacro MUI_PAGE_INSTFILES 126 127 ; finish 128 !define MUI_FINISHPAGE_NOAUTOCLOSE 129 !define MUI_FINISHPAGE_LINK "Visit the Ettercap website for the latest news, FAQs and support" 130 !define MUI_FINISHPAGE_LINK_LOCATION "http://ettercap.sf.net/" 131 132 !define MUI_FINISHPAGE_NOREBOOTSUPPORT 133 !insertmacro MUI_PAGE_FINISH 134 135 ; uninstall 136 !insertmacro MUI_UNPAGE_CONFIRM 137 !insertmacro MUI_UNPAGE_INSTFILES 138 139;-------------------------------- 140;Languages 141 142 !insertmacro MUI_LANGUAGE "English" 143 144 145 146;-------------------------------- 147;Installer Sections 148 149Section "Ettercap NG core" SecCore 150 151 ; this is required, make it unchangeable by the user 152 SectionIn RO 153 154 SetOverwrite on 155 156 SetOutPath "$INSTDIR" 157 File ..\..\ettercap.exe 158 File ..\..\*.dll 159 160 SetOutPath "$INSTDIR\share" 161 File ..\..\share\* 162 163 SetOutPath "$INSTDIR\etc\pango" 164 File ..\..\etc\pango\* 165 166 SetOutPath "$INSTDIR\etc\gtk-2.0" 167 File ..\..\etc\gtk-2.0\* 168 169 SetOutPath "$INSTDIR\etc\fonts" 170 File ..\..\etc\fonts\* 171 172 SetOutPath "$INSTDIR\lib\pango\1.4.0\modules" 173 File ..\..\lib\pango\1.4.0\modules\* 174 175 SetOutPath "$INSTDIR\\lib\gtk-2.0\2.4.0\engines" 176 File ..\..\lib\gtk-2.0\2.4.0\engines\* 177 178 SetOutPath "$INSTDIR\\lib\gtk-2.0\2.4.0\loaders" 179 File ..\..\lib\gtk-2.0\2.4.0\loaders\* 180 181SectionEnd 182 183Section "Etterlog" SecEtterlog 184 185 SetOutPath "$INSTDIR" 186 187 SetOverwrite on 188 File ..\..\etterlog.exe 189 190SectionEnd 191 192Section "Etterfilter" SecEtterfilter 193 194 SetOutPath "$INSTDIR" 195 196 SetOverwrite on 197 File ..\..\etterfilter.exe 198 199SectionEnd 200 201Section "Plugins" SecPlugins 202 203 SetOutPath "$INSTDIR\lib" 204 205 SetOverwrite on 206 File ..\..\lib\*.dll 207 208 209SectionEnd 210 211Section "Documentation" SecDocs 212 213 SetOutPath "$INSTDIR\doc" 214 215 File ..\..\doc\*.pdf 216 217 IntOp $DOCUMENTATION 0 + 1 ; remember this for further use 218 219SectionEnd 220 221; Hidden section for the uninstaller 222; it needs to be created whichever options the user choose 223Section "-Make the uninstaller" 224 225 SetOutPath "$INSTDIR" 226 227 ;Store installation folder 228 WriteRegStr HKLM "Software\ettercap_ng" "" $INSTDIR 229 WriteRegDword HKLM "Software\ettercap_ng" "VersionMajor" "${VER_MAJOR}" 230 WriteRegDword HKLM "Software\ettercap_ng" "VersionMinor" "${VER_MINOR}" 231 WriteRegDword HKLM "Software\ettercap_ng" "VersionRevision" "${VER_REVISION}" 232 233 ;Create uninstaller 234 WriteUninstaller "$INSTDIR\Uninstall.exe" 235 236 ; make the unisntall appear in the control panel "add/remove programs" 237 WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ettercap_ng" "UninstallString" '"$INSTDIR\uninstall.exe"' 238 WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ettercap_ng" "InstallLocation" "$INSTDIR" 239 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ettercap_ng" "DisplayName" "Ettercap NG ${VER_DISPLAY}" 240 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ettercap_ng" "DisplayIcon" "$INSTDIR\ettercap.exe,0" 241 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ettercap_ng" "DisplayVersion" "${VER_DISPLAY}" 242 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ettercap_ng" "VersionMajor" "${VER_MAJOR}" 243 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ettercap_ng" "VersionMinor" "${VER_MINOR}" 244 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ettercap_ng" "VersionRevision" "${VER_REVISION}" 245 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ettercap_ng" "NoModify" "1" 246 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ettercap_ng" "NoRepair" "1" 247 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ettercap_ng" "URLInfoAbout" "http://ettercap.sourceforge.net" 248 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ettercap_ng" "Publisher" "Ettercap developers" 249 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ettercap_ng" "URLUpdateInfo" "http://ettercap.sf.net/download" 250 251 ;start menu 252 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application 253 254 ;Create shortcuts 255 CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER" 256 CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\ettercap.lnk" "$INSTDIR\ettercap.exe" "-G" 257 258 ; the command propmt to use etterfilter and etterlog 259 ReadRegStr $R1 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows NT\CurrentVersion" "CurrentVersion" 260 StrCpy $9 $R1 1 261 StrCmp $9 '4' 0 win_2000_XP 262 ; Windows NT 4.0 263 CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\ettercap prompt.lnk" "$SYSDIR\command.com" "" 264 Goto end 265 win_2000_XP: 266 CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\ettercap prompt.lnk" "$SYSDIR\cmd.exe" "" 267 end: 268 269 ; links to the documenation 270 IntCmp $DOCUMENTATION 1 0 no_doc 271 CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER\docs" 272 CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\docs\man-ettercap.lnk" "$INSTDIR\doc\ettercap.pdf" 273 CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\docs\man-ettercap_curses.lnk" "$INSTDIR\doc\ettercap_curses.pdf" 274 CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\docs\man-ettercap_plugins.lnk" "$INSTDIR\doc\ettercap_plugins.pdf" 275 CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\docs\man-etterfilter.lnk" "$INSTDIR\doc\etterfilter.pdf" 276 CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\docs\man-etterlog.lnk" "$INSTDIR\doc\etterlog.pdf" 277 CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\docs\man-etter.conf.lnk" "$INSTDIR\doc\etter.conf.pdf" 278 no_doc: 279 280 CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe" 281 282 !insertmacro MUI_STARTMENU_WRITE_END 283 284SectionEnd 285 286;-------------------------------- 287;Descriptions 288 289 ;Assign language strings to sections 290 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN 291 !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} "The ettercap NG core components." 292 !insertmacro MUI_DESCRIPTION_TEXT ${SecEtterlog} "Etterlog: the utility to parse the ettercap NG logs" 293 !insertmacro MUI_DESCRIPTION_TEXT ${SecEtterfilter} "Etterfilter: the utility to compile content filter scripts to be used within ettercap NG" 294 !insertmacro MUI_DESCRIPTION_TEXT ${SecPlugins} "Various plugins" 295 !insertmacro MUI_DESCRIPTION_TEXT ${SecDocs} "The most important part: the documentation !" 296 !insertmacro MUI_FUNCTION_DESCRIPTION_END 297 298 299;-------------------------------- 300;Functions 301 302Function .onInit 303 304 ; extract the ini for the custom UI 305 !insertmacro MUI_INSTALLOPTIONS_EXTRACT "eNG-radiobuttons.ini" 306 !insertmacro MUI_INSTALLOPTIONS_EXTRACT "eNG-message.ini" 307 308FunctionEnd 309 310Function UserAbort 311 312 StrCmp $CHECKFAILED "1" exit 0 313 !insertmacro MUI_ABORTWARNING 314 315 exit: 316 317FunctionEnd 318 319 320Function CheckWindowsVersion 321 322 ReadRegStr $R1 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows NT\CurrentVersion" "CurrentVersion" 323 StrCmp $R1 "" 0 GoodVersion 324 ; we are not 2000/XP/2003 325 326 ; disable the 'back' and 'next' buttons 327 GetDlgItem $NEXTBUTTON $HWNDPARENT 1 328 GetDlgItem $BACKBUTTON $HWNDPARENT 3 329 GetDlgItem $CANCELBUTTON $HWNDPARENT 2 330 ShowWindow $NEXTBUTTON 0 331 ShowWindow $BACKBUTTON 0 332 SendMessage $CANCELBUTTON ${WM_SETTEXT} 0 "STR:Exit" 333 334 StrCpy $CHECKFAILED "1" 335 336 !insertmacro MUI_INSTALLOPTIONS_WRITE "eNG-message.ini" "Field 1" "Text" "Ettercap NG was compiled to run only on Windows 2000 / XP or greater\r\n\r\nYou can download the source code and try to recompile it for your platform." 337 !insertmacro MUI_HEADER_TEXT "Incorrect Windows version" "" 338 !insertmacro MUI_INSTALLOPTIONS_DISPLAY "eNG-message.ini" 339 340 GoodVersion: 341 342FunctionEnd 343 344 345Function CheckWinpcap 346 347 IfFileExists "$SYSDIR/packet.dll" WinpcapOK 348 349 !insertmacro MUI_INSTALLOPTIONS_WRITE "eNG-message.ini" "Field 1" "Text" "The installer didn't find the file packet.dll in $SYSDIR.\r\n\r\nYou have to install winpcap in order to be able to execute ettercap." 350 !insertmacro MUI_HEADER_TEXT "Missing Winpcap installation" "" 351 !insertmacro MUI_INSTALLOPTIONS_DISPLAY "eNG-message.ini" 352 353 WinpcapOK: 354 355 FileClose $1 356 357FunctionEnd 358 359 360Function PageReinstall 361 362 ReadRegStr $R0 HKLM "Software\ettercap_ng" "" 363 364 StrCmp $R0 "" 0 +2 365 Abort 366 367 ;Detect version 368 ReadRegDWORD $R0 HKLM "Software\ettercap_ng" "VersionMajor" 369 IntCmp $R0 ${VER_MAJOR} minor_check new_version older_version 370 minor_check: 371 ReadRegDWORD $R0 HKLM "Software\ettercap_ng" "VersionMinor" 372 IntCmp $R0 ${VER_MINOR} revision_check new_version older_version 373 revision_check: 374 ReadRegDWORD $R0 HKLM "Software\ettercap_ng" "VersionRevision" 375 IntCmp $R0 ${VER_REVISION} same_version new_version older_version 376 377 new_version: 378 379 !insertmacro MUI_INSTALLOPTIONS_WRITE "eNG-radiobuttons.ini" "Field 1" "Text" "An older version of Ettercap NG is installed on your system. It's recommended that you uninstall the current version before installing. Select the operation you want to perform and click Next to continue." 380 !insertmacro MUI_INSTALLOPTIONS_WRITE "eNG-radiobuttons.ini" "Field 2" "Text" "Uninstall before installing" 381 !insertmacro MUI_INSTALLOPTIONS_WRITE "eNG-radiobuttons.ini" "Field 3" "Text" "Upgrade to version ${VER_DISPLAY}" 382 !insertmacro MUI_HEADER_TEXT "Already Installed" "Choose how you want to install Ettercap NG." 383 StrCpy $R0 "1" 384 Goto reinst_start 385 386 older_version: 387 388 !insertmacro MUI_INSTALLOPTIONS_WRITE "eNG-radiobuttons.ini" "Field 1" "Text" "A newer version of Ettercap NG is already installed! It is not recommended that you install an older version. If you really want to install this older version, it's better to uninstall the current version first. Select the operation you want to perform and click Next to continue." 389 !insertmacro MUI_INSTALLOPTIONS_WRITE "eNG-radiobuttons.ini" "Field 2" "Text" "Uninstall before installing" 390 !insertmacro MUI_INSTALLOPTIONS_WRITE "eNG-radiobuttons.ini" "Field 3" "Text" "Downgrade to version ${VER_DISPLAY}" 391 !insertmacro MUI_HEADER_TEXT "Already Installed" "Choose how you want to install Ettercap NG." 392 StrCpy $R0 "1" 393 Goto reinst_start 394 395 same_version: 396 397 !insertmacro MUI_INSTALLOPTIONS_WRITE "eNG-radiobuttons.ini" "Field 1" "Text" "Ettercap NG ${VER_DISPLAY} is already installed. Select the operation you want to perform and click Next to continue." 398 !insertmacro MUI_INSTALLOPTIONS_WRITE "eNG-radiobuttons.ini" "Field 2" "Text" "Add/Reinstall components" 399 !insertmacro MUI_INSTALLOPTIONS_WRITE "eNG-radiobuttons.ini" "Field 3" "Text" "Uninstall Ettercap NG" 400 !insertmacro MUI_HEADER_TEXT "Already Installed" "Choose the maintenance option to perform." 401 StrCpy $R0 "2" 402 403 reinst_start: 404 405 !insertmacro MUI_INSTALLOPTIONS_DISPLAY "eNG-radiobuttons.ini" 406 407FunctionEnd 408 409Function PageLeaveReinstall 410 411 ; check the selected option 412 !insertmacro MUI_INSTALLOPTIONS_READ $R1 "eNG-radiobuttons.ini" "Field 2" "State" 413 414 StrCmp $R0 "1" 0 +2 415 StrCmp $R1 "1" reinst_uninstall reinst_done 416 417 StrCmp $R0 "2" 0 +3 418 StrCmp $R1 "1" reinst_done reinst_uninstall 419 420 reinst_uninstall: 421 ReadRegStr $R1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ettercap_ng" "UninstallString" 422 423 ;Run uninstaller 424 HideWindow 425 426 ClearErrors 427 ExecWait '$R1 _?=$INSTDIR' 428 429 IfErrors no_remove_uninstaller 430 IfFileExists "$INSTDIR\ettercap.exe" no_remove_uninstaller 431 432 Delete $R1 433 RMDir $INSTDIR 434 435 no_remove_uninstaller: 436 437 StrCmp $R0 "2" 0 +2 438 Quit 439 440 BringToFront 441 442 reinst_done: 443 444FunctionEnd 445 446 447 448;-------------------------------- 449;Uninstaller Section 450 451Section "Uninstall" 452 453 Delete "$INSTDIR\Uninstall.exe" 454 455 Delete "$INSTDIR\etter*.exe" 456 Delete "$INSTDIR\*.dll" 457 Delete "$INSTDIR\ettercapNG-${VER_DISPLAY}_cvs_debug.log" 458 459 RMDir /r "$INSTDIR\doc" 460 RMDir /r "$INSTDIR\lib" 461 RMDir /r "$INSTDIR\etc" 462 RMDir /r "$INSTDIR\share" 463 RMDir "$INSTDIR" 464 465 !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP 466 467 Delete "$SMPROGRAMS\$MUI_TEMP\ettercap.lnk" 468 Delete "$SMPROGRAMS\$MUI_TEMP\ettercap prompt.lnk" 469 Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk" 470 Delete "$SMPROGRAMS\$MUI_TEMP\docs\*" 471 RMDir /r "$SMPROGRAMS\$MUI_TEMP\docs" 472 473 ;Delete empty start menu parent diretories 474 StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP" 475 476 startMenuDeleteLoop: 477 RMDir $MUI_TEMP 478 GetFullPathName $MUI_TEMP "$MUI_TEMP\.." 479 480 IfErrors startMenuDeleteLoopDone 481 482 StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop 483 startMenuDeleteLoopDone: 484 485 486 DeleteRegKey /ifempty HKLM "Software\ettercap_ng" 487 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ettercap_ng" 488 489SectionEnd 490 491; vim:ts=3:expandtab 492