# Safe To Bank Check - one-line runner https://safetobank.com/run/stb.ps1 # # This is what the "Copy command" button on https://safetobank.com runs: # powershell -NoProfile -ExecutionPolicy Bypass -Command "[Net.ServicePointManager]::SecurityProtocol='Tls12'; irm https://safetobank.com/run/stb.ps1 | iex" # # What this runner does (and nothing else): # 1. Downloads the real check, https://safetobank.com/download/SafeToBankCheck.ps1, into a new # folder in your TEMP folder. # 2. Makes sure it is exactly the published file (SHA-256 below). If not, it runs nothing. # 3. Runs it in this same window, just like SafeToBankCheck.exe does: # powershell.exe -NoProfile -ExecutionPolicy Bypass -File # 4. Deletes the temporary copy. # The check only READS settings. It needs no administrator rights, changes nothing on your PC, # and sends nothing over the internet. At the end it saves SafeToBank-Results.json on your # Desktop and opens https://safetobank.com/report in your web browser with your results already # filled in (they ride in the link after the #, which browsers never send to any website). # # Why a runner instead of piping the check itself into Invoke-Expression? The check starts with a # param() block and is saved as UTF-8 with a byte-order mark; both break under "irm | iex". # Running the downloaded file with -File keeps the check byte-for-byte identical. # # Only paste commands from safetobank.com. If someone on the phone told you to paste this, hang up. & { $Url = 'https://safetobank.com/download/SafeToBankCheck.ps1' $Sha256 = 'A83E50AFCCEC44753B925B4E2E0D890100B174074BE43C8F00C679861CA147BC' $ProgressPreference = 'SilentlyContinue' try { [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 } catch { $null = $_ } $Tmp = $env:TEMP if (-not $Tmp) { $Tmp = [IO.Path]::GetTempPath() } # Tidy up temporary copies left behind by an earlier run whose window was closed early Get-ChildItem -LiteralPath $Tmp -Directory -Filter 'SafeToBankCheck-*' -ErrorAction SilentlyContinue | Where-Object { $_.Name -match '^SafeToBankCheck-[0-9a-f]{32}$' -and $_.LastWriteTime -lt (Get-Date).AddHours(-1) } | ForEach-Object { Remove-Item -LiteralPath (Join-Path $_.FullName 'SafeToBankCheck.ps1') -Force -ErrorAction SilentlyContinue; Remove-Item -LiteralPath $_.FullName -Force -ErrorAction SilentlyContinue } $Dir = Join-Path $Tmp ('SafeToBankCheck-' + [guid]::NewGuid().ToString('N')) $File = Join-Path $Dir 'SafeToBankCheck.ps1' $Code = 3 $Started = $false Write-Host 'Safe To Bank Check: getting the check from safetobank.com...' -ForegroundColor Cyan try { $null = New-Item -ItemType Directory -Path $Dir -Force -ErrorAction Stop Invoke-WebRequest -Uri $Url -OutFile $File -UseBasicParsing -ErrorAction Stop $Actual = (Get-FileHash -LiteralPath $File -Algorithm SHA256 -ErrorAction Stop).Hash if ($Actual -ne $Sha256) { throw ('the downloaded file is not the published SafeToBankCheck.ps1 (SHA-256 {0}), so nothing was run' -f $Actual) } # 64-bit Windows PowerShell, same as SafeToBankCheck.exe (Sysnative if this window is 32-bit) $PowerShell = Join-Path $env:SystemRoot 'System32\WindowsPowerShell\v1.0\powershell.exe' try { if ([Environment]::Is64BitOperatingSystem -and -not [Environment]::Is64BitProcess) { $Native = Join-Path $env:SystemRoot 'Sysnative\WindowsPowerShell\v1.0\powershell.exe'; if (Test-Path -LiteralPath $Native) { $PowerShell = $Native } } } catch { $null = $_ } if (-not (Test-Path -LiteralPath $PowerShell)) { $PowerShell = 'powershell.exe' } $Started = $true $Process = Start-Process -FilePath $PowerShell -ArgumentList ('-NoProfile -ExecutionPolicy Bypass -File "{0}"' -f $File) -NoNewWindow -Wait -PassThru -ErrorAction Stop $Code = $Process.ExitCode } catch { Write-Host ('Safe To Bank Check could not start: {0}' -f $_.Exception.Message) -ForegroundColor Yellow Write-Host 'You can download SafeToBankCheck.exe from https://safetobank.com instead, or ask a trusted helper.' -ForegroundColor Yellow } finally { Remove-Item -LiteralPath $File -Force -ErrorAction SilentlyContinue Remove-Item -LiteralPath $Dir -Force -ErrorAction SilentlyContinue } if ($Started -and $Code -gt 2) { Write-Host '' Write-Host ('The check stopped early (code {0}). A setting on this PC may be blocking PowerShell scripts.' -f $Code) -ForegroundColor Yellow Write-Host 'You can download SafeToBankCheck.exe from https://safetobank.com instead, or ask a trusted helper.' -ForegroundColor Yellow } $global:LASTEXITCODE = $Code }