Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $cve_2023_36602 = wmic qfe list | Select-String -Pattern 'KB5031356'
- $cve_2023_35380 = wmic qfe list | Select-String -Pattern 'KB5029244'
- $url_2023_35380 = 'https://catalog.s.download.windowsupdate.com/c/msdownload/update/software/secu/2023/08/windows10.0-kb5029244-x64_fb8cdde229cf17755c2c890a12e0e8f252dd38c0.msu'
- $url_2023_36602 = 'https://catalog.s.download.windowsupdate.com/d/msdownload/update/software/secu/2023/10/windows10.0-kb5031356-x64_65d5bbc39ccb461472d9854f1a370fe018b79fcc.msu'
- #To get current os version (OS = build + UBR), combine the following
- #$build = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name CurrentBuild).CurrentBuild
- #$ubr = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name UBR).UBR
- #$OSVersion = $build + '.' + $ubr
- if(($cve_2023_36602) -and ($cve_2023_35380)){
- Write-Output "Both hotfixes were found. No need for installation"
- }
- elseif(($cve_2023_36602) -and ($cve_2023_35380 -eq $null)){
- Write-Output "Hotfix for CVE-2023-35380 (KB5029244) wasn't found", "Started downloading msu file"
- New-Item -Path "C:\" -Name "stored_msu" -ItemType Directory
- $folder_path_cve_2023_35380 = "C:\stored_msu\windows10.0-kb5029244-x64_fb8cdde229cf17755c2c890a12e0e8f252dd38c0.msu"
- $ProgressPreference = 'SilentlyContinue'
- Invoke-WebRequest $url_2023_35380 -outfile $folder_path_cve_2023_35380
- Write-Output "Hotfix file downloaded successfully", "Installing hotfix. It might take some time"
- Start-Process -FilePath "wusa.exe" -ArgumentList "C:\stored_msu\windows10.0-kb5029244-x64_fb8cdde229cf17755c2c890a12e0e8f252dd38c0.msu /quiet /norestart" -Wait -PassThru -NoNewWindow
- Write-Output "Done. Please restart your device in order to apply hotfix"
- }
- elseif(($cve_2023_36602 -eq $null) -and ($cve_2023_35380)){
- Write-Output "Hotfix for CVE-2023-36602 (KB5031356) wasn't found", "Started downloading msu file"
- New-Item -Path "C:\" -Name "stored_msu" -ItemType Directory
- $folder_path_cve_2023_36602 = "C:\stored_msu\windows10.0-kb5031356-x64_65d5bbc39ccb461472d9854f1a370fe018b79fcc.msu"
- $ProgressPreference = 'SilentlyContinue'
- Invoke-WebRequest $url_2023_36602 -outfile $folder_path_cve_2023_36602
- Write-Output "Hotfix file downloaded successfully", "Installing hotfix. It might take some time"
- Start-Process -FilePath "wusa.exe" -ArgumentList "C:\stored_msu\windows10.0-kb5031356-x64_65d5bbc39ccb461472d9854f1a370fe018b79fcc.msu /quiet /norestart" -Wait -PassThru -NoNewWindow
- Write-Output "Done. Please restart your device in order to apply hotfix"
- }
- else{
- Write-Output "None of the hotfixes were found", "Started downloading msu files"
- New-Item -Path "C:\" -Name "stored_msu" -ItemType Directory
- $folder_path_cve_2023_35380 = "C:\stored_msu\windows10.0-kb5029244-x64_fb8cdde229cf17755c2c890a12e0e8f252dd38c0.msu"
- $folder_path_cve_2023_36602 = "C:\stored_msu\windows10.0-kb5031356-x64_65d5bbc39ccb461472d9854f1a370fe018b79fcc.msu"
- $ProgressPreference = 'SilentlyContinue'
- Write-Output "Downloading hotfix for CVE-2023-35380"
- Invoke-WebRequest $url_2023_35380 -outfile $folder_path_cve_2023_35380
- Write-Output "Hotfix file downloaded successfully"
- Write-Output "Downloading hotfix for CVE-2023-36602"
- Invoke-WebRequest $url_2023_36602 -outfile $folder_path_cve_2023_36602
- Write-Output "Hotfix file downloaded successfully"
- Write-Output "Installing hotfixes. It might take some time"
- Start-Process -FilePath "wusa.exe" -ArgumentList "C:\stored_msu\windows10.0-kb5029244-x64_fb8cdde229cf17755c2c890a12e0e8f252dd38c0.msu /quiet /norestart" -Wait -PassThru -NoNewWindow
- Write-Output "One left hotfix left."
- Start-Process -FilePath "wusa.exe" -ArgumentList "C:\stored_msu\windows10.0-kb5031356-x64_65d5bbc39ccb461472d9854f1a370fe018b79fcc.msu /quiet /norestart" -Wait -PassThru -NoNewWindow
- Write-Output "Done. Please restart your device in order to apply hotfixes"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement