text
stringlengths
4
429
As shown in Listing 05, the Win32/Hydraq backdoor configuration is stored in the resource section
of the file. It retrieves the specified hostname, and attempts to establish a remote connection.
However, to perform this task, the backdoor needs to resolve the specified hostname. Based on
the code, the backdoor checks the hostname IP address if it is a valid IPv4 Internet address (for
example, 111.222.123.111). If it is not, it will retrieve the hostname IP address using an available DNS.
The backdoor connects to 168.95.1.1 using port 53 as an alternate DNS to resolve the server
address. This stand-by solution is only valid in the next 5 minutes from the time the backdoor accesses the alternate DNS server.
3.3.2 In the Registry Key
The backdoor also checks the registry key HKLM\Software\Sun\1.1.2\AppleTlk. The value
contained in this key is encoded information about the remote connection details.
CA ISBU-ISI WHITE PAPER: IN-DEPTH ANALYSIS OF HYDRAQ
If the registry key exist, it will decode the value using the following steps:
Perform a bitwise XOR with 0x99 as the key on each byte.
Perform the same custom decoding logic it used in the configuration found in file
s resource
section.
The updated configuration is always stored in the registry. The backdoor will then retrieve the
specified hostname and alternate DNS to establish a remote connection. It checks the hostname
IP Address if it is a valid IPv4 Internet address. If it is not, it retrieves the hostname IP address using an available DNS. If the backdoor cannot resolve the hostname IP address, it will sleep for two
minutes and attempt to resolve the IP address using an available DNS again (see Listing 06).
If the registry key HKLM\Software\Sun\1.1.2\ does not exist, the backdoor continues the connection using the configuration specified from the backdoor resource section. Take note that the
priority configuration used is always from the registry key next is the configuration from the resource.
[Listing 06 - Win32/Hydraq reconnects after 2 minutes]
3.4 Backdoor Communication Protocol 0x00: Establishing Communication
In the context of discussing the backdoor functionalities, we will refer to the following terms as
follows:
Client or remote server - is defined as the remote attacker.
Server - is defined as the system where the Win32/Hydraq backdoor is installed.
As soon as the server
s IP address is resolved, the server attempts to initiate a connection to the
client and a 3-way handshake process is performed:
3.4.1 SYNchronize
CA ISBU-ISI WHITE PAPER: IN-DEPTH ANALYSIS OF HYDRAQ
The client sends a custom SYNchronize packet containing the following 20 bytes as initial handshake.
FF FF FF FF FF FF 00 00 FE FF FF FF FF FF FF FF FF FF 88 FF
The set of bytes above are encrypted using a bitwise NOT operation. Thus, the raw set of bytes is
the following:
00 00 00 00 00 00 FF FF 01 00 00 00 00 00 00 00 00 00 77 00
As shown in Listing 07, the Win32/Hydraq backdoor
code includes a routine that constructs the 20 byte
SYNchronization packet that is sent to the client.
The initial handshake was captured during a test
simulation performed in a controlled environment as
shown in Appendix B. The backdoor uses port 443
to connect to the server. Port 443 is the known default
port for the HTTPS protocol.
However, in this case, the Win32/Hydraq backdoor did
not take advantage of the available SSL/TLS encryption to secure its communication to the client. The information contained in the packet is evidently showing
the set of bytes constructed by the malware.
3.4.2 SYNchronize-ACKnowledgement
[Listing 07 - Constructing Initial Handshake routine ]
The client will identify the initial SYN packet sent by the server. If valid, the client will respond a
SYNchronize ACKnowledgement packet 20 bytes in size. The sets of bytes are encrypted using a
bitwise XOR with 0xCC as the key.
CC CC CC CC CD CC CC CC CD CC CC CC CC CC CC CC AA AA AA AA
[Listing 08 - Acknowledgment data decryption routine ]
CA ISBU-ISI WHITE PAPER: IN-DEPTH ANALYSIS OF HYDRAQ
The server will validate the SYN-ACK packet from the client expecting the following decrypted values:
00 00 00 00
01 00 00 00
01 00 00 00
00 00 00 00
00 00 00 00
Take note that,
Offset 0x00 must be equal to 0x0000
Offset 0x04 must be equal to 0x0001
Offset 0x08 must be equal to 0x0001
Offset 0x0C must be equal to 0x0000
3.4.3 ACKnowledge
Once the server receives the expected SYN-ACK
packet, it will respond by sending an ACKnowledgement
of receipt. The following tasks are performed:
a. Collect the following information from the compromised system.
Computer name
CPU clock speed
Memory status
specifically gets the amount of actual physical memory in bytes and converts it to megabytes.
Operating system information
[ Listing 09 - Collected system information ]
CA ISBU-ISI WHITE PAPER: IN-DEPTH ANALYSIS OF HYDRAQ
b. Encrypt the information collected using a custom encryption were the key used is derived from
the result of GetTickCount API. The encrypted data will be encrypted again using a bitwise NOT.
c. Generate a CRC hash value of the encrypted information.
d. Send the collected information to the client.
Header Information
Encrypted Information collected in the system
[Listing 10 - Constructed message from the server]
[Listing 11 - Captured packet received by the client]
The server is now ready to accept backdoor commands from the remote attacker.
The complete 3-way handshake process between the backdoor server and the client will look like
this:
[Listing 12 - The backdoor 3-way handshake process]
CA ISBU-ISI WHITE PAPER: IN-DEPTH ANALYSIS OF HYDRAQ
3.5 Backdoor Communication Protocol 0x01: Execution of Client-Server Commands
During the 3-way handshake process, we discovered that the Win32/Hydraq backdoor constructs a
custom packet. This is a communication protocol designed so that the client and server can recognize each other over the network. The information header format is different from each end point.
3.5.1 Client
s Information Header Format
[Figure 1 - The client process the server information header.]
The constructed information header is 20 bytes in size in the following format: (Note: The values in