
Recently, the SonicWall Capture Labs Research team analyzed a Raspberry Robin, which is known for its endless anti-evasion's techniques and multiple layers of packing. The layers have several anti-debugger, anti-sandbox, anti-VM and anti-emulator checks. The malware keeps evolving over the time and intensified itself to become more robust by adding various evasions and tactics.
Raspberry Robin is packed with 14 layers, each one is heavily obfuscated and performing a particular goal. From the structure of each layer, we can understand that initially it began as PE files but were changed into unique encrypted structures without PE headers that could only be retrieved and decrypted by the preceding layers.
Once Raspberry Robin identified the execution is happening in a controlled environment then it mislead the execution flow in a variety of ways:
Malware does an extensive use of obfuscation. This makes it exceedingly difficult to statically analyze anti-analysis tactics and figure out how to get malware to unpack itself by passing all the checks. Malware uses API hashing to retrieve API addresses. Malware only uses VirtualAlloc and VirtualProtect API's to unpack next layer.
Malware directly starts decryption of layer 1, which is stored in .data section, using simple XOR and jump to it:

This layer decrypts the next layer and starts its execution.
It is a DLL file with no import and exports directory:
It has one unique check , where it initially set cx = 2. After performing some instruction it checks if cx is still equal to 2. Since cx value should remain the same. The gs selector's value would be reset by a single step event and a new value would be placed into cx at the end of the procedure.
This layer decrypts the next layer and starts its execution.
This layer decrypts the next layer and starts its execution.
This layer decrypts the next layer and starts its execution:
Here, malware allocates large memory buffer with PAGE_WRITECOMBINE flag, where it first writes and then reads from it, evaluating read/write performance. Malware loops this check 32 times and compares that write performance is at least 6th times more than read performance.
This check focuses on the execution in the emulator, if it is unsuccessful, malware will choose an incorrect RC4 key and leads to crash.
Function responsible for write-read performance check:
Malware performs above operation 32 times:
After successfully bypassing above check, it decrypts the next layer and starts its execution.
It performs simple task of decryption by using very complex calls. Check the below call graph of this layer.
This layer decrypts the next layer and starts its execution.
Every time malware has to call any API, it search for the required module in PEB->InLoadOrderModuleList. If the module found, it retrieves the address of required API from exports:
This layer decrypts the next layer and starts its execution.
In this layer malware creates a new thread , which executes below mentioned checks as a separate function one by one:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
Malware has a variety of anti-analysis checks in this Layer. If malware is successful in detecting an analysis environment in at least one check, It will unpack and run the fake payload rather than the real payload
On physical machine MulDiv API returns value 2 but on WineHQ’s MulDiv’s API implementation it returns value 1. So malware makes use of this opportunity and detects its execution under wine successfully:
Runtime call to allocated region:
It decrypts the next layer and starts its execution.
Strings from the fake loader:
Malware drops fake payload into %TEMP% directory and execute it.
Fake Payload:
It decrypts the next layer and starts its execution.
It decrypts the next layer and starts its execution.
Raspberry Robin's Main payload is unpacked.
SonicWall Capture Labs provides protection against this threat via the following signature:
This threat is also detected by SonicWall Capture ATP w/RTDMI and the Capture Client endpoint solutions.
Share This Article

An Article By
An Article By
Security News
Security News