Anatomy of a Linux backdoor attack

Through the Back Door

© Photo by David Szweduik on Unsplash

© Photo by David Szweduik on Unsplash

Article from Issue 289/2024
Author(s):

Cybercriminals are increasingly discovering Linux and adapting malware previously designed for Windows systems. We take you inside the Linux version of a famous Windows ransomware tool.

Since the beginning of the year, security researchers from Check Point Research (CPR) have been investigating the activities of a Chinese cyber espionage threat actor focused on Southeast Asia, Africa, and South America. The toolkit for this threat actor includes the DinodasRAT [1] cross-platform backdoor, also known as XDealer, which was previously observed in attacks by the Chinese group known as LuoYu.

This article provides technical analysis of the Linux version (v11) of DinodasRAT, aka Linodas. The Linux edition appears to be more sophisticated than the Windows version and has a range of features specially tailored to Linux servers. In addition, the version under investigation introduces a separate bypass module to hide traces of malware in the system. The execution of the system binary files is modified by proxies.

Dinodas Origins

Several clues indicate DinodasRAT was originally based on the SimpleRemote [2] open source project. SimpleRemote is a remote access tool based on the Windows remote access trojan Gh0st RAT [3], but it has some additional improvements. Similarities between SimpleRemote and an older version of DinodasRAT include the use of the same Zlib library (version 1.2.11) and some overlaps in the code (Figure 1).

Figure 1: Similarities in the function for identifying the operating system version between the Dinodas example (left) and the open source code. © Check Point Software

The developers of DinodasRAT rehashed parts of the source code and added some additional open source code from another repository. This code includes functions for handling INI files. DinodasRAT uses encryption used in QQ Messenger.

Independent Code Base

All examples of the cross-platform DinodasRAT embed a string containing the internal version of the backdoor. Some strings reflecting the development of the backdoor appear in Table 1.

Table 1

Strings of the Backdoor

Marker

Discovered for the First Time

Hashes

Linux_%s_%s_%u_V7

July 2021

3d93b8954ed1441516302681674f4989bd0f20232ac2b211f4b601af0fcfc13bbf830191215e0c8db207ea320d8e795990cf6b3e6698932e6e0c9c0588fc9eff

Linux_%s_%s_%u_V10

January 2023

15412d1a6b7f79fad45bcd32cf82f9d651d9ccca082f98a0cca3ad5335284e45

Linux_%s_%s_%u_V11

November 2023

6302acdfce30cec5e9167ff7905800a6220c7dda495c0aae1f4594c7263a29b2 ebdf3d3e0867b29e66d8b7570be4e6619c64fae7e1fbd052be387f736c980c8e (embedded module)

The earliest version for Linux was first spotted in the wild by security researchers in July 2021. Linodas has the same logic as the Windows version, but it adds a number of its own behaviors and specifically targets Linux servers. The latest Linodas version (v11) can also be observed in a Windows version, which communicates with the same C2 server update.microsoft-setting[.]com (see Table 2).

Table 2

Comparing Linux and Windows Versions

Version

Operating system

Hash

Linux_%s_%s_%u_V11

Linux

6302acdfce30cec5e9167ff7905800a6220c7dda495c0aae1f4594c7263a29b2

Win_%s_%s_%u_V10

Windows

57f64f170dfeaa1150493ed3f63ea6f1df3ca71ad1722e12ac0f77744fb1a829

Two samples with different internal versions suggest that there were two different development teams or at least two backdoors in different stages of development communicating with the same C2 server. The Linux and Windows versions have overlapping command IDs that seamlessly support the same malware functionality for different operating systems. The cybercriminals have implanted their work on Linux servers to bolster their position on the network. Security researchers found malware files named ntfsys that pretend to be system or driver files in the context of the NTFS filesystem.

