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. Apologies for the holdup. We'll move on with the next session. Up next, we have Vladimir, who is a Senior Security Researcher at Microsoft. He's done some amazing research with the Quotesis framework. He's also identified some bugs in the Windows driver of the SonicWall tool. His topic for today is, from there to discovery, how OSINT and modern recon techniques uncovered a global VPN infrastructure. This presentation has a complete attack chain that showcases some advanced recognition techniques and some live demos. 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. So, please bring it up for Vladimir. Thank you for joining me today. Today, I'm going to talk about research I did last year. From there to discovery, how OSINT and modern recon techniques uncovered a global VPN infrastructure. Critical... A little louder. Okay, yeah, I'll try that. So, let's begin. It all began one night while I played Deep Rock Galactic with my friends. And basically, it's a game where dwarves roam the cosmos, mining for minerals and killing bugs. And I played with two friends, Nicky and Philip. This is Philip. And basically, Philip had some issues, some connectivity issues, some lags. And I asked him what's going on. And basically, he said he installed a new VPN, that one. And ExpressVPN, maybe you heard about it. And then we entered this chat about why should one use like VPNs, right? Security, privacy, stuff like that. And so, I didn't believe him much about that. Sure, this is worth your while. And basically, he dared me to prove him wrong, right? To prove that something is not good there. And so, basically, there I started, started looking at ExpressVPN drivers, and different files. 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, for the server. 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. And then the initialization happens with the Andes register MiniPort driver. 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. 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? And so, I dig into it. And basically, the flow is pretty trivial. First, we have the validation for the adapter that is ready to communicate. Then we have retrieval of the first driver, sorry, of the first buffer. And then basically, we will transmit this buffer in a loop for all the linked list of the buffers. And this is the top adapter transmit function. Basically, what it does is getting a net buffer structure and allocates its data length plus 24 additional bytes. 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. I'll try another mic. Okay. Is it better? Oops. Yeah, boom, boom, wow. Yeah, let's do it. And so, this is the prefix of the function. And before the end, it's allocate memory, right? Before this one. And this is how it looks. We can see the RS6 plus 18 extra and then another. It's worse. It's worse. Yeah. Cool. Let's do it. Defcon style, right? Okay. So, I hope they don't cancel each other. Yeah. Waves stuff. Okay. So, let me hold it like that. And so, this is the prefix. The idea is that we allocate a buffer and then we add 18 bytes for offset and then we add 18 bytes for size. And so, obviously, if we'll give a big enough value, we'll have integer overflow. And so, this is bad. But it's not really bad. Let's talk about what we can do with that. And so, here we allocated the memory. Then we have the ndisget data buffer, which is the pointer for the buffer that's been copied. And then we actually do the memory move, which is the copy of the data on the newly allocated memory, right? And so, the idea is that we will allocate 17 bytes and then write it with a lot of data. And this is while kernel overflow. Now, generally speaking, there are some explanations why kernel copy overflows. But they are hard. Why they are hard? Because there are tons of mitigations in the kernel to prevent this. And, like, modern HVCI, stuff like that, even page fall handler, device guard, stuff like that will make it very hard. Now, the issue is that this will be hard even for simple overwrite. For while kernel overflow, which basically will overwrite a lot of memory, it's even harder. And so, in this case, I just left it on the side and went a few days without thinking about it. And then I started looking at ProtonVPN source code. Not source code, but on the driver again. And find the same bug, right? And so, I've already seen that. 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? And obviously, also a disaster, right? Because if we can't search for it, we can't find a lot of leads. And so, in this case, I just decided to create Yarrow rules to search for the problematic allocation of memory. And this is the part we want to search for. This is the assembly of it. And we can see that it's using the tag, the pull tag here, noted in yellow. And I just created a Yarrow rule to search for that, for 64 bits and 32. And then I searched for it in Yarrow, and found 50 matches. Now, the cool stuff is that there are a lot of drivers with the same issue. 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. And so, the next question was, ChatGPT, what is the most popular VPN? And obviously, OpenVPN is the answer. And so, OpenVPN is really huge, right? It's used by tons of different VPNs, by ExpressVPN, NordVPN, CyberGhost, ProtonVPN, whatnot. And beside all that, it's a big, big repo in GitHub with a lot of sub-repos inside of it. 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. 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. And obviously, I started looking at tap Windows 6. And basically, after some search, I found this nice method, which does exactly that. 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. And so, this is the bug, right? This is the source of the of the bug that we found in OpenVPN. And now, after we found the reason to look at OpenVPN, let's take a deep dive inside of VPN. We'll find some cool stuff there, I promise. 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. Then we have the OpenVPN GUI, which is basically the GUI part that allows us to use OpenVPN on Windows. And we have the tap Windows 6 that we've already seen. And for current session, this is the repos that are relevant and interesting for us. They have a lot more solutions and a lot more stuff to provide. So, if you'd like to check them out, look at their GitHub page. Now, the client server is pretty straightforward. We have the client that will be connected to the server. Obviously, SSL, MTLS, even if needed, and the classical handshake and stuff will flow on both ways. 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. And then, in the user mode, we have the daemon that runs OpenVPN and actually encrypts the messages and does all the VPNing. And so, OpenVPN, in addition to being a big open source, it's actually a standard for protocol of communication between server and client. And the structure of it, it's pretty straightforward. It can be over TCP or UDP. And first, we'll have the packet length, 16 bits. Then, we have the key ID, the opcode, which is the thing we want to do. And then, we have the payload, which is pretty straightforward. This is an image of a handshake for OpenVPN protocol. Now, another very interesting part about OpenVPN is that it's supported on almost every big or small operating system and different tools. You basically can open a random router and find an OpenVPN binary there, right? And so, it works on Windows, Linux, macOS, iOS, Android, whatnot. And so, the question is how they achieve that. It's pretty standard. 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. They'll be using a lot of macros and then with different flows or different even functions and even different includes to do that. And so, this is like the macro logic of OpenVPN. Now, let's take a look inside other cool, open VPN, one of which is the OpenVPN plugins. 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. All that can be implemented with plugins, right? 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. In this example, they are setting credentials. And then we have the FuncV1, which will basically do the logic that it needs to be done. And here, it will validate for credentials. So, down the line of plugins in OpenVPN, they are cool. They allow a lot of stuff, a lot of validation, auditioning, stuff like that. Now, let's talk about the actual architecture of the OpenVPN service on Windows system. And so, we have the OpenVPN server, which is the system-level running service that has an open name pipe called OpenVPN slash service. And a process will connect to it and send information to this name pipe. How this will look on the OpenVPN server side, creating name pipe instance, and then create intent to handle it. And we will validate stuff and basically create the relevant security descriptor for it. Then, we will wait for connection. After connection achieved, the OpenVPN server will wait for get startup data, which is basically the way that other process communicate with OpenVPN server. They will send a string that explains where they want to run the new OpenVPN process. The actual daemon will do the VPN-ing. OpenVPN server will just managing those and a lot of other instances of OpenVPN can be created. And so, the startup data is the directory, configuration, and the log file that should be executed. And so, this is an example for initializing execution of OpenVPN programmatically. And after this startup data will be passed and validated and checked that it's okay, the OpenVPN server will impersonate the client. And then, it will validate that this client is the OpenVPN group of users. And then, we'll proceed to basically create another name pipe, which it will pass to the execution of the OpenVPN process. Right? And so, then it will run this OpenVPN as the user that he has impersonated. And so, this is how it looks on Windows. We have the OpenVPN server that through OpenVPN service got startup data and initialized and executed OpenVPN process. And then, we have another name pipe. For instance, here is service 1234 through which OpenVPN will communicate with OpenVPN serve. And so, the travel question is why do we need this another name pipe or why so many name pipes? 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. For that, and this is a weak user. For that, it will send specific messages to the OpenVPN service and the service will do it on its behalf. Right? And so, this is how it actually looks like. 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. Now, there are some logic that can be achieved with that. The client can send address message or route message or DNS configuration message and then, the server will send back acknowledge message for that. So, how it will look like? The OpenVPN will send a route message, for instance, for open service. 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. 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. And now, in the, let's call it like the network level, this is the full architecture of the communication. We have the server with the plugin inside the OpenVPN daemon and then, information will pass through the plugin. The plugin can audit it, can log at it and stuff like that. And now, we can talk about first cool discovery that found here. 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. And for instance, we have the sweet potato, which waits for WAPT queries on the network. It will answer the address for WAPT server, which will point to the attacker. Then, the legitimate client will actually ask for WAPT that file, which is the file that defines proxy on Windows. And then, the malicious attacker will answer bad WAPT file that points again to its controlled proxy. 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. And so, this is pretty much what will happen here. I'll show you a vulnerability and then how we can exploit to get local privilege escalation. So, this is the logic in the service of OpenVPN that handles messages that received from the OpenVPN demo. The logic is pretty simple. First, we'll have the amount of bytes we want to read, the PICNAME bypassing. Then, we'll handle a message. 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? And so, here we can see on the left upper part the amount of bytes we want to read. Then, we can see that message is a union of structs but basically, it will be just the longest of them on the stack. And then, we have the read bypassing that will read the same amount of bytes onto the message struct. And so, this is a stack overflow because if we can write more data than this message, we will overflow it. 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. 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? Which is good and hard. So, let's think about what we can do with the canary. This is the message, the handle, this is the function that handles the messages. And this is its prefix. And here, we can see the security cookie usage. Now, basically, a security cookie defined here to be of value. 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. Now, the actually interesting question is where it's being set. And so, we have this security cookie function. And this is the logic that happens there. And basically, first run, we'll check if the security cookie value is constantly defined for first run. 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. And the down the line here is that it will be very, very hard to guess this value. And the only way, the only possible way to bypass that would be if we had rig primitive on the memory of this process. But we don't have it. And so, the underline here is that it will crash. If we'll overflow, we'll basically crash the process. Now, let's talk a little bit about some issues that are associated with name pipes. 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. Now, another issue is the superfluous pipe connectivity issue, which basically says that the client don't really know who it's connecting to. And so, the attacker that created the name pipe can do, for instance, malicious impersonation of the client. Now, let's sum it up in the all of this together into a vulnerability and a local privilege escalation vulnerability. And basically, what we'll do, we'll create a malicious DLL. And then, we will load this malicious DLL in open VPN daemon. And through the inner name pipe, we will crush the open VPN service. 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. And then, the next user that will connect, it will connect not to original open VPN service, but to our malicious plugin, right? And so, the DLL main basically will extract the command line argument and deduplicate the handle that was passed there. 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. And after that, it will create the open VPN service name pipe and wait for connection. If a connection occurred, it will basically impersonate. First, it will get the startup data because this is the protocol. Then, it will impersonate the connected client. If the connected client is strong enough, it will execute on its behalf, for instance, malicious application called driver communicator. And so, this is the demo. On the right, we have weak user that executes the logic. And on the right, we have the client that connects. 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. 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. Then, here, we can see that we have a very strong level process, for instance, system level in this case. And, yeah, take me a while to get there. But, yeah, cool. Now, this was cool because we got local privilege escalation. But the question is, can we do it remotely, right? And so, the question is, how do we use name pipes remotely? And the answer is pretty simple. Windows have different mechanisms for sharing resources. In this case, name pipes are IPCs, resources. And basically, the idea is that there are some protocols for that, SMB and SMB2. 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. Now, we can do that, for instance, with net use. 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. And so, how would an attempt like that would look like? First, we'll see the tree connect request for the IPC on specific endpoints. And then we also can see the request was declined because it's not that simple. And the thing is that there are some Windows definitions, some set of rules that allow and disallow connection to name pipes. For instance, we have the network access, name pipes that can be accessed anonymously. By default, there are none such as that that could be accessed anonymously. And another thing that we have is that we restrict anonymous access to name pipe, and this is enabled by default. And so, the thing is that it means that it's very hard for us to do it without, basically, without credentials. But don't worry, we can get those. And basically, we should do that with reconnaissance. We can wait on the network and sniff for different hashes and then break them and get the credentials. 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. Basically, NTLM is a NetLAN manager, a set of protocols that allow us to connect securely. And this is how it will look like. First, we'll have the NTLM SSB negotiated request with the challenge. Then the server will send the challenge. Then the client will send back the NTL-proof STR. And in the end, we'll have the full hash in the packet. And we can capture that with tons of different tools. And I used here the responder in Kali. 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. And the other question would be, how can we crack that, right? And basically, there are tons of open sources there. And the most two promised things that I found was Hashcat and JohnDeRipper because they're widely used and very good. And I proceed with Hashcat because it's very good with GPUs. And first, I started with my own laptop, my gaming laptop that have RTX 3070 with almost 6,000 CUDA cores. 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. And for starters, pretty good if you have a very short password, right? If you have one short password, it will do it momentarily. But if you have a long password, it will take something like a few years and we don't really have time for that. Those are indeed rookie numbers. And so, other thing I thought about was maybe we can build cool hardware to crack it. 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. And so, from here, I decided to find another solution. Basically, I thought about how can I use cloud platforms for that. And basically, there is this cool platform called Vast AI, which basically allows you to rent machines with specific GPUs on time for time. And it's very, very easy to use. You've got a Docker images that can run on those machines. And it's pretty cheap, right? For instance, here we can rent a machine with 18 RTX 4090 for $8.5 an hour, which is pretty cheap. 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? 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. And so, the question is, like, will the improvement be 50 times more? And obviously not, because we have tons of different bottlenecks. 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. And it took me less than three minutes to track a nine char password, which is pretty fast. And yeah, it's hell yeah, for sure. And then now we have basically all the things that we need to create actual RCA, right? Because we can. Firstly, we used OSINT leads to find a basic issue, and then we keep digging into OpenVPN and find another issue. And then we understood that we need SMB enumeration and hash tracking to get credentials. And in the end, we cracked those hashes with cloud tracking. All of this together allow us to actually get an RCA vector. And the idea is that first we'll work on the network, wait for hashes, then recap them and track them. And then we'll use them with Netuse to actually be able to access other PC IPCs. 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. After that, we will pass to it a malicious configuration and log on attacker controlled share, as shown here. 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. 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. And after this configuration on the attacker controlled share, we got it working. First, we have the request for tree for share. Then we have the request for the configuration. And in the end, we have the request for the malicious plugin that executes the logic. 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. And this is pretty cool because this allows me to actually remote execute on the remote endpoint. In this specific example, it just dumped a lot of files on the desktop, which was pretty cool again. Now the question is, can we mount those two logics together? Can we execute the remote code execution and then the local provisioning solution? And the answer is yes. We just need to mount the LP logic onto the malicious plugin that we execute remotely. 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. And after executing this, we have an RCNLP vector. And the question is, what can we do from here? And some travel attempts, some stuff that APDs love to do is bring your vulnerable driver. And then again, it will be pretty easy in this stage because we have already APD. We can actually use the SC manager and create service with our malicious driver. For instance, we could use this one, which has read-write primitives into kernel memory, which make us very, very strong. And another technique we could use is living off the land, which is again used widely by APDs. Maybe find some install MSI and mangle with it. And the classical approach could be even exploiting one day or even new zero day in Windows and Windows machines in the driver kernel. This is actually what has been executed in this research. And I took it as well. 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. And the other question will be, now what? Okay, so we have remote code execution, and we have LPA, then we have even read-write kernel primitives. 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. And what we would like to do, and generally, APD would like to kill those and bypass them. 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. 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. And the rule is that the higher the process, it can mingle with lower processes, but lower processes can actually communicate with those processes. And the regular processes, even if they system, can't actually affect the PPLs, right? And so, what we'd like to do is abuse those redrive primitives to maybe un-PPL a process. How would we do that? Let's use WinDBG. Basically, there is this struct called PSProtection, which indicates the PPL protection level of a system, of a process. 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. 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. So, if we have WinDBG, we could do it with actually overwriting the memory, right? 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. And now, this will be our full chain. 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. 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? And so, this is the demo for that. 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, 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, and this gives us a full chain. And the question is, as I said, why an attacker would love to do this? Well, basically, they have tons of stuff they would like to bypass. 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. 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. And here we have the summary of the session. Basically, the takeaways here is that first, one bug can be a pretty big deal. In this case, the plugin mechanism was implemented not on the best side, but it allowed us to do a lot of damage. 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. And yeah, it's basically easier, probably more cheaper and available for everybody. 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. And this is a real romance between the two. And this is it. Thank you for joining me today. And I think we are finished. Any questions?