WEBVTT

00:00.000 --> 00:09.280
Alright, so what I'd recommend for people in the back is to just move a little bit ahead so that you can hear the whole thing properly.

00:10.100 --> 00:11.660
Apologies for the holdup.

00:11.660 --> 00:13.480
We'll move on with the next session.

00:13.580 --> 00:19.040
Up next, we have Vladimir, who is a Senior Security Researcher at Microsoft.

00:20.080 --> 00:23.920
He's done some amazing research with the Quotesis framework.

00:23.920 --> 00:28.400
He's also identified some bugs in the Windows driver of the SonicWall tool.

00:28.920 --> 00:39.220
His topic for today is, from there to discovery, how OSINT and modern recon techniques uncovered a global VPN infrastructure.

00:39.540 --> 00:48.120
This presentation has a complete attack chain that showcases some advanced recognition techniques and some live demos.

00:48.460 --> 01:05.700
Here, we'll run some practical methodologies that can help us do improve our OSINT skills and put emphasis on the intelligence gathering process that can help you even proceed with other attacks.

01:05.700 --> 01:07.620
So, please bring it up for Vladimir.

01:16.580 --> 01:19.460
Thank you for joining me today.

01:19.460 --> 01:22.380
Today, I'm going to talk about research I did last year.

01:22.600 --> 01:27.320
From there to discovery, how OSINT and modern recon techniques uncovered a global VPN infrastructure.

01:29.740 --> 01:30.260
Critical...

01:30.260 --> 01:31.440
A little louder.

01:31.440 --> 01:33.100
Okay, yeah, I'll try that.

01:33.520 --> 01:35.180
So, let's begin.

01:35.440 --> 01:40.620
It all began one night while I played Deep Rock Galactic with my friends.

01:40.740 --> 01:48.840
And basically, it's a game where dwarves roam the cosmos, mining for minerals and killing bugs.

01:49.140 --> 01:52.200
And I played with two friends, Nicky and Philip.

01:52.200 --> 01:53.380
This is Philip.

01:53.380 --> 01:57.980
And basically, Philip had some issues, some connectivity issues, some lags.

01:57.980 --> 02:00.780
And I asked him what's going on.

02:00.780 --> 02:04.820
And basically, he said he installed a new VPN, that one.

02:04.820 --> 02:07.120
And ExpressVPN, maybe you heard about it.

02:07.240 --> 02:12.220
And then we entered this chat about why should one use like VPNs, right?

02:12.220 --> 02:13.940
Security, privacy, stuff like that.

02:13.940 --> 02:16.360
And so, I didn't believe him much about that.

02:16.920 --> 02:19.440
Sure, this is worth your while.

02:19.480 --> 02:23.840
And basically, he dared me to prove him wrong, right?

02:23.840 --> 02:26.280
To prove that something is not good there.

02:26.280 --> 02:35.580
And so, basically, there I started, started looking at ExpressVPN drivers, and different files.

02:35.580 --> 02:51.780
And one of the first things I found was the top driver, which is top adapter, which implements for Windows, basically virtual network card, which will basically get information, wrap it and send it through a tunnel to other endpoint of the VPN, for instance,

02:51.780 --> 02:52.780
for the server.

02:53.140 --> 03:05.920
And basically, I started reverse engineering it and opened the driver and found this nice piece of code, which initialized the MiniPort driver characteristics object, which has a lot of callbacks.

03:06.560 --> 03:11.520
And then the initialization happens with the Andes register MiniPort driver.

03:11.520 --> 03:21.820
And so, this object has a lot of callbacks that usually used for different actions in the driver, sending messages, receiving messages, and stuff like that.

03:22.100 --> 03:31.840
One of them, one that I actually looked at was very interesting for me, was the MiniPort send that buffer list, which is a method that sends information, right?

03:31.840 --> 03:34.020
And so, I dig into it.

03:34.020 --> 03:36.520
And basically, the flow is pretty trivial.

03:36.520 --> 03:42.020
First, we have the validation for the adapter that is ready to communicate.

03:42.020 --> 03:48.000
Then we have retrieval of the first driver, sorry, of the first buffer.

03:48.000 --> 03:56.620
And then basically, we will transmit this buffer in a loop for all the linked list of the buffers.

03:57.540 --> 04:01.160
And this is the top adapter transmit function.

04:01.240 --> 04:08.940
Basically, what it does is getting a net buffer structure and allocates its data length plus 24 additional bytes.

04:09.580 --> 04:21.040
Then it gets the actual pointer from this net buff structure and copy the memory from this net buff object into the newly allocated data.

04:23.120 --> 04:24.740
I'll try another mic.

04:24.740 --> 04:25.400
Okay.

04:25.400 --> 04:26.240
Is it better?

04:26.240 --> 04:27.340
Oops.

04:27.340 --> 04:28.620
Yeah, boom, boom, wow.

04:29.740 --> 04:31.180
Yeah, let's do it.

04:31.200 --> 04:34.020
And so, this is the prefix of the function.

04:34.020 --> 04:36.040
And before the end, it's allocate memory, right?

04:36.040 --> 04:37.160
Before this one.

04:37.220 --> 04:38.400
And this is how it looks.

04:38.400 --> 04:42.260
We can see the RS6 plus 18 extra and then another.

04:42.500 --> 04:43.700
It's worse.

04:43.880 --> 04:44.540
It's worse.

04:44.540 --> 04:45.140
Yeah.

04:49.020 --> 04:49.820
Cool.

04:50.500 --> 04:51.420
Let's do it.

04:51.960 --> 04:53.260
Defcon style, right?

04:53.260 --> 04:53.840
Okay.

04:53.840 --> 04:57.880
So, I hope they don't cancel each other.

04:58.280 --> 04:58.800
Yeah.

04:58.820 --> 04:59.960
Waves stuff.

04:59.960 --> 05:00.360
Okay.

05:00.360 --> 05:03.420
So, let me hold it like that.

05:03.420 --> 05:05.640
And so, this is the prefix.

05:05.640 --> 05:12.660
The idea is that we allocate a buffer and then we add 18 bytes for offset and then we add 18 bytes for size.

05:12.660 --> 05:17.000
And so, obviously, if we'll give a big enough value, we'll have integer overflow.

05:17.000 --> 05:19.280
And so, this is bad.

05:19.280 --> 05:21.040
But it's not really bad.

05:21.040 --> 05:22.980
Let's talk about what we can do with that.

05:22.980 --> 05:25.160
And so, here we allocated the memory.

05:25.160 --> 05:30.420
Then we have the ndisget data buffer, which is the pointer for the buffer that's been copied.

05:30.420 --> 05:36.620
And then we actually do the memory move, which is the copy of the data on the newly allocated memory, right?

05:36.620 --> 05:41.880
And so, the idea is that we will allocate 17 bytes and then write it with a lot of data.

05:41.880 --> 05:43.880
And this is while kernel overflow.

05:44.180 --> 05:50.360
Now, generally speaking, there are some explanations why kernel copy overflows.

05:50.440 --> 05:51.640
But they are hard.

05:51.640 --> 05:52.320
Why they are hard?

05:52.320 --> 05:58.060
Because there are tons of mitigations in the kernel to prevent this.

05:58.060 --> 06:12.940
And, like, modern HVCI, stuff like that, even page fall handler, device guard, stuff like that will make it very hard.

06:12.940 --> 06:19.780
Now, the issue is that this will be hard even for simple overwrite.

06:19.780 --> 06:25.860
For while kernel overflow, which basically will overwrite a lot of memory, it's even harder.

06:25.860 --> 06:32.860
And so, in this case, I just left it on the side and went a few days without thinking about it.

06:32.860 --> 06:36.680
And then I started looking at ProtonVPN source code.

06:36.780 --> 06:39.900
Not source code, but on the driver again.

06:39.900 --> 06:41.180
And find the same bug, right?

06:41.180 --> 06:43.800
And so, I've already seen that.

06:43.880 --> 06:52.300
And at this point, I asked myself, do we have, like, a one-off issue, or is it a systematic issue, something that is more bigger than two drivers?

06:52.360 --> 06:54.600
And obviously, also a disaster, right?

06:54.600 --> 06:57.920
Because if we can't search for it, we can't find a lot of leads.

06:57.920 --> 07:05.900
And so, in this case, I just decided to create Yarrow rules to search for the problematic allocation of memory.

07:06.620 --> 07:10.040
And this is the part we want to search for.

07:10.040 --> 07:11.380
This is the assembly of it.

07:11.380 --> 07:18.320
And we can see that it's using the tag, the pull tag here, noted in yellow.

07:18.320 --> 07:25.020
And I just created a Yarrow rule to search for that, for 64 bits and 32.

07:26.640 --> 07:32.740
And then I searched for it in Yarrow, and found 50 matches.

07:32.920 --> 07:38.120
Now, the cool stuff is that there are a lot of drivers with the same issue.

07:38.120 --> 07:48.840
And so, at this point, I just asked myself, or told myself, that it's probably something that is widely used by a lot of drivers, something to do with VPNs.

07:48.840 --> 07:54.620
And so, the next question was, ChatGPT, what is the most popular VPN?

07:54.620 --> 07:57.780
And obviously, OpenVPN is the answer.

07:58.040 --> 08:00.380
And so, OpenVPN is really huge, right?

08:00.380 --> 08:09.060
It's used by tons of different VPNs, by ExpressVPN, NordVPN, CyberGhost, ProtonVPN, whatnot.

08:09.240 --> 08:16.140
And beside all that, it's a big, big repo in GitHub with a lot of sub-repos inside of it.

08:16.140 --> 08:28.680
We have the OpenVPN daemon, we have the EasyRSA, which is their implementation for RSA, also the GUI, tap Windows 6, OpenVPN 3 Linux, which is the OpenVPN implementation for Linux.

08:29.740 --> 08:40.540
And basically, at this stage, I asked myself, okay, so we found this bug in a number of drivers, Windows drivers, let's find some repo that's relevant to that.

08:40.540 --> 08:42.560
And obviously, I started looking at tap Windows 6.

08:42.780 --> 08:48.560
And basically, after some search, I found this nice method, which does exactly that.

08:48.560 --> 08:59.260
And this is the issue we've seen with the assembly part, because it allocates the packet length from the buffer and then adds to it the additional error size with this macro.

08:59.260 --> 09:01.000
And so, this is the bug, right?

09:01.000 --> 09:04.540
This is the source of the of the bug that we found in OpenVPN.

09:04.880 --> 09:10.640
And now, after we found the reason to look at OpenVPN, let's take a deep dive inside of VPN.

09:10.680 --> 09:13.100
We'll find some cool stuff there, I promise.

09:13.180 --> 09:22.600
And, okay, first, one of the most interesting repos of OpenVPN, obviously, is the OpenVPN daemon, which is the process that will execute all the VPNing.

09:23.540 --> 09:30.420
Then we have the OpenVPN GUI, which is basically the GUI part that allows us to use OpenVPN on Windows.

09:30.640 --> 09:33.540
And we have the tap Windows 6 that we've already seen.

09:33.560 --> 09:40.120
And for current session, this is the repos that are relevant and interesting for us.

09:40.120 --> 09:44.760
They have a lot more solutions and a lot more stuff to provide.

09:44.760 --> 09:48.960
So, if you'd like to check them out, look at their GitHub page.

09:49.760 --> 09:52.700
Now, the client server is pretty straightforward.

09:52.700 --> 09:55.580
We have the client that will be connected to the server.

09:55.680 --> 10:05.320
Obviously, SSL, MTLS, even if needed, and the classical handshake and stuff will flow on both ways.

10:05.880 --> 10:21.160
Now, on the single machine level, on the client level, we'll have the kernel space logic that will create a virtual NIC, through which we will send data that will be roped and sent through the actual physical NICs.

10:21.160 --> 10:30.340
And then, in the user mode, we have the daemon that runs OpenVPN and actually encrypts the messages and does all the VPNing.

10:31.240 --> 10:42.700
And so, OpenVPN, in addition to being a big open source, it's actually a standard for protocol of communication between server and client.

10:42.700 --> 10:45.760
And the structure of it, it's pretty straightforward.

10:45.760 --> 10:48.140
It can be over TCP or UDP.

10:48.240 --> 10:50.760
And first, we'll have the packet length, 16 bits.

10:50.760 --> 10:56.760
Then, we have the key ID, the opcode, which is the thing we want to do.

10:56.800 --> 11:00.120
And then, we have the payload, which is pretty straightforward.

11:00.120 --> 11:04.980
This is an image of a handshake for OpenVPN protocol.

11:06.360 --> 11:17.980
Now, another very interesting part about OpenVPN is that it's supported on almost every big or small operating system and different tools.

11:17.980 --> 11:23.220
You basically can open a random router and find an OpenVPN binary there, right?

11:23.220 --> 11:29.540
And so, it works on Windows, Linux, macOS, iOS, Android, whatnot.

11:29.880 --> 11:32.160
And so, the question is how they achieve that.

11:32.160 --> 11:33.860
It's pretty standard.

11:33.860 --> 11:47.100
They have a lot of includes with different macros and a lot of implementations for a specific system, which allows them to be like dynamical and very fast and very efficient on the specific operating system.

11:50.000 --> 12:00.220
They'll be using a lot of macros and then with different flows or different even functions and even different includes to do that.

12:01.100 --> 12:04.600
And so, this is like the macro logic of OpenVPN.

12:04.600 --> 12:13.480
Now, let's take a look inside other cool, open VPN, one of which is the OpenVPN plugins.

12:13.500 --> 12:27.340
Now, OpenVPN have plugins to allow specific or additional credential validation or audition of the information or even creating ETW events on specific logic that we want to do.

12:27.340 --> 12:30.300
All that can be implemented with plugins, right?

12:30.300 --> 12:40.580
And so, the idea is that we have this DLL that can export some functions and can be called with, for instance, OpenVPN plugin OpenV1, which is the initialization function.

12:40.580 --> 12:43.960
In this example, they are setting credentials.

12:43.960 --> 12:50.340
And then we have the FuncV1, which will basically do the logic that it needs to be done.

12:50.340 --> 12:52.960
And here, it will validate for credentials.

12:53.180 --> 12:57.580
So, down the line of plugins in OpenVPN, they are cool.

12:57.580 --> 13:03.780
They allow a lot of stuff, a lot of validation, auditioning, stuff like that.

13:04.820 --> 13:11.920
Now, let's talk about the actual architecture of the OpenVPN service on Windows system.

13:11.920 --> 13:21.500
And so, we have the OpenVPN server, which is the system-level running service that has an open name pipe called OpenVPN slash service.

13:21.600 --> 13:27.680
And a process will connect to it and send information to this name pipe.

13:27.680 --> 13:35.820
How this will look on the OpenVPN server side, creating name pipe instance, and then create intent to handle it.

13:35.820 --> 13:45.100
And we will validate stuff and basically create the relevant security descriptor for it.

13:45.260 --> 13:47.240
Then, we will wait for connection.

13:47.240 --> 13:58.800
After connection achieved, the OpenVPN server will wait for get startup data, which is basically the way that other process communicate with OpenVPN server.

13:58.800 --> 14:07.060
They will send a string that explains where they want to run the new OpenVPN process.

14:07.060 --> 14:10.240
The actual daemon will do the VPN-ing.

14:10.240 --> 14:16.500
OpenVPN server will just managing those and a lot of other instances of OpenVPN can be created.

14:16.500 --> 14:23.280
And so, the startup data is the directory, configuration, and the log file that should be executed.

14:23.620 --> 14:30.700
And so, this is an example for initializing execution of OpenVPN programmatically.

14:30.840 --> 14:43.480
And after this startup data will be passed and validated and checked that it's okay, the OpenVPN server will impersonate the client.

14:43.900 --> 14:50.300
And then, it will validate that this client is the OpenVPN group of users.

14:50.300 --> 15:00.460
And then, we'll proceed to basically create another name pipe, which it will pass to the execution of the OpenVPN process.

15:00.460 --> 15:00.720
Right?

15:00.720 --> 15:08.520
And so, then it will run this OpenVPN as the user that he has impersonated.

15:08.520 --> 15:11.240
And so, this is how it looks on Windows.

15:11.240 --> 15:20.340
We have the OpenVPN server that through OpenVPN service got startup data and initialized and executed OpenVPN process.

15:20.680 --> 15:22.960
And then, we have another name pipe.

15:22.960 --> 15:28.460
For instance, here is service 1234 through which OpenVPN will communicate with OpenVPN serve.

15:28.460 --> 15:34.660
And so, the travel question is why do we need this another name pipe or why so many name pipes?

15:34.660 --> 15:47.240
And the answer is that, for instance, if we have a weak client that connects to OpenVPN service and it wants to change some DNS configuration, maybe add some routes, you need to be able to do that.

15:47.240 --> 15:49.400
For that, and this is a weak user.

15:49.400 --> 15:55.840
For that, it will send specific messages to the OpenVPN service and the service will do it on its behalf.

15:55.900 --> 15:56.220
Right?

15:56.220 --> 15:59.780
And so, this is how it actually looks like.

15:59.780 --> 16:08.540
Through the same pipe, the data pipe, we will get some data and then, we'll convert it to messages based on the type they have passed.

16:08.540 --> 16:11.660
Now, there are some logic that can be achieved with that.

16:11.660 --> 16:22.240
The client can send address message or route message or DNS configuration message and then, the server will send back acknowledge message for that.

16:22.240 --> 16:24.020
So, how it will look like?

16:24.020 --> 16:28.360
The OpenVPN will send a route message, for instance, for open service.

16:28.360 --> 16:38.680
The service will actually execute the logic for that, add another route, then send an acknowledge message back to OpenVPN to signal that it has finished the logic.

16:38.680 --> 16:55.340
Now, if we want to take a look on the broader side of Windows, we also have the OpenVPN GUI, which will basically send the relevant data through the OpenVPN service to OpenVPN service that will initialize the daemon for the user.

16:56.160 --> 17:03.920
And now, in the, let's call it like the network level, this is the full architecture of the communication.

17:03.920 --> 17:11.120
We have the server with the plugin inside the OpenVPN daemon and then, information will pass through the plugin.

17:11.120 --> 17:14.580
The plugin can audit it, can log at it and stuff like that.

17:14.580 --> 17:20.740
And now, we can talk about first cool discovery that found here.

17:20.740 --> 17:39.540
It's relevant to the potatoes class of vulnerabilities in Windows and basically, potatoes vulnerabilities are vulnerabilities that allow, by exploiting some misconfiguration, some issues in Windows, achieve privilege escalation.

17:39.540 --> 17:45.260
And for instance, we have the sweet potato, which waits for WAPT queries on the network.

17:45.260 --> 17:52.280
It will answer the address for WAPT server, which will point to the attacker.

17:52.280 --> 18:00.020
Then, the legitimate client will actually ask for WAPT that file, which is the file that defines proxy on Windows.

18:00.020 --> 18:09.180
And then, the malicious attacker will answer bad WAPT file that points again to its controlled proxy.

18:09.180 --> 18:26.040
And in this case, the Windows client will start sending through the proxy different queries and then, the malicious proxy can require NTLM authentication, execute NTLM authentication and do relay or crack or whatever they like to.

18:26.100 --> 18:30.780
And so, this is pretty much what will happen here.

18:30.980 --> 18:35.880
I'll show you a vulnerability and then how we can exploit to get local privilege escalation.

18:35.880 --> 18:45.600
So, this is the logic in the service of OpenVPN that handles messages that received from the OpenVPN demo.

18:45.800 --> 18:47.280
The logic is pretty simple.

18:47.280 --> 18:53.000
First, we'll have the amount of bytes we want to read, the PICNAME bypassing.

18:53.000 --> 18:54.320
Then, we'll handle a message.

18:54.320 --> 19:07.400
In the handle message, we will allocate a struct on the stack and then, basically, we'll write onto this allocated struct the amount of data that we read from the pipe, right?

19:07.400 --> 19:13.420
And so, here we can see on the left upper part the amount of bytes we want to read.

19:13.420 --> 19:20.960
Then, we can see that message is a union of structs but basically, it will be just the longest of them on the stack.

19:20.980 --> 19:27.160
And then, we have the read bypassing that will read the same amount of bytes onto the message struct.

19:27.160 --> 19:33.820
And so, this is a stack overflow because if we can write more data than this message, we will overflow it.

19:34.060 --> 19:46.560
For instance, if you have the message header here with tab type and message ID and then, we have the address message or even the DNS config message which is bigger, if we send more data than it contains, it will overflow it.

19:46.700 --> 19:57.400
And if we'll do it, we'll have, we'll get fast fail stack cookies check failure which indicates that we have stack overflow but we had a cookie issue, right?

19:57.520 --> 19:58.940
Which is good and hard.

19:58.940 --> 20:01.940
So, let's think about what we can do with the canary.

20:02.620 --> 20:06.620
This is the message, the handle, this is the function that handles the messages.

20:08.120 --> 20:09.760
And this is its prefix.

20:09.760 --> 20:12.640
And here, we can see the security cookie usage.

20:13.360 --> 20:18.300
Now, basically, a security cookie defined here to be of value.

20:18.580 --> 20:27.340
And then, what will happen is that we'll store it on the stack again and in the end of the function, we'll validate its value and see that it hasn't been changed.

20:27.580 --> 20:30.680
Now, the actually interesting question is where it's being set.

20:30.680 --> 20:33.120
And so, we have this security cookie function.

20:33.200 --> 20:36.000
And this is the logic that happens there.

20:36.000 --> 20:41.820
And basically, first run, we'll check if the security cookie value is constantly defined for first run.

20:41.820 --> 20:51.060
And then, we do a lot of XORs with different information from the operating system such as time as a file, performance count, and stuff like that.

20:51.060 --> 20:55.820
And the down the line here is that it will be very, very hard to guess this value.

20:55.960 --> 21:03.660
And the only way, the only possible way to bypass that would be if we had rig primitive on the memory of this process.

21:03.660 --> 21:04.860
But we don't have it.

21:04.860 --> 21:07.560
And so, the underline here is that it will crash.

21:07.560 --> 21:11.460
If we'll overflow, we'll basically crash the process.

21:12.200 --> 21:17.240
Now, let's talk a little bit about some issues that are associated with name pipes.

21:17.240 --> 21:32.940
First, we have the classical name pipe instance race condition, which means that if a client connects to a server through a name pipe, if somebody creates the same name pipe with the same name, before the server, the client will connect to it.

21:32.940 --> 21:40.860
Now, another issue is the superfluous pipe connectivity issue, which basically says that the client don't really know who it's connecting to.

21:41.440 --> 21:51.620
And so, the attacker that created the name pipe can do, for instance, malicious impersonation of the client.

21:51.960 --> 21:59.440
Now, let's sum it up in the all of this together into a vulnerability and a local privilege escalation vulnerability.

21:59.800 --> 22:03.540
And basically, what we'll do, we'll create a malicious DLL.

22:03.540 --> 22:08.520
And then, we will load this malicious DLL in open VPN daemon.

22:08.520 --> 22:13.180
And through the inner name pipe, we will crush the open VPN service.

22:13.180 --> 22:23.100
And then, the open VPN daemon will create the malicious DLL in the open VPN will create same name pipe and export it to other users.

22:23.100 --> 22:32.660
And then, the next user that will connect, it will connect not to original open VPN service, but to our malicious plugin, right?

22:32.660 --> 22:41.120
And so, the DLL main basically will extract the command line argument and deduplicate the handle that was passed there.

22:41.300 --> 22:52.400
And through that handle, we'll send a malicious packet that will basically kill the open VPN service, which is just long enough data that will overflow the stack.

22:52.400 --> 22:59.300
And after that, it will create the open VPN service name pipe and wait for connection.

22:59.300 --> 23:03.680
If a connection occurred, it will basically impersonate.

23:04.320 --> 23:07.280
First, it will get the startup data because this is the protocol.

23:07.280 --> 23:09.440
Then, it will impersonate the connected client.

23:09.440 --> 23:19.720
If the connected client is strong enough, it will execute on its behalf, for instance, malicious application called driver communicator.

23:19.720 --> 23:23.200
And so, this is the demo.

23:24.320 --> 23:29.460
On the right, we have weak user that executes the logic.

23:29.640 --> 23:33.060
And on the right, we have the client that connects.

23:33.060 --> 23:47.320
Now, on the right side here, we had an exploit that actually sends malicious, that loads a malicious plugin and kills the open VPN service and then runs with the name pipe and waits for connection.

23:47.320 --> 23:59.120
Then, on the left side here, a client connected to this unknowingly because, well, it's the same name of the open VPN service name pipe.

23:59.120 --> 24:07.400
Then, here, we can see that we have a very strong level process, for instance, system level in this case.

24:07.400 --> 24:10.600
And, yeah, take me a while to get there.

24:10.740 --> 24:13.200
But, yeah, cool.

24:13.440 --> 24:17.820
Now, this was cool because we got local privilege escalation.

24:17.820 --> 24:20.020
But the question is, can we do it remotely, right?

24:20.020 --> 24:26.380
And so, the question is, how do we use name pipes remotely?

24:26.380 --> 24:27.980
And the answer is pretty simple.

24:27.980 --> 24:32.120
Windows have different mechanisms for sharing resources.

24:32.120 --> 24:35.780
In this case, name pipes are IPCs, resources.

24:36.060 --> 24:40.580
And basically, the idea is that there are some protocols for that, SMB and SMB2.

24:40.580 --> 24:51.960
And we will, to use a specific resource for a specific endpoint, we will use an endpoint server and then the path to the share and the path to the resource.

24:52.300 --> 24:55.620
Now, we can do that, for instance, with net use.

24:55.840 --> 25:04.340
And we can actually then see the IPCs process, which is good, which means that we could potentially connect to remote endpoint and use its name pipe remotely.

25:04.460 --> 25:08.100
And so, how would an attempt like that would look like?

25:08.100 --> 25:13.000
First, we'll see the tree connect request for the IPC on specific endpoints.

25:13.060 --> 25:19.500
And then we also can see the request was declined because it's not that simple.

25:19.720 --> 25:30.240
And the thing is that there are some Windows definitions, some set of rules that allow and disallow connection to name pipes.

25:30.240 --> 25:34.080
For instance, we have the network access, name pipes that can be accessed anonymously.

25:34.080 --> 25:39.600
By default, there are none such as that that could be accessed anonymously.

25:39.680 --> 25:49.560
And another thing that we have is that we restrict anonymous access to name pipe, and this is enabled by default.

25:49.560 --> 25:57.580
And so, the thing is that it means that it's very hard for us to do it without, basically, without credentials.

25:58.040 --> 26:00.900
But don't worry, we can get those.

26:01.320 --> 26:06.180
And basically, we should do that with reconnaissance.

26:06.180 --> 26:12.260
We can wait on the network and sniff for different hashes and then break them and get the credentials.

26:12.860 --> 26:28.960
And then this is not something new everybody uses, such as APT28 and then another processes exploitation by Mimikads, or even malicious plugins for different web browsers that do exactly that.

26:29.420 --> 26:36.300
Basically, NTLM is a NetLAN manager, a set of protocols that allow us to connect securely.

26:36.360 --> 26:38.940
And this is how it will look like.

26:38.940 --> 26:45.320
First, we'll have the NTLM SSB negotiated request with the challenge.

26:45.320 --> 26:48.360
Then the server will send the challenge.

26:48.360 --> 26:53.220
Then the client will send back the NTL-proof STR.

26:53.240 --> 26:57.400
And in the end, we'll have the full hash in the packet.

26:58.380 --> 27:02.320
And we can capture that with tons of different tools.

27:02.320 --> 27:06.280
And I used here the responder in Kali.

27:06.280 --> 27:15.820
And basically, we can see that it captured the username, the domain, the server challenge, and the extra hash payload that actually hashes the password.

27:16.080 --> 27:19.700
And the other question would be, how can we crack that, right?

27:19.700 --> 27:23.840
And basically, there are tons of open sources there.

27:24.080 --> 27:31.040
And the most two promised things that I found was Hashcat and JohnDeRipper because they're widely used and very good.

27:31.040 --> 27:34.920
And I proceed with Hashcat because it's very good with GPUs.

27:34.920 --> 27:46.060
And first, I started with my own laptop, my gaming laptop that have RTX 3070 with almost 6,000 CUDA cores.

27:46.060 --> 28:02.980
And basically, 6,000 CUDA cores for net NTLM v2 hashes will allow me to break something like almost 2,800 million hashes per second, which is pretty fast.

28:02.980 --> 28:06.760
And for starters, pretty good if you have a very short password, right?

28:06.760 --> 28:09.360
If you have one short password, it will do it momentarily.

28:09.460 --> 28:15.660
But if you have a long password, it will take something like a few years and we don't really have time for that.

28:15.700 --> 28:19.000
Those are indeed rookie numbers.

28:19.240 --> 28:25.480
And so, other thing I thought about was maybe we can build cool hardware to crack it.

28:25.480 --> 28:36.300
And we can do that, but it will take a lot more money and a lot more time because to actually get a lot of GeForce, it takes a lot of time and a lot of patience.

28:37.060 --> 28:42.000
And so, from here, I decided to find another solution.

28:42.000 --> 28:46.800
Basically, I thought about how can I use cloud platforms for that.

28:46.800 --> 28:58.720
And basically, there is this cool platform called Vast AI, which basically allows you to rent machines with specific GPUs on time for time.

28:58.720 --> 29:01.480
And it's very, very easy to use.

29:01.480 --> 29:04.780
You've got a Docker images that can run on those machines.

29:04.900 --> 29:06.740
And it's pretty cheap, right?

29:06.740 --> 29:17.140
For instance, here we can rent a machine with 18 RTX 4090 for $8.5 an hour, which is pretty cheap.

29:17.240 --> 29:30.200
And now let's calculate quick math, as they say, the amount of CUDA cores and how much more such machine will give me in terms of tracking per hour, right?

29:30.200 --> 29:42.900
And so, if my old laptop has almost 6,000 CUDA cores, the RTX 4090 have almost two and a half times more, and the 18 times have almost 50 times more.

29:42.900 --> 29:46.980
And so, the question is, like, will the improvement be 50 times more?

29:46.980 --> 29:50.420
And obviously not, because we have tons of different bottlenecks.

29:51.180 --> 30:01.120
But in the end, I proceeded with the big lad, the machine with a lot of RTXs, and basically installed it and executed the tracking of a long password.

30:01.120 --> 30:07.000
And it took me less than three minutes to track a nine char password, which is pretty fast.

30:07.140 --> 30:09.320
And yeah, it's hell yeah, for sure.

30:10.200 --> 30:15.420
And then now we have basically all the things that we need to create actual RCA, right?

30:15.420 --> 30:16.520
Because we can.

30:19.260 --> 30:27.740
Firstly, we used OSINT leads to find a basic issue, and then we keep digging into OpenVPN and find another issue.

30:27.860 --> 30:34.420
And then we understood that we need SMB enumeration and hash tracking to get credentials.

30:34.420 --> 30:37.420
And in the end, we cracked those hashes with cloud tracking.

30:37.420 --> 30:42.000
All of this together allow us to actually get an RCA vector.

30:42.000 --> 30:49.260
And the idea is that first we'll work on the network, wait for hashes, then recap them and track them.

30:49.260 --> 30:58.360
And then we'll use them with Netuse to actually be able to access other PC IPCs.

30:58.380 --> 31:09.620
And then what we'll have in our exploit is actually connection to the remote endpoint name pipe of the OpenVPN service that we try to attack.

31:10.000 --> 31:19.880
After that, we will pass to it a malicious configuration and log on attacker controlled share, as shown here.

31:20.000 --> 31:30.280
And so in the configuration of OpenVPN, we'll have the directive to load a malicious plugin, which is again located on the malicious share controlled by the attacker.

31:31.060 --> 31:40.100
And so basically, first attempt, it didn't work because we need to allow anonymous access to the share and allow everyone to connect to it.

31:40.100 --> 31:47.020
And after this configuration on the attacker controlled share, we got it working.

31:47.020 --> 31:49.980
First, we have the request for tree for share.

31:49.980 --> 31:53.000
Then we have the request for the configuration.

31:53.020 --> 31:57.100
And in the end, we have the request for the malicious plugin that executes the logic.

31:57.360 --> 32:19.280
And this is the example of the demo that we'll first execute on the attacker controlled share machine will execute the exploit, which will connect to the remote endpoint and through name pipe will load a malicious plugin from attacker controlled share.

32:19.440 --> 32:26.600
And this is pretty cool because this allows me to actually remote execute on the remote endpoint.

32:26.600 --> 32:31.660
In this specific example, it just dumped a lot of files on the desktop, which was pretty cool again.

32:31.860 --> 32:40.920
Now the question is, can we mount those two logics together?

32:40.920 --> 32:45.080
Can we execute the remote code execution and then the local provisioning solution?

32:45.080 --> 32:46.000
And the answer is yes.

32:46.000 --> 32:51.740
We just need to mount the LP logic onto the malicious plugin that we execute remotely.

32:51.740 --> 33:02.360
And in this case, after the malicious LP executed, we will execute the reclaim and the file that called reclaimed the Dwarven Kingdoms of Erebor.

33:02.720 --> 33:07.760
And after executing this, we have an RCNLP vector.

33:07.760 --> 33:10.280
And the question is, what can we do from here?

33:10.680 --> 33:19.700
And some travel attempts, some stuff that APDs love to do is bring your vulnerable driver.

33:19.800 --> 33:25.160
And then again, it will be pretty easy in this stage because we have already APD.

33:25.160 --> 33:31.140
We can actually use the SC manager and create service with our malicious driver.

33:31.140 --> 33:40.880
For instance, we could use this one, which has read-write primitives into kernel memory, which make us very, very strong.

33:41.000 --> 33:47.180
And another technique we could use is living off the land, which is again used widely by APDs.

33:47.180 --> 33:51.560
Maybe find some install MSI and mangle with it.

33:51.920 --> 34:05.320
And the classical approach could be even exploiting one day or even new zero day in Windows and Windows machines in the driver kernel.

34:05.400 --> 34:08.680
This is actually what has been executed in this research.

34:08.680 --> 34:09.980
And I took it as well.

34:09.980 --> 34:21.280
Basically, the idea is to exploit and vulnerability which will change the previous mode and allow us to have arbitrary read-write into kernel memory.

34:21.520 --> 34:25.440
And the other question will be, now what?

34:25.440 --> 34:34.000
Okay, so we have remote code execution, and we have LPA, then we have even read-write kernel primitives.

34:34.000 --> 34:48.680
Now, APDs would love that because basically, when you have executed some malicious logic on endpoint, you have a lot of anti-malware and anti-virus application that will hunt for you.

34:48.680 --> 34:53.840
And what we would like to do, and generally, APD would like to kill those and bypass them.

34:53.840 --> 35:08.080
And so, usually those come in the form of PPL, which is a Protected Process Line, which was invented somewhere in Windows 8, if I'm not mistaken, which allows us to protect processes.

35:08.080 --> 35:18.620
The idea is that we will have a process that is digitally signed, and they have an hierarchy of different PPLs that are digitally signed.

35:18.620 --> 35:27.080
And the rule is that the higher the process, it can mingle with lower processes, but lower processes can actually communicate with those processes.

35:27.080 --> 35:34.000
And the regular processes, even if they system, can't actually affect the PPLs, right?

35:34.000 --> 35:40.140
And so, what we'd like to do is abuse those redrive primitives to maybe un-PPL a process.

35:40.140 --> 35:41.320
How would we do that?

35:41.320 --> 35:43.240
Let's use WinDBG.

35:43.760 --> 35:51.820
Basically, there is this struct called PSProtection, which indicates the PPL protection level of a system, of a process.

35:51.820 --> 36:10.920
And we can use, for instance, a process directive to see the LSAS information, which is basically type-protected, and it's a protected sign on system, which is pretty high up the level, which means not much of different process can communicate with them and affect it.

36:11.580 --> 36:18.940
Now, if we'll try to kill a process, which is a PPL, we will fail, even if we are a system, because, again, we are not a PPL.

36:18.940 --> 36:24.500
So, if we have WinDBG, we could do it with actually overwriting the memory, right?

36:24.500 --> 36:40.660
We can find the memory, overwrite it, and then basically we'll crash the process in this case, because if we'll overwrite the PPL field of Winint, it's a very high and important process, and it will basically crash the system.

36:41.460 --> 36:44.320
And now, this will be our full chain.

36:44.320 --> 37:02.720
We'll use the DRCE to gain code execution with a plugin, then the same plugin will execute the local provision escalation logic, the PLC, and then with that, it will wait and abuse the app ID sys flow to get arbitrary kernel read-write.

37:02.860 --> 37:13.180
And in the end, it will, with those abilities, overwrite the PPL protection of specifically Winint for us to be able to crash it, right?

37:13.180 --> 37:15.080
And so, this is the demo for that.

37:15.440 --> 37:42.140
Again, this is a remotely executed exploit that will connect to the remote endpoint on the IPC, on the OpenVPN name pipe service, execute a plugin, the plugin will wait for a connection , and here we can see the log that means that stage one and stage two loading of the plugin were successful,

37:42.140 --> 38:01.580
and then we'll have a user just execute the OpenVPN GUI, which runs on highly elevated privileges, and it will send the startup data to already our exploit, and then we'll have stage three and stage four, which allows us to actually overwrite Winint PPS protection,

38:01.580 --> 38:03.980
and this gives us a full chain.

38:04.300 --> 38:09.860
And the question is, as I said, why an attacker would love to do this?

38:09.860 --> 38:13.160
Well, basically, they have tons of stuff they would like to bypass.

38:13.160 --> 38:25.910
Security of OSes, anti-viruses, stealth attacks, maybe they want to hide something, rootkits, and so this could be a pretty cool vector for attacker.

38:27.080 --> 38:42.140
And basically, the Rekon and the OSINT tools stack I used here was VirusTotal, Yara rules, Trudan and Zoom, I haven't talked about it in length, but basically those helped me to find how much OpenVPN is used and popular, which is pretty much.

38:42.140 --> 38:45.500
And here we have the summary of the session.

38:45.500 --> 38:52.100
Basically, the takeaways here is that first, one bug can be a pretty big deal.

38:52.440 --> 38:59.620
In this case, the plugin mechanism was implemented not on the best side, but it allowed us to do a lot of damage.

39:00.200 --> 39:14.440
And another thing is that currently, we don't really need to create a heavy hardware system with a lot of GPUs locally, we can just rent some cloud from some cloud provider.

39:14.440 --> 39:24.340
And yeah, it's basically easier, probably more cheaper and available for everybody.

39:24.780 --> 39:35.680
And the third thing is that security researchers will probably use OSINT and Rekon tools a lot because, well, we know that that makes our life easier.

39:35.680 --> 39:38.660
And this is a real romance between the two.

39:39.660 --> 39:41.380
And this is it.

39:41.420 --> 39:43.500
Thank you for joining me today.

39:43.580 --> 39:45.820
And I think we are finished.

39:45.820 --> 39:46.780
Any questions?

