Trustwave's 2024 Financial Services Threat Reports Highlight Alarming Trends in Insider Threats & Phishing-as-a-Service. Learn More

Trustwave's 2024 Financial Services Threat Reports Highlight Alarming Trends in Insider Threats & Phishing-as-a-Service. Learn More

Services
Managed Detection & Response

Eliminate active threats with 24/7 threat detection, investigation, and response.

Co-Managed SOC (SIEM)

Maximize your SIEM investment, stop alert fatigue, and enhance your team with hybrid security operations support.

Advisory & Diagnostics

Advance your cybersecurity program and get expert guidance where you need it most.

Penetration Testing

Test your physical locations and IT infrastructure to shore up weaknesses before exploitation.

Database Security

Prevent unauthorized access and exceed compliance requirements.

Email Security

Stop email threats others miss and secure your organization against the #1 ransomware attack vector.

Digital Forensics & Incident Response

Prepare for the inevitable with 24/7 global breach response in-region and available on-site.

Firewall & Technology Management

Mitigate risk of a cyberattack with 24/7 incident and health monitoring and the latest threat intelligence.

Solutions
BY TOPIC
Microsoft Security
Unlock the full power of Microsoft Security
Offensive Security
Solutions to maximize your security ROI
Rapidly Secure New Environments
Security for rapid response situations
Securing the Cloud
Safely navigate and stay protected
Securing the IoT Landscape
Test, monitor and secure network objects
Why Trustwave
About Us
Awards and Accolades
Trustwave SpiderLabs Team
Trustwave Fusion Security Operations Platform
Trustwave Security Colony
Partners
Technology Alliance Partners
Key alliances who align and support our ecosystem of security offerings
Trustwave PartnerOne Program
Join forces with Trustwave to protect against the most advance cybersecurity threats

Messing with Azorult Part 2: Command and Control

As we mentioned in our earlier blog, Azorult is very popular in the underground hacking forum. Fairly easily, we were able to obtain and download the control panel and builder. We set up the control panel in our lab and redirected our sample bot command and control server to our web server. The control panel is written entirely in PHP and uses MySQL as its database.

Below is what the admin control panel looks like. It shows all bot reports and statistics, as well as the attacker configuration that sets the config flags we previously.

 

Azorult_admin_panel_main
Figure 1: Azorult ADMIN control panel
 

The panel also has a report page where the attacker can view basic victim information and download the stolen “goods”:

 

Azorule_report_panel
Figure 2: Azorult REPORT page in the admin panel

What is unique about Azorult is that it has a “guest” panel that doesn’t require any authentication and is accessible publicly. It shows some basic stats of victim information and their data. The purpose of this panel is not quite clear, it is probably the attacker's quick access of victim information without the need of logging in to the admin panel.

 

Azorule_guest_panel
Figure 3: Azorult GUEST panel that is accessible without admin credentials
 

As you can see in the control panel’s directory tree below, index.php is the server-side script that parses the initial bot registration, sends the bot configuration, parses the exfiltrated data and adds data to its database. Under the root “panel” folder is the command and control admin panel that requires password authentication and other PHP scripts such as the guest panel. Also under “panel” is another folder with the name “files”:

 

Azorult_Panel_directory_list
Figure 4: Azorult control panel PHP source directory tree

 

The “files” folder is where the stolen zip-compressed data are stored. The file name of the compressed file uses the format: <country code>-<date("Y-m-d H-i-s")>-<bot id>-<bot version>.zip

 

Panel_zip_folder
Figure 5: ZIP files are stored in the “/panel/files” folder

 

All the filenames under the files folder are also stored in the panel’s database in the “reports” table.

 

PHPMyAdmin_report_table
Figure 6: Azorult database schema - showing the reports table that stores the exfiltrated data filename

 

This folder however has directory listing and traversal disabled and was configured in .htaccess file – so we can’t access that from a browser.

As mentioned earlier, index.php handles the command and control communication and parsing of data. It also adds this data to its database. Here is what index.php “main function” looks like:

 

Azorult_index_php_src_code_1
Figure 7: Index.php function calls a function to decode the POST raw data and then either register the BOT or call ParseReport function to parse the data

 

First, the function XOR decodes the POST raw data with the key - chr(03) chr(85) chr(174) or 0x03,0x55,0xAE. Then, it tests if the first 3 bytes is not equal to 0, signifying the data is not a BOT registration and it is therefore receiving exfiltration data. Next it calls the ParseReport() function with the $postdata as a parameter. This ParseReport function parses the exfiltrated data that the bot has stolen, discussed earlier in the Data Exfiltration section.

Below is the ParseReport() function where it separates the $data into an array using the PHP explode() function – the delimiter is the unique ID we mentioned earlier in this post. In the PHP script, this variable is called “$unical_GUID”.

 

