cover image for post 'Rogue Security Software with Encrypted DGA Domains'

Rogue Security Software with Encrypted DGA Domains

Advent of DGAs - Day 6

Today I am revisiting the 360 Netlab DGA repository on GitHub. The sample comes from issue 14:

FieldValue
MD594d31d4606a0ddf45a2a3da37ab67304
SHA181f6ec7c6e0e07968ffba12540088549924746fa
SHA256aaf39c1dbe041ebbb3e2a614b125b7e6895f11727be5c3ec4b42e471f25ec54a
File size292,864 bytes
FormatPE32 executable, GUI subsystem
ArchitectureIntel i386
LanguageUnknown (native x86 code)
RuntimeNot applicable
VirusTotalView sample on VirusTotal

It produces domains like these

  • bivobakumuv[.]com
  • cysuhevuzilu[.]com
  • dewyvoryr[.]com
  • gajejunymepewo[.]com
  • jeryqitego[.]com
  • kakukunucatih[.]com
  • kipuhazasalel[.]com
  • kypojufiruqym[.]com
  • merurelecotele[.]com
  • negujavigoken[.]com
  • pelituhypivi[.]com
  • qamikumopy[.]com
  • vahijitenate[.]com
  • wabypukov[.]com
  • wavysyfykylic[.]com
  • wewaqaloqad[.]com
  • wyqaqitasulaz[.]com
  • zisixexaboci[.]com

The issue suspect them to be a “new time independent DGA” because two runs on different days produced the same list. The first half of that observation turned out to be correct, but the second half is not: there is no generator. The names are stored in the sample, encrypted, in the third of three payload layers. A small configuration blob holds three hostname tables of thirty slots each, and domain names above are from one of them.

The malware is a rogue security product: it imitates the Windows Security Center, carries alarming scan and infection messages, asks for a registration key, and holds a list of real antivirus processes. The hostname tables are the way it phones home. Searches for the window classes, command-line switches, configuration layout and request format turned up no public report that ties them to a named family, so this post describes the sample by what it does and does not pin it to a family.

Unpacking

The original file looks like an ordinary GUI program with a very large import table and a lot of dead code. The first layer hides in its data section. A routine in the entry code allocates a buffer and fills it with a decoder that uses a running sum: each stored value is added to an accumulator, the result becomes the next output dword, and the accumulator is advanced by the result plus a second constant. The loop ends when the output equals a sentinel 0xB2865BD3. The 2308 bytes it produces are position-independent shellcode:

The loop in the sample that rebuilds the first-stage shellcode from the data section.

That shellcode is a reflective loader for payload that is spread over the data section as a chain of nearly a thousand blocks, each prefixed by an encoded length and an encoded pointer to the next block, and interleaved with unrelated filler. The loader walks the chain, concatenates the blocks and runs the result through a simple byte-wise rolling XOR:

The rolling XOR decoder in the first-stage shellcode.

It then decompresses the result with aPLib directly over the memory of the host image. It then resolves the imports of the new image through hashed API lookups, updates the module list entry in the process environment block and returns the new entry point.

The image that results is another packer stub with a third layer to unpack. The stub finds kernel32 through the process environment block, resolves the allocation and protection APIs by comparing export names and runs an inline LZMA decoder. The decompressed output is the final payload, preceded by a small relocation stub and a table of base relocations that the stub would apply if the image were loaded away from its preferred address.

The figure shows how each layer sits in its parent. The block chain in the original’s data section produces the second stage, the compressed stream inside the second stage produces the third and final stage. The configuration in the final stage is itself encrypted. The detail view at the bottom has its own scale because the configuration is small.

Unpacking chain of the sample

Phoning Home

The malware builds a plain HTTP/1.0 request and sends it with an Internet Explorer 6 user agent. The request path is ten digits:

  • The first eight are two numbers taken from the configuration (probably some kind of bot id or campaign id).
  • The last two report the victim’s Windows version and service pack level.

The malware supports Windows XP, Vista and 7 and exits on anything else, demonstrating how old the malware is. The C2 is expected to answer in two ways only:

  • A reply of OK lets the program continue to the code that builds its fake security interface.
  • A reply of WA stops the current malware run.

Any other answer moves on to the next domain name. When the table is exhausted or a C2 answered WA, the program sleeps for one hour and starts again from the first slot.

A short dynamic run confirms this: the malware resolved all eighteen names from Netlab 360’s issue in exactly the stored order and sent one request to each, all within well under a second, with the Internet Explorer 6 user agent and the ten-digit path described above.

Source of the Domains

The domain names come from a loop over thirty slots of a fixed size. Each slot holds an encrypted UTF-16 string; the loop decrypts twelve AES blocks per slot with the same key, treats a zero first character as an empty slot and passes the others to the request code in slot order. There is no shuffling and no selection by date or machine; the order of the first query is the order of the table.

The key for the slots lives in the decrypted configuration. The malware carries a blob of about 21 kilobytes, encrypted with AES-128 in ECB mode with the key stored directly in front of the blob. Decrypting it yields a flat structure that mixes plaintext and encrypted parts. Short identifier strings and an update path (/files/update123.exe) are in the clear.

The hostnames are stored in three tables of thirty slots each, and the key that decrypts the slots sits at the end of the structure, in the clear. So the whole mechanism is two AES-ECB layers where both keys are stored beside the data they protect, which hides the names from a string search and from a signature on the domain list but not from anyone who has access to the binary.

The three tables differ in how they are used:

  • Table A: 21 used slots, probed for reachability while the sample runs in its initial mode; also used to build a URL that is opened in the user’s browser
  • Table B: 6 used slots, probed for reachability once the configuration marks the sample as installed; its first reachable host serves the update download
  • Table C: 18 used slots, walked by the beacon loop described above; these are the domain names from the introduction

Tables A and B are decrypted at start-up into arrays that worker threads use to test whether a host answers on port 80 within a timeout. If the host fails, the code tries microsoft.com as a connectivity probe, so that it can tell a dead name from a machine without internet access, and it records the result per slot. The two tables are used in different modes. The mode is selected by a flag in the configuration:

  • In the analysed configuration the flag is unset, which is the mode that runs the beacon loop over table C.
  • In the other mode, a helper picks the first reachable name from table B and downloads the update path from the configuration, /files/update123.exe, over the same HTTP routine. A body larger than 1024 bytes is written to disk and launched with a -qav switch, with a minimum spacing of a day between attempts.

Table A feeds a routine that builds a URL from a reachable host and hands it to the shell to open in the browser, with the system’s Internet Explorer as a fallback; that is probably the landing page of a rogue product, but I found no online example to confirm.

Both tables A and B and table C use the same naming style: pronounceable strings of mostly alternating consonants and vowels (counting y as a vowel), between 9 and 14 letters before the suffix, always under .com. The style is what makes the list look algorithmic and is what led to the DGA label.

Indicators of Compromise

IndicatorTypeClassification
fekitekilisaga[.]comdomainTable A
fitowisas[.]comdomainTable A
mijejazixed[.]comdomainTable A
nawiqimipijyb[.]comdomainTable A
bybiluvolodut[.]comdomainTable A
famawomacepo[.]comdomainTable A
huhyligefiqy[.]comdomainTable A
dyrufozuvycy[.]comdomainTable A
xenyqupabire[.]comdomainTable A
fevelojiso[.]comdomainTable A
ketupejovyhana[.]comdomainTable A
kisowogove[.]comdomainTable A
jotowakiduzega[.]comdomainTable A
wemyfajykok[.]comdomainTable A
huzifatohov[.]comdomainTable A
ziwycazumup[.]comdomainTable A
qizycudetewyny[.]comdomainTable A
nudajabamimo[.]comdomainTable A
zexepajaw[.]comdomainTable A
nejigidal[.]comdomainTable A
pecimurinaje[.]comdomainTable A
gusavonasetyr[.]comdomainTable B
warypydekesix[.]comdomainTable B
bucakyqej[.]comdomainTable B
waquwajyqak[.]comdomainTable B
worumubakuxak[.]comdomainTable B
qikinuzeficu[.]comdomainTable B
zisixexaboci[.]comdomainTable C
merurelecotele[.]comdomainTable C
wyqaqitasulaz[.]comdomainTable C
cysuhevuzilu[.]comdomainTable C
kypojufiruqym[.]comdomainTable C
kakukunucatih[.]comdomainTable C
pelituhypivi[.]comdomainTable C
wabypukov[.]comdomainTable C
qamikumopy[.]comdomainTable C
jeryqitego[.]comdomainTable C
kipuhazasalel[.]comdomainTable C
bivobakumuv[.]comdomainTable C
wavysyfykylic[.]comdomainTable C
dewyvoryr[.]comdomainTable C
gajejunymepewo[.]comdomainTable C
negujavigoken[.]comdomainTable C
vahijitenate[.]comdomainTable C
wewaqaloqad[.]comdomainTable C
/files/update123.exeURI path
GET /<ten digits> HTTP/1.0request patternobserved digits 10070007
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)user agentcommon at the time
e8s6j3722aspx5r38kv4uj28nf60g8ifilenameconfiguration token
%LOCALAPPDATA%\<three random letters>.exepathself-copy
ir4cnxm3oi333, uqyua7mwx2, 1ydvtha273b54stringsconfiguration identifiers
3rfth36w354yha2a, 5y4545hg4whystringsembedded literals
8fa5dc39bde4d1637b160f9e1005b539stringAES-128 key 1
6779cf3606a8de9b24c4697e732dd0fastringAES-128 key 2

References

About this post

Table of Contents
Advent of DGAs

This post is part of Advent of DGAs, a daily series in which I look at one malware sample that appears to use a domain generation algorithm (DGA). Check out all parts of the series.

I’m working with samples I don’t expect to be relevant to current threats. To keep up with the daily schedule, I spend only a short time on each one, so the write-ups are closer to research notes than exhaustive analyses. I also use AI to help with the analysis and writing.

Disclaimer

These are just unpolished notes. The content likely lacks clarity and structure; and the results might not be adequately verified and/or incomplete.