# Farewell to Kelihos and ZOMBIE SPIDER **crowdstrike.com/blog/farewell-to-kelihos-and-zombie-spider/** Brett Stone-Gross, Tillmann Werner, and Bex Hartley December 5, 2018 The Kelihos peer-to-peer botnet was one of the largest and longest-operating cybercrime infrastructures in existence. Its origins can be traced [back to the Storm Worm, a botnet that emerged in 2007 and was one of the earliest criminal malware infrastructures to leverage peer-to-peer](https://www.crowdstrike.com/epp-101/malware/) technology. After the demise of Storm, it was replaced by another new botnet known as Waledac that also leveraged peer-to-peer communications. Waledac was taken over and neutralized by a group of researchers in September 2010 . The first generation of Kelihos1 emerged in December that year, three months after its predecessor Waledac was dismantled. Kelihos itself was subject to several takeover operations, each of which lead to the botnet being rebuilt in a new, more robust manner. The2 3 4 fifth and last generation of the botnet had been around since summer 2013, with an estimated size of 40,000 infected machines. It was neutralized by the U.S. Department of Justice with technical assistance by CrowdStrike in April 2017 .5 The Kelihos malware featured a wide assortment of plugins for different criminal purposes but was primarily used to deliver spam emails. Its peer-to-peer network protocol was designed to be difficult to reverse engineer, containing several layers of encryption, including RSA, Blowfish and a custom obfuscation algorithm that the malware author referred to as “monkey” functions in the code. This design is a clear reaction to previous takedowns with the goal to raise the bar for future attacks, but it ultimately failed to protect the botnet against attacks. The primary threat actor, who was tracked by CrowdStrike as ZOMBIE SPIDER, rose to prominence in the criminal underground under the moniker Peter Severa. The individual behind this handle is Peter Yuryevich LEVASHOV6 who was arrested in Spain when the final version of [Kelihos was taken over in April 2017, and who recently pleaded guilty to operating the botnet for criminal purposes .7](https://www.crowdstrike.com/blog/inside-the-takedown-of-zombie-spider-and-the-kelihos-botnet/) The purpose of this blog is to summarize and share our findings about Kelihos and its operator. The first section summarizes the results of our technical analysis of the Kelihos malware. The second section discusses attribution and provides some context around the threat actor. The blog concludes with an outlook section and we provide a YARA rule for detection in the Appendix. ## Technical Analysis of Kelihos Modern spam botnets have to be flexible in the way they run campaigns in order to be able to quickly adapt to new detection techniques. Kelihos, like many others, implemented a sophisticated spam engine that automatically constructs spam messages from templates and additional inputs to avoid any patterns that can be used in filters. Despite the flexibility provided by the template system, some spam campaigns exhibited recurring characteristics and several researchers believed that there existed multiple simultaneously operated versions of the botnet. This was never the case. Spam jobs that were distributed by the botnet operator defined a message template. A bot would populate this template with randomly generated strings or information taken from additional dictionary files that contained, for example, subject lines or URLs. A captured spam template is shown below, with several variable fields highlighted in different colors. ``` Received: from %^C0%^P%^R3-6^%:qwertyuiopasdfghjklzxcvbnm^%^% ([%^C6%^I^%.%^I^%.%^I^%.%^I^%^%]) by %^A^% %^Fsendmailver^% with SMTP id %^Y%^C5%^R20-300^%^%^%037036; %^D%^V5^%^% Message-ID: <%^O%^V6^%:%^R3-50^% %%^V0^%>From: "%^C4%^Fmynames^%^%" <%^Fnames^%@%^Fdomains^%> To: <%^0^%> Subject: %^Fpharma^% Date: %^D-%^R30-600^%^% MIME-Version: 1.0 Content-Type: text/plain; format=flowed; ``` ----- ``` ; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.%^C7%^Foutver.6^%^% X-MimeOLE: Produced By Microsoft MimeOLE V6.00.%^V7^% %^J%^Fpharma^% %^Fmirabella_links2^%^% ``` The following is an email constructed from this template. ``` Received: from iaw ([232.59.54.125]) by ppp-188-174-39-206.dynamic.mnet-online.de (8.13.1/8.13.1) with SMTP id 201104051045037036; Tue, 5 Apr 2011 10:45:55 +0100 Message-ID: <002101cbf36d$426b6370$e83b367d@seclabiaw> From: "Christina" To: <[redacted]> Subject: Wonderful revealing effect on your libido. Date: Tue, 5 Apr 2011 10:32:16 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Bring more enjoyment to your life, get a magicpil! http://drokkies[.]nl/dwg2c4v.html ``` For several years, pump-and-dump stock scams, dating ruses, credential phishing, money mule recruitment and rogue online pharmacy advertisements were the most common spam themes. In 2017, however, Kelihos was frequently used to spread other malware such as _LuminosityLink, Zyklon HTTP, Neutrino, Nymaim, Gozi/ISFB, Panda Zeus, Kronos, and TrickBot. It was also observed spreading ransomware_ families including Shade, Cerber, and FileCrypt2. ### Malware Distribution The Kelihos malware distribution model involved affiliates of a pay-per-install service operated by ZOMBIE SPIDER. Each affiliate was provided with a custom malware binary with a unique tag hard-coded into the executable. The criminal operators of Kelihos were able to track and credit affiliates for infections based on these tags when the malware communicated with their backend infrastructure. Compared to other malware families, Kelihos executables are relatively large due to the use of several third-party libraries, including Crypto++ for handling encryption-related functions, the Boost library that provides a wide variety of convenience functions, and the WinPcap library that is used for capturing credentials used in plaintext network protocols. Affiliates frequently distributed Kelihos executables through social engineering and exploit kits. In addition, the Kelihos peer-to-peer network provided a fast-flux DNS hosting service that was often used in combination with spam campaigns to serve its own binaries. As an example, the URL `http://betaler[.]com/gl1_1.php was hosted by that fast-flux service network. In this case, the content served from this URL` was some simple JavaScript-based redirect code shown below: ``` ``` The domain `combach[.]com from the redirect target was hosted on the Kelihos fast-flux service network as well. Visiting users were` presented with the fake Adobe Flash Player website shown in Figure 1 in an attempt to deceive them into clicking the installation link, which would, in turn, provide a Kelihos malware executable. ----- Figure 1. Fake Adobe Flash Player Installer Website ### Installation and Persistence The malware establishes persistence by creating a registry name and value pair under the key ``` Software\Microsoft\Windows\CurrentVersion\Run in the HKEY_LOCAL_MACHINE hive if the user has administrator privileges, or the HKEY_CURRENT_USER hive, otherwise. The registry name consists of a word from the prefix noun list shown below concatenated with a word ``` from an action suffix list. Its value points to the Kelihos executable on disk. Kelihos modifies the file attributes on its own executable to hidden and read only. The following prefix nouns were used: ``` Connection CrashReport Database Desktop Folder Icon Media Network Time Tray Video ``` The following is the list of suffix nouns used to construct the name string: ``` Checker Informer Notifyer Saver Updater Verifyer ``` Upon initial infection, the malware generates a 16-byte unique bot identifier that is used during peer-to-peer communications. This value is created from 15 randomly generated bytes plus a single-byte checksum that is computed by adding the 15 random bytes together. All Kelihos binaries start with a list of hard-coded peers to bootstrap the process of joining the peer-to-peer network. All analyzed samples had dozens of such hard-coded entries, each consisting of an IP address, a TCP port number (which in all cases is 80), the last time a peer has been contacted (which defaults to 0 in the bootstrap list), a bot ID, and the number of seconds a peer has been live, also defaulting to 0. The peer list is stored in the Windows registry with the name determined by concatenating strings from three dictionaries. However, due to a bug in the code, this name will always be `DBSavedUse when the malware is executed for the first time. The value stored at this name always` starts with the magic byte pattern `A2 49 4D F3 D9 1E 9F 88 01 that is used as a signature to identify serialized data and also present in` each peer-to-peer protocol message. In addition to the peer list, Kelihos will create three more name/value pairs under this registry key that ----- sto e ( ) a aste ey a ue, ( ) t e ast job a ue, a d (3) t e bot a ue e coded t ase6 ue to t e bug e t o ed ea e, t ese registry names will always be `PersistentLocalizedName,` `PlatformCompressedValid, and` `LineLoadedQuick` `. In addition, if Kelihos` is running in router mode (see below), the registry name `RecordEnabledCheck will also be created.` Despite the bug in the code, identifying the registry key that stores the Kelihos configuration information is non-trivial. The precise location of the registry key is selected by computing a histogram of the character length and the uppercase and lowercase frequencies for each key and subkey in the `HKEY_CURRENT_USERS hive. The results of the histogram are then sorted, and the first entry in the list is chosen to hold the` configuration information. Consequently, different infected machines will likely store the data in different locations. ### Peer-to-Peer Protocol Infected machines form a peer-to-peer network with a hierarchical architecture shown in Figure 2. There are three tiers, referred to as job _servers, router nodes, and worker nodes. When a system is infected, the malware checks the network adapter settings to determine whether it_ has a publicly routable IP address. If that is the case, the bot will start in the router mode of operation and create network services on TCP port 80 for peer-to-peer communications and on UDP port 53 for participating in the fast-flux network. If the system has no public IP address, the malware will start in worker mode and receive tasks to generate spam emails. Figure 2. Kelihos Botnet Architecture There are two primary types of peer-to-peer messages: peer lists and jobs. All peer-to-peer communications occur over TCP port 80, with peer lists being exchanged over a custom binary protocol and jobs being distributed using the same protocol with the addition of HTTP encapsulation. This distinction comes from the fact that messages related to tasking are being processed by the HTTP-based backend servers, whereas all other messages are exchanged between nodes that are part of the dynamic, self-organizing, peer-to-peer network — there is no need to encapsulate these in HTTP sessions. The custom network protocol used for all message types makes use of RSA to perform a key exchange among peers and subsequently encrypt data with this session key. The first packet of the key exchange is similar to the following: ``` 00000000 d5 e2 57 60 6c 55 55 45 03 10 48 40 99 5b 9f ad ..W`lUUE ..H@.[.. 00000010 72 1e 36 2f 44 e1 00 0c 16 dd 9e 04 30 46 02 41 r.6/D... ....0F.A 00000020 00 d0 5f a9 4d e0 34 a9 21 c8 e4 30 43 47 aa 7a .._.M.4. !..0CG.z 00000030 00 6f ea 0d a4 8f d6 3f b1 c9 6b c9 c4 93 54 5f .o.....? ..k...T_ 00000040 d7 70 1a de 1c b1 5c 4d ca cf 61 86 14 a4 31 63 .p....\M ..a...1c 00000050 75 60 9e 9b 69 b4 8e d7 19 26 1f 56 66 49 ab bd u`..i... .&.VfI.. 00000060 e3 02 01 11 79 e2 f6 4d f4 56 c1 22 6c 23 90 3a ....y..M .V."l#.: 00000070 60 4f be 69 a3 78 f2 a0 bc c5 ff ca 99 c7 7c 18 `O.i.x.. ......|. 00000080 1b 65 26 2b 0f dd 1b e6 3a f4 13 e0 64 bf 25 89 .e&+.... :...d.%. 00000090 86 ba e2 1f 5d d0 f1 06 e8 71 2e ea a5 b8 64 ef ....]... .q....d. ``` ``` 000000A0 ae bf 8d a7 .... ``` The first DWORD in the hexdump above specifies the protocol version. Its value has been generated by a bit-scrambling function with random entropy to obfuscate the actual version number, which was 5 in the last generation of the botnet. The second DWORD is the size of the message, which is obfuscated using another bit-scrambling function. The four bytes at offset 8 serve as a header for the payload data, which is composed of serialized blocks. This header has the following structure: 1. Number of blocks (0x03) 2. Size of the first block: 16-byte session key (0x10) 3. Size of the second block: peer’s RSA public key in BER format (0x48) 4. Size of the third block: RSA signature of the 16-byte session key (0x40) The remote peer responds with a message similar to the following: ``` 00000020 2f f3 43 92 67 15 ac ed 3c 68 49 88 27 55 5a b5 / C g