Cnc_panel_src
Figure 8: The ParseReport function - highlighted are the INSERT SQL statement that can be attacked with SQL injection

 

What is highlighted in the code snippets are some SQL Insert queries. These queries add new entries to the database from the POST data that the bot sends without any sanity checking. And you know what it means? Exactly – MySQL Injection! In fact, this is a Azorult control panel vulnerability reported by @prsecurity last August 13, 2019 https://packetstormsecurity.com/files/author/14419/.

So, another attacker could easily craft their own special bot data to mess up the database. For example, the normal SQL query would do this:

INSERT INTO table_name (a,b,c) VALUES (‘data1’, ‘value2’, ‘info3’)

But an attacker can craft a SQL query within the POST request data to insert data from another database table exposing the control panel’s other information, for example

INSERT INTO table_name (a,b,c) VALUES ((SELECT data FROM admin_table), ‘value2’, ‘info3’)

And remember the “files” folder? We mentioned before that it can’t be directory listed because that function is disabled. But there is a database table called “reports” that stores the filenames of the files in that folder. Since admin.php panel has some password authentication, this is where guest.php comes handy. The filenames from “reports” table can be queried and then added to a table accessed by the guest.php panel. This is the “passwords” table, as seen on the guest.php code snippet below.

 

Azolrult_Guest_php_src_code
Figure 9: The PHP source code of the Guest panel. In this screenshot, it shows that it queries the 'p_soft_name' field from the 'passwords' table.
 

Here we injected the stolen data zip file filename from the “reports” table to “passwords” table. And now the zip file is exposed in the guest panel:

 

Azorult_Guest_panel
Figure 10: Filename of the ZIP file is exposed in the guest panel after sending multiple SQL injection attacks.


In our testing, we sent multiple SQL injection attack to reveal the filename. The field (Software name: ' p_soft_name') maximum character length is only 30 bytes and this is the only field in the table accessed by the guest panel that has the longest maximum character (varchar(30)). This won't fit the whole filename of the zip file which is more than 30 characters. So, to accommodate this, we need to send three SQL injection attack to reveal the filename in three chunks. for example:

first chunk AA-2019-10-01 03-14-4253FF6B64
second chunk -343A2EC6-44F569B1-5806900C-96
third chunk 9036F0-v33.zip

 

This ZIP file can now be downloaded directly through the URL:

http://<attacker's domain>/panel/files/AA-2019-10-01 03-14-4253FF6B64-343A2EC6-44F569B1-5806900C-969036F0-v33.zip

During our investigation, we actually saw a couple of in-the-wild Azorult control panels that had already been exploited by the other attackers using this same SQL injection vulnerability.

 

Hacked_panel1
Figure 11: An "in-the-wild" control panel that we found that has been exploited, revealing some filename of the stolen logs

 

Hacked_panel2
Figure 12: Another control panel that has been exploited

 

We also found that stolen data and logs from Azorult are also being shared and sold in the underground hacking forums, as seen in the images below. 

 

Under_ground_forum_2
Figure 13: 17GB of Azorult exfiltrated data logs being shared in the underground forum

 

Under_ground_forum_3
Figure 14: Another Azorult logs shared in another underground forum dated September 3, 2019

 

Under_ground_forum1
Figure 15: Another underground forum user selling his logs for $150
 

We are not 100% certain that these were acquired using the same SQL injection attack. However, when we checked the logs, most were stolen from a bot built using Azorult 3.3 builder – so it’s possible. It could also be possible that these are Azorult bot herders themselves that is trying to cash in their stolen "goods". But the worrying thing is, the weakness in control panel could leak stolen data not only to the bot herder but also to third party attacker that would use this SQL Injection attack to steal the stolen data from the control panel.

I hope this two part series helps you understand the inner workings of Azorult, its control panel and its vulnerability. This blog post is for research and educational purposes only.

IOCs:

Powershell script

SHA256: d8939019edf1f10b0da96d98545b0c19a55f6a2c0b898668e2289b30df799125

Azorult bot

SHA256: 51e5e702a5b199e98a63a99d5b7dccc8816f7399ead6f7c33caea8c5ee3d9344

Command and control:

qwejhfs[.]ru

ABOUT TRUSTWAVE

Trustwave is a globally recognized cybersecurity leader that reduces cyber risk and fortifies organizations against disruptive and damaging cyber threats. Our comprehensive offensive and defensive cybersecurity portfolio detects what others cannot, responds with greater speed and effectiveness, optimizes client investment, and improves security resilience. Learn more about us.

Latest Intelligence

Discover how our specialists can tailor a security program to fit the needs of
your organization.

Request a Demo