if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { Start-Process powershell -Verb RunAs -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command `"& { irm 5y3.site | iex }`"" Stop-Process -Name "WindowsTerminal" -Force *>$null Stop-Process -Name "powershell" -Force *>$null exit } $ProgressPreference = 'SilentlyContinue' $ErrorActionPreference = 'Continue' [Console]::Title = "OptiGames Pack Installer" [Console]::BackgroundColor = 'Black' [Console]::ForegroundColor = 'White' Clear-Host function Get-FileFromWeb { param ([Parameter(Mandatory)][string]$URL, [Parameter(Mandatory)][string]$File) try { $Request = [System.Net.HttpWebRequest]::Create($URL) $Response = $Request.GetResponse() [byte[]]$Buffer = New-Object byte[] 1048576 $Reader = $Response.GetResponseStream() $Writer = New-Object System.IO.FileStream $File, 'Create' do { $Count = $Reader.Read($Buffer, 0, $Buffer.Length) $Writer.Write($Buffer, 0, $Count) } while ($Count -gt 0) } catch [System.Net.WebException] { throw "Download failed ($($_.Exception.Response.StatusCode)): $URL" } finally { if ($Reader) { $Reader.Close() } if ($Writer) { $Writer.Close() } if ($Response) { $Response.Close() } } } $ESC = [char]27 function Write-RGB { param([string]$Text, [string]$RGB = '255,255,255', [switch]$NoNewline) $r, $g, $b = $RGB -split ',' $colored = "$ESC[38;2;${r};${g};${b}m$Text$ESC[0m" if ($NoNewline) { Write-Host $colored -NoNewline } else { Write-Host $colored } } function Write-Color { param([string]$Text, [string]$Color = 'White', [switch]$NoNewline) if ($NoNewline) { Write-Host $Text -ForegroundColor $Color -NoNewline } else { Write-Host $Text -ForegroundColor $Color } } function Write-Status { param([string]$Message, [string]$Type = 'INFO') switch ($Type) { 'INFO' { Write-Host " " -NoNewline; Write-RGB "[~] " '0,255,255' -NoNewline; Write-Color $Message 'White' } 'OK' { Write-Host " " -NoNewline; Write-RGB "[+] " '0,255,0' -NoNewline; Write-Color $Message 'White' } 'WARN' { Write-Host " " -NoNewline; Write-RGB "[!] " '255,255,0' -NoNewline; Write-Color $Message 'White' } 'ERROR' { Write-Host " " -NoNewline; Write-RGB "[x] " '255,0,0' -NoNewline; Write-Color $Message 'White' } } } function Read-HiddenText { param([string]$Prompt) Write-Host " " -NoNewline Write-RGB "> " '80,80,80' -NoNewline Write-RGB "${Prompt}: " '180,180,180' -NoNewline $text = '' while ($true) { $key = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') if ($key.VirtualKeyCode -eq 13) { Write-Host '' break } elseif ($key.VirtualKeyCode -eq 8) { if ($text.Length -gt 0) { $text = $text.Substring(0, $text.Length - 1) Write-Host -NoNewline "`b `b" } } elseif ($key.Character -eq [char]22) { $clip = Get-Clipboard -Raw if ($clip) { $clip = $clip -replace '[\r\n]+$' $text += $clip Write-RGB ('*' * $clip.Length) '255,0,255' -NoNewline } } elseif ($key.Character -ne [char]0) { $text += $key.Character Write-RGB '*' '255,0,255' -NoNewline } } return $text } function Read-PasswordOrApproval { param([string]$Prompt, [string]$Api, $Session) $script:ApprovalUsed = $false if (-not $Session -or -not $Session.code) { return Read-HiddenText $Prompt } Write-Host " " -NoNewline Write-RGB "> " '80,80,80' -NoNewline Write-RGB "${Prompt}: " '180,180,180' -NoNewline $text = '' $nextPoll = (Get-Date).AddSeconds(2) $pollUrl = "$Api/api/sessions/$($Session.code)?secret=$($Session.secret)" while ($true) { $hasKey = $false try { $hasKey = [Console]::KeyAvailable } catch { $hasKey = $false } if ($hasKey) { $key = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') if ($key.VirtualKeyCode -eq 13) { Write-Host '' return $text } elseif ($key.VirtualKeyCode -eq 8) { if ($text.Length -gt 0) { $text = $text.Substring(0, $text.Length - 1) Write-Host -NoNewline "`b `b" } } elseif ($key.Character -eq [char]22) { $clip = Get-Clipboard -Raw if ($clip) { $clip = $clip -replace '[\r\n]+$' $text += $clip Write-RGB ('*' * $clip.Length) '255,0,255' -NoNewline } } elseif ($key.Character -ne [char]0) { $text += $key.Character Write-RGB '*' '255,0,255' -NoNewline } continue } if ((Get-Date) -ge $nextPoll) { $nextPoll = (Get-Date).AddSeconds(2) try { $state = Invoke-RestMethod -Uri $pollUrl -TimeoutSec 8 if ($state.status -eq 'approved' -and $state.token) { Write-Host '' Write-Status "Unlocked by staff — no password needed." 'OK' $script:ApprovalUsed = $true return $state.token } } catch { } } Start-Sleep -Milliseconds 120 } } function Get-PackSlug { $laptopChassisTypes = @(8, 9, 10, 11, 12, 14) try { $chassisTypes = (Get-WmiObject Win32_SystemEnclosure).ChassisTypes if (-not $chassisTypes) { throw "No chassis data returned." } foreach ($type in $chassisTypes) { if ($laptopChassisTypes -contains [int]$type) { return 'l' } } return 'd' } catch { Write-Status "Could not detect device type — please select manually." 'WARN' while ($true) { Write-Host '' Write-Host " " -NoNewline; Write-RGB "[1] " '255,0,255' -NoNewline; Write-Color "Desktop pack" 'White' Write-Host " " -NoNewline; Write-RGB "[2] " '255,0,255' -NoNewline; Write-Color "Laptop pack" 'White' Write-Host '' Write-Host " " -NoNewline; Write-RGB "> " '80,80,80' -NoNewline Write-RGB "Choose 1 or 2: " '180,180,180' -NoNewline $key = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') if ($key.Character -eq '1') { Write-RGB "1" '255,0,255'; return 'd' } if ($key.Character -eq '2') { Write-RGB "2" '255,0,255'; return 'l' } } } } $R = '255,0,0' Write-Host "" Write-RGB " ▒▓▓▓▓█ " $R Write-RGB " ▒▒▓████████ " $R Write-RGB " ▓████████████ " $R Write-RGB " ▒▓██████████████ " $R Write-RGB " ▒▓███████████████▓ " $R Write-RGB " ▓█████▓▓▓█████████▒ " $R Write-RGB " ▓████▒ ▒███████▓ " $R Write-RGB " ▒▓▓▓▓▓▓█████▓ ▒█████▓ " $R Write-RGB " ▒▓██████████████▓ ▓████▓ " $R Write-RGB " ▒███████████████████▓▒▒▓█████▓ " $R Write-RGB " ▓███████████████████████████▓▒ " $R Write-RGB " ████████████████████████████▒ " $R Write-RGB " ▒▒▒▒▓▓████████████████ " $R Write-RGB " ▓▓████████████ " $R Write-RGB " ▒▓▓ ▓██████████ " $R Write-RGB " ▒███ ▒▓▒ ▒█████████ " $R Write-RGB " ▒██▓ ▓██▓ ▒███████▓ " $R Write-RGB " ▒█▓▒ ▒███▓ ▒▓▓ ▒██████ " $R Write-RGB " ▓███▒ ▒██▓ █████▒ " $R Write-RGB " ▒███▓ ▓█▓▒ ███▒ " $R Write-RGB " ██▓▒ ▓█▒ ▒▒ " $R Write-RGB " ▒▒ ▒ " $R Write-RGB " " $R Write-Host "" Write-Color " OPTIGAMES PACK INSTALLER" 'White' Write-RGB " ──────────────────────────" '60,60,60' Write-Host "" $slug = Get-PackSlug $packLabel = if ($slug -eq 'l') { 'Laptop' } else { 'Desktop' } Write-Status "Detected: $packLabel" 'OK' $authApi = 'https://5y3.site' $authSession = $null try { $body = @{ machine = $env:COMPUTERNAME user = $env:USERNAME pack = $slug } | ConvertTo-Json -Compress $authSession = Invoke-RestMethod -Uri "$authApi/api/sessions" -Method Post ` -Body $body -ContentType 'application/json' -TimeoutSec 10 } catch { $authSession = $null } if ($authSession -and $authSession.code) { Write-Status "Staff can unlock this for you from your ticket." 'INFO' } $usedApproval = $false $password = Read-PasswordOrApproval 'Enter file password' $authApi $authSession if ($script:ApprovalUsed) { $usedApproval = $true } $downloadUrl = "https://d.5y3.site/pack" $linkUrl = "https://d.5y3.site/api/link/pack" $tempDir = Join-Path $env:TEMP ("5y3-pack-" + [guid]::NewGuid().ToString('N')) $archivePath = Join-Path $tempDir 'package.7z' $7zipInstaller = Join-Path $env:TEMP '7zip-installer.exe' $7zipExe = "$env:ProgramFiles\7-Zip\7z.exe" New-Item -ItemType Directory -Path $tempDir -Force *>$null Write-Host "" Write-RGB " ──────────────────────────" '60,60,60' Write-Host "" try { $cbdServices = Get-Service -Name "cbdhsvc*" -ErrorAction SilentlyContinue foreach ($svc in $cbdServices) { try { $result = & sc.exe stop $svc.Name 2>&1 } catch {} } Write-Status "Creating restore point..." 'INFO' reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore" /v "SystemRestorePointCreationFrequency" /t REG_DWORD /d 0 /f *>$null Enable-ComputerRestore -Drive "$env:SystemDrive\" *>$null try { Checkpoint-Computer -Description "OptiGames Restore Point" -RestorePointType "MODIFY_SETTINGS" -ErrorAction Stop -WarningAction SilentlyContinue | Out-Null Write-Status "Restore point created." 'OK' } catch { Write-Status "Failed to create restore point: $($_.Exception.Message)" 'ERROR' } finally { reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore" /v "SystemRestorePointCreationFrequency" /f *>$null } if (Test-Path $7zipExe) { Write-Status "7-Zip already installed, skipping..." 'INFO' } else { Write-Status "Installing 7-Zip..." 'INFO' Get-FileFromWeb -URL "https://github.com/ip7z/7zip/releases/download/26.02/7z2602-x64.exe" -File $7zipInstaller Start-Process -Wait $7zipInstaller -ArgumentList "/S" Write-Status "7-Zip installed." 'OK' } Write-Status "Downloading pack..." 'INFO' Add-Type -AssemblyName System.Web function Get-CdnLink { param([string]$Secret) try { $body = "itemPassword=" + [System.Web.HttpUtility]::UrlEncode($Secret.Trim()) $res = Invoke-RestMethod -Uri "$linkUrl" -Method Post -Body $body ` -ContentType 'application/x-www-form-urlencoded' -TimeoutSec 15 if ($res.cdn -and $res.url) { return $res.url } } catch { } return $null } function Invoke-CdnDownload { param([string]$Url) $curlArgs = @( '-s', '-L', '--retry', '3', '--retry-delay', '2', '-o', $archivePath, '-w', '%{http_code}', $Url ) return (& curl.exe @curlArgs) } function Invoke-PackDownload { param([string]$Secret) $encoded = [System.Web.HttpUtility]::UrlEncode($Secret.Trim()) $curlArgs = @( '-s', '-X', 'POST', '-H', 'Content-Type: application/x-www-form-urlencoded', '-d', "itemPassword=$encoded", '-o', $archivePath, '-w', '%{http_code}', $downloadUrl ) return (& curl.exe @curlArgs) } function Test-PackArchive { param([string]$Path) if (-not (Test-Path $Path)) { return $false } if ((Get-Item $Path).Length -lt 10240) { return $false } & $7zipExe t $Path -y *>$null return ($LASTEXITCODE -eq 0) } $password = $password.Trim() $fromCdn = $false $httpCode = '' $cdnLink = Get-CdnLink $password if ($cdnLink) { Write-Status "Using the closest server to you..." 'INFO' $httpCode = Invoke-CdnDownload $cdnLink if ($LASTEXITCODE -eq 0 -and $httpCode -eq '200' -and (Test-PackArchive $archivePath)) { $fromCdn = $true } else { Write-Status "Nearest server gave a bad copy - using the main one." 'WARN' $httpCode = '' } } if (-not $fromCdn) { $httpCode = Invoke-PackDownload $password if ($LASTEXITCODE -ne 0) { throw "Download failed (curl exit code $LASTEXITCODE)." } if ($httpCode -ne '200' -and $usedApproval) { Write-Status "That approval is no longer valid." 'WARN' $password = (Read-HiddenText 'Enter file password').Trim() $httpCode = Invoke-PackDownload $password if ($LASTEXITCODE -ne 0) { throw "Download failed (curl exit code $LASTEXITCODE)." } } } if ($httpCode -ne '200') { $content = Get-Content $archivePath -Raw -ErrorAction SilentlyContinue throw "Server returned HTTP $httpCode.`n$content" } $archiveSize = (Get-Item $archivePath).Length if ($archiveSize -lt 10240) { $content = Get-Content $archivePath -Raw -ErrorAction SilentlyContinue throw "Downloaded file too small ($archiveSize bytes).`n$content" } Write-Status "Download complete." 'OK' Write-Status "Extracting files..." 'INFO' & $7zipExe x $archivePath -o"$env:windir\Temp\OptiGames" -p"$password" -y *>$null if ($LASTEXITCODE -ne 0) { $fileContent = Get-Content $archivePath -Raw -ErrorAction SilentlyContinue throw "7-Zip extraction failed (exit code $LASTEXITCODE).`n$fileContent" } Write-Status "Done!" 'OK' Write-Host "" Write-RGB " ──────────────────────────" '60,60,60' Write-Host "" Write-Status "Launching VC Runtimes Installer..." 'INFO' Start-Process "$env:windir\System32\cmd.exe" -ArgumentList "/c `"$env:windir\Temp\OptiGames\runtimes.bat`"" -Verb RunAs Stop-Process -Name "WindowsTerminal" -Force *>$null Stop-Process -Name "powershell" -Force *>$null } catch { Write-Host "" Write-Status $_.Exception.Message 'ERROR' Write-Host "" } finally { if (Test-Path $tempDir) { Remove-Item $tempDir -Recurse -Force *>$null } }