Fido icon indicating copy to clipboard operation
Fido copied to clipboard

"The 'Referer' header must be modified using the appropriate property or method" on Windows 7

Open pbatard opened this issue 2 years ago • 2 comments

Per pbatard/rufus#2026 The fix for #41 (adding -Headers @{ 'Referer' = 'https://www.microsoft.com/software-download/windows11' } to Invoke-WebRequest) does not seem to be compatible with older versions of PowerShell, such as the ones used on Windows 7.

At this stage, I am not planning to try to fix this (it's just not worth the effort) but instead disable the ability to run Fido on platforms where Invoke-WebRequest cannot set the Referer property through the -Headers @{ ... } method.

I am however opening this issue so that people who run into this error can find it, and to give them a chance to propose a fix before I disable the script on their platform, if they really want to still be able to run it there...

pbatard avatar Aug 18 '22 14:08 pbatard

Replacing this:

$r = Invoke-WebRequest -Method Post -Headers @{"Referer" = $ref} -UseBasicParsing -UserAgent $UserAgent -WebSession $Session $url

with this:

$wr = [System.Net.WebRequest]::Create($url)
$wr.Method = "POST"
$wr.Referer = $ref
$wr.UserAgent = $UserAgent
$wr.ContentLength = 0
$sr = New-Object System.IO.StreamReader($wr.GetResponse().GetResponseStream())
$r = $sr.ReadToEnd()

might solve the Windows 7 issue. I have not tested it on Windows 7 though, since I don't have access to such a platform at the moment, and I am a bit weary of breaking Windows 8/10/11 behaviour for the sake of a few encroached Windows 7 users, especially as this drops the -WebSession $Session part altogether...

pbatard avatar Sep 13 '22 15:09 pbatard

hello , please show how to test this as on my computer with rufus am only able to download windows 7 iso (no more 8,10,11) due to referer issue.

mrkapqa avatar Sep 17 '22 15:09 mrkapqa

@mrkapqa wrote:

hello, please show how to test this as on my computer with rufus am only able to download windows 7 iso (no more 8,10,11) due to referer issue.

The author (pbatard) has implemented a backward-compatibility fix to the script, which has completely fixed the "referer-header" error on Windows 7 SP1 systems.

You may also want to take a look at: Rufus, Issue 2026

Hopefully this clears the issue for you also.

AgentSam avatar Sep 27 '22 15:09 AgentSam