As soon as the backdoor is executed, it checks whether it has been launched for the first time by requesting two arguments: the letter d and the process ID of the calling daemon. If it cannot find the arguments, it calls the daemon function and establishes its persistence on the system. The backdoor then restarts itself. It retrieves the process ID and its exec self path and calls the system function to run the [SELF_PATH] d [SELF_PID] command.

Persistence Methods

The persistence process is relatively extensive and includes several Ubuntu versions and Red Hat distributions. The first step is to determine the current operating system version by reading the /proc/version and etc/lsb-release files and analyzing the output. Then, based on the data collected, persistence can be achieved using one of the following methods.

Method 1 (Ubuntu) – rc.local activated via systemd: The malware first checks whether the /lib/systemd/system/rc.local.service file exists and writes the code from Listing 1 to the file.

Listing 1

rc.local Activated via systemd

[Unit]
Description=/etc/rc.local Compatibility
ConditionFilelsExecutable=/etc/rc.local
After=network.target
[Service]
Type=forking
ExecStart/=etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes

It then creates the following symlink.

/lib/systemd/system/rc.local.service --> /etc/systemd/system/

In the next step, the malware determines whether the /etc/rc.local file exists and, if it does, adds the following character string:

#!/bin/bash
[SELF_FILE_PATH] exit 0

Linodas then runs the chmod 777 command to make the /etc/rc.local file executable and evaluates whether the persistence has been correctly written to the file. Finally, the malware changes the INI fields in the /lib/systemd/system/rc.local.service file (Listing 2).

Listing 2

Changing INI Fields

[Service]
RemainAfterExit=no
[Install]
WantedBy=multi-user.target Alias=rc-local.service

Method 2 (Red Hat) – init.d script: The backdoor calls up the command, the output from which is analyzed by Chkconfig, and attempts to execute it. If the command is found and executed correctly, it adds it to the PATH environment variable and continues with the actual persistence. The malware checks whether the file /etc/init.d/[SELF_FILE_NAME] exists and then writes the code from Listing 3 to it.

Listing 3

Modify /etc/init.d/

#!/bin/sh
### BEGIN INIT INFO
# Provides:          [SELF_FILE_NAME]
# Required Start:    $local_fs $network
# Required Stop:     $local_fs
# Default Start:     2 3 4 5
# Default Stop:      0 1 6
# Short Description: [SELF_FILE_NAME] service
# Description:       [SELF_FILE_NAME] service daemon
### END INIT INFO
[SELF_FULL_ATH] restart

If the file has not been created, it writes the same data to the /etc/ch.sh file and executes the following command:

mv /etc/ch.sh /etc/init.d/[SELF_FILE_NAME]

The malware then executes the chmod 777 command for the created file and checks the persistence using the next call:

chkconfig --list | grep [SELF_FILE_NAME]

If the result does not contain 6:, the following two commands are used:

chkconfig --add [SELF_FLE_NAME] chkconfig zentao [SELF_FLE_NAME]

Method 3 (Red Hat) – rc.local: Persistence takes place via the file /etc/rc.d/rc.local. If the file exists, the backdoor checks whether its self path exists in the content – if not, it adds itself to the file with the \n[SELF_PATH]\n string.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Backdoors

    Backdoors give attackers unrestricted access to a zombie system. If you plan to stop the bad guys from settling in, you’ll be interested in this analysis of the tools they might use for building a private entrance.

  • ESET Discovers New Linux Malware

    WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.

  • SpeakUp Trojan Targets Linux Servers

    It’s exploiting a known vulnerability.

  • News

    In the news: Linux Mint 20.3 Now Available; Linux Gets an Exciting New Firmware Feature; elementary OS 6.1 Has Been Released; Intel Releases Linux Patch for Alder Lake Thread Director; New Multiplatform Backdoor Malware Targets Linux, macOS, and Windows; and WhiteSource Releases Free Log4j Detection Tool.

  • Honeynet

    Security-conscious admins can use a honeynet to monitor, log, and analyze intrusion techniques.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News