Skip to content

Instantly share code, notes, and snippets.

@TheDeadCode
Last active December 21, 2021 17:04
Show Gist options
  • Save TheDeadCode/53da403bb5156ac5b8a496acb7634e75 to your computer and use it in GitHub Desktop.
Save TheDeadCode/53da403bb5156ac5b8a496acb7634e75 to your computer and use it in GitHub Desktop.
Quick script to auto-fix warframe (OUTDATED: ISPs HAVE FIXED THE ISSUE)
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
Exit
}
}
$hosts = "C:\Windows\System32\Drivers\etc\hosts"
$hostsValue = "127.0.0.1 content.warframe.com"
$blank = [Environment]::NewLine
$caddy = "$($env:USERPROFILE)\Downloads\caddy_windows_amd64.exe"
function getHostsLine() {
return Select-String -Path $hosts -Pattern "content.warframe.com"
}
function addToHosts() {
if (-not [IO.File]::ReadAllText($hosts).EndsWith($blank)) {
Add-Content -path $hosts -Value $blank
}
Start-Sleep -Seconds 1
Add-Content -path $hosts -Value $hostsValue -NoNewLine
}
function removeFromHosts() {
$contents = [IO.File]::ReadAllText($hosts)
$contents = $contents.Replace("$($hostsValue)$($blank)", "").Replace($hostsValue, "")
Start-Sleep -Seconds 1
Set-Content -Path $hosts -Value $contents -NoNewLine
}
if (getHostsLine)
{
Write-Host "DNS Redirection Detected, removing..."
removeFromHosts
Write-Host "Run this script again to activate the launcher fix."
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
Exit
}
Write-Host "Enabling Launcher Fix..."
if (-not (Test-Path -Path $caddy -PathType Leaf)) {
Write-Host "Caddy not detected. Downloading..."
Invoke-WebRequest -Uri "https://caddyserver.com/api/download?os=windows&arch=amd64" -OutFile $caddy
Write-Host "Download successful to $($caddy)!"
}
Write-Host "Starting Proxy..."
$process = Start-Process -FilePath $caddy -ArgumentList "reverse-proxy --from http://content.warframe.com --to https://cds.b5q9z7i8.hwcdn.net -insecure" -PassThru -WindowStyle Hidden
Write-Host "Re-writing hosts file..."
addToHosts
Write-Host "Please start warframe launcher. PRESS ON ENTER BEFORE PRESSING THE PLAY BUTTON"
Write-Host "DO NOT EXIT THIS WINDOW, PRESS ON ENTER INSTEAD"
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
Write-Host "Shutting down server"
$process.Kill()
removeFromHosts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment