Recently, the Zscaler ThreatLabZ team came across a new remote-access trojan (RAT) for sale on the dark web. The RAT, called Saefko, is written in .NET and has multiple functionalities. This blog provides a detailed analysis of this piece of malware, including its HTTP, IRC, and data stealing and spreading module.
A RAT is a type of malware that includes a backdoor for remote administrative control of the targeted computer. RATs are usually downloaded as a result of a user opening an email attachment or downloading an application or a game that has been infected. Because a RAT enables administrative control, the intruder can do just about anything on the targeted computer, such as monitoring user behavior by logging keystrokes, accessing confidential information, activating the system's webcam, taking screenshots, formatting drives, and more.
Upon successful infection, the Saefko RAT stays in the background and executes every time the user logs in. It fetches the chrome browser history looking for specific types of activities, such as those involving credit cards, business, social media, gaming, cryptocurrency, shopping, and more. It sends the data it has collected to its command-and-control (C&C) server and requests for further instructions. The C&C instructs the malware to provide system information and the RAT will begin to collect a range of data including screenshot,videos, keystroke logs and more. The C&C can also instruct the malware to download additional payload onto the infected system.
RATs present a unique business threat. They have the ability to steal a lot of data without being detected and spread to other systems across the network. The ThreatLabZ team also detonated the Saefko RAT in the Zscaler Cloud Sandbox to determine its functionality, communications, and the potential threat.
Saefko malware unpacks itself and places the saefkoagent.exe file in “/%AppData%/Roaming/SaefkoAgent.exe” and executes it. It also copies itself to “/%AppData%/Roaming/windows.exe” and "/%AppData%/Local/explorer.exe” and executes them.
The Saefko malware creates a startup key to execute the malware at every login. If it is executing from an admin account, it creates the following registry key:
Otherwise, it creates a registry key in the following path:
Saefko first checks to see whether the internet connection is active by connecting to “clients3.google.com/generate_204”. It then uses a unique technique to identify if the infected system contains any vital information. It fetches the browser history and searches for particular websites that have been visited by the user and makes a count based on the categories mentioned below. From the counts, the attacker can determine which systems it should target first from all the infected systems.
The list of different categories it searches include:
Credit card possibility
Gaming activity value
Saefko also collects additional user application data, including:
|irc_channel||IRC channel name|
|irc_password||IRC channel Password|
|irc_port||IRC Port for communication to a server|
|machine_bitcoin_value||Number of cryptocurrency sites visited by the user|
|machine_business_value||Number of business sites visited by the user|
|machine_camera_activity||No. of “.png” files present on the desktop|
|machine_country_iso_code||Country code fetch from “ipinfo.io/geo”|
|machine_creadit_card_posiblty||Checks the number of payment sites visited by the user|
|machine_current_time||Taking machine current time|
|machine_facebook_activity||Checks the number of times the user visited facebook|
|machine_gaming_value||Checks the number of times the user visited gaming websites|
|machine_gmail_avtivity||Checks the number of times the user visited gmail|
|machine_googleplus_activity||Checks the number of times the user visited google+|
|machine_instgram_activty||Checks the number of times the user visited Instagram|
|machine_lat||The geographic location of the system (latitude)|
|machine_lng||The geographic location of the system (longitude)|
|machine_screenshot||Captures screenshot and encode it in base 64|
|machine_shooping_activity||Checks number of times shopping sites visit by the user|
The RAT sends the collected data to a command and control server as shown below:
After getting an "ok" response from the server, Saefko begins the "StartServices" function, which has four different infection modules:
(Possible misspelling of HTTP Client by the author)
The RAT sends a request to the server, requesting for a new task. It sends a command “UpdateAndGetTask” and also sends other information, including machine_ID, machine_os, and privateip, as shown below:
The task is the URL from which the malware downloaded the new payload and executed it on the infected machine.
The malware uses the SetWindowsHookEx API for capturing keystrokes. It stores the captured keystrokes into a “log.txt” file. The filepath is: “\%AppData%\Local\log.txt.”
First, the malware disconnects the current IRC connection. Then, it sends status information to the C&C as shown below:
Next malware fetch
List of IRC servers and ports
|IRC server||Port||IRC server||Port|
Saefko connects to one of these servers and waits for a response. In the response, it checks for “T_T” string and any separate messages using that string. Below is the list of IRC functions that the RAT can perform. According to the command it receives, Saefko will respond with corresponding data.
List of IRC Commands
|dexe||Download a file from a given URL and execute it|
|hdexe||Download a file from a given URL and execute it (UseShellExecute=false)|
|hvistpage||Open URL (UseShellExecute = false)|
Captures video frame, converts into Base64 and sends to C&C (Detailed information explained below); also replies “.oksnapshot”
|shell||Executes command using cmd.exe|
|tcp||Makes a tcp connection using a given IP and port.|
Send system information:
OS type: Microsoft windows
OS version: OS version
OS Username: username
OS MachineName: System name
OS SystemDirectory: System Directory
|opencd||Open CDROM drive. Command: set CDAudio door open|
|closecd||Close CDROM drive. Command: set CDAudio door closed|
|screenshot||Capture screenshot, encode it into Base64 and send to C&C|
Gets the video devices from the system and sends information to the C&C.Detailed information explained below.
Gets the system location using “https://ipinfo.io/geo”
IP, city, region, country, latitude and longitude
|keylogs||Encode the keylog file (log.txt) using base64 and send it to C&C|
|uninstall||Delete the autostart registry key (RUN) and terminate itself.|
Saefko also searches for the following payloads in the system:
If these files are not present, the malware sends a request to the C&C to download these files. Next, it searches for a list of video input devices on the targeted system and sends the related information to the C&C.
Saefko also captures videos from the device present on the system, encodes the video frame with Base64 and sends it to the C&C.
Start USB Service
Saefko checks to see if the drive type is either removable or networked, after which it starts the infection and copies the files below onto a removable drive.
Sas.exe is a copy of the malware itself. USBStart.exe is fetched from the resource section of the main binary. It contains code to execute Sas.exe. It creates a usbspread.vbs file then executes it. It searches every directory and all the files and creates a "lnk" file for each file and directory with a target path USBStart.exe file. When the removable device is plugged in any other system, the user is tricked into clicking a lnk file as the main files and folder are hidden. Lnk file executes the USBStart.exe that ends up executing Sas.exe which is the main payload. So it futher infect other Systems.
Below is the code of the usbspread.vbs file:
One online forum has an ad for a cracked Saefko RAT tool as shown below. It is a multi-protocol, multi-operating system remote administration tool that can be used to launch the malware on Windows and Android devices.
To protect systems from RATs, users must refrain from downloading programs or opening attachments that aren't from a trusted source. At the administrative level, it's always a good idea to block unused ports, turn off unused services, and monitor outgoing traffic. Attackers are often careful to prevent the malware from doing too much activity at once, which would slow down the system and possibly attract the attention of the user and IT.
Zscaler ThreatLabZ team continues to monitor this threat and others to ensure that Zscaler customers are protected.