Trustwave's 2024 Financial Services Threat Reports Highlight Alarming Trends in Insider Threats & Phishing-as-a-Service. Learn More
Get access to immediate incident response assistance.
Get access to immediate incident response assistance.
Trustwave's 2024 Financial Services Threat Reports Highlight Alarming Trends in Insider Threats & Phishing-as-a-Service. Learn More
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.
The panel also has a report page where the attacker can view basic victim information and download the stolen “goods”:
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.
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”:
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
All the filenames under the files folder are also stored in the panel’s database in the “reports” table.
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:
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”.
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.
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:
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.
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.
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.
Powershell script
SHA256: d8939019edf1f10b0da96d98545b0c19a55f6a2c0b898668e2289b30df799125
Azorult bot
SHA256: 51e5e702a5b199e98a63a99d5b7dccc8816f7399ead6f7c33caea8c5ee3d9344
Command and control:
qwejhfs[.]ru
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.
Copyright © 2024 Trustwave Holdings, Inc. All rights reserved.