mirror of
https://github.com/rapid7/metasploitable3.git
synced 2024-09-21 00:01:14 +02:00
download windows pre-req files using the host OS
Many pre-req file have moved to require TLS 1.2, to address this downloading these files in the host system will allows this requirement to be meet even when the guest OS being built does not yet support TLS 1.2. * downloads dotnet and wmf from a provisioner run by the host OS * updates dotnet to 4.5.2 * update wmf for powershell 5.1 * adjust install process for wmf to run as SYSTEM * moves boxstarter and Ruby install into the chocolatey_installs path Furhter work should be done to validate the downlaod hash and support caching downloads instead of force each build to download again. This does not remove the need for downloads by chocolatey when preforming those installs.
This commit is contained in:
parent
2dadd8c585
commit
fe91dcbf67
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,6 +2,7 @@
|
||||||
packer_cache/
|
packer_cache/
|
||||||
packer/builds/
|
packer/builds/
|
||||||
resources/drivers/
|
resources/drivers/
|
||||||
|
resources/windows_pre_downloads/
|
||||||
*.vfd
|
*.vfd
|
||||||
*.exe
|
*.exe
|
||||||
*.msi
|
*.msi
|
||||||
|
|
|
@ -261,16 +261,6 @@
|
||||||
<CommandLine>cmd.exe /c mkdir -p C:\vagrant\scripts</CommandLine>
|
<CommandLine>cmd.exe /c mkdir -p C:\vagrant\scripts</CommandLine>
|
||||||
<Description>Create directory for vagrant files to avoid provisioner bug with packer.</Description>
|
<Description>Create directory for vagrant files to avoid provisioner bug with packer.</Description>
|
||||||
<Order>26</Order>
|
<Order>26</Order>
|
||||||
</SynchronousCommand>
|
|
||||||
<SynchronousCommand wcm:action="add">
|
|
||||||
<CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\install_dotnet45.ps1 -AutoStart</CommandLine>
|
|
||||||
<Order>97</Order>
|
|
||||||
<Description>Install .NET 4.5.1</Description>
|
|
||||||
</SynchronousCommand>
|
|
||||||
<SynchronousCommand wcm:action="add">
|
|
||||||
<CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\install_wmf.ps1 -AutoStart</CommandLine>
|
|
||||||
<Order>98</Order>
|
|
||||||
<Description>Installing Windows Management Framework 5.0</Description>
|
|
||||||
</SynchronousCommand>
|
</SynchronousCommand>
|
||||||
<!--WITHOUT WINDOWS UPDATES -->
|
<!--WITHOUT WINDOWS UPDATES -->
|
||||||
<SynchronousCommand wcm:action="add">
|
<SynchronousCommand wcm:action="add">
|
||||||
|
|
|
@ -18,8 +18,6 @@
|
||||||
"{{user `scripts_dir`}}/configs/microsoft-updates.bat",
|
"{{user `scripts_dir`}}/configs/microsoft-updates.bat",
|
||||||
"{{user `scripts_dir`}}/configs/win-updates.ps1",
|
"{{user `scripts_dir`}}/configs/win-updates.ps1",
|
||||||
"{{user `scripts_dir`}}/installs/openssh.ps1",
|
"{{user `scripts_dir`}}/installs/openssh.ps1",
|
||||||
"{{user `scripts_dir`}}/installs/install_dotnet45.ps1",
|
|
||||||
"{{user `scripts_dir`}}/installs/install_wmf.ps1",
|
|
||||||
"{{user `resources_dir`}}/certs/oracle-cert.cer",
|
"{{user `resources_dir`}}/certs/oracle-cert.cer",
|
||||||
"{{user `resources_dir`}}/certs/gdig2.crt",
|
"{{user `resources_dir`}}/certs/gdig2.crt",
|
||||||
"{{user `resources_dir`}}/certs/comodorsadomainvalidationsecureserverca.crt",
|
"{{user `resources_dir`}}/certs/comodorsadomainvalidationsecureserverca.crt",
|
||||||
|
@ -56,8 +54,6 @@
|
||||||
"{{user `scripts_dir`}}/configs/microsoft-updates.bat",
|
"{{user `scripts_dir`}}/configs/microsoft-updates.bat",
|
||||||
"{{user `scripts_dir`}}/configs/win-updates.ps1",
|
"{{user `scripts_dir`}}/configs/win-updates.ps1",
|
||||||
"{{user `scripts_dir`}}/installs/openssh.ps1",
|
"{{user `scripts_dir`}}/installs/openssh.ps1",
|
||||||
"{{user `scripts_dir`}}/installs/install_dotnet45.ps1",
|
|
||||||
"{{user `scripts_dir`}}/installs/install_wmf.ps1",
|
|
||||||
"{{user `resources_dir`}}/certs/oracle-cert.cer",
|
"{{user `resources_dir`}}/certs/oracle-cert.cer",
|
||||||
"{{user `resources_dir`}}/certs/gdig2.crt",
|
"{{user `resources_dir`}}/certs/gdig2.crt",
|
||||||
"{{user `resources_dir`}}/certs/comodorsadomainvalidationsecureserverca.crt",
|
"{{user `resources_dir`}}/certs/comodorsadomainvalidationsecureserverca.crt",
|
||||||
|
@ -99,8 +95,6 @@
|
||||||
"{{user `scripts_dir`}}/configs/microsoft-updates.bat",
|
"{{user `scripts_dir`}}/configs/microsoft-updates.bat",
|
||||||
"{{user `scripts_dir`}}/configs/win-updates.ps1",
|
"{{user `scripts_dir`}}/configs/win-updates.ps1",
|
||||||
"{{user `scripts_dir`}}/installs/openssh.ps1",
|
"{{user `scripts_dir`}}/installs/openssh.ps1",
|
||||||
"{{user `scripts_dir`}}/installs/install_dotnet45.ps1",
|
|
||||||
"{{user `scripts_dir`}}/installs/install_wmf.ps1",
|
|
||||||
"{{user `resources_dir`}}/certs/oracle-cert.cer",
|
"{{user `resources_dir`}}/certs/oracle-cert.cer",
|
||||||
"{{user `resources_dir`}}/certs/gdig2.crt",
|
"{{user `resources_dir`}}/certs/gdig2.crt",
|
||||||
"{{user `resources_dir`}}/certs/comodorsadomainvalidationsecureserverca.crt",
|
"{{user `resources_dir`}}/certs/comodorsadomainvalidationsecureserverca.crt",
|
||||||
|
@ -150,8 +144,6 @@
|
||||||
"{{user `scripts_dir`}}/configs/microsoft-updates.bat",
|
"{{user `scripts_dir`}}/configs/microsoft-updates.bat",
|
||||||
"{{user `scripts_dir`}}/configs/win-updates.ps1",
|
"{{user `scripts_dir`}}/configs/win-updates.ps1",
|
||||||
"{{user `scripts_dir`}}/installs/openssh.ps1",
|
"{{user `scripts_dir`}}/installs/openssh.ps1",
|
||||||
"{{user `scripts_dir`}}/installs/install_dotnet45.ps1",
|
|
||||||
"{{user `scripts_dir`}}/installs/install_wmf.ps1",
|
|
||||||
"{{user `resources_dir`}}/certs/oracle-cert.cer",
|
"{{user `resources_dir`}}/certs/oracle-cert.cer",
|
||||||
"{{user `resources_dir`}}/certs/gdig2.crt",
|
"{{user `resources_dir`}}/certs/gdig2.crt",
|
||||||
"{{user `resources_dir`}}/certs/comodorsadomainvalidationsecureserverca.crt",
|
"{{user `resources_dir`}}/certs/comodorsadomainvalidationsecureserverca.crt",
|
||||||
|
@ -184,6 +176,16 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"provisioners": [
|
"provisioners": [
|
||||||
|
{
|
||||||
|
"type": "shell-local",
|
||||||
|
"only_on": ["linux", "darwin"],
|
||||||
|
"inline": ["cd {{user `resources_dir`}} && {{user `resources_dir`}}/download-windows-files.sh"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "shell-local",
|
||||||
|
"only_on": ["windows"],
|
||||||
|
"inline": ["cd {{user `resources_dir`}} && powershell {{user `resources_dir`}}/download-windows-files.ps1"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"source": "{{user `scripts_dir`}}",
|
"source": "{{user `scripts_dir`}}",
|
||||||
|
@ -200,7 +202,6 @@
|
||||||
"execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
|
"execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
|
||||||
"scripts": [
|
"scripts": [
|
||||||
"{{user `scripts_dir`}}/configs/update_root_certs.bat",
|
"{{user `scripts_dir`}}/configs/update_root_certs.bat",
|
||||||
"{{user `scripts_dir`}}/configs/disable-auto-logon.bat",
|
|
||||||
"{{user `scripts_dir`}}/configs/enable-rdp.bat"
|
"{{user `scripts_dir`}}/configs/enable-rdp.bat"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -215,6 +216,25 @@
|
||||||
{
|
{
|
||||||
"type": "windows-restart"
|
"type": "windows-restart"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "powershell",
|
||||||
|
"scripts": [
|
||||||
|
"{{user `scripts_dir`}}/installs/install_dotnet45.ps1"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "windows-restart"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "powershell",
|
||||||
|
"scripts": [
|
||||||
|
"{{user `scripts_dir`}}/installs/install_wmf.ps1"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "windows-restart",
|
||||||
|
"pause_before": "180s"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "powershell",
|
"type": "powershell",
|
||||||
"scripts": [
|
"scripts": [
|
||||||
|
@ -240,7 +260,9 @@
|
||||||
"remote_path": "C:/Windows/Temp/script.bat",
|
"remote_path": "C:/Windows/Temp/script.bat",
|
||||||
"execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
|
"execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
|
||||||
"scripts": [
|
"scripts": [
|
||||||
"{{user `scripts_dir`}}/installs/install_boxstarter.bat",
|
"{{user `scripts_dir`}}/configs/disable-auto-logon.bat",
|
||||||
|
"{{user `scripts_dir`}}/chocolatey_installs/chocolatey-compatibility.bat",
|
||||||
|
"{{user `scripts_dir`}}/chocolatey_installs/boxstarter.bat",
|
||||||
"{{user `scripts_dir`}}/chocolatey_installs/7zip.bat",
|
"{{user `scripts_dir`}}/chocolatey_installs/7zip.bat",
|
||||||
"{{user `scripts_dir`}}/configs/apply_password_settings.bat",
|
"{{user `scripts_dir`}}/configs/apply_password_settings.bat",
|
||||||
"{{user `scripts_dir`}}/configs/create_users.bat",
|
"{{user `scripts_dir`}}/configs/create_users.bat",
|
||||||
|
@ -267,7 +289,7 @@
|
||||||
"{{user `scripts_dir`}}/installs/install_wordpress.bat",
|
"{{user `scripts_dir`}}/installs/install_wordpress.bat",
|
||||||
"{{user `scripts_dir`}}/installs/install_openjdk6.bat",
|
"{{user `scripts_dir`}}/installs/install_openjdk6.bat",
|
||||||
"{{user `scripts_dir`}}/installs/setup_jmx.bat",
|
"{{user `scripts_dir`}}/installs/setup_jmx.bat",
|
||||||
"{{user `scripts_dir`}}/installs/install_ruby.bat",
|
"{{user `scripts_dir`}}/chocolatey_installs/ruby.bat",
|
||||||
"{{user `scripts_dir`}}/installs/install_devkit.bat"
|
"{{user `scripts_dir`}}/installs/install_devkit.bat"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
23
resources/download-windows-files.ps1
Normal file
23
resources/download-windows-files.ps1
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
$Logfile = "C:\Windows\Temp\wmf-install.log"
|
||||||
|
function LogWrite {
|
||||||
|
Param ([string]$logstring)
|
||||||
|
$now = Get-Date -format s
|
||||||
|
Add-Content $Logfile -value "$now $logstring"
|
||||||
|
Write-Host $logstring
|
||||||
|
}
|
||||||
|
|
||||||
|
LogWrite "Downloading dotNet 4.5.2"
|
||||||
|
try {
|
||||||
|
(New-Object System.Net.WebClient).DownloadFile('https://download.microsoft.com/download/E/2/1/E21644B5-2DF2-47C2-91BD-63C560427900/NDP452-KB2901907-x86-x64-AllOS-ENU.exe', 'windows_pre_downloads/dotnet.exe')
|
||||||
|
} catch {
|
||||||
|
LogWrite $_.Exception | Format-List -force
|
||||||
|
LogWrite "Failed to download file."
|
||||||
|
}
|
||||||
|
|
||||||
|
LogWrite "Downloading Windows Management Framework 5.1"
|
||||||
|
try {
|
||||||
|
(New-Object System.Net.WebClient).DownloadFile('https://download.microsoft.com/download/6/F/5/6F5FF66C-6775-42B0-86C4-47D41F2DA187/Win7AndW2K8R2-KB3191566-x64.zip', 'windows_pre_downloads/wmf.zip')
|
||||||
|
} catch {
|
||||||
|
LogWrite $_.Exception | Format-List -force
|
||||||
|
LogWrite "Failed to download file."
|
||||||
|
}
|
3
resources/download-windows-files.sh
Executable file
3
resources/download-windows-files.sh
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash -e
|
||||||
|
curl -L --output windows_pre_downloads/dotnet.exe https://download.microsoft.com/download/E/2/1/E21644B5-2DF2-47C2-91BD-63C560427900/NDP452-KB2901907-x86-x64-AllOS-ENU.exe
|
||||||
|
curl -L --output windows_pre_downloads/wmf.zip https://download.microsoft.com/download/6/F/5/6F5FF66C-6775-42B0-86C4-47D41F2DA187/Win7AndW2K8R2-KB3191566-x64.zip
|
0
resources/windows_pre_downloads/.gitkeep
Normal file
0
resources/windows_pre_downloads/.gitkeep
Normal file
4
scripts/chocolatey_installs/chocolatey-compatibility.bat
Normal file
4
scripts/chocolatey_installs/chocolatey-compatibility.bat
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
chocolatey feature enable -n=allowGlobalConfirmation
|
||||||
|
choco install chocolatey-compatibility.extension
|
||||||
|
chocolatey feature disable -n=allowGlobalConfirmation
|
||||||
|
exit
|
|
@ -1 +0,0 @@
|
||||||
@powershell -NoProfile -ExecutionPolicy Bypass -File "%systemdrive%\vagrant\scripts\installs\install_chocolatey.ps1"
|
|
|
@ -40,6 +40,10 @@ function Invoke-CLR4PowerShellCommand {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(Test-Path -Path $PROFILE)) {
|
||||||
|
New-Item -ItemType File -Path $PROFILE -Force
|
||||||
|
}
|
||||||
|
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
Set-StrictMode -Version Latest
|
Set-StrictMode -Version Latest
|
||||||
|
|
||||||
|
|
|
@ -6,17 +6,9 @@ function LogWrite {
|
||||||
Write-Host $logstring
|
Write-Host $logstring
|
||||||
}
|
}
|
||||||
|
|
||||||
LogWrite "Downloading dotNet 4.5.1"
|
|
||||||
try {
|
|
||||||
(New-Object System.Net.WebClient).DownloadFile('http://download.microsoft.com/download/1/6/7/167F0D79-9317-48AE-AEDB-17120579F8E2/NDP451-KB2858728-x86-x64-AllOS-ENU.exe', 'C:\Windows\Temp\dotnet.exe')
|
|
||||||
} catch {
|
|
||||||
LogWrite $_.Exception | Format-List -force
|
|
||||||
LogWrite "Failed to download file."
|
|
||||||
}
|
|
||||||
|
|
||||||
LogWrite "Starting installation process..."
|
LogWrite "Starting installation process..."
|
||||||
try {
|
try {
|
||||||
Start-Process -FilePath "C:\Windows\Temp\dotnet.exe" -ArgumentList "/I /q /norestart" -Wait -PassThru
|
Start-Process -FilePath "C:\vagrant\resources\windows_pre_downloads\dotnet.exe" -ArgumentList "/I /q /norestart" -Wait -PassThru
|
||||||
} catch {
|
} catch {
|
||||||
LogWrite $_.Exception | Format-List -force
|
LogWrite $_.Exception | Format-List -force
|
||||||
LogWrite "Exception during install process."
|
LogWrite "Exception during install process."
|
||||||
|
|
|
@ -6,18 +6,30 @@ function LogWrite {
|
||||||
Write-Host $logstring
|
Write-Host $logstring
|
||||||
}
|
}
|
||||||
|
|
||||||
LogWrite "Downloading Windows Management Framework 5.0"
|
|
||||||
try {
|
LogWrite "Extracting Archive..."
|
||||||
(New-Object System.Net.WebClient).DownloadFile('https://download.microsoft.com/download/2/C/6/2C6E1B4A-EBE5-48A6-B225-2D2058A9CEFB/Win7AndW2K8R2-KB3134760-x64.msu', 'C:\Windows\Temp\wmf.msu')
|
|
||||||
} catch {
|
$extractLocation = "C:\vagrant\resources\windows_pre_downloads\wmf_install"
|
||||||
LogWrite $_.Exception | Format-List -force
|
New-Item -Path $extractLocation -ItemType Directory
|
||||||
LogWrite "Failed to download file."
|
|
||||||
|
$shell = New-Object -ComObject shell.application
|
||||||
|
$zip = $shell.NameSpace("C:\vagrant\resources\windows_pre_downloads\wmf.zip")
|
||||||
|
foreach ($item in $zip.items()) {
|
||||||
|
$shell.Namespace($extractLocation).CopyHere($item)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Set-Location -Path $extractLocation -PassThru
|
||||||
|
$installCmd = "powershell.exe -ExecutionPolicy Bypass -Command " + '"' + ${extractLocation} + "\Install-WMF5.1.ps1 -AcceptEula" + '"'
|
||||||
|
|
||||||
LogWrite "Starting installation process..."
|
LogWrite "Starting installation process..."
|
||||||
try {
|
|
||||||
Start-Process -FilePath "wusa.exe" -ArgumentList "C:\Windows\Temp\wmf.msu /quiet /norestart" -Wait -PassThru
|
New-Item C:\vagrant\resources\windows_pre_downloads\wmf_install\install_wmf.bat -ItemType "file"
|
||||||
} catch {
|
Set-Content C:\vagrant\resources\windows_pre_downloads\wmf_install\install_wmf.bat $installCmd
|
||||||
LogWrite $_.Exception | Format-List -force
|
|
||||||
LogWrite "Exception during install process."
|
$Taskname = "updatepsh"
|
||||||
}
|
|
||||||
|
SCHTASKS /CREATE /sc ONCE /st 00:00 /TN $Taskname /RU SYSTEM /RL HIGHEST /TR "C:\vagrant\resources\windows_pre_downloads\wmf_install\install_wmf.bat"
|
||||||
|
schtasks /Run /TN $Taskname
|
||||||
|
start-sleep -s 5
|
||||||
|
schtasks /delete /tn $Taskname /f
|
||||||
|
start-sleep -s 30
|
||||||
|
|
Loading…
Reference in New Issue
Block a user