text
stringlengths
4
429
...kernel32.DeleteFileA
...kernel32.MultiByteToWideChar
The decrypted file is saved to b.exe in the same directory and the file a.exe
is deleted to avoid discovery.
// Install Win32/Hydraq dropper
kernel32.CreateProcessInternalW
CA ISBU-ISI WHITE PAPER: IN-DEPTH ANALYSIS OF HYDRAQ
2. How Hackers Maintain Access
Once the exploit attack is successful, the attacker will attempt to install a backdoor to maintain
access. In this case, the downloaded executable from the internet is a dropper component of
Hydraq (Win32/Hydraq dropper).
The Win32/Hydraq dropper is responsible for the installation of the DLL component, which contains all the features and functionalities for Hydraq
s remote attacker. (see Appendix A for other
variants methods of installation)
2.1 Win32/Hydraq (EXE) Dropper: Generating Random Service
2.1.1 Method of Installation
1. Upon execution, Win32/Hydraq dropper generates a random service name in the following format:
Ups<3 random characters>
2. It drops the DLL component from its resource to %System%\Rasmon.dll.
3. It adds the generated service name to the registry entry below:
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SvcHost\SysIns
4. It then creates and starts a service with the following characteristics detailed below. This
enables the DLL component to be executed under the context of the generic host process, Svchost.exe.
ServiceName = "Ups<3 random characters>"
DesiredAccess = SERVICE_ALL_ACCESS
ServiceType = SERVICE_WIN32_SHARE_PROCESS
StartType = SERVICE_AUTO_START
ErrorControl = SERVICE_ERROR_NORMAL
BinaryPathName = "%SystemRoot%\System32\svchost.exe -k SysIns"
2.1.2 Deleting Traces of Installation
1. Win32/Hydraq dropper
s job is to install the DLL component and remove its installation
traces in the registry to avoid forensic discovery. The data added in the registry key below is deleted:
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SvcHost\SysIns
CA ISBU-ISI WHITE PAPER: IN-DEPTH ANALYSIS OF HYDRAQ
2. Furthermore, as part of clearing its traces on a compromised system, the dropper component creates and executes a batch file in %Windows%\DFS.bat. Its primary goal is to delete
the Win32/Hydraq dropper file (b.exe).
2.2 Win32/Hydraq (DLL) Backdoor: Method of Installation
2.2.1 Method of Installation
Once the
Ups<3 random characters>
service starts to execute, it will run Win32/Hydraq
DLL under the generic host process, Svchost.exe. The DLL component will then perform the following actions:
1. It checks the service name it is running on. It performs a case sensitive comparison on
the first three characters of the service name
. If it is not the same, it stops the
service operation and deletes the current service. It then registers a new service name in
the following format:
<random 4 characters>
This behavior suggests that Win32/Hydraq DLL changes its service name every time an infected
system is rebooted, or the service is restarted. The malware will never have a service name
starting with
due to the fact that it generates a service name starting with
(Take
note of the case sensitive comparison).
2. The DLL component creates a service with the following characteristics:
ErrorControl: SERVICE_ERROR_IGNORE
Start: SERVICE_AUTO_START
Type: SERVICE_WIN32_SHARE_PROCESS
ImagePath: %SystemRoot%\System32\svchost.exe -k netsvcs
3. Similar to the Win32/Hydraq dropper, the DLL component takes advantage of the available
privileges running under the context of trusted Windows system processes. It adds the following registry entry as a parameter to the newly created service.
HKLM\SYSTEM\CurrentControlSet\Services\RaS<4 random
acters>\Parameters\ServiceDll = %system%\Rasmon.dll
char-
4. In addition, the DLL component also adds an entry of its service name in the following registry entry below.
HKLM\SOFTWARE\Microsoft\WindowsNT\CurrentVersions\Svchost\netsvcs
CA ISBU-ISI WHITE PAPER: IN-DEPTH ANALYSIS OF HYDRAQ
3. Cyber Spy In Control
3.1 Initialization of the Backdoor Configuration
The attackers behind Hydraq maintain access by installing the Win32/Hydraq DLL component.
Once installed, the backdoor will start to initialize the configuration needed to perform its functionalities.
The configuration file is encrypted and stored in the resource section of the DLL file. To decode
it, Win32/Hydraq DLL employs the following steps:
1. Decryption using bitwise XOR with 0x99 as the key.
2. Customized character decoding (see Appendix C).
3. Decryption using bitwise XOR with 0xAB as the key.
Take note that some variants of Hydraq do not store the configuration in the resource file. These
variants reference the registry entry HKLM\Software\Sun\1.1.2\AppleTlk for the remote
connection information. The data found in the key can be decoded using the customized character decoding logic as specified (see Appendix C).
3.1.1 Using an Interactive Service
The Win32/Hydraq DLL backdoor component is installed and running under the context of
Svchost.exe, which is a system process. This service is non-interactive and cannot interact with
the user or access GUI objects. To enable the interactive service, the backdoor will perform the
following:
1. Assign the default desktop object to the Win32/Hydraq DLL thread.
2. Assign the winstat0 window station to the Win32/Hydraq DLL process.
These actions enable access to GUI objects.
3.2 Command and Control
Win32/Hydraq contains an encoded backdoor configuration in the file
s resource section. Once decoded it uses this information to communicate with the Command and Control (C&C) server.
The first information accessed in the configuration is the C&C server hostname, which can be
found at offset 0x00 until the null delimiter.
CA ISBU-ISI WHITE PAPER: IN-DEPTH ANALYSIS OF HYDRAQ
[Listing 05 - Win32/Hydraq decoded resource]
3.3 Backdoor Configuration: Resource Section and Registry Key
The Win32/Hydraq backdoor configuration determines the parameters to enable the remote attacker recognize and gain control of the affected system. The configuration is stored in the: File
Resource Section, and/or in a Registry Key.
3.3.1 File
s Resource Section