HackDig : Dig high-quality web security articles for hacker

IBM X-Force Research recently observed a wave of malware-induced Active Directory (AD) lockouts across several incident response engagements. The lockouts caused hundreds to thousands of AD users to get locked out of their company’s domain in rapid succession, leaving employees of the impacted organizations unable to access their endpoints, company servers and networked assets.

Active Directory manages users and user access on Microsoft servers, as well as the policies and procedures that enable network access. X-Force researchers associated the mass AD lockouts with malicious activity by an existing banking Trojan known as QakBot, aka PinkSlip.

X-Force Incident Response and Intelligence Services (IRIS) responders, who investigated recent QakBot activity waves, suspect that numerous organizations have suffered and will continue to suffer from these lockout waves.

QakBot Back in Business

According to X-Force research, QakBot is financial malware known to target businesses to drain their online banking accounts. The malware features worm capabilities to self-replicate through shared drives and removable media. It uses powerful information-stealing features to spy on users’ banking activity and eventually defraud them of large sums of money.

Though well-known and familiar from previous online fraud attacks, QakBot continually evolves. This is the first time IBM X-Force has seen the malware cause AD lockouts in affected organizational networks.

Although part of QakBot is known to be a worm, it is a banking Trojan in every other sense. QakBot is modular, multithread malware whose various components implement online banking credential theft, a backdoor feature, SOCKS proxy, extensive anti-research capabilities and the ability to subvert antivirus (AV) tools. Aside from its evasion techniques, given admin privileges, QakBot’s current variant can disable security software running on the endpoint.

Overall, QakBot’s detection circumvention mechanisms are less common than those used by other malware of its class. Upon infecting a new endpoint, the malware uses rapid mutation to keep AV systems guessing. It makes minor changes to the malware file to modify it and, in other cases, recompiles the entire code to make it appear unrecognizable.

QakBot’s Dropper Run

Much like other malware of its class, the QakBot Trojan is ushered into infected endpoints through a dropper. The dropper typically uses delayed execution to evade detection. It lands on the target endpoint and halts before any further action for 10 to 15 minutes, hoping to elude sandboxes that might try to analyze it upon arrival. Next, the dropper opens an explorer.exe instance and injects the QakBot Dynamic Link Libraries (DLL) into that process.

After deployment, the dropper corrupts its original file. It uses the ping.exe utility to invoke a ping command that will repeat six times in a loop:

When the pings are complete, the contents of the original QakBot dropper are overwritten by the legitimate Windows autoconv.exe command. (Autoconv.exe converts file allocation table (FAT) and FAT32 volumes to the NTFS file system, leaving existing files and directories intact at startup after Autochk runs.) A snippet of QakBot’s JavaScript downloader is shown below:

Figure 1: QakBot downloader script

In the example above, the download locations that would fetch the QakBot payload were lightly obfuscated using character codes. The downloader from this sample attempted to connect to the following three update servers:

projects[.]montgomerytech[.]com

n[.]abcwd0.seed.fastsecureservers[.]com

css.kbaf.myzen[.]co[.]uk

At the time we ran the sample, the following download server responded with a large amount of ASCII hex, which was the QakBot payload: projects[.]montgomerytech[.]com/TealeafTarget.php.

Figure 2: QakBot obfuscated payload

Shortly after the payload was received on the infected machine, randomly named copies of QakBot were deployed to the system, as was the legitimate autoconv.exe utility.

To communicate with infected machines via rendezvous domains created on the fly, QakBot uses both a Domain Generation Algorithm (DGA) and a list of hardcoded command-and-control (C&C) servers. The hardcoded C&C servers observed in our sample are included at bottom of this article.

Persistence Mechanisms

QakBot is notorious for its capability to persist on infected machines. This, combined with the malware’s AD lockout capabilities, makes it especially frustrating to detect and remove in enterprise environments.

To keep itself alive after system reboots and removal attempts, QakBot establishes persistence mechanisms on the target systems using a Registry runkey and scheduled tasks. It creates a “CurrentVersionRun” registry entry to automatically launch itself after each new run of the operating system. An example run key created by the malware was “HKCUSoftwareMicrosoftWindowsCurrentVersionRunxyhz,” which pointed to “C:UsersUserNameAppDataRoamingMicrosoftGraroaojrgraroaoj.exe.”

QakBot adds another layer of persistence and creates recurring, named, scheduled tasks via “schtasks.exe” to run itself on timed intervals and ensure that it has not been disabled or removed.

Deploying malicious executables to network shares and registering them as a service.

Guessing User Credentials Until Lockout

To spread through the affected network, QakBot can move laterally, both automatically and on demand, by a remote command from its C&C server. To activate that capability, the attacker launches the malware’s command “13,” also known as “nbscan” in earlier variants of QakBot.

To access and infect other machines in the network, the malware uses the credentials of the affected user and a combination of the same user’s login and domain credentials, if they can be obtained from the domain controller (DC). QakBot may collect the username of the infected machine and use it to attempt to log in to other machines in the domain. If the malware fails to enumerate usernames from the domain controller and the target machine, the malware will use a list of hardcoded usernames instead.

Figure 4: QakBot’s hardcoded usernames.

To authenticate itself to the network, the malware will attempt to match usernames with various passwords. We have observed three password schemes, which may serve to defeat weak or default passwords:

Below is the assembly of a stack frame to attempt a connection to the IPC$ administrative share of a target machine using a username obtained from a domain controller:

Figure 6: Attempted connection to the IPC$ administrative share.

IPC$ is part of the common hidden network shares that are accessible only to administrators. Attackers may use it in conjunction with administrator-level credentials to remotely access a networked system over server message block (SMB). Usually, the purpose is to interact with systems using remote procedure calls, transfer files and run transferred binaries through remote execution, which could help QakBot run its malicious code.

Once the malware successfully connects to the IPC$ administrative share of the target machine, it checks to determine whether it can create a service locally. If it can, QakBot proceeds to enumerate the network shares of the target machine and then attempts to drop a copy of itself to one of the shares. Once a copy of the malware is dropped, the malware creates and starts a service in the target machine to execute it.

Under certain domain configurations, the malware’s dictionary attack for accessing the target machines can result in multiple failed authentication attempts, which eventually trigger an account lockout.

Figure 7: Accounts lockouts logged.

Enter Banking Trojan Mode

QakBot’s main purpose is to take over the bank accounts of a business, and possibly those of infected employees who browse their online banking at work.

QakBot implements man-in-the-browser (MitB) functionality that allows injected malicious code to be inserted into online banking sessions. Instead of keeping them inside its configuration file, QakBot fetches these malicious scripts on the fly from the domain it controls, in the following format:

These scripts are commonly referred to as webinjections because they are used to manipulate the visual content that infected users see on their banking websites. The code snippet below, labeled “WIRE” by the author, appears to check whether “To enroll in the” is visible on the wire transfer page of the targeted bank.

This is very typical Trojan behavior, designed to figure out where to start inserting the malicious code to modify the page and match the fraud M.O. the attacker has planned. It’s easy to see in this example that QakBot is targeting corporate banking services and aiming to reach the “change address” page of the compromised account.

Figure 8: QakBot webinjections targeting corporate banking accounts.

Another snippet from the same webinjection script seeks to collect personal information displayed in the online banking session by querying the document object model (DOM) elements of the page with names that are known to house sensitive details, such as date of birth and Social Security number.

Information Stealing Modules

The malware’s operators typically use QakBot to piggyback on banking sessions initiated by the user. QakBot’s theft mechanisms allow it to steal information including:

User keystrokes;

Cached credentials;

Digital certificates;

HTTP(S) session authentication data;

Cookies, including authentication tokens and Flash cookies; and

FTP and POP3 credentials.

Other data typically exfiltrated by QakBot and sent to a criminal-controlled FTP server include:

System information;

IP address;

Domain Name System (DNS) name;

Host name;

Username;

Domain;

User privilege;

OS version;

Network interfaces (address, netmask and status);

Installed software;

Credentials from the endpoint’s protected storage;

Account name and webserver credentials;

Connection type;

POP3 username, server and password; and

SMTP server and email addresses.

Typical Online Propagation

QakBot propagation in the wild most often takes place via exploit kits (EKs) and spam campaigns that target employees rather than widespread webmail users. Once inside the network, QakBot acts as a worm that can spread through network shares and removable drives.

In terms of magnitude, researchers reported that a recent QakBot botnet had successfully militarized over 54,000 infected computers.

QakBot’s Targets

Discovered in the wild in 2009, QakBot is historically considered one of the most advanced banking Trojans active in the wild. It is also the first Trojan that was designed to exclusively target the business banking sector, a vocation to which it has kept true throughout the past eight years.

In current QakBot campaigns, the malware is focused on U.S. business banking services, including treasury, corporate banking and commercial banking. X-Force IRIS responders have seen QakBot attacks in the pharmaceutical and technology sectors.

According to X-Force researchers, QakBot’s operators have been upgrading the malware’s code, persistence mechanisms, anti-AV and anti-research capabilities. As the malware evolves, it has also been known to target organizations in the health care and education sectors.

Researchers believe that a closed, organized cybercrime gang with roots in Eastern Europe is responsible for QakBot.

Global Perspective

From a global perspective, QakBot’s focus on the business sector and its periods of inactivity leave it at the bottom of the top 10 list of the most active malware families. In the past five years, the group operating QakBot has been in and out of the cybercrime arena, likely in an attempt to keep attacks to a minimum and avoid law enforcement attention.

Mitigating QakBot Infections

To detect threats such as QakBot, banks and service providers should use adaptive malware detection solutions that provide real-time insight into fraudster techniques and address the relentless evolution of the threat landscape.

Keeping QakBot out of employee endpoints starts with cybersecurity awareness, since this malware may come through infected websites or via email attachments. Users can protect themselves and their organizations by practicing browsing hygiene, disabling online ads, filtering macro execution in files that come via email and observing other security best practices.

Security basics go a long way toward protecting against EK deliveries. It’s critical to keep all operating systems up to date across the organization, update frequently used programs and delete those no longer in use. To mitigate QakBot activity on the network, make sure domain accounts are configured with the least privilege required to perform job tasks.

Organizations can also create a random domain admin account for safety purposes and ensure that it reports directly to the security information and event management (SIEM) system upon any attempt to use it. A special emergency account can enable security staff to recover service and determine the source when network users are being locked out.

Finally, prevent workstation-to-workstation communications where possible to force malware out of the trenches and into areas where central detection systems will pick it up quickly.

Indicators of Compromise

Malware dropper MD5:

2C5901F06E6211BB7F6D22AB3376C22C

A1593E2DC521EA8F66BB727B4725EC2C

Malware sample MD5:

8a3ab5d3fa3644ec1829e7825b0a22a3

08BACFFCC1E4DF896670047790373497

847BCDB4F5C2EBA96E8943430C4402C8

QakBot’s hardcoded C2 servers (note that connection to these IPs will always fail; network traffic will not be generated due to WinInet HTTPS/HTTP port blocking):