Compare commits

..

1 Commits

Author SHA1 Message Date
mend-bolt-for-github[bot]
ed204fd049 Add .whitesource configuration file 2023-01-11 20:22:45 +00:00
5 changed files with 84 additions and 88 deletions

View File

@@ -2,8 +2,7 @@
root = true
[*]
trim_trailing_whitespace = true
insert_final_newline = true
# Must use a BOM else Unicode strings will not display
charset = utf-8-bom
insert_final_newline = true
indent_style = tab
trim_trailing_whitespace = true

3
.gitattributes vendored
View File

@@ -1,6 +1,3 @@
* text=auto
*.ps1 eol=crlf
*.sh eol=lf
.gitattributes export-ignore
.gitignore export-ignore
sign.sh export-ignore

14
.whitesource Normal file
View File

@@ -0,0 +1,14 @@
{
"scanSettings": {
"baseBranches": []
},
"checkRunSettings": {
"vulnerableCheckRunConclusionLevel": "failure",
"displayMode": "diff",
"useMendCheckNames": true
},
"issueSettings": {
"minSeverityLevel": "LOW",
"issueType": "DEPENDENCY"
}
}

149
Fido.ps1
View File

@@ -1,5 +1,5 @@
#
# Fido v1.44 - Feature ISO Downloader, for retail Windows images and UEFI Shell
# Fido v1.40 - 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
@@ -45,7 +45,9 @@ param(
# (Optional) Only display the download URL [Toggles commandline mode]
[switch]$GetUrl = $False,
# (Optional) Increase verbosity
[switch]$Verbose = $False
[switch]$Verbose = $False,
# (Optional) Disable the progress bar
[switch]$DisableProgress = $False
)
#endregion
@@ -58,28 +60,6 @@ if ($Win -or $Rel -or $Ed -or $Lang -or $Arch -or $GetUrl) {
$Cmd = $True
}
# Return a decimal Windows version that we can then check for platform support.
# Note that because we don't want to have to support this script on anything
# other than Windows, this call returns 0.0 for PowerShell running on Linux/Mac.
function Get-Platform-Version()
{
$version = 0.0
$platform = [string][System.Environment]::OSVersion.Platform
# This will filter out non Windows platforms
if ($platform.StartsWith("Win")) {
# Craft a decimal numeric version of Windows
$version = [System.Environment]::OSVersion.Version.Major * 1.0 + [System.Environment]::OSVersion.Version.Minor * 0.1
}
return $version
}
$winver = Get-Platform-Version
# 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 = @"
[DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = true, BestFitMapping = false, ThrowOnUnmappableChar = true)]
@@ -333,7 +313,7 @@ $WindowsVersions = @(
)
),
@(
@("UEFI Shell 2.0", "UEFI_SHELL 2.0"),
@("UEFI Shell 2.0", "UEFI_SHELL 2.0"),
@(
"4.632 [20100426]",
@("Release", 0)
@@ -638,24 +618,29 @@ if ($Cmd) {
# Localization
$EnglishMessages = "en-US|Version|Release|Edition|Language|Architecture|Download|Continue|Back|Close|Cancel|Error|Please wait...|" +
"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 on this platform."
"PowerShell 3.0 or later is required to run this script.|Do you want to go online and download it?"
[string[]]$English = $EnglishMessages.Split('|')
[string[]]$Localized = $null
if ($LocData -and (-not $LocData.StartsWith("en-US"))) {
$Localized = $LocData.Split('|')
# 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)]
if ($Localized.Length -ne $English.Length) {
Write-Host "Error: Missing or extra translated messages provided ($($Localized.Length)/$($English.Length))"
exit 101
}
$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)
{
@@ -669,8 +654,7 @@ function Size-To-Human-Readable([uint64]$size)
}
# Check if the locale we want is available - Fall back to en-US otherwise
function Check-Locale
{
function Check-Locale {
try {
$url = "https://www.microsoft.com/" + $QueryLocale + "/software-download/"
if ($Verbosity -ge 2) {
@@ -755,8 +739,7 @@ function Get-Windows-Languages([int]$SelectedVersion, [int]$SelectedEdition)
if ($r -match "errorModalMessage") {
Throw-Error -Req $r -Alt "Could not retrieve languages from server"
}
$r = $r -replace "`n" -replace "`r"
$pattern = '.*<select id="product-languages"[^>]*>(.*)</select>.*'
$pattern = '(?s)<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")
@@ -807,7 +790,7 @@ function Get-Windows-Download-Links([int]$SelectedVersion, [int]$SelectedRelease
$xml = New-Object System.Xml.XmlDocument
if ($Verbosity -ge 2) {
Write-Host Querying $url
}
}
$xml.Load($url)
$sep = ""
$archs = ""
@@ -841,13 +824,24 @@ function Get-Windows-Download-Links([int]$SelectedVersion, [int]$SelectedRelease
$Is64 = [Environment]::Is64BitOperatingSystem
# Must add a referer for this request, else Microsoft's servers will deny it
$ref = "https://www.microsoft.com/software-download/windows11"
$r = Invoke-WebRequest -Method Post -Headers @{ "Referer" = $ref } -UseBasicParsing -UserAgent $UserAgent -WebSession $Session $url
$wr = [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()
if ($r -match "errorModalMessage") {
$Alt = [regex]::Match($r, '<p id="errorModalMessage">(.+?)<\/p>').Groups[1].Value -replace "<[^>]+>" -replace "\s+", " " -replace "\?\?\?", "-"
$regex = New-Object Text.RegularExpressions.Regex '<p id="errorModalMessage">(.+?)<\/p>'
$m = $regex.Match($r)
# Make the typical error message returned by Microsoft's servers more presentable
$Alt = $m.Groups[1] -replace "<[^>]+>" -replace "\s+", " "
$Alt += " " + $SessionId + "."
if (-not $Alt) {
$Alt = "Could not retrieve architectures from server"
} else {
$Alt += " " + $SessionId + "."
}
Throw-Error -Req $r -Alt $Alt
}
@@ -897,7 +891,10 @@ function Process-Download-Link([string]$Url)
$tmp_size = [uint64]::Parse($str_size)
$Size = Size-To-Human-Readable $tmp_size
Write-Host "Downloading '$File' ($Size)..."
Start-BitsTransfer -Source $Url -Destination $File
if ($DisableProgress) {
$ProgressPreference = 'SilentlyContinue'
}
Invoke-WebRequest -UseBasicParsing -Uri $Url -OutFile $File
} else {
Write-Host Download Link: $Url
Start-Process -FilePath $Url
@@ -918,12 +915,6 @@ if ($Cmd) {
$winLanguageName = $null
$winLink = $null
# Windows 7 and non Windows platforms are too much of a liability
if ($winver -le 6.1) {
Error(Get-Translation("This feature is not available on this platform."))
exit 403
}
$i = 0
$Selected = ""
if ($Win -eq "List") {
@@ -1091,12 +1082,6 @@ $WindowsVersionTitle.Text = Get-Translation("Version")
$Continue.Content = Get-Translation("Continue")
$Back.Content = Get-Translation("Close")
# Windows 7 and non Windows platforms are too much of a liability
if ($winver -le 6.1) {
Error(Get-Translation("This feature is not available on this platform."))
exit 403
}
# Populate the Windows versions
$i = 0
$versions = @()
@@ -1226,8 +1211,8 @@ exit $ExitCode
# SIG # Begin signature block
# MIIkWQYJKoZIhvcNAQ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+10
# 2WQbtRqxUpuFAlL4kWZlra4VM5rB2u1YkhleZYwFrQNUwjDwvQ6XTaviKbk5gOAI
# z7bGgUFgJ4DVEbQWvy9/mMOpO50DsmwNdAFqj67N9wfZm6mPTiDldINEAN6K3QtN
# oGn9d/kLGKY3Uxxej0TLNb8wCpQPWMgryyHy32PjSvbaXnDy8FLUnw9u5NpgK7qV
# EJjcjiwTaR+PrDbskzu+knaphRGWkk8TmqKVLC3Zi/puTeDBafarunOPzXIV
# SIG # End signature block

View File

@@ -87,6 +87,7 @@ The options are:
architecture as the one from the current system.
- `GetUrl`: By default, the script attempts to automatically launch the download. But when using the `-GetUrl` switch,
the script only displays the download URL, which can then be piped into another command or into a file.
- `DisableProgress`: Disable progress report. This may speed up downloads when using the command line.
Examples of a commandline download: