-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
79d2559
commit 3586f2b
Showing
3 changed files
with
23 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -386,25 +386,38 @@ function Install-ContainerD { | |
Start-Job -Name containerd -ScriptBlock { containerd.exe } | ||
} | ||
|
||
function Reapply-Long-Term-Update { | ||
Install-Module -Name PSWindowsUpdate -Force -Scope CurrentUser | ||
Import-Module PSWindowsUpdate | ||
Get-WindowsUpdate | Where-Object {$_.Title -match "Cumulative Update"} | Install-WindowsUpdate -AcceptAll -AutoReboo | ||
} | ||
|
||
function Install-OpenSSH { | ||
Write-Log "Installing OpenSSH Server" | ||
|
||
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 | ||
|
||
# It’s by design that files within the C:\Windows\System32\ folder are not modifiable. | ||
# When the OpenSSH Server starts, it copies C:\windows\system32\openssh\sshd_config_default to C:\programdata\ssh\sshd_config, if the file does not already exist. | ||
$OriginalConfigPath = "C:\windows\system32\OpenSSH\sshd_config_default" | ||
$ConfigPath = "C:\programdata\ssh\sshd_config" | ||
$ConfigDirectory = "C:\programdata\ssh" | ||
New-Item -ItemType Directory -Force -Path $ConfigDirectory | ||
$ConfigPath = $ConfigDirectory + "\sshd_config" | ||
Write-Log "Updating $ConfigPath for CVE-2023-48795" | ||
$ModifiedConfigContents = Get-Content $OriginalConfigPath ` | ||
| %{$_ -replace "#RekeyLimit default none", "$&`r`n# Disable cipher to mitigate CVE-2023-48795`r`nCiphers [email protected]`r`nMacs -*[email protected]`r`n"} | ||
Write-Log "Updating $ConfigPath for CVE-2006-5051" | ||
$ModifiedConfigContents = $ModifiedConfigContents.Replace("#LoginGraceTime 2m", "LoginGraceTime 0") | ||
Stop-Service sshd | ||
Out-File -FilePath $ConfigPath -InputObject $ModifiedConfigContents -Encoding UTF8 | ||
Start-Service sshd | ||
Write-Log "Updated $ConfigPath for CVEs" | ||
} | ||
|
||
function Start-OpenSSH { | ||
Start-Service sshd | ||
Write-Log "Started SSHd" | ||
} | ||
|
||
function Install-WindowsPatches { | ||
Write-Log "Installing Windows patches" | ||
Write-Log "The length of patchUrls is $($patchUrls.Length)" | ||
|
@@ -476,6 +489,8 @@ function Update-WindowsFeatures { | |
Write-Log "Enabling Windows feature: $feature" | ||
Install-WindowsFeature $feature | ||
} | ||
|
||
Reapply-Long-Term-Update | ||
} | ||
|
||
function Enable-WindowsFixInFeatureManagement { | ||
|
@@ -906,11 +921,13 @@ try{ | |
Log-ReofferUpdate | ||
Install-OpenSSH | ||
Log-ReofferUpdate | ||
Install-WindowsPatches | ||
Update-WindowsFeatures | ||
Log-ReofferUpdate | ||
Install-WindowsPatches | ||
} | ||
"2" { | ||
Write-Log "Performing actions for provisioning phase 2" | ||
Start-OpenSSH | ||
Log-ReofferUpdate | ||
Set-WinRmServiceAutoStart | ||
Install-ContainerD | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters