From e815ceb47a8b3bb8c4b2184c78804f027aeb851c Mon Sep 17 00:00:00 2001 From: Jared Haight <1220886+jaredhaight@users.noreply.github.com> Date: Sat, 17 Feb 2018 17:53:36 -0800 Subject: [PATCH 01/15] initial commit of windows build script --- build.ps1 | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 build.ps1 diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..b74f906 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,168 @@ +<# +.Synopsis + This script is used to deploy a fresh install of DetectionLab +.DESCRIPTION + This scripts runs a series of tests before running through the + DetectionLab deployment. It checks: + + * If Packer and Vagrant are installed + * If VirtualBox or VMWare are installed + * If the proper vagrant plugins are available + * Various aspects of system health + + Post deployment it also verifies that services are installed and + running. + +.EXAMPLE + ./build.ps1 -ProviderName virtualbox -PackerPath 'C:\packer.exe' +.EXAMPLE + ./build.ps1 -ProviderName vmware_workstation -PackerPath 'C:\packer.exe' +#> + +Param( + # Vagrant provider to use. + [ValidateSet('virtualbox', 'vmware_workstation')] + [string]$ProviderName, + [string]$PackerPath = 'C:\Hashicorp\packer.exe' +) + + +function check_packer_and_vagrant { + # Check if vagrant is in path + try { + Get-Command vagrant.exe -ErrorAction Stop + } + catch { + Write-Error 'Vagrant was not found. Please correct this before continuing.' + break + } + + # Check Vagrant version >= 2.0.0 + [System.Version]$vagrant_version = $(vagrant --version).Split(' ')[1] + [System.Version]$version_comparison = 2.0.0 + + if ($vagrant_version -lt $version_comparison) { + Write-Warning 'WARNING: It is highly recommended to use Vagrant 2.0.0 or above before continuing' + } + + #Check for packer at $PackerPath + if (!(Get-Item $PackerPath)) { + Write-Output "Packer not found at $PackerPath" + Write-Output 'Re-run the script setting the PackerPath parameter to the location of packer' + Write-Output "Example: build.ps1 -PackerPath 'C:\packer.exe'" + Write-Output 'Exiting..' + break + } +} + +# Returns 0 if not installed or 1 if installed +function check_virtualbox_installed { + if (Get-WmiObject Win32_Product -Filter "Name LIKE '%VirtualBox%'") { + return $true + } + else { + return $false + } +} +function check_vmware_workstation_installed { + if (Get-WmiObject Win32_Product -Filter "Name = 'VMWare Workstation'") { + return $true + } + else { + return $false + } +} + +#TODO: Verify that the plugin is called 'vagrant-vmware-workstation' +function check_vmware_vagrant_plugin_installed { + if (!(vagrant plugin list | Select-String 'vagrant-vmware-workstation')) { + Write-Output 'VMWare Workstation is installed, but the Vagrant plugin is not.' + Write-Output 'Visit https://www.vagrantup.com/vmware/index.html#buy-now for more information on how to purchase and install it' + Write-Output 'VMWare Workstation will not be listed as a provider until the Vagrant plugin has been installed.' + return $false + } + else { + return $true + } +} + +function list_providers { + Write-Output 'Available Providers: ' + if (check_virtualbox_installed) { + Write-Output '[*] virtualbox' + } + if (check_vmware_workstation_installed) { + Write-Output '[*] vmware_workstation' + } + if ((-Not (check_virtualbox_installed)) -and (-Not (check_vmware_workstation_installed))) { + Write-Output 'You need to install a provider such as VirtualBox or VMware Workstation to continue.' + break + } + $ProviderName = Read-Host 'Which provider would you like to use?' + if ($ProviderName -ne 'virtualbox' -or $ProviderName -ne 'vmware_workstation') { + Write-Output "Please choose a valid provider. $ProviderName is not a valid option" + break + } + return $ProviderName +} + +function preflight_checks { + $DL_DIR = $MyInvocation.MyCommand.Path + + # Check to see that no boxes exist + if ((Get-ChildItem "$DL_DIR\Boxes\*.box").Count -gt 0) { + Write-Output 'You appear to have already built at least one box using Packer. This script does not support pre-built boxes. Please either delete the existing boxes or follow the build steps in the README to continue.' + break + } + + # Check to see that no vagrant instances exist + if (($(vagrant status) | Select-String 'not created').Count -ne 4) { + Write-Output 'You appear to have already created at least one Vagrant instance. This script does not support already created instances. Please either destroy the existing instances or follow the build steps in the README to continue.' + break + } + + # Check available disk space. Recommend 80GB free, warn if less + $Drives = Get-PSDrive | Where-Object {$_.Provider -like '*FileSystem*'} + $DrivesList = @() + + forEach ($drive in $drives) { + if ($drive.free -lt 80000000) { + $DrivesList = $DrivesList + $drive + } + } + + if ($DrivesList.Count -gt 0) { + Write-Output "The following drives have less than 80GB of free space. They should not be used for deploying DetectionLab" + forEach ($drive in $DrivesList) { + Write-Output "[*] $($drive.Name)" + } + Write-Output "You can safely ignore this warning if you are deploying DetectionLab to a different drive." + } + + # Check Packer Version against known bad + [System.Version]$PackerVersion = $(& $PackerPath "--version") + [System.Version]$PackerKnownBad = 1.1.2 + + if ($PackerVersion -eq $PackerKnownBad) { + Write-Output 'Packer 1.1.2 is not supported. Please upgrade to a newer version and see https://github.com/hashicorp/packer/issues/5622 for more information.' + break + } + + # Ensure the vagrant-reload plugin is installed + if (-Not (if (!(vagrant plugin list | Select-String 'vagrant-reload')))) { + Write-Output 'The vagrant-reload plugin is required and not currently installed. This script will attempt to install it now.' + (vagrant plugin install 'vagrant-reload') + if ($LASTEXITCODE -ne 0) { + Write-Output 'Unable to install the vagrant-reload plugin. Please try to do so manually and re-run this script.' + break + } + } +} + + +$DL_DIR = $MyInvocation.MyCommand.Path +$LAB_HOSTS = ('logger', 'dc', 'wef', 'win10') +# If no ProviderName was provided, get a provider +if ($ProviderName -eq $Null) { + $ProviderName = list_providers +} \ No newline at end of file From aec9cc233fc1fc91eecab1cf98d5a73bfd6ef1bb Mon Sep 17 00:00:00 2001 From: Jared Haight <1220886+jaredhaight@users.noreply.github.com> Date: Thu, 22 Feb 2018 19:20:42 -0800 Subject: [PATCH 02/15] Commiting changes --- Boxes/.gitignore | 2 - build.ps1 | 220 +++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 201 insertions(+), 21 deletions(-) delete mode 100755 Boxes/.gitignore diff --git a/Boxes/.gitignore b/Boxes/.gitignore deleted file mode 100755 index d6b7ef3..0000000 --- a/Boxes/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/build.ps1 b/build.ps1 index b74f906..5dc0966 100644 --- a/build.ps1 +++ b/build.ps1 @@ -19,6 +19,7 @@ ./build.ps1 -ProviderName vmware_workstation -PackerPath 'C:\packer.exe' #> +[cmdletbinding()] Param( # Vagrant provider to use. [ValidateSet('virtualbox', 'vmware_workstation')] @@ -27,6 +28,33 @@ Param( ) +$DL_DIR = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition +$LAB_HOSTS = ('logger', 'dc', 'wef', 'win10') + +# Set Provider variable for use deployment functions +if ($ProviderName -eq 'vmware_workstation') { + $Provider = 'vmware' +} +else { + $Provider = 'virtualbox' +} + + +function install_checker { + param( + [string]$Name + ) + $results = Get-ItemProperty 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' | Select-Object DisplayName + $results += Get-ItemProperty 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' | Select-Object DisplayName + + forEach ($result in $results) { + if ($result -like "*$Name*") { + return $true + } + } + return $false +} + function check_packer_and_vagrant { # Check if vagrant is in path try { @@ -42,12 +70,12 @@ function check_packer_and_vagrant { [System.Version]$version_comparison = 2.0.0 if ($vagrant_version -lt $version_comparison) { - Write-Warning 'WARNING: It is highly recommended to use Vagrant 2.0.0 or above before continuing' + Write-Warning 'It is highly recommended to use Vagrant 2.0.0 or above before continuing' } #Check for packer at $PackerPath if (!(Get-Item $PackerPath)) { - Write-Output "Packer not found at $PackerPath" + Write-Error "Packer not found at $PackerPath" Write-Output 'Re-run the script setting the PackerPath parameter to the location of packer' Write-Output "Example: build.ps1 -PackerPath 'C:\packer.exe'" Write-Output 'Exiting..' @@ -57,24 +85,31 @@ function check_packer_and_vagrant { # Returns 0 if not installed or 1 if installed function check_virtualbox_installed { - if (Get-WmiObject Win32_Product -Filter "Name LIKE '%VirtualBox%'") { + Write-Verbose '[check_virtualbox_installed] Running..' + if (install_checker -Name "VirtualBox") { + Write-Verbose '[check_virtualbox_installed] Virtualbox found.' return $true } else { + Write-Verbose '[check_virtualbox_installed] Virtualbox not found.' return $false } } function check_vmware_workstation_installed { - if (Get-WmiObject Win32_Product -Filter "Name = 'VMWare Workstation'") { + Write-Verbose '[check_vmware_workstation_installed] Running..' + if (install_checker -Name "VMWare Workstation") { + Write-Verbose '[check_vmware_workstation_installed] Vmware found.' return $true } else { + Write-Verbose '[check_vmware_workstation_installed] Vmware not found.' return $false } } #TODO: Verify that the plugin is called 'vagrant-vmware-workstation' function check_vmware_vagrant_plugin_installed { + Write-Verbose '[check_vmware_vagrant_plugin_installed] Running..' if (!(vagrant plugin list | Select-String 'vagrant-vmware-workstation')) { Write-Output 'VMWare Workstation is installed, but the Vagrant plugin is not.' Write-Output 'Visit https://www.vagrantup.com/vmware/index.html#buy-now for more information on how to purchase and install it' @@ -82,6 +117,7 @@ function check_vmware_vagrant_plugin_installed { return $false } else { + Write-Verbose '[check_vmware_vagrant_plugin_installed] VMware vagrant plugin found.' return $true } } @@ -95,38 +131,43 @@ function list_providers { Write-Output '[*] vmware_workstation' } if ((-Not (check_virtualbox_installed)) -and (-Not (check_vmware_workstation_installed))) { - Write-Output 'You need to install a provider such as VirtualBox or VMware Workstation to continue.' + Write-Error 'You need to install a provider such as VirtualBox or VMware Workstation to continue.' break } $ProviderName = Read-Host 'Which provider would you like to use?' if ($ProviderName -ne 'virtualbox' -or $ProviderName -ne 'vmware_workstation') { - Write-Output "Please choose a valid provider. $ProviderName is not a valid option" + Write-Error "Please choose a valid provider. $ProviderName is not a valid option" break } return $ProviderName } function preflight_checks { - $DL_DIR = $MyInvocation.MyCommand.Path - + Write-Verbose '[preflight_checks] Running..' # Check to see that no boxes exist + Write-Verbose '[preflight_checks] Checking for pre-existing boxes..' if ((Get-ChildItem "$DL_DIR\Boxes\*.box").Count -gt 0) { - Write-Output 'You appear to have already built at least one box using Packer. This script does not support pre-built boxes. Please either delete the existing boxes or follow the build steps in the README to continue.' + Write-Error 'You appear to have already built at least one box using Packer. This script does not support pre-built boxes. Please either delete the existing boxes or follow the build steps in the README to continue.' break } # Check to see that no vagrant instances exist + Write-Verbose '[preflight_checks] Checking for vagrant instances..' + $CurrentDir = Get-Location + Set-Location "$DL_DIR\Vagrant" if (($(vagrant status) | Select-String 'not created').Count -ne 4) { - Write-Output 'You appear to have already created at least one Vagrant instance. This script does not support already created instances. Please either destroy the existing instances or follow the build steps in the README to continue.' + Write-Error 'You appear to have already created at least one Vagrant instance. This script does not support already created instances. Please either destroy the existing instances or follow the build steps in the README to continue.' break } + Set-Location $CurrentDir # Check available disk space. Recommend 80GB free, warn if less - $Drives = Get-PSDrive | Where-Object {$_.Provider -like '*FileSystem*'} - $DrivesList = @() + Write-Verbose '[preflight_checks] Checking disk space..' + $drives = Get-PSDrive | Where-Object {$_.Provider -like '*FileSystem*'} + $drivesList = @() forEach ($drive in $drives) { - if ($drive.free -lt 80000000) { + if ($drive.free -lt 80GB) { $DrivesList = $DrivesList + $drive } } @@ -140,29 +181,170 @@ function preflight_checks { } # Check Packer Version against known bad + Write-Verbose '[preflight_checks] Checking for bad packer version..' [System.Version]$PackerVersion = $(& $PackerPath "--version") [System.Version]$PackerKnownBad = 1.1.2 if ($PackerVersion -eq $PackerKnownBad) { - Write-Output 'Packer 1.1.2 is not supported. Please upgrade to a newer version and see https://github.com/hashicorp/packer/issues/5622 for more information.' + Write-Error 'Packer 1.1.2 is not supported. Please upgrade to a newer version and see https://github.com/hashicorp/packer/issues/5622 for more information.' break } # Ensure the vagrant-reload plugin is installed - if (-Not (if (!(vagrant plugin list | Select-String 'vagrant-reload')))) { + Write-Verbose '[preflight_checks] Checking if vagrant-reload is installed..' + if (-Not (vagrant plugin list | Select-String 'vagrant-reload')) { Write-Output 'The vagrant-reload plugin is required and not currently installed. This script will attempt to install it now.' (vagrant plugin install 'vagrant-reload') if ($LASTEXITCODE -ne 0) { - Write-Output 'Unable to install the vagrant-reload plugin. Please try to do so manually and re-run this script.' + Write-Error 'Unable to install the vagrant-reload plugin. Please try to do so manually and re-run this script.' break } } + Write-Verbose '[preflight_checks] Finished.' } +function packer_build_box { + param( + [string]$Box + ) + + Write-Verbose "[packer_build_box] Running for $Box" + $CurrentDir = Get-Location + Set-Location "$DL_DIR\Packer" + Write-Output "Using Packer to build the $BOX Box. This can take 90-180 minutes depending on bandwidth and hardware." + &$PackerPath @('build', "--only=$Provider-iso", "$box.json") + Write-Verbose "[packer_build_box] Finished for $Box. Got exit code: $LASTEXITCODE" + + if ($LASTEXITCODE -ne 0) { + Write-Error "Something went wrong while attempting to build the $BOX box." + Write-Output "To file an issue, please visit https://github.com/clong/DetectionLab/issues/" + break + } + Set-Location $CurrentDir +} + +function move_boxes { + Write-Verbose "[move_boxes] Running.." + Move-Item -Path $DL_DIR\Packer\*.box -Destination $DL_DIR\Boxes + if (-Not (Test-Path "$DL_DIR\Boxes\windows_10_$Provider.box")) { + Write-Error "Windows 10 box is missing from the Boxes directory. Qutting." + break + } + if (-Not (Test-Path "$DL_DIR\Boxes\windows_2016_$Provider.box")) { + Write-Error "Windows 2016 box is missing from the Boxes directory. Qutting." + break + } + Write-Verbose "[move_boxes] Finished." +} + +function vagrant_up_host { + param( + [string]$VagrantHost + ) + Write-Verbose "[vagrant_up_host] Running for $VagrantHost" + Write-Host "Attempting to bring up the $VagrantHost host using Vagrant" + $CurrentDir = Get-Location + Set-Location "$DL_DIR\Vagrant" + &vagrant.exe @('up', $VagrantHost, '--provider', "$Provider") + Set-Location $CurrentDir + Write-Verbose "[vagrant_up_host] Finished for $VagrantHost. Got exit code: $LASTEXITCODE" + return $LASTEXITCODE +} + +function vagrant_reload_host { + param( + [string]$VagrantHost + ) + Write-Verbose "[vagrant_reload_host] Running for $VagrantHost" + $CurrentDir = Get-Location + Set-Location "$DL_DIR\Vagrant" + &vagrant.exe @('reload', $VagrantHost, '--provision') | Out-Null + Set-Location $CurrentDir + Write-Verbose "[vagrant_reload_host] Finished for $VagrantHost. Got exit code: $LASTEXITCODE" + return $LASTEXITCODE +} + +function download { + param( + [string]$URL, + [string]$PatternToMatch + ) + Write-Verbose "[download] Running for $URL, looking for $PatternToMatch" + [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls" + + $wc = New-Object System.Net.WebClient + $result = $wc.DownloadString($URL) + if ($result -like "*$PatternToMatch*") { + Write-Verbose "[download] Found $PatternToMatch at $URL" + return $true + } + else { + Write-Verbose "[download] Could not find $PatternToMatch at $URL" + return $false + } +} + +function post_build_checks { + + Write-Verbose '[post_build_checks] Running Caldera Check.' + $CALDERA_CHECK = download -URL 'https://192.168.38.5:8888' -PatternToMatch 'CALDERA' + Write-Verbose "[post_build_checks] Cladera Result: $CALDERA_CHECK" + + Write-Verbose '[post_build_checks] Running Splunk Check.' + $SPLUNK_CHECK = download -URL 'https://192.168.38.5:8000/en-US/account/login?return_to=%2Fen-US%2F' -PatternToMatch 'This browser is not supported by Splunk' + Write-Verbose "[post_build_checks] Splunk Result: $SPLUNK_CHECK" + + Write-Verbose '[post_build_checks] Running Fleet Check.' + $FLEET_CHECK = download -URL 'https://192.168.38.5:8412' -PatternToMatch 'Kolide Fleet' + Write-Verbose "[post_build_checks] Fleet Result: $FLEET_CHECK" + + if ($CALDERA_CHECK -eq $false) { + Write-Warning 'Caldera failed post-build tests and may not be functioning correctly.' + } + if ($SPLUNK_CHECK -eq $false) { + Write-Warning 'Splunk failed post-build tests and may not be functioning correctly.' + } + if ($FLEET_CHECK -eq $false) { + Write-Warning 'Fleet failed post-build tests and may not be functioning correctly.' + } +} -$DL_DIR = $MyInvocation.MyCommand.Path -$LAB_HOSTS = ('logger', 'dc', 'wef', 'win10') # If no ProviderName was provided, get a provider if ($ProviderName -eq $Null) { $ProviderName = list_providers -} \ No newline at end of file +} + +# Run check functions +preflight_checks + +# Build Packer Boxes +packer_build_box -Box 'windows_2016' +packer_build_box -Box 'windows_10' + +# Move Packer Boxes +move_boxes + +# Vagrant up each box and attempt to reload one time if it fails +forEach ($VAGRANT_HOST in $LAB_HOSTS) { + Write-Verbose "[main] Running vagrant_up_host for: $VAGRANT_HOST" + $result = vagrant_up_host -VagrantHost $VAGRANT_HOST + if ($result -eq 0) { + Write-Output "Good news! $VAGRANT_HOST was built successfully!" + } + else { + Write-Warning "Something went wrong while attempting to build the $VAGRANT_HOST box." + Write-Output "Attempting to reload and reprovision the host..." + Write-Verbose "[main] Running vagrant_reload_host for: $VAGRANT_HOST" + $retryResult = vagrant_reload_host -VagrantHost $VAGRANT_HOST + if ($retryResult -ne 0) { + Write-Error "Failed to bring up $VAGRANT_HOST after a reload. Exiting" + break + } + } + Write-Verbose "[main] Finished for: $VAGRANT_HOST" +} + + +Write-Verbose "[main] Running post_build_checks" +post_build_checks +Write-Verbose "[main] Finished post_build_checks" \ No newline at end of file From af1bccd74af7347874d6df978d52930512bec1f2 Mon Sep 17 00:00:00 2001 From: Jared Haight <1220886+jaredhaight@users.noreply.github.com> Date: Tue, 27 Feb 2018 09:07:58 -0800 Subject: [PATCH 03/15] fixed bugs. might work now. --- build.ps1 | 120 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 93 insertions(+), 27 deletions(-) diff --git a/build.ps1 b/build.ps1 index 5dc0966..bb9d5de 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,3 +1,5 @@ +#Requires -Version 4.0 + <# .Synopsis This script is used to deploy a fresh install of DetectionLab @@ -24,7 +26,8 @@ Param( # Vagrant provider to use. [ValidateSet('virtualbox', 'vmware_workstation')] [string]$ProviderName, - [string]$PackerPath = 'C:\Hashicorp\packer.exe' + [string]$PackerPath = 'C:\Hashicorp\packer.exe', + [swtich]$VagrantOnly ) @@ -55,7 +58,17 @@ function install_checker { return $false } -function check_packer_and_vagrant { +function check_packer { + #Check for packer at $PackerPath + if (!(Get-Item $PackerPath)) { + Write-Error "Packer not found at $PackerPath" + Write-Output 'Re-run the script setting the PackerPath parameter to the location of packer' + Write-Output "Example: build.ps1 -PackerPath 'C:\packer.exe'" + Write-Output 'Exiting..' + break + } +} +function check_vagrant { # Check if vagrant is in path try { Get-Command vagrant.exe -ErrorAction Stop @@ -72,18 +85,9 @@ function check_packer_and_vagrant { if ($vagrant_version -lt $version_comparison) { Write-Warning 'It is highly recommended to use Vagrant 2.0.0 or above before continuing' } - - #Check for packer at $PackerPath - if (!(Get-Item $PackerPath)) { - Write-Error "Packer not found at $PackerPath" - Write-Output 'Re-run the script setting the PackerPath parameter to the location of packer' - Write-Output "Example: build.ps1 -PackerPath 'C:\packer.exe'" - Write-Output 'Exiting..' - break - } } -# Returns 0 if not installed or 1 if installed +# Returns false if not installed or true if installed function check_virtualbox_installed { Write-Verbose '[check_virtualbox_installed] Running..' if (install_checker -Name "VirtualBox") { @@ -107,28 +111,32 @@ function check_vmware_workstation_installed { } } -#TODO: Verify that the plugin is called 'vagrant-vmware-workstation' function check_vmware_vagrant_plugin_installed { Write-Verbose '[check_vmware_vagrant_plugin_installed] Running..' - if (!(vagrant plugin list | Select-String 'vagrant-vmware-workstation')) { - Write-Output 'VMWare Workstation is installed, but the Vagrant plugin is not.' - Write-Output 'Visit https://www.vagrantup.com/vmware/index.html#buy-now for more information on how to purchase and install it' - Write-Output 'VMWare Workstation will not be listed as a provider until the Vagrant plugin has been installed.' - return $false - } - else { + if (vagrant plugin list | Select-String 'vagrant-vmware-workstation') { Write-Verbose '[check_vmware_vagrant_plugin_installed] VMware vagrant plugin found.' return $true } + else { + Write-Host 'VMWare Workstation is installed, but the Vagrant plugin is not.' + Write-Host 'Visit https://www.vagrantup.com/vmware/index.html#buy-now for more information on how to purchase and install it' + Write-Host 'VMWare Workstation will not be listed as a provider until the Vagrant plugin has been installed.' + return $false + } } function list_providers { + [cmdletbinding()] + param() + Write-Output 'Available Providers: ' if (check_virtualbox_installed) { Write-Output '[*] virtualbox' } if (check_vmware_workstation_installed) { - Write-Output '[*] vmware_workstation' + if (check_vmware_vagrant_plugin_installed) { + Write-Output '[*] vmware_workstation' + } } if ((-Not (check_virtualbox_installed)) -and (-Not (check_vmware_workstation_installed))) { Write-Error 'You need to install a provider such as VirtualBox or VMware Workstation to continue.' @@ -142,9 +150,62 @@ function list_providers { return $ProviderName } +function download_boxes { + Write-Verbose '[download_boxes] Running..' + if ($ProviderName -eq 'virtualbox') { + $win10Filename = 'windows_10_virtualbox.box' + $win2016Filename = 'windows_2016_virtualbox.box' + $win10Hash = '30b06e30b36b02ccf1dc5c04017654aa' + $win2016Hash = '614f984c82b51471b5bb753940b59d38' + } + if ($ProviderName -eq 'vmware') { + $win10Filename = 'windows_10_vmware.box' + $win2016Filename = 'windows_2016_vmware.box' + $win10Hash = '174ad0f0fd2089ff74a880c6dadac74c' + $win2016Hash = '1511b9dc942c69c2cc5a8dc471fa8865' + } + + $wc = New-Object System.Net.WebClient + Write-Verbose "[download_boxes] Downloading $win10Filename" + $wc.DownloadFile("https://www.detectionlab.network/$win10Filename", "$DL_DIR\Boxes\$win10Filename") + Write-Verbose "[download_boxes] Downloading $win2016Filename" + $wc.DownloadFile("https://www.detectionlab.network/$win2016Filename", "$DL_DIR\Boxes\$win2016Filename") + $wc.Dispose() + + if (-Not (Test-Path "$DL_DIR\Boxes\$win2016Filename")) { + Write-Error 'Windows 2016 box is missing from the Boxes directory. Qutting.' + break + } + if (-Not (Test-Path "$DL_DIR\Boxes\$win10Filename")) { + Write-Error 'Windows 10 box is missing from the Boxes directory. Qutting.' + break + } + + Write-Verbose "[download_boxes] Getting filehash for: $win10Filename" + $win10Filehash = Get-FileHash -Path "$DL_DIR\Boxes\$win10Filename" -Algorithm MD5 + Write-Verbose "[download_boxes] Getting filehash for: $win2016Filename" + $win2016Filehash = Get-FileHash -Path "$DL_DIR\Boxes\$win2016Filename" -Algorithm MD5 + + Write-Verbose '[download_boxes] Checking Filehashes..' + if ($win10hash -ne $win10Filehash) { + Write-Error 'Hash mismatch on windows_10_virtualbox.box' + } + if ($win2016hash -ne $win2016Filehash) { + Write-Error 'Hash mismatch on windows_2016_virtualbox.box' + } + Write-Verbose '[download_boxes] Finished.' +} + function preflight_checks { Write-Verbose '[preflight_checks] Running..' # Check to see that no boxes exist + if (-Not ($VagrantOnly)) { + Write-Verbose '[preflight_checks] Checking if packer is installed' + check_packer + } + Write-Verbose '[preflight_checks] Checking if vagrant is installed' + check_vagrant + Write-Verbose '[preflight_checks] Checking for pre-existing boxes..' if ((Get-ChildItem "$DL_DIR\Boxes\*.box").Count -gt 0) { Write-Error 'You appear to have already built at least one box using Packer. This script does not support pre-built boxes. Please either delete the existing boxes or follow the build steps in the README to continue.' @@ -318,17 +379,22 @@ if ($ProviderName -eq $Null) { preflight_checks # Build Packer Boxes -packer_build_box -Box 'windows_2016' -packer_build_box -Box 'windows_10' - -# Move Packer Boxes -move_boxes +if ($VagrantOnly) { + download_boxes +} +else { + packer_build_box -Box 'windows_2016' + packer_build_box -Box 'windows_10' + # Move Packer Boxes + move_boxes +} # Vagrant up each box and attempt to reload one time if it fails forEach ($VAGRANT_HOST in $LAB_HOSTS) { Write-Verbose "[main] Running vagrant_up_host for: $VAGRANT_HOST" $result = vagrant_up_host -VagrantHost $VAGRANT_HOST - if ($result -eq 0) { + Write-Verbose "[main] vagrant_up_host finished. Exitcode: $result" + if ($result -eq '0') { Write-Output "Good news! $VAGRANT_HOST was built successfully!" } else { From 979c57c08704a3d93b1f5e822973e0291007ffc9 Mon Sep 17 00:00:00 2001 From: Jared Haight <1220886+jaredhaight@users.noreply.github.com> Date: Tue, 27 Feb 2018 17:34:15 -0800 Subject: [PATCH 04/15] fixed stuff maybe --- .../packer-virtualbox-iso-1519780950.vdi | Bin 0 -> 2097152 bytes build.ps1 | 34 ++++++++++++++---- 2 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 Packer/output-virtualbox-iso/packer-virtualbox-iso-1519780950.vdi diff --git a/Packer/output-virtualbox-iso/packer-virtualbox-iso-1519780950.vdi b/Packer/output-virtualbox-iso/packer-virtualbox-iso-1519780950.vdi new file mode 100644 index 0000000000000000000000000000000000000000..787bbbad4df3fc56c5af2d23d7f634668c925e6f GIT binary patch literal 2097152 zcmeF&W3XoVqHpQ6ZQHhO+qP}nwr$(CZQFKLR%TY-k$pO%&yBdfJEG%!92N2G-+#{e zF679y)~>3ZJ5QcG3CeeB*tkv81l7tWsMfMmm#z)l6l&iiL6Mf7TPG;lwqf(83G(I3 z7b?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RsjM7%*VKfB^#r3>YwAz<>b*1`HT5V8DO@0|pEjFkrxd0RsjM7%*VKfB^#r3>YwA zz<>b*1`HT5V8DO@0|pEjFkrxd0RsjM7%*VKfB^#r3>YwAz<>b*1`HT5V8DO@0|pEj zFkrxd0RsjM7%*VKfB^#r3>YwAz<>b*1`HT5V8DO@0|pEjFkrxd0RsjM7%*VKfB^#r z3>YwAz<>b*1`HT5V8DO@0|pEjFkrxd0RsjM7%*VKfB^#r3>YwAz<>b*1`HT5V8DO@ z0|pEjFkrxd0RsjM7%*VKfB^#r3>YwAz<>b*1`HT5V8DO@0|pEjFkrxd0RsjM7%*VK zfB^#r3>YwAz<>b*1`HT5V8DO@0|pEjFkrxd0RsjM7%*VKfB^#r3>YwAz<>b*1`HT5 zV8DO@0|pEjFkrxd0RsjM7%*VKfB^#r3>YwAz<>b*1`HT5V8DO@0|pEjFkrxd0RsjM z7%*VKfB^#r3>YwAz<>b*1`HT5V8DO@0|pEjFkrxd0RsjM7%*VKfB^#r3>YwAz<>b* v1`HT5V8DO@0|pEjFkrxd0RsjM7%*VKfB^#r3>YwAz<>b*1`HT5U|=>7dTWA% literal 0 HcmV?d00001 diff --git a/build.ps1 b/build.ps1 index bb9d5de..041b9f5 100644 --- a/build.ps1 +++ b/build.ps1 @@ -3,6 +3,7 @@ <# .Synopsis This script is used to deploy a fresh install of DetectionLab + .DESCRIPTION This scripts runs a series of tests before running through the DetectionLab deployment. It checks: @@ -13,12 +14,32 @@ * Various aspects of system health Post deployment it also verifies that services are installed and - running. + running. + + If you encounter issues, feel free to open an issue at + https://github.com/clong/DetectionLab/issues + +.PARAMETER ProviderName + The Hypervisor you're using for the lab. Valid options are 'virtualbox' or 'vmware_workstation' + +.PARAMETER PackerPath + The full path to the packer executable. Default is C:\Hashicorp\packer.exe + +.PARAMETER VagrantOnly + This switch skips building packer boxes and instead downloads from www.deploymentlab.network .EXAMPLE - ./build.ps1 -ProviderName virtualbox -PackerPath 'C:\packer.exe' + build.ps1 -ProviderName virtualbox + + This builds the DeploymentLab using virtualbox and the default path for packer (C:\Hashicorp\packer.exe) .EXAMPLE - ./build.ps1 -ProviderName vmware_workstation -PackerPath 'C:\packer.exe' + build.ps1 -ProviderName vmware_workstation -PackerPath 'C:\packer.exe' + + This builds the DeploymentLab using Vmware and sets the packer path to 'C:\packer.exe' +.EXAMPLE + build.ps1 -ProviderName vmware_workstation -VagrantOnly + + This command builds the DeploymentLab using vmware and skips the packer process, downloading the boxes instead. #> [cmdletbinding()] @@ -27,7 +48,7 @@ Param( [ValidateSet('virtualbox', 'vmware_workstation')] [string]$ProviderName, [string]$PackerPath = 'C:\Hashicorp\packer.exe', - [swtich]$VagrantOnly + [switch]$VagrantOnly ) @@ -71,7 +92,7 @@ function check_packer { function check_vagrant { # Check if vagrant is in path try { - Get-Command vagrant.exe -ErrorAction Stop + Get-Command vagrant.exe -ErrorAction Stop | Out-Null } catch { Write-Error 'Vagrant was not found. Please correct this before continuing.' @@ -331,7 +352,8 @@ function download { [string]$PatternToMatch ) Write-Verbose "[download] Running for $URL, looking for $PatternToMatch" - [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls" + [System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true } + #[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls" $wc = New-Object System.Net.WebClient $result = $wc.DownloadString($URL) From 4f831c9c697fdd3acfbd0e5fa2eda54f67b742d6 Mon Sep 17 00:00:00 2001 From: Jared Haight <1220886+jaredhaight@users.noreply.github.com> Date: Tue, 20 Mar 2018 17:32:49 -0700 Subject: [PATCH 05/15] ready for merge --- build.ps1 | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/build.ps1 b/build.ps1 index bb9d5de..27badc3 100644 --- a/build.ps1 +++ b/build.ps1 @@ -3,6 +3,7 @@ <# .Synopsis This script is used to deploy a fresh install of DetectionLab + .DESCRIPTION This scripts runs a series of tests before running through the DetectionLab deployment. It checks: @@ -13,21 +14,42 @@ * Various aspects of system health Post deployment it also verifies that services are installed and - running. + running. + + If you encounter issues, feel free to open an issue at + https://github.com/clong/DetectionLab/issues + +.PARAMETER ProviderName + The Hypervisor you're using for the lab. Valid options are 'virtualbox' or 'vmware_workstation' + +.PARAMETER PackerPath + The full path to the packer executable. Default is C:\Hashicorp\packer.exe + +.PARAMETER VagrantOnly + This switch skips building packer boxes and instead downloads from www.deploymentlab.network .EXAMPLE - ./build.ps1 -ProviderName virtualbox -PackerPath 'C:\packer.exe' + build.ps1 -ProviderName virtualbox + + This builds the DeploymentLab using virtualbox and the default path for packer (C:\Hashicorp\packer.exe) .EXAMPLE - ./build.ps1 -ProviderName vmware_workstation -PackerPath 'C:\packer.exe' + build.ps1 -ProviderName vmware_workstation -PackerPath 'C:\packer.exe' + + This builds the DeploymentLab using Vmware and sets the packer path to 'C:\packer.exe' +.EXAMPLE + build.ps1 -ProviderName vmware_workstation -VagrantOnly + + This command builds the DeploymentLab using vmware and skips the packer process, downloading the boxes instead. #> [cmdletbinding()] Param( # Vagrant provider to use. + [Parameter(Mandatory=$true)] [ValidateSet('virtualbox', 'vmware_workstation')] [string]$ProviderName, [string]$PackerPath = 'C:\Hashicorp\packer.exe', - [swtich]$VagrantOnly + [switch]$VagrantOnly ) @@ -71,7 +93,7 @@ function check_packer { function check_vagrant { # Check if vagrant is in path try { - Get-Command vagrant.exe -ErrorAction Stop + Get-Command vagrant.exe -ErrorAction Stop | Out-Null } catch { Write-Error 'Vagrant was not found. Please correct this before continuing.' @@ -189,9 +211,11 @@ function download_boxes { Write-Verbose '[download_boxes] Checking Filehashes..' if ($win10hash -ne $win10Filehash) { Write-Error 'Hash mismatch on windows_10_virtualbox.box' + break } if ($win2016hash -ne $win2016Filehash) { Write-Error 'Hash mismatch on windows_2016_virtualbox.box' + break } Write-Verbose '[download_boxes] Finished.' } @@ -331,6 +355,7 @@ function download { [string]$PatternToMatch ) Write-Verbose "[download] Running for $URL, looking for $PatternToMatch" + [System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true } [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls" $wc = New-Object System.Net.WebClient From cc09989393290f26008702194957894756df53d4 Mon Sep 17 00:00:00 2001 From: Jared Haight <1220886+jaredhaight@users.noreply.github.com> Date: Tue, 20 Mar 2018 17:42:40 -0700 Subject: [PATCH 06/15] undoing gitignore removal --- Boxes/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Boxes/.gitignore diff --git a/Boxes/.gitignore b/Boxes/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/Boxes/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore From 502816a56dacd255f95daaaef8e26838739b6e70 Mon Sep 17 00:00:00 2001 From: Jared Haight <1220886+jaredhaight@users.noreply.github.com> Date: Sat, 31 Mar 2018 11:37:05 -0700 Subject: [PATCH 07/15] s/DeploymentLab/DetectionLab/g --- build.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.ps1 b/build.ps1 index 27badc3..d1ca61b 100644 --- a/build.ps1 +++ b/build.ps1 @@ -26,20 +26,20 @@ The full path to the packer executable. Default is C:\Hashicorp\packer.exe .PARAMETER VagrantOnly - This switch skips building packer boxes and instead downloads from www.deploymentlab.network + This switch skips building packer boxes and instead downloads from www.detectionlab.network .EXAMPLE build.ps1 -ProviderName virtualbox - This builds the DeploymentLab using virtualbox and the default path for packer (C:\Hashicorp\packer.exe) + This builds the DetectionLab using virtualbox and the default path for packer (C:\Hashicorp\packer.exe) .EXAMPLE build.ps1 -ProviderName vmware_workstation -PackerPath 'C:\packer.exe' - This builds the DeploymentLab using Vmware and sets the packer path to 'C:\packer.exe' + This builds the DetectionLab using Vmware and sets the packer path to 'C:\packer.exe' .EXAMPLE build.ps1 -ProviderName vmware_workstation -VagrantOnly - This command builds the DeploymentLab using vmware and skips the packer process, downloading the boxes instead. + This command builds the DetectionLab using vmware and skips the packer process, downloading the boxes instead. #> [cmdletbinding()] From 6d3e5fad4fb5bea68bc0f793b68c2963ca896ef5 Mon Sep 17 00:00:00 2001 From: Jared Haight <1220886+jaredhaight@users.noreply.github.com> Date: Sat, 31 Mar 2018 11:38:57 -0700 Subject: [PATCH 08/15] Changed Get-Item to Test-Item --- build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.ps1 b/build.ps1 index d1ca61b..5eb83a9 100644 --- a/build.ps1 +++ b/build.ps1 @@ -82,7 +82,7 @@ function install_checker { function check_packer { #Check for packer at $PackerPath - if (!(Get-Item $PackerPath)) { + if (!(Test-Path $PackerPath)) { Write-Error "Packer not found at $PackerPath" Write-Output 'Re-run the script setting the PackerPath parameter to the location of packer' Write-Output "Example: build.ps1 -PackerPath 'C:\packer.exe'" From f01c0390ae8df12de998de99d9f2e4ee38f2495f Mon Sep 17 00:00:00 2001 From: Jared Haight <1220886+jaredhaight@users.noreply.github.com> Date: Sat, 31 Mar 2018 12:19:21 -0700 Subject: [PATCH 09/15] Fixed Provider Prompt --- build.ps1 | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/build.ps1 b/build.ps1 index 5eb83a9..b948b1a 100644 --- a/build.ps1 +++ b/build.ps1 @@ -45,26 +45,15 @@ [cmdletbinding()] Param( # Vagrant provider to use. - [Parameter(Mandatory=$true)] [ValidateSet('virtualbox', 'vmware_workstation')] [string]$ProviderName, [string]$PackerPath = 'C:\Hashicorp\packer.exe', [switch]$VagrantOnly ) - $DL_DIR = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition $LAB_HOSTS = ('logger', 'dc', 'wef', 'win10') -# Set Provider variable for use deployment functions -if ($ProviderName -eq 'vmware_workstation') { - $Provider = 'vmware' -} -else { - $Provider = 'virtualbox' -} - - function install_checker { param( [string]$Name @@ -151,23 +140,25 @@ function list_providers { [cmdletbinding()] param() - Write-Output 'Available Providers: ' + Write-Host 'Available Providers: ' if (check_virtualbox_installed) { - Write-Output '[*] virtualbox' + Write-Host '[*] virtualbox' } if (check_vmware_workstation_installed) { if (check_vmware_vagrant_plugin_installed) { - Write-Output '[*] vmware_workstation' + Write-Host '[*] vmware_workstation' } } if ((-Not (check_virtualbox_installed)) -and (-Not (check_vmware_workstation_installed))) { Write-Error 'You need to install a provider such as VirtualBox or VMware Workstation to continue.' break } - $ProviderName = Read-Host 'Which provider would you like to use?' - if ($ProviderName -ne 'virtualbox' -or $ProviderName -ne 'vmware_workstation') { - Write-Error "Please choose a valid provider. $ProviderName is not a valid option" - break + while (-Not ($ProviderName -eq 'virtualbox' -or $ProviderName -eq 'vmware_workstation')) { + $ProviderName = Read-Host 'Which provider would you like to use?' + Write-Debug "ProviderName = $ProviderName" + if (-Not ($ProviderName -eq 'virtualbox' -or $ProviderName -eq 'vmware_workstation')) { + Write-Error "Please choose a valid provider. $ProviderName is not a valid option" + } } return $ProviderName } @@ -395,11 +386,21 @@ function post_build_checks { } } + # If no ProviderName was provided, get a provider -if ($ProviderName -eq $Null) { +if ($ProviderName -eq $Null -or $ProviderName -eq "") { $ProviderName = list_providers } +# Set Provider variable for use deployment functions +if ($ProviderName -eq 'vmware_workstation') { + $Provider = 'vmware' +} +else { + $Provider = 'virtualbox' +} + + # Run check functions preflight_checks From ea0d11061bbb9b5ac49d08d375b50e6d0bb14453 Mon Sep 17 00:00:00 2001 From: Jared Haight <1220886+jaredhaight@users.noreply.github.com> Date: Sat, 31 Mar 2018 12:32:07 -0700 Subject: [PATCH 10/15] fix for 'not created' vs 'not_created' in vagrant status --- build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.ps1 b/build.ps1 index b948b1a..d2d3ab1 100644 --- a/build.ps1 +++ b/build.ps1 @@ -231,7 +231,7 @@ function preflight_checks { Write-Verbose '[preflight_checks] Checking for vagrant instances..' $CurrentDir = Get-Location Set-Location "$DL_DIR\Vagrant" - if (($(vagrant status) | Select-String 'not created').Count -ne 4) { + if (($(vagrant status) | Select-String -Pattern "not[ _]created").Count -ne 4) { Write-Error 'You appear to have already created at least one Vagrant instance. This script does not support already created instances. Please either destroy the existing instances or follow the build steps in the README to continue.' break } From d4a2cded0a0f0a607b5e754f8ead8d0e916b35c1 Mon Sep 17 00:00:00 2001 From: Jared Haight <1220886+jaredhaight@users.noreply.github.com> Date: Sat, 31 Mar 2018 12:38:49 -0700 Subject: [PATCH 11/15] Change to for clarity and update references --- build.ps1 | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/build.ps1 b/build.ps1 index d2d3ab1..cb5ebd1 100644 --- a/build.ps1 +++ b/build.ps1 @@ -165,18 +165,18 @@ function list_providers { function download_boxes { Write-Verbose '[download_boxes] Running..' - if ($ProviderName -eq 'virtualbox') { - $win10Filename = 'windows_10_virtualbox.box' - $win2016Filename = 'windows_2016_virtualbox.box' + if ($PackerProvider -eq 'virtualbox') { $win10Hash = '30b06e30b36b02ccf1dc5c04017654aa' $win2016Hash = '614f984c82b51471b5bb753940b59d38' } - if ($ProviderName -eq 'vmware') { - $win10Filename = 'windows_10_vmware.box' - $win2016Filename = 'windows_2016_vmware.box' + if ($PackerProvider -eq 'vmware') { $win10Hash = '174ad0f0fd2089ff74a880c6dadac74c' $win2016Hash = '1511b9dc942c69c2cc5a8dc471fa8865' } + + + $win10Filename = "windows_10_$PackerProvider.box" + $win2016Filename = "windows_2016_$PackerProvider.box" $wc = New-Object System.Net.WebClient Write-Verbose "[download_boxes] Downloading $win10Filename" @@ -288,7 +288,7 @@ function packer_build_box { $CurrentDir = Get-Location Set-Location "$DL_DIR\Packer" Write-Output "Using Packer to build the $BOX Box. This can take 90-180 minutes depending on bandwidth and hardware." - &$PackerPath @('build', "--only=$Provider-iso", "$box.json") + &$PackerPath @('build', "--only=$PackerProvider-iso", "$box.json") Write-Verbose "[packer_build_box] Finished for $Box. Got exit code: $LASTEXITCODE" if ($LASTEXITCODE -ne 0) { @@ -302,11 +302,11 @@ function packer_build_box { function move_boxes { Write-Verbose "[move_boxes] Running.." Move-Item -Path $DL_DIR\Packer\*.box -Destination $DL_DIR\Boxes - if (-Not (Test-Path "$DL_DIR\Boxes\windows_10_$Provider.box")) { + if (-Not (Test-Path "$DL_DIR\Boxes\windows_10_$PackerProvider.box")) { Write-Error "Windows 10 box is missing from the Boxes directory. Qutting." break } - if (-Not (Test-Path "$DL_DIR\Boxes\windows_2016_$Provider.box")) { + if (-Not (Test-Path "$DL_DIR\Boxes\windows_2016_$PackerProvider.box")) { Write-Error "Windows 2016 box is missing from the Boxes directory. Qutting." break } @@ -394,10 +394,10 @@ if ($ProviderName -eq $Null -or $ProviderName -eq "") { # Set Provider variable for use deployment functions if ($ProviderName -eq 'vmware_workstation') { - $Provider = 'vmware' + $PackerProvider = 'vmware' } else { - $Provider = 'virtualbox' + $PackerProvider = 'virtualbox' } From 235dd00cbe48d4d8410dfc7077eef257e35974cf Mon Sep 17 00:00:00 2001 From: Jared Haight <1220886+jaredhaight@users.noreply.github.com> Date: Sat, 31 Mar 2018 12:40:28 -0700 Subject: [PATCH 12/15] Fixed hash check --- build.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.ps1 b/build.ps1 index cb5ebd1..dd602c5 100644 --- a/build.ps1 +++ b/build.ps1 @@ -195,9 +195,9 @@ function download_boxes { } Write-Verbose "[download_boxes] Getting filehash for: $win10Filename" - $win10Filehash = Get-FileHash -Path "$DL_DIR\Boxes\$win10Filename" -Algorithm MD5 + $win10Filehash = (Get-FileHash -Path "$DL_DIR\Boxes\$win10Filename" -Algorithm MD5).Hash Write-Verbose "[download_boxes] Getting filehash for: $win2016Filename" - $win2016Filehash = Get-FileHash -Path "$DL_DIR\Boxes\$win2016Filename" -Algorithm MD5 + $win2016Filehash = (Get-FileHash -Path "$DL_DIR\Boxes\$win2016Filename" -Algorithm MD5).Hash Write-Verbose '[download_boxes] Checking Filehashes..' if ($win10hash -ne $win10Filehash) { From 3be47e70c8e19a7252f767fe314674f859bef893 Mon Sep 17 00:00:00 2001 From: Jared Haight <1220886+jaredhaight@users.noreply.github.com> Date: Sat, 31 Mar 2018 12:41:59 -0700 Subject: [PATCH 13/15] Only check packer version if not VagrantOnly --- build.ps1 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/build.ps1 b/build.ps1 index dd602c5..35a6776 100644 --- a/build.ps1 +++ b/build.ps1 @@ -217,6 +217,16 @@ function preflight_checks { if (-Not ($VagrantOnly)) { Write-Verbose '[preflight_checks] Checking if packer is installed' check_packer + + # Check Packer Version against known bad + Write-Verbose '[preflight_checks] Checking for bad packer version..' + [System.Version]$PackerVersion = $(& $PackerPath "--version") + [System.Version]$PackerKnownBad = 1.1.2 + + if ($PackerVersion -eq $PackerKnownBad) { + Write-Error 'Packer 1.1.2 is not supported. Please upgrade to a newer version and see https://github.com/hashicorp/packer/issues/5622 for more information.' + break + } } Write-Verbose '[preflight_checks] Checking if vagrant is installed' check_vagrant @@ -255,16 +265,6 @@ function preflight_checks { } Write-Output "You can safely ignore this warning if you are deploying DetectionLab to a different drive." } - - # Check Packer Version against known bad - Write-Verbose '[preflight_checks] Checking for bad packer version..' - [System.Version]$PackerVersion = $(& $PackerPath "--version") - [System.Version]$PackerKnownBad = 1.1.2 - - if ($PackerVersion -eq $PackerKnownBad) { - Write-Error 'Packer 1.1.2 is not supported. Please upgrade to a newer version and see https://github.com/hashicorp/packer/issues/5622 for more information.' - break - } # Ensure the vagrant-reload plugin is installed Write-Verbose '[preflight_checks] Checking if vagrant-reload is installed..' From d7caca1226c0f089aaf9e3cfedfd010a9df272c5 Mon Sep 17 00:00:00 2001 From: Jared Haight <1220886+jaredhaight@users.noreply.github.com> Date: Sat, 31 Mar 2018 12:43:38 -0700 Subject: [PATCH 14/15] Fixes vagrant up for provider vmware_workstation --- build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.ps1 b/build.ps1 index 35a6776..922343b 100644 --- a/build.ps1 +++ b/build.ps1 @@ -321,7 +321,7 @@ function vagrant_up_host { Write-Host "Attempting to bring up the $VagrantHost host using Vagrant" $CurrentDir = Get-Location Set-Location "$DL_DIR\Vagrant" - &vagrant.exe @('up', $VagrantHost, '--provider', "$Provider") + &vagrant.exe @('up', $VagrantHost, '--provider', "$ProviderName") Set-Location $CurrentDir Write-Verbose "[vagrant_up_host] Finished for $VagrantHost. Got exit code: $LASTEXITCODE" return $LASTEXITCODE From 8651397c633806b564221aa47398aebd9a1b3b6b Mon Sep 17 00:00:00 2001 From: Jared Haight <1220886+jaredhaight@users.noreply.github.com> Date: Sat, 31 Mar 2018 13:19:24 -0700 Subject: [PATCH 15/15] starting to work on returing to DL_DIR on exit --- build.ps1 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/build.ps1 b/build.ps1 index 922343b..ec8db21 100644 --- a/build.ps1 +++ b/build.ps1 @@ -54,6 +54,14 @@ Param( $DL_DIR = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition $LAB_HOSTS = ('logger', 'dc', 'wef', 'win10') +# Register-EngineEvent PowerShell.Exiting -SupportEvent -Action { +# Set-Location $DL_DIR +# } + +# Register-ObjectEvent -InputObject ([System.Console]) -EventName CancelKeyPress -Action { +# Set-Location $DL_DIR +# } + function install_checker { param( [string]$Name