Threat Research
Stay on top of the latest threat research, information on in-the-wild cyber attacks and cyber operations from Juniper Threat Labs.
Juniper Employee , Juniper Employee Juniper Employee
Threat Research
The Gozi Sleeper Cell
Jun 27, 2018

Co-Authors:  Anoop Saldanha and  Paul Kimayong


Gozi, also known as Ursnif, is a well-known banking malware. Many variants of the malware family were identified in different attacks after its source code was leaked sometime back. Various instances of Gozi are still active. Criminals have modified the code and distributed it around the web. The sample was seen in one of our customer premises. Here is the hash of the sample.






Attack Vector

Gozi is known to spread through spam emails with JavaScript attachments or Microsoft Office documents. Cisco Talos has referred to the spam campaigns in their blog:


The recent Gozi malware we discovered arrives downloaded by malicious Office files. These Office files are sent as attachments to spam, such as the example below:



email.pngspam email






















The Office document contains malicious macros and when enabled, it starts executing a PowerShell script to download the Ursnif binary.




javascript.pngjavascript attachment 















In the past, Gozi also arrived via exploit kits.


When executed, Gozi drops a copy of itself in the %APPDATA%\{random}\{filename}.exe

In our sample, it drops as:



Please note that the filename (cicsapi.exe) may vary per variant of Ursnif.


It also creates an autostart entry:


autostart.pngautostart entry 




Gozi’s main module is a DLL which is injected into explorer.exe


After successfully injecting to explorer.exe, the initial executable, cicsapi.exe, terminates. Variants may exhibit slightly different behavior.


Technical Details 

Gozi tries to evade analysis by manually “zeroing” out the PE header in memory. This behavior makes investigation more challenging due to the fact that most of the memory analysis tools usually check the PE header when inspecting a memory region.

zeroed PE header.pngzeroed PE Header 





























Gozi itself has many anti-sandbox tricks, but this sample also has a trick embedded in the  covering packer layer. This is a sleep mechanism that has not been implemented directly by calling windows API sleep() but instead uses WaitforSingleObject() API with an invalid handle. This is to avoid sandbox detection.


waitForSingleObject() sleep.pngWaitForSingleObject() sleep

 The malware uses multi-level encryption. The malware unpacks by overwriting itself and upon unpacking, you can see a number of strings specific to the Gozi family.


Here is the unpacked file for the studied sample:




Here is a screenshot of the strings present in the unpacked file:


crmdllunpacked.pngfirst level unpacked strings


























Gozi creates mailslot with the name “mailslot\ms10”, which is visible in the memory string. Mailslot is meant for interprocess communication, but Gozi tweaked the usage to make debugging harder.   Most of the time malware decrypt the code to memory buffer, but here it tries to write it to a mailslot. Standard debugging tools don’t provide a direct mechanism to look at what’s written to the mailslot.


The malware creates a mailslot using CreateMailslot API from one thread. In another thread, it gets handed to mailslot by using CreatFile API with a mailslot name as parameter. Then it writes the decoded buffer to mailslot.



mailslot.pngmailslot created

 mailslot2.pngwrite to mailslot





















To see what is written into the mailslot, a reverser can change the file name in CreateFile from the mailslot to “C:\out”. Be sure that you manually create a file with that name as parameter to createFile is “OPEN_EXISTING”.



mailslot_write.pngReplace maislot name in createfile with a name











The WriteFile API writes the decoded content into the file “C:\out” and one can easily visualize it. We see that the partially decrypted DLL is written to the file. Looking into the strings, the DLL name seems to be crm.dll.



 crmpng.pngCRM.dll in memory









Hash for crm.dll




Crm.dll is responsible for further unpacking the payload into memory. But, this is not the final payload. It loads the actual Gozi payload further. The sample has various well-known anti-sandbox features like sleep delay. But, our deep memory inspection feature allows us to identify the payload in case the sample forbids us to execute completely. We can identify a lot of string in memory that has high resemblance to the leaked source code.



memory.pngMemory block showing URL




















Below is a snapshot of one of the memory regions in the malware.If we search for the URL we can see a a number of GitHub forks.

github.pngMemory block showing URL 

































The sample has additional interesting memory strings that show the pattern of CnC communication.

crmdllunpacked.pngCnC pattern in memory



 The sample connects to its C2 server:

  • Qf1q48wdq1dd[.]net

It communicates to its C2 server via SSL.


cnc.pngCnC communication via SSL  










There are other strings ie.. PR_Read that indicates that the malware tries to install a hook into browsers like Firefox in order to steal data.


firefox hook.pngstrings indicating firefox hook

















These patterns can be used in intrusion detection signature and yara rules to identify the malware. The malware hooks API’s WSARecv, WSASend in order to intercept network communications.  


In addition to its malware, it also has the following capabilities:

  • Cookie theft
  • Email Credential theft
  • Log Browsing Activity
  • Keylogging


The stolen data is stored in the %temp% folder as a bin file with random 4-hexadecimal characters as filename, e.g, 676A.bin. It uses mscab.exe tool to archive the stolen data and sends this data to its C2 server.


stolen data stored.pngstolen data stored















stolen data transmitted.pngstolen data transmitted
























Both Juniper Sky ATP and JATP on-prem solutions detect this threat as seen in the screenshots below.  Keeping security solutions up-to-date can keep the customer protected against this threat.


cyphort.pngskyatp detection.png


Top Kudoed Members