
In the href="https://www.fireeye.com/blog/threat-research/2019/04/carbanak-week-part-one-a-rare-occurrence.html">previous
installment, we wrote about how string hashing was used in
CARBANAK to manage Windows API resolution throughout the entire
codebase. But the authors used this same string hashing algorithm for
another task as well. In this installment, we’ll pick up where we left
off and write about CARBANAK’s antivirus (AV) detection, AV evasion,
authorship artifacts, exploits, secrets, and network-based indicators.
Source code unquestionably accelerates analysis of string hashes.
For example, the function AVDetect in class="code">AV.cpp iterates processes to detect AV by process
name hash as shown in Figure 1.

Figure 1: Antivirus detection by process
name hash
What does CARBANAK do with this information? It evades AV according
to what is installed. Figure 2 shows the code for an AVG evasion that
the authors disabled by commenting it out. Based on this, it appears
as if the AVG evasion was retired, but FLARE team member href="https://twitter.com/nopandroll">Ryan Warns confirmed in
November 2017 that it still worked with one minor tweak. FLARE
disclosed this to AVG immediately upon confirming it. Avast indicates
that after our disclosure, they updated the affected DLL to ignore
DLL_PROCESS_DETACH and leave its hooks in place.

Figure 2: Commented out source code to
unload AVG user-space hooks
In November of 2017, FLARE also disclosed an evasion for Trend
Micro’s detection of process injection that remained active in the
CARBANAK source code. The evasion mirrors a technique used in href="https://github.com/hzeroo/Carberp/blob/master/source%20-%20absource/pro/all%20source/RemoteCtl/hvnc2/core/svchost_inj.cpp#L8">Carberp
that replaces remote heap allocation and a call to class="code">CreateRemoteThread with memory mapping and
queueing of an asynchronous procedure call via class="code">QueueUserAPC. Following our disclosure, Trend
Micro indicated that they had updated their behavior monitoring rules
and released OfficeScan XG SP1 in December 2017 with a new “Aggressive
Event” detection feature that covers this behavior.
Having source code could pose unique opportunities to learn about
the individuals behind the keyboard. To that end, I searched for
artifacts in the source code dump that might point to individuals. I
found the most information in Visual Studio solution files. Most of
these referenced drive O: as the source
root, but I did find the following host paths:
Unfortunately, these data points don’t yield many answers. If they
are observed in later artifacts, connections might be inferred, but as
of this writing, not much else is known about the authors.
The CARBANAK source code contained numerous exploits, previous C2
hosts, passwords, and key material. I decided to comprehensively
search these out and determine if they led to any new conclusions or
corroborated any previous observations.
I wanted to know if the CARBANAK authors wielded any exploits that
were not publicly disclosed. To the contrary, I found all the exploits
to be well-documented. Table 1 breaks out the escalation code I
reviewed from the CARBANAK source code dump.
Table 1: Exploits for elevation found in
CARBANAK source code
The CARBANAK source code also contains code copied wholesale from href="https://github.com/gentilkiwi/mimikatz">Mimikatz including
the sekurlsa module for dumping passwords
from lsass.exe and Terminal Services
patching code to allow multiple remote desktop protocol connections.
My analysis included an audit of passwords and key material found in
the source code and accompanying binaries. Although many of these were
used for debug versions, I curated them for reference in case a need
might arise to guess future passwords based on passwords used in the
source code. Table 2 shows recovered passwords used for RC2-encrypted
communications and other purposes along with the corresponding name in
the source code and their status as they were encountered (active in
source code, commented out, or compiled into a binary).
|
|
|
ADMIN_PASSWORD | valign="top"> | valign="top"> |
ADMIN_PASSWORD | valign="top"> | valign="top"> |
ADMIN_PASSWORD | valign="top"> | valign="top"> |
ADMIN_PASSWORD | valign="top"> | valign="top"> |
N/A | valign="top"> | valign="top"> |
Table 2: Passwords found in CARBANAK source code
and binaries
I found an encrypted server certificate in a debug directory. This
seemed like it could provide a new network-based indicator to
definitively tie operations together or catch new activity. It was
trivial to brute force this container by adapting a publicly available
href="https://msdn.microsoft.com/en-us/library/ms148440.aspx">code
sample of X509 handling in C# to cycle through passwords in a
popular password list. The password was found in less than 1 second
because it was the single-character password “1”. The certificate
turns out to be for testing, hence the weak password. The certificate
is shown in Figure 3, with details in Table 3.

