MBR bootkit
TDL4 (TDSS / Alureon) MBR Bootkit: Traces and Checks
TDL4 replaced the MBR boot code, kept its files in a hidden encrypted store at the end of the disk and beat x64 driver signing. Traces, offline checks, cleanup.
- Kind
- MBR bootkit · Boot layer
- Platforms
- Windows
- First seen
- 2010
- Status
- Historical
- Also known as
- TDL-4, TDSS, Alureon, Olmarik
- Checked by
- Disk boot sectors
Overview
TDL4 is the fourth generation of the TDSS rootkit family, which Microsoft calls Alureon and ESET detects as Olmarik. Kaspersky dates TDSS to 2008 and TDL-4 to July or August 2010. It is a bootkit: it replaces the boot code of the disk's master boot record (MBR), so its code runs before Windows, and it keeps its components in an encrypted store of its own at the end of the disk, outside any file system Windows can see.
TDL4 could load its driver on 64-bit Windows despite kernel-mode code signing. ESET describes the trick at the level of the boot configuration, and Microsoft closed it with an operating system loader update in April 2011 (advisory 2506014). TDL4 was a criminal botnet, not a targeted tool: Kaspersky counted 4,524,488 infected computers in the first three months of 2011. Its modules served proxies, search-result substitution and downloads of other malware, removed about 20 competing malware families, and used the public Kad peer-to-peer network as a fallback channel. Kaspersky also reported droppers using a privilege escalation exploit from Stuxnet's arsenal.
The family is historical: the reports date from 2010 to 2012, and it needs a BIOS (legacy) boot from an MBR disk. It still matters to responders as the model for the MBR and VBR bootkits that followed, such as Rovnix and Gapz, and old machines still turn up.
How it loads and hides
Kaspersky's January 2011 analysis describes this chain:
- MBR. The BIOS runs TDL4's small MBR loader. It finds
ldr16in the rootkit's encrypted store, loads it and passes control to it. The original MBR is kept in the store. ldr16. It hooks the BIOS disk interrupt (13h), puts the original MBR back in memory so Windows boots normally, and watches the disk reads that follow. When Windows reads its kernel debugger librarykdcom.dll,ldr16substitutesldr32orldr64. It also switches the boot configuration, in memory only, to Windows PE mode, which at the time skipped the kernel's code integrity checks.ldr32/ldr64. These stand in forkdcom.dllwith the same exports, which also disables the kernel debugger. They load the rootkit driver,drv32ordrv64, from the encrypted store.drv32/drv64. The driver hides the infection: when anything reads the sectors that hold the rootkit, it returns fake content, including the clean original MBR. A watchdog thread checks its hooks and the MBR and re-infects the MBR if it was changed.- User mode. Payload modules from the store (
cmd.dll,cmd64.dlland laterkad.dll,Socks.dll,r.dll) handle the command channel and the botnet's services, configured bycfg.ini, with an encrypted fallback server list inbckfg.tmp(Kaspersky, June 2011).
On 12 April 2011 Microsoft released update 2506014 for the operating system loader on 64-bit Windows Vista, 7 and Server 2008. ESET found that it stopped the loader honouring Windows PE mode for this purpose and changed kdcom.dll so TDL4 no longer recognised it. ESET also noted that TDL4 blocked Windows Update on 32-bit machines, and that already infected hosts could not be expected to install the fix.
A later variant
In October 2011 ESET described a new modification, dropped by Win32/Olmasco.R, that leaves the MBR code alone. It creates a partition of up to 50 GB in unpartitioned space at the end of the disk, writes it into a free partition table entry, marks it active and gives it its own volume boot record (VBR). That VBR reads a file named boot from the rootkit's file system, which hooks interrupt 13h and then starts the original active partition's VBR. When no partition table entry is free, the dropper reports to its server and stops.
Traces on disk
| Location | What | Source |
|---|---|---|
| Sector 0, boot code | TDL4's loader in place of the Windows MBR code. Read through the infected Windows, it looks clean | Kaspersky, January 2011 |
| Last sectors of the disk, outside any partition | Encrypted file system holding mbr (the original MBR), ldr16, ldr32, ldr64, drv32, drv64, cmd.dll, cmd64.dll, cfg.ini, bckfg.tmp | Kaspersky, January 2011 |
| Same store, later builds | kad.dll, Socks.dll, r.dll and other modules | Kaspersky, June 2011 |
| Partition table (Olmasco variant) | An extra partition of up to 50 GB at the end of the disk, flagged active, with a non-Windows VBR | ESET, October 2011 |
| BCD store on disk | Unchanged: the Windows PE switch is made in memory | Kaspersky, January 2011 |
| Windows volume | No driver file and no service key for the rootkit; its driver comes from the hidden store | Kaspersky, January 2011 |
How to check a host
Collect from outside the infected system
Do not trust anything read through the running, infected Windows: the driver returns the original MBR and hides its own sectors. And do not boot a recovery environment from the same disk, because the infected MBR runs first. Boot from external media (a Linux live system or Windows installation media), or attach the disk to another machine, and read it raw.
From a Linux live system, with the suspect disk as /dev/sda:
sudo blockdev --getsz /dev/sda # size in 512-byte sectors
sudo sfdisk -d /dev/sda # partition table: start, size, type, bootable flag
sudo dd if=/dev/sda of=sda-head.bin bs=512 count=2048
sudo dd if=/dev/sda of=sda-tail.bin bs=512 skip=$(( $(sudo blockdev --getsz /dev/sda) - 2048 ))
A full image is better still: it keeps the whole unpartitioned area for later analysis.
What to look at
- The MBR boot code (the first 446 bytes): it should be the boot code Windows writes. Anything else on a Windows machine needs an explanation (some disk encryption and boot managers replace it legitimately).
- The partition table: an active partition that is not the Windows system partition, or an entry covering the end of the disk with no file system Windows knows.
- The end of the disk: data that looks random in sectors no partition covers. An unused area is normally zeros or old data with structure.
- Live hints are weak, for the reason above. ESET reported that TDL4 blocked Windows Update on 32-bit machines, so a 32-bit host that silently stopped updating in that period deserves a raw disk check.
What the checker looks for
bootsectorreads MBR, VBR and GPT sectors from disk images or disk heads. For TDL4 it raises "MBR boot code does not match a known loader" for the replaced MBR code. For the Olmasco variant, which adds a small partition at the end of the disk, it raises "Small last partition with no recognised file system", and "More than one active partition" if the table marks it active next to the original. TDL4's encrypted store in the last sectors of the disk raises "Data after the last partition" only when the module gets a full image (it reads the first 4 MiB and the last 1 MiB); a disk head of the first MiB does not contain it.- The disk must be read from outside the infected system; a disk head captured through the running, infected Windows shows the clean MBR the rootkit returns. The module's own note says so.
windriverssees nothing: there is no service key,.sysfile or install event for the rootkit driver.espandmeasuredbootdo not apply: TDL4 needs a BIOS boot from an MBR disk, and leaves no EFI files.
For the limits of an offline check, see what an offline rootkit check can and cannot prove.
Removal and recovery
- Preserve the disk image, or at least the first and last sectors, before repairing anything.
- Repair the boot code from external media. From Windows installation media,
bootrec /fixmbrwrites new master boot code and, as Microsoft notes, overwrites only the boot code, not the partition table. For the Olmasco variant, the extra partition entry must also be removed and the Windows partition marked active again. At the time, Kaspersky recommended its TDSSKiller utility, which detected TDL-4 and earlier TDSS versions. - Prefer a rebuild. A kernel rootkit ran with a botnet's worth of payloads: proxies, downloaded malware and search hijacking. Restoring the MBR stops the bootkit but leaves the hidden store on the disk and says nothing about what the payloads did. Wipe the disk, including the unpartitioned end, and reinstall a current, supported Windows; moving to UEFI with Secure Boot and a GPT disk removes the MBR boot path altogether.
- Rotate credentials used on the machine, and look on the network for proxy traffic or the other malware TDL4 installed.
Sources
Primary public reports, newest first.
- 2011-10-18TDL4 rebootedESET
- 2011-06-27TDL4 – Top BotKaspersky
- 2011-04-15KB2506014 kills TDL4 on x64ESET
- 2011-04-12Microsoft Security Advisory: Update for the Windows Operating System LoaderMicrosoft
- 2011-01-25TDSS. TDL-4Kaspersky
See also
Related families
- RovnixVBR bootkit
- GapzVBR bootkit
- ZeroAccessWindows kernel rootkit