|
| 1 | +############################################################################### |
| 2 | +# _ _ _ _ _____ _ |
| 3 | +# | | | | | | | | | __ \(_) |
| 4 | +# | | ___ | |__ _ __ | |_| |__ ___ | |__) |_ _ __ _ __ ___ _ __ |
| 5 | +# _ | |/ _ \| '_ \| '_ \ | __| '_ \ / _ \ | _ /| | '_ \| '_ \ / _ \ '__| |
| 6 | +# | |__| | (_) | | | | | | | | |_| | | | __/ | | \ \| | |_) | |_) | __/ | |
| 7 | +# \____/ \___/|_| |_|_| |_| \__|_| |_|\___| |_| \_\_| .__/| .__/ \___|_| |
| 8 | +# | | | | |
| 9 | +# |_| |_| |
| 10 | +# |
| 11 | +# Copyright (c) 2019 Claudio André <claudioandre.br at gmail.com> |
| 12 | +# |
| 13 | +# This program comes with ABSOLUTELY NO WARRANTY; express or implied. |
| 14 | +# |
| 15 | +# This program is free software: you can redistribute it and/or modify |
| 16 | +# it under the terms of the GNU General Public License as published by |
| 17 | +# the Free Software Foundation, as expressed in version 2, seen at |
| 18 | +# http://www.gnu.org/licenses/gpl-2.0.html |
| 19 | +############################################################################### |
| 20 | +steps: |
| 21 | + - powershell: | |
| 22 | + # Setup image environment ############################################## |
| 23 | + $cygwinFolder = "C:\$env:cygwinPath" |
| 24 | +
|
| 25 | + cd $env:BUILD_FOLDER |
| 26 | + git describe --dirty=+ --always |
| 27 | + echo '--------------------------------' |
| 28 | +
|
| 29 | + # Windows 2012 does not have Chocolatey installed |
| 30 | + if ($env:SYSTEM_PHASENAME -eq "Windows_2012") { |
| 31 | + Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) |
| 32 | + choco install -y 7zip.install |
| 33 | + } |
| 34 | +
|
| 35 | + # If needed (CygWin is not installed) or as a workaround (CygWin update is required) |
| 36 | + if ($env:Cygwin -eq "install") { |
| 37 | + choco install -y cygwin cyg-get |
| 38 | + cyg-get libssl-devel libbz2-devel libgmp-devel zlib-devel gcc-core libOpenCL-devel libcrypt-devel make wget rebase perl |
| 39 | + } |
| 40 | +
|
| 41 | + # Powershell shell "Bash" run ########################################## |
| 42 | + $posixBuildFolder = $env:BUILD_FOLDER -Replace '\\', '/' |
| 43 | +
|
| 44 | + function shell($command, $dieOnError = $true) { |
| 45 | +
|
| 46 | + Write-Host "Executing '$command'" |
| 47 | + & "$cygwinFolder\bash" -lc ". /etc/profile && cd $posixBuildFolder && $command" |
| 48 | +
|
| 49 | + if ($LASTEXITCODE -ne 0) { |
| 50 | + Write-Host "'$command' failed with exit code $LASTEXITCODE! " -ForegroundColor Red -NoNewline |
| 51 | +
|
| 52 | + if ($dieOnError) { |
| 53 | + exit $LASTEXITCODE |
| 54 | + } |
| 55 | + } |
| 56 | + } |
| 57 | +
|
| 58 | + # Apply patch(es) ###################################################### |
| 59 | + wget "https://raw.githubusercontent.com/openwall/john-packages/main/patches/Remove-peflags-from-the-default-target.patch" -O 0001.patch |
| 60 | + git apply 0001.patch |
| 61 | + # 1. Remove peflags from the default target on Windows |
| 62 | +
|
| 63 | + # Build ################################################################ |
| 64 | + Write-Host "--------------------------------------------------------" |
| 65 | + Write-Host " ===== Building ===== " -ForegroundColor White |
| 66 | + Write-Host "--------------------------------------------------------" |
| 67 | +
|
| 68 | + echo 'Compiler version' |
| 69 | + shell "gcc --version" |
| 70 | + echo '--------------------------------' |
| 71 | + shell "gcc -dM -E -x c /dev/null" |
| 72 | + echo '--------------------------------' |
| 73 | +
|
| 74 | + # #### |
| 75 | + # Redirect strderr to stdout. |
| 76 | + # Otherwise it fails because of prints to stderr |
| 77 | + # + CategoryInfo : NotSpecified: (ar: creating aes.a:String) [], RemoteException |
| 78 | + # + FullyQualifiedErrorId : NativeCommandError |
| 79 | + # #### |
| 80 | + shell "./configure --enable-werror --disable-opencl --enable-simd=avx2 && make -s clean && make -sj2 2>&1 && make -s strip && mv ../run/john ../run/john-best" |
| 81 | + $EXE_NAME = "john-best.exe" |
| 82 | +
|
| 83 | + # The "windows-package" make target depends on default, |
| 84 | + # - So it needs the john.exe I built above |
| 85 | + shell "cp ../run/$EXE_NAME ../run/john.exe" |
| 86 | +
|
| 87 | + # Make this a Windows package |
| 88 | + shell "make -s windows-package" |
| 89 | +
|
| 90 | + # Use symlink.c to produce a tiny john.exe that executes the best SIMD |
| 91 | + shell "make windows-tiny-link-to-john MAIN_NAME=$EXE_NAME " |
| 92 | + ######################################################################## |
| 93 | + # I should strip the tiny john.exe at some time in the future |
| 94 | + # - But I can't call a make target that depends on default |
| 95 | + # - So, I can't run a make strip here |
| 96 | + ######################################################################## |
| 97 | +
|
| 98 | + # Required dlls (Tested on Windows 7 32 bits and Windows 10 64 bits) |
| 99 | + xcopy $cygwinFolder\cygwin1.dll ..\run\ |
| 100 | + xcopy $cygwinFolder\cygbz2-1.dll ..\run\ |
| 101 | + xcopy $cygwinFolder\cygcrypto-3.dll ..\run\ |
| 102 | + xcopy $cygwinFolder\cyggomp-1.dll ..\run\ |
| 103 | + xcopy $cygwinFolder\cyggmp-10.dll ..\run\ |
| 104 | + xcopy $cygwinFolder\cygz.dll ..\run\ |
| 105 | + xcopy $cygwinFolder\cygcrypt-2.dll ..\run\ |
| 106 | + xcopy $cygwinFolder\cygOpenCL-1.dll ..\run\ |
| 107 | + xcopy $cygwinFolder\cyggcc_s-seh-1.dll ..\run\ |
| 108 | +
|
| 109 | + # Save CygWin Dlls |
| 110 | + mkdir ..\lib |
| 111 | + xcopy $cygwinFolder\*.dll ..\lib\ |
| 112 | +
|
| 113 | + # The after_build ###################################################### |
| 114 | + cd $env:JTR_FOLDER\run |
| 115 | +
|
| 116 | + # Build info |
| 117 | + ./john --list=build-info |
| 118 | + displayName: 'Build JtR' |
| 119 | +
|
| 120 | + # Clean up ################################################################# |
| 121 | + - script: | |
| 122 | + REM # Setup worker environment |
| 123 | + SET PATH=%PATH%;C:\ProgramData\chocolatey\bin |
| 124 | + cd $(Build.SourcesDirectory) |
| 125 | +
|
| 126 | + REM # Save John the Ripper zip file |
| 127 | + if exist "%JTR_FOLDER%\run\john.exe" 7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=128m -ms=on "win_x%bits%.7z" "%JTR_FOLDER%" |
| 128 | + move "win_x%bits%.7z" c:\ |
| 129 | + displayName: 'Clean Up the Package' |
| 130 | +
|
| 131 | + - task: PublishBuildArtifacts@1 |
| 132 | + inputs: |
| 133 | + pathtoPublish: "c:\\win_x$(Bits).7z" |
| 134 | + artifactName: "tmp-win_x$(Bits).7z" |
0 commit comments