Skip to content

UEFI bootkit

ESPecter UEFI Bootkit: Traces and Offline Checks

ESPecter patches the Windows Boot Manager in the EFI system partition to load an unsigned driver. Its ESP, MBR, driver and config traces, checks and recovery.

Kind
UEFI bootkit · Boot layer
Platforms
Windows
First seen
2012
Status
In the wild
Checked by
EFI system partitionMeasured Boot logsWindows driversDisk boot sectors

Overview

ESPecter is an espionage bootkit for Windows that ESET described on 5 October 2021. ESET traced it back to at least 2012, when it was an MBR bootkit for legacy BIOS systems. The newer version persists on UEFI systems by patching the Windows Boot Manager on the EFI system partition (ESP). ESET counted it as only the second real-world UEFI bootkit persisting on the ESP; the other was the FinSpy bootkit that Kaspersky had described a week earlier.

The samples support Windows 7 through Windows 10. The payloads are a keylogger, screenshot capture, theft of documents (including from removable drives) and a backdoor. ESET did not attribute ESPecter to a known actor. It assessed with low confidence that the operators speak Chinese, based on Chinese debug messages in one component. The initial access method is unknown.

ESPecter does not exploit a Secure Boot flaw. The UEFI version only runs when Secure Boot is off. ESET lists the ways that could happen without knowing which applied: physical access, a machine where it was already off, or a firmware vulnerability.

How it loads and hides

UEFI version. The installer modifies the Windows Boot Manager, \EFI\Microsoft\Boot\bootmgfw.efi, and the fallback loader \EFI\Boot\bootx64.efi. ESET reports that it adds a new PE section named .efi and moves the entry point there. Because the file is changed, its Authenticode signature no longer verifies, which is why Secure Boot stops it.

At boot, the added code patches the boot manager in memory so that its own self-integrity check passes, then hooks the hand-over to the Windows OS loader and, through it, the kernel. In the kernel it patches the code integrity initialisation, which disables Driver Signature Enforcement for that boot. Nothing of this is written back to the Windows files: the changes exist only in memory, each boot.

With signature enforcement off, the bootkit writes and loads its own unsigned driver. ESET lists it as \SystemRoot\System32\null.sys for the UEFI version and describes it as replacing the legitimate Null driver (the legacy version used System32\drivers\null.sys on x64 and drivers\beep.sys on x86). The driver creates the device \Device\WebBK, sets up a keyboard filter for keylogging, injects WinSys.dll into svchost.exe and Client.dll into winlogon.exe, and then deletes itself. ESET's IOC list gives %windir%\Help\intel.chm as the path where the clean driver is backed up.

Legacy version. The MBR is replaced with code that hooks BIOS interrupt 13h to patch the Windows boot loader as it is read from disk. ESET reports the original MBR backed up in sector 1, the bootkit code in sectors 2 to 4, the encrypted configuration in sector 5 and the driver from sector 6, all in the unallocated space before the first partition. Installers copied cmd.exe under the name con1866.exe.

Traces on disk

LocationWhatSource
ESP\EFI\Microsoft\Boot\bootmgfw.efi, ESP\EFI\Boot\bootx64.efiPatched boot manager: extra .efi section, entry point moved, broken signatureESET
C:\Windows\System32\null.sys (UEFI); System32\drivers\null.sys or beep.sys (legacy)The bootkit's driver; deletes itself after running, so may be goneESET
C:\Windows\Help\intel.chmBackup of the clean driverESET IOC
C:\Windows\Temp\syslogEncrypted configuration (UEFI version)ESET
HKLM\SYSTEM\CurrentControlSet\Control, value DefaultConfigConfiguration in the registry; used in preference to the fileESET
C:\Windows\Temp\memlog, dd_vcredist, vmmmlog, vmmmmlogEncrypted payloads; vmmmlog.exe and vmmmmlog.exe decryptedESET IOC
C:\Windows\System32\WinSys.dll, Client.dllDecrypted user-mode payloadsESET
C:\Windows\System32\Media\NPCSJDLFSD or C:\Windows\Temp\NPCSJDLFSDHidden folder for stolen data, with SSQWCVBER (screenshots), UTXZCZXQ (documents) and KLACVSWER (keystrokes)ESET IOC
Disk sectors 1 to 5 and from 6 (legacy)Original MBR copy, bootkit code, configuration, driverESET

ESET's report and its IOC repository list SHA-1 hashes of the two compromised boot managers they found, the drivers and the installers, and C&C addresses. Copy them from there if you need them.

