Created
August 15, 2025 14:48
-
-
Save BladeWDR/8e40e8207c2ef331c1763a599c201891 to your computer and use it in GitHub Desktop.
winrar upgrade script
This file contains hidden or 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
| <# | |
| .DESCRIPTION Detects if WinRar is installed and upgrades to 7.13 if needed. Written to address CVE-2025-8088. | |
| #> | |
| function Update-Winrar | |
| { | |
| if (-not (Test-Path -Path "$TempDir")) | |
| { | |
| New-Item -Path "$TempDir" -PathType Directory | |
| } | |
| try | |
| { | |
| Invoke-WebRequest -Uri "https://www.rarlab.com/rar/winrar-x64-713.exe" -UseBasicParsing -OutFile "$WinrarInstallerPath" | |
| Start-Process -FilePath "$WinrarInstallerPath" -Wait -ArgumentList "/S" | |
| } catch | |
| { | |
| Write-Error "Error updating WinRAR. $_" | |
| } | |
| } | |
| $appName = "WinRar" | |
| $TempDir = "C:\Temp" | |
| $WinrarInstallerPath = "$TempDir\winrar-x64-7.13.0.exe" | |
| $NativeRegPath = 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' | |
| $Wow6432RegPath = 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' | |
| # Get the list of installed programs including WOW64 if present | |
| $UninstKeys = Get-ItemProperty $NativeRegPath | |
| if (Test-Path $Wow6432RegPath -PathType Container) | |
| { | |
| $UninstKeys += Get-ItemProperty $Wow6432RegPath | |
| } | |
| # Array to save PSCustomObjects into | |
| $UninstallCustom = @() | |
| foreach ($key in $UninstKeys) | |
| { | |
| # Only process entries that have a DisplayName | |
| if ($key.DisplayName) | |
| { | |
| $UninstallCustom += [PSCustomObject]@{ | |
| AppName = $key.DisplayName | |
| Version = if ($key.DisplayVersion) | |
| { $key.DisplayVersion | |
| } else | |
| { "Unknown" | |
| } | |
| } | |
| } | |
| } | |
| # Filter for WinRAR specifically | |
| $WinRARInstalls = $UninstallCustom | Where-Object { $_.AppName -like "*WinRAR*" } | |
| if ($WinRARInstalls) | |
| { | |
| $needsUpdate = $false | |
| foreach ($install in $WinRARInstalls) | |
| { | |
| Write-Host "Found WinRAR: $($install.AppName) - Version: $($install.Version)" | |
| # Convert to version object for proper comparison | |
| try | |
| { | |
| $currentVersion = [System.Version]$install.Version | |
| $targetVersion = [System.Version]"7.13.0" | |
| if ($currentVersion -lt $targetVersion) | |
| { | |
| $needsUpdate = $true | |
| Write-Host "Version $($install.Version) is older than 7.13.0" | |
| } | |
| } catch | |
| { | |
| # Handle cases where version string can't be parsed | |
| Write-Host "Could not parse version: $($install.Version)" | |
| $needsUpdate = $true # Assume update needed if we can't parse | |
| } | |
| } | |
| if ($needsUpdate) | |
| { | |
| Write-Host "Updating Winrar...." | |
| Update-Winrar | |
| Write-Host "WinRAR updated successfully!" | |
| } else | |
| { | |
| Write-Host "Already up to date." | |
| } | |
| } else | |
| { | |
| Write-Host "WinRAR not found. Nothing to do." | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment