WEBVTT

00:00.000 --> 00:11.000
We know that bots are everywhere, they're scanning your servers, they're doing it fast, and database servers is obviously a big target.

00:11.940 --> 00:20.000
So we have created a high interaction MySQL honeypot.

00:20.260 --> 00:32.460
So we create a tool that mimics the database, implements MySQL protocol, and those bots start connecting to this honeypot.

00:33.780 --> 00:37.360
So we need to understand the MySQL protocol.

00:37.360 --> 00:45.020
And MySQL protocol, unlike other database protocols, actually a server initiated.

00:45.020 --> 00:50.200
So if we just start a TCP server, then it will not be enough.

00:50.200 --> 00:58.380
If you connect to your MySQL server using Telnet on the port 3306, you will see this.

00:58.860 --> 01:04.160
And this is what MySQL server provides for the client to be able to connect.

01:04.160 --> 01:09.500
It specifies version, it specifies fault, it specifies client plugin.

01:10.860 --> 01:15.660
So listening to the port, a TCP server is not enough.

01:16.100 --> 01:24.400
So what we did to create the high interaction MySQL honeypot is we used the Python module.

01:25.000 --> 01:28.960
The Python provides, there's a module called MySQL mimic.

01:28.960 --> 01:35.460
It implements MySQL protocol, it's a really powerful thing, and you can do a lot of things with that.

01:36.300 --> 01:43.080
So from there, we started the honeypot, and we start receiving the connections.

01:43.080 --> 01:49.860
So you start the honeypot as a fake MySQL server on an open port from the internet.

01:49.860 --> 01:52.060
And you start receiving the connections.

01:52.180 --> 01:57.100
And you can see a lot of information about the connection actually.

01:57.100 --> 02:06.480
Like the HTTP protocol, MySQL protocol also have this client version recorded and stuff like that.

02:06.480 --> 02:08.640
So this is called attributes.

02:08.640 --> 02:12.160
MySQL provides a lot of attributes as a part of the connection.

02:12.160 --> 02:13.420
That's part of protocol.

02:13.420 --> 02:17.120
We have client version, OS, and stuff like that.

02:17.140 --> 02:23.000
So we started the honeypot and we immediately see the fingerprints of the connections.

02:23.000 --> 02:31.220
And you can see the version of the client library, you can see the operating system, you can see all other stuff.

02:31.220 --> 02:33.060
This is very useful actually.

02:34.380 --> 02:41.500
Now from there, the part two is what kind of attacks we have.

02:41.500 --> 02:51.020
We have seen from this honeypot, we see two major attacks on MySQL.

02:51.020 --> 02:56.460
The first is an attempt to own MySQL server and create a backdoor.

02:56.460 --> 03:00.840
This actually pretty well-known attack, and there's a blog post about that.

03:00.840 --> 03:10.760
What is interesting about that is we can see right away that it's using a very old MySQL client version.

03:10.760 --> 03:14.660
It actually only works for older servers as well.

03:15.100 --> 03:18.140
So the second is even more interesting attack.

03:18.140 --> 03:19.880
It's a ransomware.

03:20.120 --> 03:34.840
It tries to download your data, basically brute force the password first, then try to download the data, and then drops the databases and asks for ransom.

03:35.120 --> 03:37.140
So this is exactly the same thing.

03:37.140 --> 03:38.280
We see the fingerprints.

03:38.280 --> 03:43.080
We see what OS version, we see what the client is using.

03:43.480 --> 03:50.620
So now, from there, we started an atomic version of the honeypot.

03:50.820 --> 03:53.320
Honeypot that strikes back.

03:53.340 --> 04:00.940
So what we want to do, our goal is actually interact with those attacks.

04:01.140 --> 04:10.560
And our goal was to see what they are doing, how they do that, and potentially download the malicious code that they are using.

04:11.380 --> 04:15.660
So our atomic honeypot now strikes back.

04:15.740 --> 04:17.500
What do we have?

04:17.500 --> 04:24.640
So we have been juggling with different CVEs in MySQL client.

04:25.020 --> 04:30.920
And we have arbitrary file read, which is super old issue.

04:31.080 --> 04:38.720
We have the remote code execution where MySQL server attacks you.

04:38.720 --> 04:43.380
We actually found that issue a year ago, 2023.

04:43.380 --> 04:52.500
We have presented it, and we can use that to actually execute code on the client.

04:52.760 --> 05:00.140
And then finally, this year we have found another issue in MySQL client utility.

05:00.140 --> 05:01.480
We reported it to Oracle.

05:01.480 --> 05:06.660
This is the second remote code execution in MySQL client.

05:07.840 --> 05:09.020
All right.

05:09.020 --> 05:13.960
So MySQL server attacks MySQL client.

05:13.960 --> 05:15.920
This is how it works.

05:16.320 --> 05:18.300
There are two things here.

05:18.560 --> 05:32.620
The first thing is that we have a MySQL client arbitrary file read, and we create a server, and then your client connects to the server, and the server requests a file.

05:33.080 --> 05:37.620
So we can have an arbitrary file read from the client.

05:37.620 --> 05:43.360
The second is the one that we found a year ago, and we presented it last year.

05:43.360 --> 05:45.400
There are lots of details there.

05:45.400 --> 05:54.000
And basically, the prerequisite of this attack is that you need to have the shared library uploaded to the client first.

05:54.000 --> 06:04.420
Then, whatever the connection will be established, you can actually take that client connection to execute your shared library.

06:04.500 --> 06:08.360
You don't need to execute the shared library itself.

06:08.360 --> 06:11.640
You just need to have that file on the client.

06:12.600 --> 06:25.140
And finally, we have found this year, we have found a new issue in MySQL client utility, and then I will invite Martin, my colleague Martin, to explain how it works.

06:25.140 --> 06:31.020
And this is the first time we are releasing the details about the CVE.

06:31.020 --> 06:32.280
Martin?

06:34.250 --> 06:35.420
Hi.

06:35.480 --> 06:38.880
So let's jump into this CVE.

06:39.140 --> 06:55.560
As you probably know, MySQL dump is a tool which allows you to produce logical backups of a database, basic script tables, and other objects and data to be transferred to another server.

06:56.060 --> 07:02.920
So this is an example how you can use MySQL dump together with MySQL.

07:02.920 --> 07:10.480
You just pipe the output of MySQL dump to MySQL to recreate a database on another server.

07:10.480 --> 07:14.360
And this is pretty close to what the official documentation says.

07:14.720 --> 07:16.400
Where is the problem?

07:16.400 --> 07:21.960
The MySQL utility allows you to use so-called meta comments.

07:22.060 --> 07:33.760
For example, if you do backslash, exclamation mark, and then space in the comment, it's going to execute a shell comment on a computer where the MySQL tool is running.

07:34.000 --> 07:41.720
So the CVE itself is about tricking MySQL dump to emit such a shell comment, for example.

07:42.180 --> 07:44.980
So how this works exactly?

07:44.980 --> 07:54.140
By default, MySQL dump tries to process everything it receives from a server, but it's not the case for the version.

07:54.140 --> 08:02.220
As you can see, there is a version string coming from a server, and it is emitted as a comment in the output of MySQL dump.

08:02.220 --> 08:10.040
But this is not processed, this is not sanitized, and it just is sent back to output as is.

08:10.040 --> 08:15.620
We can leverage this by simply creating our own server, the MySQL server.

08:15.720 --> 08:17.660
So this is a patched version of a server.

08:17.880 --> 08:26.620
As you can see here, I just replaced a version with a hard -coded string, a new line, and then my comment of choice to be executed on the machine.

08:26.620 --> 08:28.400
Here, just create a file.

08:28.840 --> 08:32.500
And if you could tell that to this patched server, you will see this.

08:32.500 --> 08:34.500
In red, you see our comment.

08:35.200 --> 08:38.940
And then, this is output of a MySQL dump.

08:38.940 --> 08:43.380
We have a common execution for this vulnerability.

08:43.380 --> 08:47.460
All we need to do is to provide a fake server.

08:48.140 --> 09:07.840
So, we have created Honeypot, which is a Python code, which allows you to exploit this specific vulnerability and also the plugin-loading vulnerability by passing specific configuration options to this Honeypot.

09:07.840 --> 09:09.960
The goal is simple.

09:09.960 --> 09:17.700
We try to run code on the clients who connect to our Honeypot by leveraging these vulnerabilities.

09:18.560 --> 09:20.620
And here's a demo.

09:24.180 --> 09:25.720
So, let's see.

09:25.720 --> 09:34.640
We have a payload script, a VBS script, which will be running on Windows, which just pops up a message, you have been pwned.

09:34.640 --> 09:39.360
Now, we start our Honeypot and pass the payload.

09:39.460 --> 09:48.260
And once... also, we start the HTTP server.

09:48.260 --> 10:00.020
And once the MySQL dump is executed on Windows now, the version is 36, which is one version before the latest, we get this pwned message.

10:01.240 --> 10:02.680
That's it.

10:03.620 --> 10:04.800
Back to you, Alex.

10:05.600 --> 10:08.500
Thank you very much.

10:08.720 --> 10:14.520
Alright, so now we successfully pwned the client.

10:14.620 --> 10:28.780
We were actually trying to figure out and scratching our heads, how do we actually attack those bad guys?

10:28.780 --> 10:33.420
So, back to the two attacks that we have been working on.

10:33.740 --> 10:39.700
The first attack, this is what we have captured, a fingerprint .

10:39.860 --> 10:40.800
Right?

10:40.800 --> 10:49.000
So, from the fingerprint itself, we can already see what we can or cannot do.

10:49.180 --> 10:53.080
So, arbitrary file read, we know this is old version.

10:53.080 --> 10:55.100
We know that it will work.

10:55.100 --> 10:57.500
Remote code execution with a plugin.

10:57.500 --> 10:58.600
We don't know.

10:58.600 --> 10:59.880
We will try it out.

10:59.880 --> 11:06.160
And there is no MySQL dump in this particular attack, so we will not be able to use the newest version.

11:06.740 --> 11:11.680
So, how do we use the arbitrary file read?

11:11.680 --> 11:13.600
Arbitrary file read is super easy.

11:13.600 --> 11:17.520
There is a tool that you can download from the internet, from the GitHub.

11:17.520 --> 11:24.720
You start this tool and you simply specify the file that you want to download from the client.

11:24.720 --> 11:32.400
Again, the client will be connecting to the server, this is fake server, and then we will be able to read the file.

11:32.500 --> 11:39.860
So, this is how the client arbitrary file read works.

11:39.860 --> 11:43.000
I will go through this real quick.

11:43.000 --> 11:57.220
So, you have this, um, uh, I download this tool, I start this tool on port 3306 and I request a password.

11:57.320 --> 12:08.480
And now I'm connecting from my machine with the old version of MySQL, uh, and I connect into this fake server and here I go.

12:08.480 --> 12:09.880
I got the file.

12:09.880 --> 12:11.480
So, I obtain this file.

12:11.480 --> 12:13.620
This is an old attack.

12:13.620 --> 12:16.680
Now, how can we use that?

12:18.740 --> 12:30.040
What we want to do is we want to first understand which version of Windows those attackers, those bots, are using.

12:30.120 --> 12:37.180
There are a number of, um, ways how you can determine the version of Windows by downloading the file.

12:37.180 --> 12:43.700
So, we started this file list and we determined that this is really old version of Windows.

12:43.700 --> 12:46.400
This is Windows server 2003.

12:46.800 --> 12:55.860
Alright, so with this attack, we were able to understand and get more details about what the attackers are using.

12:56.280 --> 13:00.700
Now, let's try the remote code execution.

13:00.720 --> 13:05.360
The remote code execution is actually on Windows you need DLL.

13:05.360 --> 13:12.520
We need to deliver that DLL to the attacker's machines, to the client, to be able to trigger it.

13:12.520 --> 13:20.940
So, we started to think, how do we deliver this code?

13:20.940 --> 13:23.780
Again, DLL doesn't need to be triggered on the client.

13:23.780 --> 13:27.420
We are triggering through the remote code execution.

13:27.980 --> 13:39.140
What we did is we collected the fingerprint, the actual commands that the server, the client, is running, is trying to run on the server.

13:39.560 --> 13:50.040
And we can see that what they are trying to do is they are trying to download the malicious code on the server.

13:50.080 --> 13:55.240
So, they are running an FTP server on their own machine.

13:55.260 --> 14:00.580
And we know the password, the username, and the port of the server.

14:00.580 --> 14:02.680
So, we started creating the simulation.

14:02.680 --> 14:04.580
Here's our plan of attack.

14:05.080 --> 14:12.540
We will upload the DDL to a public location on the client.

14:12.540 --> 14:16.140
On the actual server, Windows 2003.

14:16.260 --> 14:26.660
And then we will run the honeypot, wait for the connection, and through the connection we will trigger that DLL so we will have the remote code execution.

14:26.660 --> 14:31.840
So, we created this RCE via the simulation.

14:31.840 --> 14:34.640
So, this is how it could work.

14:34.640 --> 14:39.760
First of all, we have, we are connecting to FTP server here.

14:41.300 --> 14:44.720
Simulating that we are connecting to the actual machine.

14:44.720 --> 14:52.560
We, we do the demo demo, now we will put our evil DLL.

14:54.380 --> 15:05.220
And now, after we put the evil DLL in a public location, then we will start the server, the honeypot.

15:05.220 --> 15:06.140
So, we will start the server.

15:06.140 --> 15:09.140
Uh, this is the startup script.

15:09.140 --> 15:23.880
We specify the plugin dir, public documents, and then this thing will actually trigger the execution of our DLL via the directory traversal.

15:23.880 --> 15:30.880
I don't have much time to explain this attack, but this has been explained, uh, last year.

15:30.880 --> 15:34.540
You can actually see the recording from the HIDBI.

15:35.080 --> 15:47.840
Basically, there is a plugin dir in my SQL and the file name, and we use the directory traversal to actually trigger DLL open, which, or, or load library on Windows, which is in the server.

15:47.840 --> 15:52.880
Now, I'm listening on the port, and now here's my DDL.

15:52.880 --> 16:03.500
My DDL is displaying the, um, the text and actually create, uh, the, um, um, uh, dialogue.

16:03.800 --> 16:07.260
Here's how it works.

16:07.320 --> 16:16.980
So, we have this MySQL command line utility, and we have the evil DLL, uh, uploaded to the client.

16:16.980 --> 16:24.040
Now, the client in this simulation, that's the bad actor, they are connecting to us.

16:24.040 --> 16:25.240
And here's, here we go.

16:25.240 --> 16:30.760
We actually executed the code, remote code execution.

16:32.180 --> 16:33.660
Thank you.

16:37.200 --> 16:39.260
Alright, so this is done.

16:39.260 --> 16:46.060
We demonstrated arbitrary file read, we demonstrated remote code execution, uh, with a plugin.

16:46.420 --> 16:50.480
So, the second attack is even more interesting.

16:50.800 --> 16:53.380
Now, from the fingerprint, what do we see?

16:53.380 --> 16:59.120
We see this is later versions of MySQL client.

16:59.120 --> 17:04.740
We know that this remote code execution via plugin will not work.

17:04.740 --> 17:09.800
But, what we see immediately is that it's using MySQL dump.

17:09.800 --> 17:15.780
This is the utility, we actually found a way to, to do the, the code execution.

17:15.780 --> 17:21.720
And then again, we were scratching our heads, and then we decide, well, let's collect more information.

17:21.720 --> 17:26.640
Let's understand how this attack is being, uh, executed.

17:26.800 --> 17:29.080
So, this is what we see.

17:29.140 --> 17:33.940
The, the application that connects to, uh, our server, right?

17:33.940 --> 17:52.840
It, um, uh, connects to the server, do the show databases, and then what it will do is it will run, it will execute MySQL dump utility and, uh, pass the database and the table name.

17:52.840 --> 18:09.100
So, basically what it do, the, the goal of this thing is to download the database so that they can actually claim that they download your data.

18:09.180 --> 18:14.260
But, we can see that they're only downloading ten records.

18:14.300 --> 18:18.300
So, don't pay, obviously, right?

18:18.300 --> 18:19.060
Don't pay.

18:19.060 --> 18:20.960
Those guys don't have your data.

