@@ -1,6 +1,6 @@
#
# Fido v1.37 - Feature ISO Downloader, for retail Windows images and UEFI Shell
# Copyright © 2019-2022 Pete Batard <pete@akeo.ie>
# Fido v1.4 3 - Feature ISO Downloader, for retail Windows images and UEFI Shell
# Copyright © 2019-2023 Pete Batard <pete@akeo.ie>
# Command line support: Copyright © 2021 flx5
# ConvertTo-ImageSource: Copyright © 2016 Chris Carter
#
@@ -24,7 +24,7 @@
#region Parameters
param (
# (Optional) The title to display on the application window.
[ string ] $AppTitle = " Fido - Retail Windows ISO Downloader " ,
[ string ] $AppTitle = " Fido - Feature ISO Downloader " ,
# (Optional) '|' separated UI localization strings.
[ string ] $LocData ,
# (Optional) Path to a file that should be used for the UI icon.
@@ -45,9 +45,7 @@ param(
# (Optional) Only display the download URL [Toggles commandline mode]
[ switch ] $GetUrl = $False ,
# (Optional) Increase verbosity
[ switch ] $Verbose = $False ,
# (Optional) Disable the progress bar
[ switch ] $DisableProgress = $False
[ switch ] $Verbose = $False
)
#endregion
@@ -60,6 +58,14 @@ if ($Win -or $Rel -or $Ed -or $Lang -or $Arch -or $GetUrl) {
$Cmd = $True
}
# Craft a decimal numeric version of Windows, since Windows 7's PowerShell is too stupid to compare it to a Version object
$winver = [ System.Environment ] :: OSVersion . Version . Major * 1.0 + [ System.Environment ] :: OSVersion . Version . Minor * 0.1
# The default TLS for Windows 8.x doesn't work with Microsoft's servers so we must force it
if ( $winver -lt 10.0 ) {
[ Net.ServicePointManager ] :: SecurityProtocol = [ Net.SecurityProtocolType ] :: Tls -bor [ Net.SecurityProtocolType ] :: Tls11 -bor [ Net.SecurityProtocolType ] :: Tls12
}
#region Assembly Types
$code = @"
[ D l l I m p o r t ( " s h e l l 3 2 . d l l " , C h a r S e t = C h a r S e t . A u t o , S e t L a s t E r r o r = t r u e , B e s t F i t M a p p i n g = f a l s e , T h r o w O n U n m a p p a b l e C h a r = t r u e ) ]
@@ -499,7 +505,7 @@ function ConvertTo-ImageSource
function Throw-Error([object]$Req , [ string ] $Alt )
{
$Err = $ ( GetElementById -Request $r -Id " errorModalMessage " ) . innerText
$Err = $ ( GetElementById -Request $Req -Id " errorModalMessage " ) . innerText -replace " <[^>]+> " -replace " \s+ " , " "
if ( -not $Err ) {
$Err = $Alt
} else {
@@ -602,7 +608,7 @@ $RequestData["GetLangs"] = @("a8f8f489-4c7f-463a-9ca6-5cff94d8d041", "getskuinfo
# This GUID applies to visitors of the en-US download page. Other locales may get a different GUID.
$RequestData [ " GetLinks " ] = @ ( " 6e2a1789-ef16-4f27-a296-74ef7ef5d96b " , " GetProductDownloadLinksBySku " )
# Create a semi-random Linux User-Agent string
$FirefoxVersion = Get-Random -Minimum 5 0 -Maximum 9 0
$FirefoxVersion = Get-Random -Minimum 9 0 -Maximum 11 0
$FirefoxDate = Get-RandomDate
$UserAgent = " Mozilla/5.0 (X11; Linux i586; rv: $FirefoxVersion .0) Gecko/ $FirefoxDate Firefox/ $FirefoxVersion .0 "
$Verbosity = 2
@@ -617,30 +623,25 @@ if ($Cmd) {
# Localization
$EnglishMessages = " en-US|Version|Release|Edition|Language|Architecture|Download|Continue|Back|Close|Cancel|Error|Please wait...| " +
" Download using a browser|Temporarily banned by Microsoft for requesting too many downloads - Please try again later.. .| " +
" PowerShell 3.0 or later is required to run this script.|Do you want to go online and download it? "
" Download using a browser|Download of Windows ISOs is unavailable due to Microsoft having altered their website to prevent it .| " +
" PowerShell 3.0 or later is required to run this script.|Do you want to go online and download it?| " +
" This feature is not available for this version of Windows. "
[ string[] ] $English = $EnglishMessages . Split ( '|' )
[ string[] ] $Localized = $null
if ( $LocData -and ( -not $LocData . StartsWith ( " en-US " ) ) ) {
$Localized = $LocData . Split ( '|' )
if ( $Localized . Length -ne $English . Length ) {
Write-Host " Error: Missing or extra translated messages provided ( $ ( $Localized . Length) / $( $English . Length ) ) "
exit 101
# Adjust the $Localized array if we have more or fewer strings than in $EnglishMessages
if ($Localized . Length -lt $English . Length ) {
while ( $Localized . Length -ne $English . Length ) {
$Localized + = $English [ $Localized . Length ]
}
} elseif ( $Localized . Length -gt $English . Length ) {
$Localized = $LocData . Split ( '|' ) [ 0 . . ( $English . Length - 1 ) ]
}
$Locale = $Localized [ 0 ]
}
$QueryLocale = $Locale
# Make sure PowerShell 3.0 or later is used (for Invoke-WebRequest)
if ( $PSVersionTable . PSVersion . Major -lt 3 ) {
Write-Host Error : PowerShell 3.0 or later is required to run this script .
$Msg = " $( Get-Translation ( $English [ 15 ] ) ) `n $( Get-Translation ( $English [ 16 ] ) ) "
if ( [ System.Windows.MessageBox ] :: Show ( $Msg , $ ( Get-Translation ( " Error " ) ) , " YesNo " , " Error " ) -eq " Yes " ) {
Start-Process -FilePath https : / / www . microsoft . com / download / details . aspx ? id = 34595
}
exit 102
}
# Convert a size in bytes to a human readable string
function Size-To-Human-Readable([uint64]$size )
{
@@ -710,6 +711,17 @@ function Get-Windows-Languages([int]$SelectedVersion, [int]$SelectedEdition)
} elseif ( $WindowsVersions [ $SelectedVersion ] [ 0 ] [ 1 ] . StartsWith ( " UEFI_SHELL " ) ) {
$languages + = @ ( New-Object PsObject -Property @ { DisplayLanguage = " English (US) " ; Language = " en-us " ; Id = 0 } )
} else {
# Microsoft download protection now requires the sessionId to be whitelisted through vlscppe.microsoft.com/tags
$url = " https://vlscppe.microsoft.com/tags?org_id=y6jn8c31&session_id= " + $SessionId
if ( $Verbosity -ge 2 ) {
Write-Host Querying $url
}
try {
Invoke-WebRequest -UseBasicParsing -MaximumRedirection 0 -UserAgent $UserAgent $url | Out-Null
} catch {
Error ( $_ . Exception . Message )
return @ ( )
}
$url = " https://www.microsoft.com/ " + $QueryLocale + " /api/controls/contentinclude/html "
$url + = " ?pageId= " + $RequestData [ " GetLangs " ] [ 0 ]
$url + = " &host=www.microsoft.com "
@@ -724,11 +736,12 @@ function Get-Windows-Languages([int]$SelectedVersion, [int]$SelectedEdition)
$script:SelectedIndex = 0
try {
$r = Invoke-WebRequest -UseBasicParsing -UserAgent $UserAgent -SessionVariable " Session " $url
$r = Invoke-WebRequest -Method Post -UseBasicParsing -UserAgent $UserAgent -SessionVariable " Session " $url
if ( $r -match " errorModalMessage " ) {
Throw-Error -Req $r -Alt " Could not retrieve languages from server "
}
$pattern = '(?s)<select id="product-languages">(.*)?</select>'
$r = $r -replace " `n " -replace " `r "
$pattern = '.*<select id="product-languages"[^>]*>(.*)</select>.*'
$html = [ regex ] :: Match ( $r , $pattern ) . Groups [ 1 ] . Value
# Go through an XML conversion to keep all PowerShells happy...
$html = $html . Replace ( " selected value " , " value " )
@@ -811,20 +824,17 @@ function Get-Windows-Download-Links([int]$SelectedVersion, [int]$SelectedRelease
try {
$Is64 = [ Environment ] :: Is64BitOperatingSystem
# Must add a referer for POST requests , else Microsoft's servers will deny them
# Must add a referer for this request, else Microsoft's servers will deny i t
$ref = " https://www.microsoft.com/software-download/windows11 "
$w r = [ System.Net.WebRequest ] :: Create ( $url )
# Windows 7 PowerShell doesn't support 'Invoke-WebRequest -Headers @{"Referer" = $ref}'
# (produces "The 'Referer' header must be modified using the appropriate property or method")
# so we use StreamReader() with GetResponseStream() and do this whole gymkhana instead...
$wr . Method = " POST "
$wr . Referer = $ref
$wr . UserAgent = $UserAgent
$wr . ContentLength = 0
$sr = New-Object System . IO . StreamReader ( $wr . GetResponse ( ) . GetResponseStream ( ) )
$r = $sr . ReadToEnd ( )
$r = Invoke-WebRequest -Method Post -Headers @ { " Referer " = $ref } -UseBasicParsing -UserAgent $UserAgent -WebSession $Session $url
if ( $r -match " errorModalMessage " ) {
Throw-Error -Req $r -Alt " Could not retrieve architectures from server "
$Alt = [ regex ] :: Match ( $r , '<p id="errorModalMessage">(.+?)<\/p>' ) . Groups [ 1 ] . Value -replace " <[^>]+> " -replace " \s+ " , " " -replace " \?\?\? " , " - "
if ( -not $Alt ) {
$Alt = " Could not retrieve architectures from server "
} else {
$Alt + = " " + $SessionId + " . "
}
Throw-Error -Req $r -Alt $Alt
}
$pattern = '(?s)(<input.*?></input>)'
ForEach-Object { [ regex ] :: Matches ( $r , $pattern ) } | ForEach-Object { $html + = $_ . Groups [ 1 ] . value }
@@ -872,10 +882,7 @@ function Process-Download-Link([string]$Url)
$tmp_size = [ uint64 ] :: Parse ( $str_size )
$Size = Size-To -Human -Readable $tmp_size
Write-Host " Downloading ' $File ' ( $Size )... "
if ( $DisableProgress ) {
$ProgressPreference = 'SilentlyContinue'
}
Invoke-WebRequest -UseBasicParsing -Uri $Url -OutFile $File
Start-BitsTransfer -Source $Url -Destination $File
} else {
Write-Host Download Link : $Url
Start-Process -FilePath $Url
@@ -896,6 +903,12 @@ if ($Cmd) {
$winLanguageName = $null
$winLink = $null
# Windows 7 has become too much of a liability
if ( $winver -le 6.1 ) {
Error ( Get-Translation ( " This feature is not available for this version of Windows. " ) )
exit 403
}
$i = 0
$Selected = " "
if ( $Win -eq " List " ) {
@@ -956,7 +969,7 @@ if ($Cmd) {
if ( ! $Ed -and $Verbosity -ge 1 ) {
Write-Host " No edition specified (-Ed). Defaulting to ' $( $edition . Edition ) '. "
}
$Selected + = " , " + $edition . Edition -replace " Windows [0-9\.]* " , " "
$Selected + = " , " + $edition . Edition -replace " Windows [0-9\.]* "
$winEditionId = $edition . Id
break ;
}
@@ -1054,7 +1067,7 @@ $XMLForm.Title = $AppTitle
if ( $Icon ) {
$XMLForm . Icon = $Icon
} else {
$XMLForm . Icon = [ Gui.Utils ] :: ExtractIcon ( " shell32 .dll" , -41 , $true ) | ConvertTo-ImageSource
$XMLForm . Icon = [ Gui.Utils ] :: ExtractIcon ( " imageres .dll" , -5205 , $true ) | ConvertTo-ImageSource
}
if ( $Locale . StartsWith ( " ar " ) -or $Locale . StartsWith ( " fa " ) -or $Locale . StartsWith ( " he " ) ) {
$XMLForm . FlowDirection = " RightToLeft "
@@ -1063,6 +1076,12 @@ $WindowsVersionTitle.Text = Get-Translation("Version")
$Continue . Content = Get-Translation ( " Continue " )
$Back . Content = Get-Translation ( " Close " )
# Windows 7 has become too much of a liability
if ( $winver -le 6.1 ) {
Error ( Get-Translation ( " This feature is not available for this version of Windows. " ) )
exit 403
}
# Populate the Windows versions
$i = 0
$versions = @ ( )
@@ -1192,8 +1211,8 @@ exit $ExitCode
# SIG # Begin signature block
# MIIkWAYJKoZIhvcNAQcCoIIkSTCCJEUCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCCIu9oI700HZxb3
# w6BvRyJWzIrL4aGutJadchpCiPvxia CCElkwggVvMIIEV6ADAgECAhBI/JO0YFWU
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCAin+3j4moQLVFU
# tqR8rGAmmgj13m89LOKayGbAncwfZq CCElkwggVvMIIEV6ADAgECAhBI/JO0YFWU
# jTanyYqJ1pQWMA0GCSqGSIb3DQEBDAUAMHsxCzAJBgNVBAYTAkdCMRswGQYDVQQI
# DBJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAOBgNVBAcMB1NhbGZvcmQxGjAYBgNVBAoM
# EUNvbW9kbyBDQSBMaW1pdGVkMSEwHwYDVQQDDBhBQUEgQ2VydGlmaWNhdGUgU2Vy
@@ -1296,22 +1315,22 @@ exit $ExitCode
# aWMgQ29kZSBTaWduaW5nIENBIEVWIFIzNgIRAL+xUAG79ZLUlip3l+pzb6MwDQYJ
# YIZIAWUDBAIBBQCgfDAQBgorBgEEAYI3AgEMMQIwADAZBgkqhkiG9w0BCQMxDAYK
# KwYBBAGCNwIBBDAcBgorBgEEAYI3AgELMQ4wDAYKKwYBBAGCNwIBFTAvBgkqhkiG
# 9w0BCQQxIgQg6jgFb4FuL7yvtN2F8EfthVB5EwLiVoFh5/z9lnLw0f0 wDQYJKoZI
# hvcNAQEBBQAEggIAIaiHGVVcr5tUwEGY+uNs717INqUf4s8L/GYWuVYrpTAB6xtK
# z9UgpjfhiP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