text
stringlengths
4
429
CREATE
CMD
POST
GET
DEL
REGISTR
COPY
The usermode component of Snake communicates with its kernel-mode driver via a device called \\.\vstor32 (created under
kernel as \Device\vstor32). In its communication protocol with the driver it uses the IOCTL code of 0x222038.
To write data, it opens the device with CreateFile(
\\.\vstor32
), then calls DeviceIoControl() API on its handle with
IOCTL code of 0x222038.
Configuration parameters along with the initial set of domain names are hard-coded within the body of the DLL. However, the data
appears to be defined in the structures, so it is very likely the DLL could be generated by a stand-alone builder that
patches
the
DLL with the new/updated list of C&C.
Analysis of the commands performed by the malware suggests the following capabilities:
Scan the network for the presence of other hosts (maximum 1 hour is allocated for this task)
Set maximum upload file size
Go
stealth
mode for the specified number of days - Snake will not initiate any connections during that time
Run specified shell commands and collect the output logs for further delivery
Modify settings stored with the registry key HKLM\Software\Microsoft\Windows\CurrentVersion\ShellCore
Search for files
Upload specified files
Add new C&C domains
Update the driver with a new version
Download files
Run specified executable files
Set self-deactivation timeout
If the virtual partition \\.\vd1 exists, copy all Snake logs into that partition
Together, these commands provide complete backdoor functionality, allowing remote attacker full control over the compromised
system.
The ability to update the driver and then rely on its communication capabilities means that the components of Snake are flexible,
making possible the existence of the hybrid (kernel-centric and usermode-centric) architectures.
For example, the virtual partitions are used by kernel-centric Snake variants, where the kernel-mode driver is responsible for the
communications. If such a driver is installed via an update, the usermode component can be instructed to delegate the file upload
task to the driver by copying all the necessary logs into the shared virtual partition, physically located on the compromised host and
thus, accessible from kernel.
BAE Systems Applied Intelligence: Snake Rootkit Report 2014 13
KERNEL-CENTRIC ARCHITECTURE
This particular architecture relies on a kernel-mode driver to carry out the network communications. The usermode DLLs are still
injected into the system processes to perform high-level tasks.
The delivery mechanism is not known: it may be distributed via a thumb-drive, a phishing email attachment, or be delivered via an
exploit across the network (e.g. by using the reconnaissance tool that is explained later).
Infection starts from a dropper penetrating into the compromised system where it is allowed to run. Once executed, the dropper
installs the kernel mode driver in a pre-defined location. The dropper itself is 32-bit, so it will run both on 32-bit and 64-bit Windows
OS (in WoW64 mode). On a 32-bit OS, it will install a 32-bit driver. On a 64-bit OS, it will install a 64-bit driver.
The analysed 32-bit dropper creates a driver in the following location:
%windows%\$NtUninstallQ817473$\fdisk.sys
However, different samples may use a different path and driver file name. For example, some samples exposed these filenames:
fdisk_32.sys, A0009547.sys, or Ultra3.sys. The filename of the dropper could be rkng_inst.exe or fdisk_mon.exe.
REGISTRATION
Once executed, the driver first makes sure it is registered under a pre-defined name, such as Ultra3.
Other samples may have a different registration name, such as ~ROOT. The registration is ensured with creation of the following
registry entries:
ErrorControl = 0
Group =
Streams Drivers
ImagePath = %windows%\$NtUninstallQ817473$\fdisk.sys
Start = 1 [SYSTEM]
Type = 1
in the newly created registry key
HKEY_LOCAL_MACHINE\System\CurrentControlSer\Services\Ultra3
The driver then flags the following events with the notification purposes:
\BaseNamedObjects\{B93DFED5-9A3B-459b-A617-59FD9FAD693E}
\BaseNamedObjects\shell.{F21EDC09-85D3-4eb9-915F-1AFA2FF28153}
The rootkit then places a number of the hooks.
SYSTEM HOOKS
The first API it hooks is IoCreateDevice(). The installed hook handler calls the original API and then checks if the name of the
device is netbt or afd. If so, it will install a TDI filter driver. If the device name is Null, Beep, tcpip or Nsiproxy, it will activate
itself by enabling its hooks designed to hide the presence of Snake on a system, set up its access control lists and the messaging
system.
In order to hide its components, the driver hooks the following APIs:
ZwQueryKey
ZwEnumerateKey