Analysts found it interesting that all the products and the particular package have had widely distributed public proofs of concept for pre-auth RCE.
Looking at the Monero wallet from one such mining pool, Analysts saw that the operation is still ongoing and actively accumulating Monero as of this writing.
The miner samples Analysts found work on and abuse both Windows and Linux platforms. While the exploits used differ according to the infrastructure targeted, the batch scripts Analysts identified works on both. Analysts saw the usage of Netlify and GitHub as the malware file servers for downloading batch scripts from an attacker-controlled account. The batch script is renamed as a temporary file and deleted after it starts running in the background.
Windows
The scripts are a modified version of Monero-mining helper scripts abridged from GitHub, and these begin checking if the current session has administrative privileges.
If the privilege is of the Administrator, then the ADMIN flags are set. Afterward, the length of the Monero wallet address is calculated.
If the length is not 106 or 95 characters, the script exits. If it is 106 or 95, it jumps to “WALLET_LEN_OK” statement.
The script further conducts a series of checks in the system, such as if the USERPROFILE environment variable is defined, and whether utilities like wmic, powershell, find, findstr, and tasklist are available or not.
The wmic utility is used to further enumerate specific parameters in the system, such as the number of processors, maximum clock speed, L2 and L3 cache sizes, and CPU sockets.
These values are later used to calculate the Monero mining rate of the Windows host. For different mining rates, different ports are used on the mining pool.
After identifying the CPU’s computing power, the running c3pool_miner is removed from the host.
The zipped miner (c3.zip) is then downloaded from the attacker-controlled GitHub repository and PowerShell is used to unzip the downloaded file.
If the unzip attempt fails, 7z is downloaded to extract the zipped file, and both the downloaded files.
The script also goes on to install the latest version of XMRig for Windows from the official repository.
After unzipping the downloaded file, the 7z binary and XMRig ZIP files are removed.
Once the miner is successfully installed, the config files are modified using PowerShell.
If the miner is already running (c3.exe), the execution jumps to an ALREADY_RUNNING label. If not, the miner is executed using the “start” command in the IDLE priority class.
If the current user has administrative privileges, then execution jumps to the label ADMIN_MINER_SETUP.
If not, persistence is added by modifying the Startup directory with the batch scripts to execute c3pool XMR miner with the configuration file.
A service is created from the c3cache_worker using the Non-Sucking Service Manager (NSSM). NSSM is a service helper program that helps install applications as services, and with it a user can specify logging to user-defined files.
Linux
The shell script starts with an infinite loop to remove all competing cryptominers found in the infected system, such as kinsing, kdevtmpfsi, pty86, and .javae.
After all the competing miners are wiped out, the attribute of /var/spool/cron/root is made immutable and crontab is reloaded.
Then, if there are any processes except java, redis, weblogic, mongod, mysql, oracle, tomcat, grep, postgres, confluence, awk, and aux that are raking up more than 60% of CPU usage, they are terminated.
A function “func1” (redacted) is called and the loop is reiterated after every 30 seconds.
Analysts observed two content delivery networks (CDNs) being used as the FILE_CC_SERVER in GitHub and Netlify.
In func1, a process “java.xnk” is checked for and if the CPU usage is above or equal to 60%, the process ID is fetched into a variable “p”. If the variable is empty, then the process is killed and three directories are created, namely:
a. /var/tmp/java.xnk
b. /var/lock/java.xnk
c. /tmp/java.xnk
Different paths for “wget” and “curl” binaries are checked for and assigned to variable Wget. A file “java.xnk.bionic” is checked in the path “$DIR”.
If the file doesn’t exist, the valid Wget command is used to download and copy the file named “bionic” (a Monero miner) and “config.json,” which contains the Monero wallet address.
Executable permissions are assigned for the downloaded binary and the binary is executed via nohup.
Similarly, the following binaries are downloaded and executed in place of the file “bionic” and repeat the process:
focal as java.xnk.focal
freebsd as java.xnk.freebsd
linuxstatic as java.xnk.linux
xenial as java.xnk.xenial
xmr-stak as java.xnk.stak