How to check a host

Offline:

  • Copy the ESP. Check the Authenticode signature of bootmgfw.efi and bootx64.efi and their section table: a section named .efi or a signature whose hash no longer matches is enough to suspect tampering. Compare them with the copies in C:\Windows\Boot\EFI\, which Windows uses as the source for the ESP.
  • From the system volume, look for the files in the table above, the DefaultConfig value in the SYSTEM hive (ControlSet001\Control), and the stolen-data folders.
  • For legacy BIOS machines, image at least the first megabyte of the disk and compare the MBR with standard Windows boot code; look for data in sectors 1 to 6.
  • In the Measured Boot logs (C:\Windows\Logs\MeasuredBoot\), check whether Secure Boot was off and whether the boot manager's measurement changed between boots. See Reading Measured Boot logs.

Live, elevated:

mountvol S: /S
powershell -c "Get-AuthenticodeSignature S:\EFI\Microsoft\Boot\bootmgfw.efi, S:\EFI\Boot\bootx64.efi | Format-List Path, Status, SignerCertificate"
powershell -c "Confirm-SecureBootUEFI"
reg query HKLM\SYSTEM\CurrentControlSet\Control /v DefaultConfig
dir /a C:\Windows\Temp\syslog C:\Windows\Temp\memlog C:\Windows\Help\intel.chm
dir /a /s C:\Windows\System32\Media\NPCSJDLFSD C:\Windows\Temp\NPCSJDLFSD
mountvol S: /D

Confirm-SecureBootUEFI returns False when Secure Boot is off, which ESPecter's UEFI version needs. Running code in the kernel, ESPecter can hide or alter what these commands return; a copy of the ESP and the disk read from another system is the reliable check. The collection steps are in How to check the EFI system partition offline.

What the checker looks for

  • esp reads bootmgfw.efi and bootx64.efi and recomputes their Authenticode digest. A boot manager patched after signing raises "The file was changed after it was signed", linked to this page when the file has an added .efi section or its entry point in its last section, the layout ESET describes. "The entry point is in an unusual section" flags the moved entry point, and "is much newer than the other files in its folder" a patch time well after its neighbours'.
  • measuredboot raises "Secure Boot was off during this boot", or "Secure Boot was on in the previous boot and off in this one", the condition ESPecter's UEFI version needs. When logs from before and after the patch exist, "The digest of \EFI\Microsoft\Boot\bootmgfw.efi changed since the previous boot" shows the change; Windows updates do the same, so match it with the update history.
  • windrivers reads every .sys file under C/ in the collection. If ESPecter's driver is still there (System32\null.sys for the UEFI version, System32\drivers\null.sys or beep.sys for the legacy one) and carries no signature, it raises "An unsigned kernel driver"; a signed driver whose bytes changed raises "The driver was changed after it was signed". The driver deletes itself after running, so most collections will not hold it.
  • bootsector, for the legacy version, raises "MBR boot code does not match a known loader", and "Data before the first partition does not match a known loader" for the code and configuration in the sectors after the MBR. The original MBR kept there can add "Copy of a boot sector before the first partition". Only a disk read from outside the running system shows them.

The checker does not read the DefaultConfig registry value, the Temp files or the stolen-data folders; look for those by hand. It cannot see the in-memory patches or the injected DLLs.

Removal and recovery

The bootkit's patches live in the boot manager files, but once it has run, its driver has had kernel access and its keylogger has captured whatever was typed.

  1. Preserve: copy the ESP, image the disk (or its first megabyte on legacy systems), and export the SYSTEM hive.
  2. Rebuild the host from trusted media. Replacing bootmgfw.efi from a clean copy, or rewriting the MBR from Windows RE (bootrec /fixmbr), removes the boot stage but leaves any user-mode payloads and changed files behind; it is acceptable only as a stopgap.
  3. Turn Secure Boot on, and set a firmware administrator password so that it cannot be switched off without one. ESET notes that Secure Boot blocks this bootkit.
  4. Keep firmware up to date, and restrict administrator rights, which installing ESPecter needs.
  5. Rotate every credential typed or stored on the host. The keylogger and document theft mean passwords, documents and anything on attached USB drives should be treated as taken.

Sources

Primary public reports, newest first.

  1. 2021-10-05UEFI threats moving to the ESP: Introducing ESPecter bootkitESET
  2. 2021-10-05ESPecter indicators of compromiseESET
  3. 2021-10-05ESET Research discovers ESPecter, a UEFI bootkit for cyberespionageESET

See also