18:20.960 --> 18:26.860
They claim that they have downloaded, backed it up, backed your database, but they didn't.

18:26.860 --> 18:28.560
They only have ten records.

18:29.180 --> 18:29.620
Right?

18:29.620 --> 18:35.780
And then, from here, we were started brainstorming.

18:35.780 --> 18:39.060
Can we download the code via arbitrary file rate?

18:39.240 --> 18:39.960
No.

18:39.960 --> 18:42.240
Can we execute code via plugin?

18:42.420 --> 18:43.980
Actually, no as well.

18:43.980 --> 18:44.400
Right?

18:44.400 --> 18:47.300
We know because this is the newer versions.

18:47.340 --> 18:51.460
So, we started looking again, how this attack is being handled.

18:51.460 --> 18:55.780
So, we see that they're using MySQL, MyADB connector, right?

18:55.780 --> 18:57.280
This is from the fingerprint.

18:57.580 --> 18:59.880
This should be some application there, right?

18:59.880 --> 19:04.360
And then suddenly, MySQL dump connects to our server.

19:04.400 --> 19:14.660
So, they probably do some execution of the MySQL dump and then we see back, we see that the application connects back.

19:15.200 --> 19:17.880
So, we also see this.

19:18.180 --> 19:20.900
Again, we are providing the server.

19:20.920 --> 19:25.000
Whatever client will execute, we will see immediately.

19:25.580 --> 19:26.840
And this is what we see.

19:26.840 --> 19:29.280
This is our table that we generated.

19:29.280 --> 19:31.820
It's sending it up, up, back to us.

19:32.460 --> 19:39.900
So, maybe, if this is what they're doing, maybe we can actually do a command injection.

19:40.740 --> 19:44.660
And, we started experimenting with this.

19:44.660 --> 19:46.980
We created a fake database.

19:46.980 --> 19:48.900
A schema name is a database in MySQL.

19:48.900 --> 19:53.180
We created this, a classical command injection.

19:54.000 --> 19:56.860
And, uh, we were surprised.

19:56.860 --> 19:58.760
It actually worked.

19:58.760 --> 20:04.580
So, we use the command injection on this client attack, right?

20:04.580 --> 20:11.200
On this bot, just like this, and we receive all the information, uh, out of this command back to us.

20:11.200 --> 20:15.980
So, we downloaded the evil code from those attackers.

20:15.980 --> 20:19.780
This is how it is looking like.

20:19.780 --> 20:21.600
It's a MySQL dump.

20:21.600 --> 20:25.720
We have a command injection here and here's what we see.

20:25.720 --> 20:27.160
We got the evil code.

20:27.160 --> 20:29.180
So, it's a Python script.

20:29.180 --> 20:39.740
It's a Python script that connects to your database, try to brute force the password, and then, uh, execute the MySQL dump.

20:39.740 --> 20:41.040
The multiple injections.

20:41.040 --> 20:48.280
We were looking at this code and we were like, well, there are multiple places where you can execute the command.

20:48.800 --> 20:58.280
Alright, so, we successfully, we achieved our goal, but not the way we thought originally.

20:58.280 --> 21:00.320
We executed the command injection.

21:00.440 --> 21:03.360
How do you try that at home?

21:03.860 --> 21:12.800
Uh, I'm pretty sure this will be fixed shortly, so you need to try it right now if you want to see what it looks like.

21:12.960 --> 21:16.140
Uh, and you don't even need the tool.

21:16.300 --> 21:20.920
You can start a MySQL database server, any version.

21:21.020 --> 21:24.040
You will create a root with no password.

21:24.240 --> 21:28.700
This is a born version of, of MySQL server, right?

21:28.700 --> 21:32.540
You don't care if they will be downloading your data.

21:32.540 --> 21:33.900
Uh, I'm done almost.

21:33.900 --> 21:38.520
And then you open that and this is the injections that you will do.

21:38.520 --> 21:42.300
Create database, put it in a backticks, and that's it.

21:42.300 --> 21:47.620
This is how you will be able to attack, uh, the bad guys.

21:47.620 --> 21:48.640
Alright, this is done.

21:48.640 --> 21:49.500
All done.

21:49.500 --> 21:53.460
So, new CV, details, and thank you.

