From bd6c3520f3ca9bb62eea02b10b1a13007a1b3663 Mon Sep 17 00:00:00 2001 From: Chris Long Date: Sat, 23 Jun 2018 23:27:23 -0700 Subject: [PATCH 1/3] Update Win10 to 1804 & Fixes --- .gitignore | 2 +- Packer/scripts/MakeWindows10GreatAgain.ps1 | 12 +++-- Packer/scripts/MakeWindows10GreatAgain.reg | 6 ++- Packer/scripts/debloat-windows.ps1 | 3 -- Packer/scripts/enable-winrm.ps1 | 3 +- Packer/scripts/vm-guest-tools.bat | 5 ++- Packer/windows_10.json | 6 +-- Vagrant/Vagrantfile | 44 ++++++++++++++++--- Vagrant/bootstrap.sh | 23 ++++++++-- Vagrant/scripts/configure-wef-gpo.ps1 | 6 +-- Vagrant/scripts/download_palantir_osquery.ps1 | 5 ++- Vagrant/scripts/download_palantir_wef.ps1 | 2 +- Vagrant/scripts/fix-second-network.ps1 | 13 +++--- .../scripts/install-autorunstowineventlog.ps1 | 5 +-- Vagrant/scripts/install-caldera-agent.ps1 | 11 ++--- Vagrant/scripts/install-splunkuf.ps1 | 8 ++-- Vagrant/scripts/install-sysinternals.ps1 | 23 +++++++--- Vagrant/scripts/install-utilities.ps1 | 39 +++++++++------- build.sh | 3 +- 19 files changed, 145 insertions(+), 74 deletions(-) diff --git a/.gitignore b/.gitignore index a5307ee..12f9c20 100755 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ Vagrant/.vagrant/* -Vagrant/vagrant_build.log +Vagrant/vagrant*.log Packer/packer_cache/* Packer/packer_build.log Boxes/* diff --git a/Packer/scripts/MakeWindows10GreatAgain.ps1 b/Packer/scripts/MakeWindows10GreatAgain.ps1 index 8706268..16313f1 100644 --- a/Packer/scripts/MakeWindows10GreatAgain.ps1 +++ b/Packer/scripts/MakeWindows10GreatAgain.ps1 @@ -3,10 +3,6 @@ Write-Host "Making Windows 10 Great again" Write-Host "Importing registry keys..." regedit /s a:\MakeWindows10GreatAgain.reg -# Install Powershell Help items -Write-Host "Updating Powershell Help Library..." -Update-Help - # Remove OneDrive from the System Write-Host "Removing OneDrive..." $onedrive = Get-Process onedrive -ErrorAction SilentlyContinue @@ -14,3 +10,11 @@ if ($onedrive) { taskkill /f /im OneDrive.exe } c:\Windows\SysWOW64\OneDriveSetup.exe /uninstall + +Update-Help -Force -ErrorAction SilentlyContinue + +# Remove Microsoft Store and Edge shortcuts from the taskbar +$appname = "Microsoft Edge" +((New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ?{$_.Name -eq $appname}).Verbs() | ?{$_.Name.replace('&','') -match 'Unpin from taskbar'} | %{$_.DoIt(); $exec = $true} +$appname = "Microsoft Store" +((New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ?{$_.Name -eq $appname}).Verbs() | ?{$_.Name.replace('&','') -match 'Unpin from taskbar'} | %{$_.DoIt(); $exec = $true} diff --git a/Packer/scripts/MakeWindows10GreatAgain.reg b/Packer/scripts/MakeWindows10GreatAgain.reg index 503d399..e8ed2d4 100644 --- a/Packer/scripts/MakeWindows10GreatAgain.reg +++ b/Packer/scripts/MakeWindows10GreatAgain.reg @@ -36,10 +36,14 @@ Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel] "{20D04FE0-3AEA-1069-A2D8-08002B30309D}"=dword:00000000 - + [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu] "{20D04FE0-3AEA-1069-A2D8-08002B30309D}"=dword:00000000 # Enable Developer Mode (prerequisite for Linux subsystem) [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock] "AllowDevelopmentWithoutDevLicense"=dword:00000001 + +# Disable Microsoft People icon from taskbar +[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People] +"PeopleBand"=dword:00000000 diff --git a/Packer/scripts/debloat-windows.ps1 b/Packer/scripts/debloat-windows.ps1 index 686943c..bae63da 100755 --- a/Packer/scripts/debloat-windows.ps1 +++ b/Packer/scripts/debloat-windows.ps1 @@ -14,9 +14,6 @@ if ($env:PACKER_BUILDER_TYPE -And $($env:PACKER_BUILDER_TYPE).startsWith("hyperv #. $env:TEMP\Debloat-Windows-10-master\scripts\block-telemetry.ps1 #Write-Host Disable services #. $env:TEMP\Debloat-Windows-10-master\scripts\disable-services.ps1 - Write-host Disable Windows Defender - #. $env:TEMP\Debloat-Windows-10-master\scripts\disable-windows-defender.ps1 - Uninstall-WindowsFeature Windows-Defender-Features Write-host Optimize Windows Update . $env:TEMP\Debloat-Windows-10-master\scripts\optimize-windows-update.ps1 #Write-host Disable Windows Update diff --git a/Packer/scripts/enable-winrm.ps1 b/Packer/scripts/enable-winrm.ps1 index c0c7587..b294cd3 100755 --- a/Packer/scripts/enable-winrm.ps1 +++ b/Packer/scripts/enable-winrm.ps1 @@ -9,5 +9,6 @@ winrm set winrm/config/client/auth '@{Basic="true"}' winrm set winrm/config/listener?Address=*+Transport=HTTP '@{Port="5985"}' netsh advfirewall firewall set rule group="Windows Remote Administration" new enable=yes netsh advfirewall firewall set rule name="Windows Remote Management (HTTP-In)" new enable=yes action=allow -Set-Service winrm -startuptype "auto" +sc config winrm start= disabled +reg add HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce /v StartWinRM /t REG_SZ /f /d "cmd.exe /c 'sc config winrm start= auto & sc start winrm'" Restart-Service winrm diff --git a/Packer/scripts/vm-guest-tools.bat b/Packer/scripts/vm-guest-tools.bat index cd33b74..137d4da 100755 --- a/Packer/scripts/vm-guest-tools.bat +++ b/Packer/scripts/vm-guest-tools.bat @@ -1,6 +1,9 @@ if not exist "C:\Windows\Temp\7z920-x64.msi" ( powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://www.7-zip.org/a/7z920-x64.msi', 'C:\Windows\Temp\7z920-x64.msi')" &2 "Attempting to bring up the $HOST host using Vagrant") cd "$DL_DIR"/Vagrant || exit 1 - VAGRANT_LOG=info $(which vagrant) up "$HOST" --provider="$PROVIDER" 3>&1 1>&2 2>&3 | tee -a "$DL_DIR/Vagrant/vagrant_build.log" + $(which vagrant) up "$HOST" --provider="$PROVIDER" 2> "$DL_DIR/Vagrant/vagrant_up_$HOST.log" echo "$?" } @@ -373,6 +373,7 @@ choose_md5_tool() { # Downloads pre-built Packer boxes from detectionlab.network to save time during CI builds download_boxes() { + choose_md5_tool if [ "$PROVIDER" == "virtualbox" ]; then wget "https://www.detectionlab.network/windows_2016_virtualbox.box" -O "$DL_DIR"/Boxes/windows_2016_virtualbox.box wget "https://www.detectionlab.network/windows_10_virtualbox.box" -O "$DL_DIR"/Boxes/windows_10_virtualbox.box From 4ac14cb432248d4a07c4a3136cc28618375d2c4d Mon Sep 17 00:00:00 2001 From: Chris Long Date: Sun, 24 Jun 2018 13:29:13 -0700 Subject: [PATCH 2/3] Fixing 7zip download and packer build ordering --- Packer/scripts/vm-guest-tools.bat | 4 ++-- Packer/windows_10.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Packer/scripts/vm-guest-tools.bat b/Packer/scripts/vm-guest-tools.bat index 137d4da..aa1a74d 100755 --- a/Packer/scripts/vm-guest-tools.bat +++ b/Packer/scripts/vm-guest-tools.bat @@ -1,8 +1,8 @@ if not exist "C:\Windows\Temp\7z920-x64.msi" ( - powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://www.7-zip.org/a/7z920-x64.msi', 'C:\Windows\Temp\7z920-x64.msi')" Date: Tue, 26 Jun 2018 23:48:11 -0700 Subject: [PATCH 3/3] Adding some small fixes --- Packer/scripts/debloat-windows.ps1 | 3 +++ Packer/scripts/vm-guest-tools.bat | 7 ++++++- Vagrant/Vagrantfile | 3 ++- Vagrant/scripts/configure-ou.ps1 | 7 +++---- Vagrant/scripts/fix-second-network.ps1 | 8 +++----- Vagrant/scripts/install-sysinternals.ps1 | 21 ++++++++++++--------- 6 files changed, 29 insertions(+), 20 deletions(-) diff --git a/Packer/scripts/debloat-windows.ps1 b/Packer/scripts/debloat-windows.ps1 index bae63da..686943c 100755 --- a/Packer/scripts/debloat-windows.ps1 +++ b/Packer/scripts/debloat-windows.ps1 @@ -14,6 +14,9 @@ if ($env:PACKER_BUILDER_TYPE -And $($env:PACKER_BUILDER_TYPE).startsWith("hyperv #. $env:TEMP\Debloat-Windows-10-master\scripts\block-telemetry.ps1 #Write-Host Disable services #. $env:TEMP\Debloat-Windows-10-master\scripts\disable-services.ps1 + Write-host Disable Windows Defender + #. $env:TEMP\Debloat-Windows-10-master\scripts\disable-windows-defender.ps1 + Uninstall-WindowsFeature Windows-Defender-Features Write-host Optimize Windows Update . $env:TEMP\Debloat-Windows-10-master\scripts\optimize-windows-update.ps1 #Write-host Disable Windows Update diff --git a/Packer/scripts/vm-guest-tools.bat b/Packer/scripts/vm-guest-tools.bat index aa1a74d..35a4860 100755 --- a/Packer/scripts/vm-guest-tools.bat +++ b/Packer/scripts/vm-guest-tools.bat @@ -18,7 +18,7 @@ if exist "C:\Users\vagrant\windows.iso" ( ) if not exist "C:\Windows\Temp\windows.iso" ( - powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://softwareupdate.vmware.com/cds/vmw-desktop/ws/14.1.1/7528167/windows/packages/tools-windows.tar', 'C:\Windows\Temp\vmware-tools.tar')" NUL +IF ERRORLEVEL 1060 cmd /c C:\Windows\Temp\VMWare\setup.exe /S /v"/qn REBOOT=R\" +sc query vmtools > NUL +IF ERRORLEVEL 1060 ECHO "Unable to install VMware Tools." & exit /b 1 + rd /Q "C:\Windows\Temp\vmware-tools.tar" rd /Q "C:\Windows\Temp\windows.iso" rd /S /Q "C:\Windows\Temp\VMware" diff --git a/Vagrant/Vagrantfile b/Vagrant/Vagrantfile index d268b86..722ef4f 100644 --- a/Vagrant/Vagrantfile +++ b/Vagrant/Vagrantfile @@ -31,7 +31,7 @@ Vagrant.configure("2") do |config| config.vm.define "dc" do |cfg| cfg.vm.box = "../Boxes/windows_2016_virtualbox.box" cfg.vm.hostname = "dc" - + cfg.vm.boot_timeout = 600 # use the plaintext WinRM transport and force it to use basic authentication. # NB this is needed because the default negotiate transport stops working # after the domain controller is installed. @@ -89,6 +89,7 @@ Vagrant.configure("2") do |config| config.vm.define "wef" do |cfg| cfg.vm.box = "../Boxes/windows_2016_virtualbox.box" cfg.vm.hostname = "wef" + cfg.vm.boot_timeout = 600 cfg.vm.communicator = "winrm" cfg.winrm.basic_auth_only = true cfg.winrm.timeout = 300 diff --git a/Vagrant/scripts/configure-ou.ps1 b/Vagrant/scripts/configure-ou.ps1 index 07ae82f..dc4e589 100644 --- a/Vagrant/scripts/configure-ou.ps1 +++ b/Vagrant/scripts/configure-ou.ps1 @@ -1,9 +1,8 @@ # Purpose: Sets up the Server and Workstations OUs -Write-Host "Sleeping for 30 seconds, then creating Server and Workstation OUs" -Start-Sleep 30 -Write-Host "Creating Servers OU" +Write-Host "Creating Server and Workstation OUs..." +Write-Host "Creating Servers OU..." if (!([ADSI]::Exists("LDAP://OU=Servers,DC=windomain,DC=local"))) -{ +{ New-ADOrganizationalUnit -Name "Servers" -Server "dc.windomain.local" } else diff --git a/Vagrant/scripts/fix-second-network.ps1 b/Vagrant/scripts/fix-second-network.ps1 index d716ae7..a032d15 100755 --- a/Vagrant/scripts/fix-second-network.ps1 +++ b/Vagrant/scripts/fix-second-network.ps1 @@ -5,24 +5,22 @@ if (! (Test-Path 'C:\Program Files\VMware\VMware Tools')) { Write-Host "Nothing to do for other providers than VMware." exit 0 } -Write-Host "Setting IP address and DNS information for the second network adapter" +Write-Host "Setting IP address and DNS information for the Ethernet1 interface" +Write-Host "If this step times out, it's because vagrant is connecting to the VM on the wrong interface" +Write-Host "See https://github.com/clong/DetectionLab/issues/114 for more information" $subnet = $ip -replace "\.\d+$", "" -write-host "debug 1" $name = (Get-NetIPAddress -AddressFamily IPv4 ` | Where-Object -FilterScript { ($_.IPAddress).StartsWith($subnet) } ` ).InterfaceAlias -write-host "debug 2" if (!$name) { $name = (Get-NetIPAddress -AddressFamily IPv4 ` | Where-Object -FilterScript { ($_.IPAddress).StartsWith("169.254.") } ` ).InterfaceAlias } -write-host "debug 3" if ($name) { Write-Host "Set IP address to $ip of interface $name" & netsh.exe int ip set address "$name" static $ip 255.255.255.0 "$subnet.1" -write-host "debug 4" if ($dns) { Write-Host "Set DNS server address to $dns of interface $name" & netsh.exe interface ipv4 add dnsserver "$name" address=$dns index=1 diff --git a/Vagrant/scripts/install-sysinternals.ps1 b/Vagrant/scripts/install-sysinternals.ps1 index 20695d3..00df8c5 100755 --- a/Vagrant/scripts/install-sysinternals.ps1 +++ b/Vagrant/scripts/install-sysinternals.ps1 @@ -24,25 +24,28 @@ $sysmonPath = "C:\Tools\Sysinternals\Sysmon64.exe" $tcpviewPath = "C:\Tools\Sysinternals\Tcpview.exe" $sysmonConfigPath = "$sysmonDir\sysmonConfig.xml" + +# Microsoft likes TLSv1.2 as well +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 Write-Host "Downloading Autoruns64.exe..." -Invoke-WebRequest -Uri "https://live.sysinternals.com/Autoruns64.exe" -OutFile $autorunsPath +(New-Object System.Net.WebClient).DownloadFile('https://live.sysinternals.com/Autoruns64.exe', $autorunsPath) Write-Host "Downloading Procmon.exe..." -Invoke-WebRequest -Uri "https://live.sysinternals.com/Procmon.exe" -OutFile $procmonPath +(New-Object System.Net.WebClient).DownloadFile('https://live.sysinternals.com/Procmon.exe', $procmonPath) Write-Host "Downloading PsExec64.exe..." -Invoke-WebRequest -Uri "https://live.sysinternals.com/PsExec64.exe" -OutFile $psexecPath +(New-Object System.Net.WebClient).DownloadFile('https://live.sysinternals.com/PsExec64.exe', $psexecPath) Write-Host "Downloading procexp64.exe..." -Invoke-WebRequest -Uri "https://live.sysinternals.com/procexp64.exe" -OutFile $procexpPath +(New-Object System.Net.WebClient).DownloadFile('https://live.sysinternals.com/procexp64.exe', $procexpPath) Write-Host "Downloading Sysmon64.exe..." -Invoke-WebRequest -Uri "https://live.sysinternals.com/Sysmon64.exe" -Outfile $sysmonPath +(New-Object System.Net.WebClient).DownloadFile('https://live.sysinternals.com/Sysmon64.exe', $sysmonPath) Write-Host "Downloading Tcpview.exe..." -Invoke-WebRequest -Uri "https://live.sysinternals.com/Tcpview.exe" -Outfile $tcpviewPath +(New-Object System.Net.WebClient).DownloadFile('https://live.sysinternals.com/Tcpview.exe', $tcpviewPath) Copy-Item $sysmonPath $sysmonDir # Download SwiftOnSecurity's Sysmon config Write-Host "Downloading SwiftOnSecurity's Sysmon config..." -Invoke-WebRequest -Uri "https://raw.githubusercontent.com/SwiftOnSecurity/sysmon-config/master/sysmonconfig-export.xml" -Outfile "$sysmonConfigPath" -# Alternative: Download Olaf Hartong's Sysmon config (more CPU intensive) -#Invoke-WebRequest -Uri "https://raw.githubusercontent.com/olafhartong/sysmon-modular/master/sysmonconfig.xml" -Outfile "$sysmonConfigPath" +(New-Object System.Net.WebClient).DownloadFile('https://raw.githubusercontent.com/SwiftOnSecurity/sysmon-config/master/sysmonconfig-export.xml', "$sysmonConfigPath") +# Alternative: Download Olaf Hartongs Sysmon config (more CPU intensive) +# (New-Object System.Net.WebClient).DownloadFile('https://raw.githubusercontent.com/olafhartong/sysmon-modular/master/sysmonconfig.xml, "$sysmonConfigPath" # Start Sysmon Write-Host "Starting Sysmon..."