Figure 3: Test Company certificate
|
|
Subject | CN=Test |
Issuer | CN=Test |
Serial Number | valign="top"> |
Not Before | valign="top"> |
Not After | valign="top"> |
Thumbprint | valign="top"> |
Signature Algorithm | valign="top"> |
Public Key | valign="top"> |
Private Key | Key Provider Name: Microsoft Strong Provider type: 1 Key Key Container Name: Unique Key Container Hardware Device: False Removable: False Protected: False |
Table 3: Test Company certificate details
I also parsed an unprotected private key from the source code dump.
Figure 4 and Table 4 show the private key parameters at a glance and
in detail, respectively.

Figure 4: Parsed 512-bit private key
|
|
bType | 7 |
bVersion | 2 |
aiKeyAlg | 0xA400 |
Magic | RSA2 |
Bitlen | 512 |
PubExp | 65537 |
Modulus | 0B CA 8A 20 5D 54 03 02 EA A8 15 46 9F 3E 14 57 F5 1F D0 B7 27 42 0E D1 |
P | 8B 01 8F 7D 1D E0 05 FA D0 35 B2 BF |
Q | 81 69 AB 3D D7 9A 3B 83 EC 2F F1 F7 |
Dp | B5 C7 AE 0F 9E 2B 0E 57 F3 DB |
Dq | 81 AC 0D 20 C3 9D 66 C9 2E 0A |
Iq | C2 D2 55 32 24 76 09 2B 56 71 |
D | 01 6A F3 FA 6A 7C 68 28 70 4D FB 6A 2A 0F FB 39 13 BD 1B 46 6A 2F A3 BD B3 E5 D6 85 98 4D 1C 06 |
Table 4: Private key parameters
I found a value named PUBLIC_KEY defined
in a configuration header, with comments indicating it was for
debugging purposes. The parsed values are shown in Table 5.
|
|
bType | 6 |
bVersion | 2 |
aiKeyAlg | 0xA400 |
Magic | RSA1 |
Bitlen | 512 |
PubExp | 65537 |
Modulus | 0B CA 8A 20 5D 54 03 02 EA A8 15 46 9F 3E 14 57 F5 1F D0 B7 27 42 0E D1 |
Table 5: Key parameters for PUBLIC_KEY defined
in configuration header
The source code and binaries contained multiple Network-Based
Indicators (NBIs) having significant overlap with CARBANAK backdoor
activity and FIN7 operations previously observed and documented by
FireEye. Table 6 shows these indicators along with the associated
FireEye public documentation. This includes the status of each NBI as
it was encountered (active in source code, commented out, or compiled
into a binary). Domain names are de-fanged to prevent accidental
resolution or interaction by browsers, chat clients, etc.
Table 6: NBIs and prevously observed activity
Four of these TCP endpoints (80.84.49[.]50:443, 52.11.125[.]44:443,
85.25.84[.]223, and 37.1.212[.]100:700) were new to me, although some
have been href="https://www.rsa.com/content/dam/en/white-paper/the-carbanak-fin7-syndicate.pdf">documented elsewhere.
Our analysis of this source code dump confirmed it was CARBANAK and
turned up a few new and interesting data points. We were able to
notify vendors about disclosures that specifically targeted their
security suites. The previously documented NBIs, Windows API function
resolution, backdoor command hash values, usage of Windows cabinet
file APIs, and other artifacts associated with CARBANAK all match, and
as they say, if the shoe fits, wear it. Interestingly though, the
project itself isn’t called CARBANAK or even Anunak as the information
security community has come to call it based on the string artifacts
found within the malware. The authors mainly refer to the malware as
“bot” in the Visual Studio project, filenames, source code comments,
output binaries, user interfaces, and manuals.
The breadth and depth of this analysis was a departure from the
usual requests we receive on the FLARE team. The journey included
learning some Russian, searching through a hundred thousand of lines
of code for new information, and analyzing a few dozen binaries. In
the end, I’m thankful I had the opportunity to take this request.
In the next episode, Tom Bennett takes the reins to provide a
retrospective on his and Barry Vengerik’s href="https://www.fireeye.com/blog/threat-research/2017/06/behind-the-carbanak-backdoor.html">previous
analysis in light of the source code.