1 00:00:00,000 --> 00: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. 2 00:00:10,100 --> 00:00:11,660 Apologies for the holdup. 3 00:00:11,660 --> 00:00:13,480 We'll move on with the next session. 4 00:00:13,580 --> 00:00:19,040 Up next, we have Vladimir, who is a Senior Security Researcher at Microsoft. 5 00:00:20,080 --> 00:00:23,920 He's done some amazing research with the Quotesis framework. 6 00:00:23,920 --> 00:00:28,400 He's also identified some bugs in the Windows driver of the SonicWall tool. 7 00:00:28,920 --> 00:00:39,220 His topic for today is, from there to discovery, how OSINT and modern recon techniques uncovered a global VPN infrastructure. 8 00:00:39,540 --> 00:00:48,120 This presentation has a complete attack chain that showcases some advanced recognition techniques and some live demos. 9 00:00:48,460 --> 00: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. 10 00:01:05,700 --> 00:01:07,620 So, please bring it up for Vladimir. 11 00:01:16,580 --> 00:01:19,460 Thank you for joining me today. 12 00:01:19,460 --> 00:01:22,380 Today, I'm going to talk about research I did last year. 13 00:01:22,600 --> 00:01:27,320 From there to discovery, how OSINT and modern recon techniques uncovered a global VPN infrastructure. 14 00:01:29,740 --> 00:01:30,260 Critical... 15 00:01:30,260 --> 00:01:31,440 A little louder. 16 00:01:31,440 --> 00:01:33,100 Okay, yeah, I'll try that. 17 00:01:33,520 --> 00:01:35,180 So, let's begin. 18 00:01:35,440 --> 00:01:40,620 It all began one night while I played Deep Rock Galactic with my friends. 19 00:01:40,740 --> 00:01:48,840 And basically, it's a game where dwarves roam the cosmos, mining for minerals and killing bugs. 20 00:01:49,140 --> 00:01:52,200 And I played with two friends, Nicky and Philip. 21 00:01:52,200 --> 00:01:53,380 This is Philip. 22 00:01:53,380 --> 00:01:57,980 And basically, Philip had some issues, some connectivity issues, some lags. 23 00:01:57,980 --> 00:02:00,780 And I asked him what's going on. 24 00:02:00,780 --> 00:02:04,820 And basically, he said he installed a new VPN, that one. 25 00:02:04,820 --> 00:02:07,120 And ExpressVPN, maybe you heard about it. 26 00:02:07,240 --> 00:02:12,220 And then we entered this chat about why should one use like VPNs, right? 27 00:02:12,220 --> 00:02:13,940 Security, privacy, stuff like that. 28 00:02:13,940 --> 00:02:16,360 And so, I didn't believe him much about that. 29 00:02:16,920 --> 00:02:19,440 Sure, this is worth your while. 30 00:02:19,480 --> 00:02:23,840 And basically, he dared me to prove him wrong, right? 31 00:02:23,840 --> 00:02:26,280 To prove that something is not good there. 32 00:02:26,280 --> 00:02:35,580 And so, basically, there I started, started looking at ExpressVPN drivers, and different files. 33 00:02:35,580 --> 00: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, 34 00:02:51,780 --> 00:02:52,780 for the server. 35 00:02:53,140 --> 00: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. 36 00:03:06,560 --> 00:03:11,520 And then the initialization happens with the Andes register MiniPort driver. 37 00:03:11,520 --> 00: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. 38 00:03:22,100 --> 00: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? 39 00:03:31,840 --> 00:03:34,020 And so, I dig into it. 40 00:03:34,020 --> 00:03:36,520 And basically, the flow is pretty trivial. 41 00:03:36,520 --> 00:03:42,020 First, we have the validation for the adapter that is ready to communicate. 42 00:03:42,020 --> 00:03:48,000 Then we have retrieval of the first driver, sorry, of the first buffer. 43 00:03:48,000 --> 00:03:56,620 And then basically, we will transmit this buffer in a loop for all the linked list of the buffers. 44 00:03:57,540 --> 00:04:01,160 And this is the top adapter transmit function. 45 00:04:01,240 --> 00:04:08,940 Basically, what it does is getting a net buffer structure and allocates its data length plus 24 additional bytes. 46 00:04:09,580 --> 00: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. 47 00:04:23,120 --> 00:04:24,740 I'll try another mic. 48 00:04:24,740 --> 00:04:25,400 Okay. 49 00:04:25,400 --> 00:04:26,240 Is it better? 50 00:04:26,240 --> 00:04:27,340 Oops. 51 00:04:27,340 --> 00:04:28,620 Yeah, boom, boom, wow. 52 00:04:29,740 --> 00:04:31,180 Yeah, let's do it. 53 00:04:31,200 --> 00:04:34,020 And so, this is the prefix of the function. 54 00:04:34,020 --> 00:04:36,040 And before the end, it's allocate memory, right? 55 00:04:36,040 --> 00:04:37,160 Before this one. 56 00:04:37,220 --> 00:04:38,400 And this is how it looks. 57 00:04:38,400 --> 00:04:42,260 We can see the RS6 plus 18 extra and then another. 58 00:04:42,500 --> 00:04:43,700 It's worse. 59 00:04:43,880 --> 00:04:44,540 It's worse. 60 00:04:44,540 --> 00:04:45,140 Yeah. 61 00:04:49,020 --> 00:04:49,820 Cool. 62 00:04:50,500 --> 00:04:51,420 Let's do it. 63 00:04:51,960 --> 00:04:53,260 Defcon style, right? 64 00:04:53,260 --> 00:04:53,840 Okay. 65 00:04:53,840 --> 00:04:57,880 So, I hope they don't cancel each other. 66 00:04:58,280 --> 00:04:58,800 Yeah. 67 00:04:58,820 --> 00:04:59,960 Waves stuff. 68 00:04:59,960 --> 00:05:00,360 Okay. 69 00:05:00,360 --> 00:05:03,420 So, let me hold it like that. 70 00:05:03,420 --> 00:05:05,640 And so, this is the prefix. 71 00:05:05,640 --> 00: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. 72 00:05:12,660 --> 00:05:17,000 And so, obviously, if we'll give a big enough value, we'll have integer overflow. 73 00:05:17,000 --> 00:05:19,280 And so, this is bad. 74 00:05:19,280 --> 00:05:21,040 But it's not really bad. 75 00:05:21,040 --> 00:05:22,980 Let's talk about what we can do with that. 76 00:05:22,980 --> 00:05:25,160 And so, here we allocated the memory. 77 00:05:25,160 --> 00:05:30,420 Then we have the ndisget data buffer, which is the pointer for the buffer that's been copied. 78 00:05:30,420 --> 00:05:36,620 And then we actually do the memory move, which is the copy of the data on the newly allocated memory, right? 79 00:05:36,620 --> 00:05:41,880 And so, the idea is that we will allocate 17 bytes and then write it with a lot of data. 80 00:05:41,880 --> 00:05:43,880 And this is while kernel overflow. 81 00:05:44,180 --> 00:05:50,360 Now, generally speaking, there are some explanations why kernel copy overflows. 82 00:05:50,440 --> 00:05:51,640 But they are hard. 83 00:05:51,640 --> 00:05:52,320 Why they are hard? 84 00:05:52,320 --> 00:05:58,060 Because there are tons of mitigations in the kernel to prevent this. 85 00:05:58,060 --> 00:06:12,940 And, like, modern HVCI, stuff like that, even page fall handler, device guard, stuff like that will make it very hard. 86 00:06:12,940 --> 00:06:19,780 Now, the issue is that this will be hard even for simple overwrite. 87 00:06:19,780 --> 00:06:25,860 For while kernel overflow, which basically will overwrite a lot of memory, it's even harder. 88 00:06:25,860 --> 00:06:32,860 And so, in this case, I just left it on the side and went a few days without thinking about it. 89 00:06:32,860 --> 00:06:36,680 And then I started looking at ProtonVPN source code. 90 00:06:36,780 --> 00:06:39,900 Not source code, but on the driver again. 91 00:06:39,900 --> 00:06:41,180 And find the same bug, right? 92 00:06:41,180 --> 00:06:43,800 And so, I've already seen that. 93 00:06:43,880 --> 00: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? 94 00:06:52,360 --> 00:06:54,600 And obviously, also a disaster, right? 95 00:06:54,600 --> 00:06:57,920 Because if we can't search for it, we can't find a lot of leads. 96 00:06:57,920 --> 00:07:05,900 And so, in this case, I just decided to create Yarrow rules to search for the problematic allocation of memory. 97 00:07:06,620 --> 00:07:10,040 And this is the part we want to search for. 98 00:07:10,040 --> 00:07:11,380 This is the assembly of it. 99 00:07:11,380 --> 00:07:18,320 And we can see that it's using the tag, the pull tag here, noted in yellow. 100 00:07:18,320 --> 00:07:25,020 And I just created a Yarrow rule to search for that, for 64 bits and 32. 101 00:07:26,640 --> 00:07:32,740 And then I searched for it in Yarrow, and found 50 matches. 102 00:07:32,920 --> 00:07:38,120 Now, the cool stuff is that there are a lot of drivers with the same issue. 103 00:07:38,120 --> 00: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. 104 00:07:48,840 --> 00:07:54,620 And so, the next question was, ChatGPT, what is the most popular VPN? 105 00:07:54,620 --> 00:07:57,780 And obviously, OpenVPN is the answer. 106 00:07:58,040 --> 00:08:00,380 And so, OpenVPN is really huge, right? 107 00:08:00,380 --> 00:08:09,060 It's used by tons of different VPNs, by ExpressVPN, NordVPN, CyberGhost, ProtonVPN, whatnot. 108 00:08:09,240 --> 00:08:16,140 And beside all that, it's a big, big repo in GitHub with a lot of sub-repos inside of it. 109 00:08:16,140 --> 00: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. 110 00:08:29,740 --> 00: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. 111 00:08:40,540 --> 00:08:42,560 And obviously, I started looking at tap Windows 6. 112 00:08:42,780 --> 00:08:48,560 And basically, after some search, I found this nice method, which does exactly that. 113 00:08:48,560 --> 00: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. 114 00:08:59,260 --> 00:09:01,000 And so, this is the bug, right? 115 00:09:01,000 --> 00:09:04,540 This is the source of the of the bug that we found in OpenVPN. 116 00:09:04,880 --> 00:09:10,640 And now, after we found the reason to look at OpenVPN, let's take a deep dive inside of VPN. 117 00:09:10,680 --> 00:09:13,100 We'll find some cool stuff there, I promise. 118 00:09:13,180 --> 00: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. 119 00:09:23,540 --> 00:09:30,420 Then we have the OpenVPN GUI, which is basically the GUI part that allows us to use OpenVPN on Windows. 120 00:09:30,640 --> 00:09:33,540 And we have the tap Windows 6 that we've already seen. 121 00:09:33,560 --> 00:09:40,120 And for current session, this is the repos that are relevant and interesting for us. 122 00:09:40,120 --> 00:09:44,760 They have a lot more solutions and a lot more stuff to provide. 123 00:09:44,760 --> 00:09:48,960 So, if you'd like to check them out, look at their GitHub page. 124 00:09:49,760 --> 00:09:52,700 Now, the client server is pretty straightforward. 125 00:09:52,700 --> 00:09:55,580 We have the client that will be connected to the server. 126 00:09:55,680 --> 00:10:05,320 Obviously, SSL, MTLS, even if needed, and the classical handshake and stuff will flow on both ways. 127 00:10:05,880 --> 00: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. 128 00:10:21,160 --> 00: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. 129 00:10:31,240 --> 00: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. 130 00:10:42,700 --> 00:10:45,760 And the structure of it, it's pretty straightforward. 131 00:10:45,760 --> 00:10:48,140 It can be over TCP or UDP. 132 00:10:48,240 --> 00:10:50,760 And first, we'll have the packet length, 16 bits. 133 00:10:50,760 --> 00:10:56,760 Then, we have the key ID, the opcode, which is the thing we want to do. 134 00:10:56,800 --> 00:11:00,120 And then, we have the payload, which is pretty straightforward. 135 00:11:00,120 --> 00:11:04,980 This is an image of a handshake for OpenVPN protocol. 136 00:11:06,360 --> 00: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. 137 00:11:17,980 --> 00:11:23,220 You basically can open a random router and find an OpenVPN binary there, right? 138 00:11:23,220 --> 00:11:29,540 And so, it works on Windows, Linux, macOS, iOS, Android, whatnot. 139 00:11:29,880 --> 00:11:32,160 And so, the question is how they achieve that. 140 00:11:32,160 --> 00:11:33,860 It's pretty standard. 141 00:11:33,860 --> 00: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. 142 00:11:50,000 --> 00: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. 143 00:12:01,100 --> 00:12:04,600 And so, this is like the macro logic of OpenVPN. 144 00:12:04,600 --> 00:12:13,480 Now, let's take a look inside other cool, open VPN, one of which is the OpenVPN plugins. 145 00:12:13,500 --> 00: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. 146 00:12:27,340 --> 00:12:30,300 All that can be implemented with plugins, right? 147 00:12:30,300 --> 00: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. 148 00:12:40,580 --> 00:12:43,960 In this example, they are setting credentials. 149 00:12:43,960 --> 00:12:50,340 And then we have the FuncV1, which will basically do the logic that it needs to be done. 150 00:12:50,340 --> 00:12:52,960 And here, it will validate for credentials. 151 00:12:53,180 --> 00:12:57,580 So, down the line of plugins in OpenVPN, they are cool. 152 00:12:57,580 --> 00:13:03,780 They allow a lot of stuff, a lot of validation, auditioning, stuff like that. 153 00:13:04,820 --> 00:13:11,920 Now, let's talk about the actual architecture of the OpenVPN service on Windows system. 154 00:13:11,920 --> 00: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. 155 00:13:21,600 --> 00:13:27,680 And a process will connect to it and send information to this name pipe. 156 00:13:27,680 --> 00:13:35,820 How this will look on the OpenVPN server side, creating name pipe instance, and then create intent to handle it. 157 00:13:35,820 --> 00:13:45,100 And we will validate stuff and basically create the relevant security descriptor for it. 158 00:13:45,260 --> 00:13:47,240 Then, we will wait for connection. 159 00:13:47,240 --> 00: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. 160 00:13:58,800 --> 00:14:07,060 They will send a string that explains where they want to run the new OpenVPN process. 161 00:14:07,060 --> 00:14:10,240 The actual daemon will do the VPN-ing. 162 00:14:10,240 --> 00:14:16,500 OpenVPN server will just managing those and a lot of other instances of OpenVPN can be created. 163 00:14:16,500 --> 00:14:23,280 And so, the startup data is the directory, configuration, and the log file that should be executed. 164 00:14:23,620 --> 00:14:30,700 And so, this is an example for initializing execution of OpenVPN programmatically. 165 00:14:30,840 --> 00: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. 166 00:14:43,900 --> 00:14:50,300 And then, it will validate that this client is the OpenVPN group of users. 167 00:14:50,300 --> 00: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. 168 00:15:00,460 --> 00:15:00,720 Right? 169 00:15:00,720 --> 00:15:08,520 And so, then it will run this OpenVPN as the user that he has impersonated. 170 00:15:08,520 --> 00:15:11,240 And so, this is how it looks on Windows. 171 00:15:11,240 --> 00:15:20,340 We have the OpenVPN server that through OpenVPN service got startup data and initialized and executed OpenVPN process. 172 00:15:20,680 --> 00:15:22,960 And then, we have another name pipe. 173 00:15:22,960 --> 00:15:28,460 For instance, here is service 1234 through which OpenVPN will communicate with OpenVPN serve. 174 00:15:28,460 --> 00:15:34,660 And so, the travel question is why do we need this another name pipe or why so many name pipes? 175 00:15:34,660 --> 00: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. 176 00:15:47,240 --> 00:15:49,400 For that, and this is a weak user. 177 00:15:49,400 --> 00:15:55,840 For that, it will send specific messages to the OpenVPN service and the service will do it on its behalf. 178 00:15:55,900 --> 00:15:56,220 Right? 179 00:15:56,220 --> 00:15:59,780 And so, this is how it actually looks like. 180 00:15:59,780 --> 00: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. 181 00:16:08,540 --> 00:16:11,660 Now, there are some logic that can be achieved with that. 182 00:16:11,660 --> 00: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. 183 00:16:22,240 --> 00:16:24,020 So, how it will look like? 184 00:16:24,020 --> 00:16:28,360 The OpenVPN will send a route message, for instance, for open service. 185 00:16:28,360 --> 00: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. 186 00:16:38,680 --> 00: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. 187 00:16:56,160 --> 00:17:03,920 And now, in the, let's call it like the network level, this is the full architecture of the communication. 188 00:17:03,920 --> 00:17:11,120 We have the server with the plugin inside the OpenVPN daemon and then, information will pass through the plugin. 189 00:17:11,120 --> 00:17:14,580 The plugin can audit it, can log at it and stuff like that. 190 00:17:14,580 --> 00:17:20,740 And now, we can talk about first cool discovery that found here. 191 00:17:20,740 --> 00: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. 192 00:17:39,540 --> 00:17:45,260 And for instance, we have the sweet potato, which waits for WAPT queries on the network. 193 00:17:45,260 --> 00:17:52,280 It will answer the address for WAPT server, which will point to the attacker. 194 00:17:52,280 --> 00:18:00,020 Then, the legitimate client will actually ask for WAPT that file, which is the file that defines proxy on Windows. 195 00:18:00,020 --> 00:18:09,180 And then, the malicious attacker will answer bad WAPT file that points again to its controlled proxy. 196 00:18:09,180 --> 00: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. 197 00:18:26,100 --> 00:18:30,780 And so, this is pretty much what will happen here. 198 00:18:30,980 --> 00:18:35,880 I'll show you a vulnerability and then how we can exploit to get local privilege escalation. 199 00:18:35,880 --> 00:18:45,600 So, this is the logic in the service of OpenVPN that handles messages that received from the OpenVPN demo. 200 00:18:45,800 --> 00:18:47,280 The logic is pretty simple. 201 00:18:47,280 --> 00:18:53,000 First, we'll have the amount of bytes we want to read, the PICNAME bypassing. 202 00:18:53,000 --> 00:18:54,320 Then, we'll handle a message. 203 00:18:54,320 --> 00: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? 204 00:19:07,400 --> 00:19:13,420 And so, here we can see on the left upper part the amount of bytes we want to read. 205 00:19:13,420 --> 00: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. 206 00:19:20,980 --> 00:19:27,160 And then, we have the read bypassing that will read the same amount of bytes onto the message struct. 207 00:19:27,160 --> 00:19:33,820 And so, this is a stack overflow because if we can write more data than this message, we will overflow it. 208 00:19:34,060 --> 00: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. 209 00:19:46,700 --> 00: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? 210 00:19:57,520 --> 00:19:58,940 Which is good and hard. 211 00:19:58,940 --> 00:20:01,940 So, let's think about what we can do with the canary. 212 00:20:02,620 --> 00:20:06,620 This is the message, the handle, this is the function that handles the messages. 213 00:20:08,120 --> 00:20:09,760 And this is its prefix. 214 00:20:09,760 --> 00:20:12,640 And here, we can see the security cookie usage. 215 00:20:13,360 --> 00:20:18,300 Now, basically, a security cookie defined here to be of value. 216 00:20:18,580 --> 00: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. 217 00:20:27,580 --> 00:20:30,680 Now, the actually interesting question is where it's being set. 218 00:20:30,680 --> 00:20:33,120 And so, we have this security cookie function. 219 00:20:33,200 --> 00:20:36,000 And this is the logic that happens there. 220 00:20:36,000 --> 00:20:41,820 And basically, first run, we'll check if the security cookie value is constantly defined for first run. 221 00:20:41,820 --> 00: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. 222 00:20:51,060 --> 00:20:55,820 And the down the line here is that it will be very, very hard to guess this value. 223 00:20:55,960 --> 00: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. 224 00:21:03,660 --> 00:21:04,860 But we don't have it. 225 00:21:04,860 --> 00:21:07,560 And so, the underline here is that it will crash. 226 00:21:07,560 --> 00:21:11,460 If we'll overflow, we'll basically crash the process. 227 00:21:12,200 --> 00:21:17,240 Now, let's talk a little bit about some issues that are associated with name pipes. 228 00:21:17,240 --> 00: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. 229 00:21:32,940 --> 00: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. 230 00:21:41,440 --> 00:21:51,620 And so, the attacker that created the name pipe can do, for instance, malicious impersonation of the client. 231 00:21:51,960 --> 00:21:59,440 Now, let's sum it up in the all of this together into a vulnerability and a local privilege escalation vulnerability. 232 00:21:59,800 --> 00:22:03,540 And basically, what we'll do, we'll create a malicious DLL. 233 00:22:03,540 --> 00:22:08,520 And then, we will load this malicious DLL in open VPN daemon. 234 00:22:08,520 --> 00:22:13,180 And through the inner name pipe, we will crush the open VPN service. 235 00:22:13,180 --> 00: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. 236 00:22:23,100 --> 00: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? 237 00:22:32,660 --> 00:22:41,120 And so, the DLL main basically will extract the command line argument and deduplicate the handle that was passed there. 238 00:22:41,300 --> 00: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. 239 00:22:52,400 --> 00:22:59,300 And after that, it will create the open VPN service name pipe and wait for connection. 240 00:22:59,300 --> 00:23:03,680 If a connection occurred, it will basically impersonate. 241 00:23:04,320 --> 00:23:07,280 First, it will get the startup data because this is the protocol. 242 00:23:07,280 --> 00:23:09,440 Then, it will impersonate the connected client. 243 00:23:09,440 --> 00:23:19,720 If the connected client is strong enough, it will execute on its behalf, for instance, malicious application called driver communicator. 244 00:23:19,720 --> 00:23:23,200 And so, this is the demo. 245 00:23:24,320 --> 00:23:29,460 On the right, we have weak user that executes the logic. 246 00:23:29,640 --> 00:23:33,060 And on the right, we have the client that connects. 247 00:23:33,060 --> 00: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. 248 00:23:47,320 --> 00: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. 249 00:23:59,120 --> 00:24:07,400 Then, here, we can see that we have a very strong level process, for instance, system level in this case. 250 00:24:07,400 --> 00:24:10,600 And, yeah, take me a while to get there. 251 00:24:10,740 --> 00:24:13,200 But, yeah, cool. 252 00:24:13,440 --> 00:24:17,820 Now, this was cool because we got local privilege escalation. 253 00:24:17,820 --> 00:24:20,020 But the question is, can we do it remotely, right? 254 00:24:20,020 --> 00:24:26,380 And so, the question is, how do we use name pipes remotely? 255 00:24:26,380 --> 00:24:27,980 And the answer is pretty simple. 256 00:24:27,980 --> 00:24:32,120 Windows have different mechanisms for sharing resources. 257 00:24:32,120 --> 00:24:35,780 In this case, name pipes are IPCs, resources. 258 00:24:36,060 --> 00:24:40,580 And basically, the idea is that there are some protocols for that, SMB and SMB2. 259 00:24:40,580 --> 00: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. 260 00:24:52,300 --> 00:24:55,620 Now, we can do that, for instance, with net use. 261 00:24:55,840 --> 00: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. 262 00:25:04,460 --> 00:25:08,100 And so, how would an attempt like that would look like? 263 00:25:08,100 --> 00:25:13,000 First, we'll see the tree connect request for the IPC on specific endpoints. 264 00:25:13,060 --> 00:25:19,500 And then we also can see the request was declined because it's not that simple. 265 00:25:19,720 --> 00: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. 266 00:25:30,240 --> 00:25:34,080 For instance, we have the network access, name pipes that can be accessed anonymously. 267 00:25:34,080 --> 00:25:39,600 By default, there are none such as that that could be accessed anonymously. 268 00:25:39,680 --> 00:25:49,560 And another thing that we have is that we restrict anonymous access to name pipe, and this is enabled by default. 269 00:25:49,560 --> 00: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. 270 00:25:58,040 --> 00:26:00,900 But don't worry, we can get those. 271 00:26:01,320 --> 00:26:06,180 And basically, we should do that with reconnaissance. 272 00:26:06,180 --> 00:26:12,260 We can wait on the network and sniff for different hashes and then break them and get the credentials. 273 00:26:12,860 --> 00: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. 274 00:26:29,420 --> 00:26:36,300 Basically, NTLM is a NetLAN manager, a set of protocols that allow us to connect securely. 275 00:26:36,360 --> 00:26:38,940 And this is how it will look like. 276 00:26:38,940 --> 00:26:45,320 First, we'll have the NTLM SSB negotiated request with the challenge. 277 00:26:45,320 --> 00:26:48,360 Then the server will send the challenge. 278 00:26:48,360 --> 00:26:53,220 Then the client will send back the NTL-proof STR. 279 00:26:53,240 --> 00:26:57,400 And in the end, we'll have the full hash in the packet. 280 00:26:58,380 --> 00:27:02,320 And we can capture that with tons of different tools. 281 00:27:02,320 --> 00:27:06,280 And I used here the responder in Kali. 282 00:27:06,280 --> 00: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. 283 00:27:16,080 --> 00:27:19,700 And the other question would be, how can we crack that, right? 284 00:27:19,700 --> 00:27:23,840 And basically, there are tons of open sources there. 285 00:27:24,080 --> 00:27:31,040 And the most two promised things that I found was Hashcat and JohnDeRipper because they're widely used and very good. 286 00:27:31,040 --> 00:27:34,920 And I proceed with Hashcat because it's very good with GPUs. 287 00:27:34,920 --> 00:27:46,060 And first, I started with my own laptop, my gaming laptop that have RTX 3070 with almost 6,000 CUDA cores. 288 00:27:46,060 --> 00: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. 289 00:28:02,980 --> 00:28:06,760 And for starters, pretty good if you have a very short password, right? 290 00:28:06,760 --> 00:28:09,360 If you have one short password, it will do it momentarily. 291 00:28:09,460 --> 00: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. 292 00:28:15,700 --> 00:28:19,000 Those are indeed rookie numbers. 293 00:28:19,240 --> 00:28:25,480 And so, other thing I thought about was maybe we can build cool hardware to crack it. 294 00:28:25,480 --> 00: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. 295 00:28:37,060 --> 00:28:42,000 And so, from here, I decided to find another solution. 296 00:28:42,000 --> 00:28:46,800 Basically, I thought about how can I use cloud platforms for that. 297 00:28:46,800 --> 00: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. 298 00:28:58,720 --> 00:29:01,480 And it's very, very easy to use. 299 00:29:01,480 --> 00:29:04,780 You've got a Docker images that can run on those machines. 300 00:29:04,900 --> 00:29:06,740 And it's pretty cheap, right? 301 00:29:06,740 --> 00:29:17,140 For instance, here we can rent a machine with 18 RTX 4090 for $8.5 an hour, which is pretty cheap. 302 00:29:17,240 --> 00: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? 303 00:29:30,200 --> 00: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. 304 00:29:42,900 --> 00:29:46,980 And so, the question is, like, will the improvement be 50 times more? 305 00:29:46,980 --> 00:29:50,420 And obviously not, because we have tons of different bottlenecks. 306 00:29:51,180 --> 00: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. 307 00:30:01,120 --> 00:30:07,000 And it took me less than three minutes to track a nine char password, which is pretty fast. 308 00:30:07,140 --> 00:30:09,320 And yeah, it's hell yeah, for sure. 309 00:30:10,200 --> 00:30:15,420 And then now we have basically all the things that we need to create actual RCA, right? 310 00:30:15,420 --> 00:30:16,520 Because we can. 311 00:30:19,260 --> 00:30:27,740 Firstly, we used OSINT leads to find a basic issue, and then we keep digging into OpenVPN and find another issue. 312 00:30:27,860 --> 00:30:34,420 And then we understood that we need SMB enumeration and hash tracking to get credentials. 313 00:30:34,420 --> 00:30:37,420 And in the end, we cracked those hashes with cloud tracking. 314 00:30:37,420 --> 00:30:42,000 All of this together allow us to actually get an RCA vector. 315 00:30:42,000 --> 00:30:49,260 And the idea is that first we'll work on the network, wait for hashes, then recap them and track them. 316 00:30:49,260 --> 00:30:58,360 And then we'll use them with Netuse to actually be able to access other PC IPCs. 317 00:30:58,380 --> 00: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. 318 00:31:10,000 --> 00:31:19,880 After that, we will pass to it a malicious configuration and log on attacker controlled share, as shown here. 319 00:31:20,000 --> 00: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. 320 00:31:31,060 --> 00: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. 321 00:31:40,100 --> 00:31:47,020 And after this configuration on the attacker controlled share, we got it working. 322 00:31:47,020 --> 00:31:49,980 First, we have the request for tree for share. 323 00:31:49,980 --> 00:31:53,000 Then we have the request for the configuration. 324 00:31:53,020 --> 00:31:57,100 And in the end, we have the request for the malicious plugin that executes the logic. 325 00:31:57,360 --> 00: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. 326 00:32:19,440 --> 00:32:26,600 And this is pretty cool because this allows me to actually remote execute on the remote endpoint. 327 00:32:26,600 --> 00:32:31,660 In this specific example, it just dumped a lot of files on the desktop, which was pretty cool again. 328 00:32:31,860 --> 00:32:40,920 Now the question is, can we mount those two logics together? 329 00:32:40,920 --> 00:32:45,080 Can we execute the remote code execution and then the local provisioning solution? 330 00:32:45,080 --> 00:32:46,000 And the answer is yes. 331 00:32:46,000 --> 00:32:51,740 We just need to mount the LP logic onto the malicious plugin that we execute remotely. 332 00:32:51,740 --> 00: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. 333 00:33:02,720 --> 00:33:07,760 And after executing this, we have an RCNLP vector. 334 00:33:07,760 --> 00:33:10,280 And the question is, what can we do from here? 335 00:33:10,680 --> 00:33:19,700 And some travel attempts, some stuff that APDs love to do is bring your vulnerable driver. 336 00:33:19,800 --> 00:33:25,160 And then again, it will be pretty easy in this stage because we have already APD. 337 00:33:25,160 --> 00:33:31,140 We can actually use the SC manager and create service with our malicious driver. 338 00:33:31,140 --> 00:33:40,880 For instance, we could use this one, which has read-write primitives into kernel memory, which make us very, very strong. 339 00:33:41,000 --> 00:33:47,180 And another technique we could use is living off the land, which is again used widely by APDs. 340 00:33:47,180 --> 00:33:51,560 Maybe find some install MSI and mangle with it. 341 00:33:51,920 --> 00: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. 342 00:34:05,400 --> 00:34:08,680 This is actually what has been executed in this research. 343 00:34:08,680 --> 00:34:09,980 And I took it as well. 344 00:34:09,980 --> 00: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. 345 00:34:21,520 --> 00:34:25,440 And the other question will be, now what? 346 00:34:25,440 --> 00:34:34,000 Okay, so we have remote code execution, and we have LPA, then we have even read-write kernel primitives. 347 00:34:34,000 --> 00: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. 348 00:34:48,680 --> 00:34:53,840 And what we would like to do, and generally, APD would like to kill those and bypass them. 349 00:34:53,840 --> 00: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. 350 00:35:08,080 --> 00: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. 351 00:35:18,620 --> 00: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. 352 00:35:27,080 --> 00:35:34,000 And the regular processes, even if they system, can't actually affect the PPLs, right? 353 00:35:34,000 --> 00:35:40,140 And so, what we'd like to do is abuse those redrive primitives to maybe un-PPL a process. 354 00:35:40,140 --> 00:35:41,320 How would we do that? 355 00:35:41,320 --> 00:35:43,240 Let's use WinDBG. 356 00:35:43,760 --> 00:35:51,820 Basically, there is this struct called PSProtection, which indicates the PPL protection level of a system, of a process. 357 00:35:51,820 --> 00: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. 358 00:36:11,580 --> 00: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. 359 00:36:18,940 --> 00:36:24,500 So, if we have WinDBG, we could do it with actually overwriting the memory, right? 360 00:36:24,500 --> 00: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. 361 00:36:41,460 --> 00:36:44,320 And now, this will be our full chain. 362 00:36:44,320 --> 00: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. 363 00:37:02,860 --> 00: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? 364 00:37:13,180 --> 00:37:15,080 And so, this is the demo for that. 365 00:37:15,440 --> 00: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, 366 00:37:42,140 --> 00: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, 367 00:38:01,580 --> 00:38:03,980 and this gives us a full chain. 368 00:38:04,300 --> 00:38:09,860 And the question is, as I said, why an attacker would love to do this? 369 00:38:09,860 --> 00:38:13,160 Well, basically, they have tons of stuff they would like to bypass. 370 00:38:13,160 --> 00: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. 371 00:38:27,080 --> 00: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. 372 00:38:42,140 --> 00:38:45,500 And here we have the summary of the session. 373 00:38:45,500 --> 00:38:52,100 Basically, the takeaways here is that first, one bug can be a pretty big deal. 374 00:38:52,440 --> 00: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. 375 00:39:00,200 --> 00: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. 376 00:39:14,440 --> 00:39:24,340 And yeah, it's basically easier, probably more cheaper and available for everybody. 377 00:39:24,780 --> 00: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. 378 00:39:35,680 --> 00:39:38,660 And this is a real romance between the two. 379 00:39:39,660 --> 00:39:41,380 And this is it. 380 00:39:41,420 --> 00:39:43,500 Thank you for joining me today. 381 00:39:43,580 --> 00:39:45,820 And I think we are finished. 382 00:39:45,820 --> 00:39:46,780 Any questions?