text
stringlengths
4
429
When decrypted with the same XOR key that was used by Agent.BTZ, these files expose the following contents:
mtmon.sdb - C&C communication log that looks as the logs shown above.
mtmon_.sdb - installation log, that shows infected processes (Internet Explorer), the random name of the dropped DLL
(e.g. kbdfaori.dll), log directory, and the registry entry ShellCore that stores other configuration details:
03:52:02 TVer=1.2
03:52:02 Parent:C:\Program Files\Internet Explorer\IEXPLORE.EXE
03:52:02 ver 3.2.0.0a inj dll K:0 PID:712,
C:\WINDOWS\system32\kbdfaori.dll,
hostID:ea5cfa5ea1681bd6(16887647987074341846)
03:52:02 C:\WINDOWS\$NtUninstallQ812589$,
Temp:C:\WINDOWS\$NtUninstallQ812589$\SPUNINST\Temp
03:52:02 REG:Software\Microsoft\Windows\CurrentVersion\ShellCore
03:52:02 ModuleStart: 03:51:42
scmp.bin - pipe server log that shows its assigned name (COMPUTERNAME is the name of the test system) and
what processes it operates from:
02:04:24 TVer=1.6
02:04:24 SPCOMPUTERNAME: Pipe server thread start
02:04:24 Inj[1620]:explorer.exe
03:51:42 Inj[712]:iexplore.exe
ucmp.bin - another pipe server log:
02:04:44 TVer=1.6
02:04:44 UPCOMPUTERNAME: Pipe server thread start
BAE Systems Applied Intelligence: Snake Rootkit Report 2014 11
INTER-PROCESS COMMUNICATIONS
Analysis of the sample reveals that it supports 3 modes of fetching C&C commands.
In the first mode, it relies on Windows Internet (WinINet) APIs, such as HttpOpenRequest(), HttpSendRequest(),
InternetReadFile(), etc.
In the second mode, it uses Windows Sockets 2 (Winsock) APIs, such as WSAStartup(), socket(), connect(),
send(), etc.
In the third mode, it works in the
pipe server
mode, when it passes the web requests it is interested in (as a client) to the
pipe server that runs within Windows Explorer (explorer.exe) and/or Internet Explorer (iexplore.exe) processes.
Memory pipes is a common mechanism for Inter-Process Communications (IPC). When the pipe server reads such requests from the
pipes, it performs the web request on behalf of a client by using WinINet APIs, so it effectively serves as a proxy.
The diagram below demonstrates the last,
pipe server
mode of Snake operation:
Injected Snake DLL System Process
(e.g. services.exe)
Snake DLL Internet
3 in
pipe server
mode
4
3
Legitimate Process
Injected Snake DLL
(e.g. a browser)
User Mode
2
1
Kernel Mode
Legitimate Process
(e.g. a browser)
2
Embedded
Snake
s Kernel Mode DLL Module
Driver, with the DLL
module embedded in it
The diagram illustrates the operation steps 1-4:
1 First, the malicious driver with the embedded DLL module injects that DLL into a system process,
such as services.exe; once loaded, the DLL will function in the
pipe server
mode.
As soon as the driver detects a usermode process that goes online (e.g. a browser), it will inject malicious DLL module
2 into it; depending on the operational mode, the DLL may start communicating with C&C directly.
In the
pipe mode
of operation, the injected DLL will start communicating with the pipe server by sending messages into
3 the established inter-process communication pipes.
Once the task of communication with C&C is delegated to the pipe server, it will start communicating with the C&C,
4
bypassing the host-based firewalls that keep an infected system process in a white-list.
BAE Systems Applied Intelligence: Snake Rootkit Report 2014 12
The reason behind the pipes usage is to
legitimise
the outbound web requests, forcing them to originate from the host firewall-
friendly system services.
Pipe server is a special mode of the injected DLL. In order to switch into that mode, a dedicated thread is spawned to listen for IPC
messages received through the pipes. The memory pipes used by Snake are named as:
\\.\Pipe\SP[COMPUTERNAME]
\\.\Pipe\UP[COMPUTERNAME]
where [COMPUTERNAME] is the name of the host computer.
Apart from GET/POST requests, the pipe clients (infected usermode processes) may also ask the pipe server to perform other
operations on their behalf, such as saving data into a temporary file, copy/delete files, save configuration data into the registry
under the aforementioned ShellCore value.
This delegation of tasks is designed to keep infected processes under the radar of the behavioural analysis tools for as long as
possible. Another reason is to overcome account restrictions imposed on a browser process in order to be able to write into files/
registry.
To delegate different types of tasks, the clients send messages to the pipe server using the following task identification headers:
DATA