Good morning. You know, one of the great things that I like about DEF CON, well, besides of the great talks and everything, well, I believe it's the first conference that starts at 10 a.m., right? Yeah, it's great. Well, you know what? I'm having some difficulties sleeping last couple of days due to some jet lag problems. Well, basically, my clock has been shifted about 10 hours. Last night, I woke up at about 3 a.m. Well, I thought to myself, it must be a beautiful day. So, basically, what we're going to talk about today, we're not going to talk about my jet lag problems. We're going to talk about managed code rootkits. My name is Erez Metula. I'm a software engineer working at 2B Secure, working as the application security department manager. And what we're going to see today, we're going to see, we're going to see injections into the managed code environment. And, basically, we're going to start with a simple example, a very trivial questions, which goes like this. Well, this is the software engineering 101 class, which talks about Hello World in Java. Well, basically, what does the following code should do? Supposed to print the string Hello World, right? So, let's run this code, and let's see what happens. So, basically, I'm having this class, the Hello World Dutch Java class. So, when I'm going to run this class, well, it gives me this strange behavior. Well, basically, the string that was supposed to be printed, the Hello World, was printed twice. And the reason for that to happen is that because the internal implementation of the managed code was modified. So, the code, basically, what the code is, what the application level code says, it's not necessarily what it's going to do. And this is a little bit of, it's a little bit of a problem when we're doing code reviews. Well, when we are doing code reviews, the malicious code might not be at the application level. But this was just a simple example of language modification. We're going to use this example of language modification and take this further and further, and that will be able to inject rootkits into runtime, into application virtual machine runtimes. And what we're going to talk about today, we're going to start with the managed code environment, execution model. We'll start with an overview about that. We're going to talk about managed code rootkits and how to implement managed code rootkits, what's so special about that. We'll see a couple of demos and a couple of attack scenarios so that we can understand that managed code rootkits can be very dangerous and they have their own advantages due to some very interesting techniques. And I'm going to expose to you a tool that I wrote called .NET. What is a .NET exploit? Well, a .NET exploit is a custom language modification tool. It enables you to change and to customize your own version of the .NET language. Well, it is a general purpose tool. I use it to show the attacks that I have demos for. But basically, you can use it for any purpose you like. You can even take it and it's an open source and customize it to other languages. So a little bit of background. It all started... with the idea of changing the language back in 2008. I played a little bit with the .NET language modification. Well, soon I realized that it might lead to some very interesting attack. I wrote a paper about it called .NET Framework Rootkits Backdoors Inside Your Framework. I presented it in Black Hat Europe and in CancerQuest. But .NET Rootkits was just a case study. And people actually thought that there is a problem with the .NET Framework and that the concept that I was talking about was .NET specific. Well, it wasn't. And it was really, really important to me to show you guys the general purpose case so that I'm also going to talk about Java Rootkits today. So I'm taking another language as an example to show you the general case study. So what is a managed code? Well, managed code is code that runs... and executes under the management of a virtual machine, an application-level virtual machine. For example, the JVM, the Java JVM, or the .NET CLR. Well, think about it as an operating system for applications. So basically, this is another language we are talking about. We're not talking about assembly language, but we are talking about a virtual language. We're talking about a high-level object, object-oriented intermediate language. Basically, it looks like assembly, but it has the characteristics of an object-oriented language. We can create objects, and we have classes, and inheritance, and stuff like that. Well, basically, it looks something like this. This is how Java bytecode looks like after disassembling. So as you might see, it looks kind of like an assembly code, but it's not. If I will execute this code, if I give the CPU this kind of code, it will not understand what I'm talking about. The CPU does not understand virtual languages. But basically, the magic that is being performed is being performed using the virtual machine that translates the high-level intermediate language to the machine-specific assembly code. So that if I'm having an executable, and sorry, guys, about my graphics. I suck in graphics. But what I wanted to show you here is that the same executable can be run under this code. It's a different platform. So we have a Windows machine, and a Linux machine, and a Mac, and a mainframe, and et cetera, et cetera. But for each machine, there is a specific virtual machine. So we have that for Windows, the virtual machine is in blue, and for the Linux box, it's in green. And basically, what happened here is that the executable is executed inside the virtual machine that translates the adjusting time code and gives that to the CPU. So basically, the virtual... The virtual machine acts as the bridge to the CPU. Well, a couple of examples of managed code run times. So we're talking about Java, JVM, .NET Framework, the PHP Z engine, the Flash Action Script, the virtual machine, the AVM, Python, Dalvik. Basically, there are lots of languages which are virtual machine-based. And today, we're going to discuss .NET and Java as the case studies, basically because they're very common languages. Many projects are written today using... .NET and Java. And because their model is very similar and very easy to understand. So a little bit of overview of Java execution model. Well, basically, we have three layers. As opposed to, for example... A code which... The quality of the following recording is not up to our usual standards. However, we are releasing this due to the importance of the material presented. It's unmanaged. For example, C of C++ code, in which you have the executable, which contains compiled code, find assembly code, and you have the OS. Basically, now we're talking about three layers, not two. We have the application. We have the runtime. In our example, this is the JVM, and we have the OS. So when the application source code is compiled and we have a bytecode, the class, it is hosted inside the JVM. The JVM loads the class libraries from JAWS based on the name. And when it generates using a just-in-time compiler, a code which is machine-specific, this is what the OS, the CPU, looks and sees and executes. But the .NET model is pretty much the same, so only that now we have assemblies. This is .NET mutation for compiled code. We're talking about DXCs and DLFs. And now that the code is being loaded, the libraries is being loaded from the GAC, the Global Assembly Cache. These were all the low-level code, all the low-level methods are being scoped. Well, think about it as a system call. Basically, this is where the code is located. This is where functions have been implemented. And again, the jitter is generating machine-specific code, and this is what the machine is executing. So what are Managed Code Rootkits, or MCRs? Well, Managed Code Rootkits, this is a user-mode, application-level rootkit hidden inside the Managed Code environment libraries. Well, I know that most of you guys think about, well, user-level mode, this is not like your nail level mode. Nail-level mode is awesome. Well, in nail-level mode, we can do many things. Well, there is a couple of great things that you can do in user-mode. In user-mode, well, although you are sacrificing a little bit of hiding, you can do very sophisticated attacks. And you can do very sophisticated logical attacks so that the target of the MCRs is the virtual machine that provides the services to the upper-level application. So basically, we are hiding information from the application, not in traditional rootkits when we are hiding from the OS or maybe from the CPU or stuff like that. We are hiding it from applications. So the influence that we have is on all of the applications that run on a specific virtual machine. And basically, what we can do, we can do stuff like regular rootkits. So, for example, we can hide files and we can hide processes and registry keys and stuff like that. We can also do some very interesting logical things. A little bit of advantages of MCRs. Well, first thing is that it is an overlooked place. No one looks at virtual machines for malicious code. No antivirus, IPSs, IDSs, stuff like that. They understand intermediate language. They don't know if you're writing your own malicious code. They do not understand it. Well, basically, they also cannot tell whether your application is doing something wrong. From here. From its point of view, the application can do whatever it wants. So basically, it cannot detect those kind of malicious behavior. Well, forensics. Forensics checklist does not cover virtual machines, right? So basically, if forensic guys over here, today you have another place, another place to look for so that it's not just the operating system binaries you look for, also for another places. And basically, another interesting thing is about developers. And developers backdoors. Now we're talking about malicious developers that they know that their code will be audited. And they know that some security guy will open their own code, maybe looking for backdoors. They will not hide it inside application library. They will hide it downstairs in a virtual machine. We're also talking about universal wordkits. Due to the fact that the virtual machine performs the translation for us, we can write code which is not machine-specific, right? The same code, the same malicious code will be translated to the machine-specific instruction set using the virtual machine. This is what I call universal wordkits. And we have large attack surface due to the fact that virtual machines are pre-installed on operating systems. We have Java and .NET are pre-installed in latest versions. We can deploy all of... Sorry, we can control all of the applications from only one place. Think about a scenario of, for example, a hosting web server in which you are controlling all of the application's behavior using only one injection. Well, another interesting thing is that the MCRs are becoming part... Sorry, the managed code becomes part of the operating system. Microsoft is pushing very hard for that. .NET will perform more and more things like, let's take an example, .NET PowerShell cmdlets. And the last thing is that we can perform some very sophisticated attacks as we're going to see today. So when we are talking about language modification and implementation, basically what we see here, we see the three layers. We see here the application level, the runtime level, and the OS level. So basically when an application calls some specific runtime method, basically the runtime method, and this is the implementation of the runtime method, it is being called and executed. In MCR, we're taking away this method, throwing away, and writing our own implementation. So now when the application calls runtime method, well, basically it does something different, right? So when a call comes to this method, well, it goes, generates the code, and the system will be hacked. No one can see it. You cannot detect it from the application level. If we're talking about an example, and in the beginning we saw the demo of Java write line twice towards print line. This is the Java version for printing a string. We can do the same thing in .NET. So basically this is the same code that was able to perform the same thing as the string twice. So I'm just giving it here as a reference. But basically this is the original code. What I did in order to make it able to print a string twice, I just doubled the code, and the modified code looks like this. So basically I took the same thing and doubled the code. I had to rearrange a little bit the addresses, right? Because basically I had to calculate, and this is a very intensive task now. I just had to calculate the three lines of code. When we're talking about injections of very sophisticated attacks, a very large amount of code, you have to do a very large amount of calculations. A little bit about the attack scenarios. Well, messing with the sandbox, messing with the application virtual machine usually requires administrator-level privileges. And basically we're talking about two main scenarios. One scenario, this is the scenario of housekeeping attack vector. Now we're talking about post-exploitation attacks in which the attacker has already managed to gain control of the system using some other kind of vulnerability. Now he has control of the system, and now he's thinking, what should I do next? So he can utilize MCRs to his purpose, right? This is another alternative attack vector so you can use it. But in the second scenario, we're talking about the trusted insider. This is one of the major problems that we're facing today in security in which those are the people that already have access to the system. Now we're talking about IT managers. We're talking about developers, DBAs. Those guys already have access to the administrative-level access. They don't have to steal this access, right? So they can take advantage of it and probably install an MCR. Think about a developer, for example, that is developing a very sensitive financing application, and he knows, for example, that he'll be reviewed, and he wants to enter some kind of code that says, hey, if you see my own bank account, well, give me a little bit of space, right? And those kind of backups are very common when we're talking about malicious developers. The implementation techniques can be divided basically into two parts. We have the non-invasive techniques. Those are the ones that are called by-design techniques. By-design techniques are techniques in which you're not hacking anything. You're just utilizing something which was there by design so that the virtual machine lets you change its meaning using its own controls and own mechanism. For example, AOP, AOP or aspect-oriented programming using dynamic weaving lets you inject code into applications. And configuration modifications, for example, setting an alternative evil class loader or, for example, loading a malicious agent in Java. This is how you do that. And maybe messing with the machine configuring in .NET. You can do that in all those techniques. But this is not something which is invasive if the application inquiries that the virtual machine knows about it. And what we're going to discuss today, we're going to discuss invasive techniques in which we are talking about direct modification of the intermediate language code so that the application would not know that something happened. Basically, the virtual machine lies to the application, right? So, when we're talking about Java techniques, Java rootkits, this is just an example of an invasion technique. There are many ways of performing the same thing. What I did here is I took the print stream class, this class which implements the print line, I extracted it from arty.jar, arty, which is the runtime jar containing all of the code of most of the Java runtime. I extracted it out, disassembled it, using Jasper disassembler, modified the code, recompiled it back, reassembled it back using Jasmin assembler, and deployed it back into the runtime, right? Well, basically, for more information, you can access this site and get a look at it. But the interesting thing is that you can change the .NET language by that and the application will know about it. But doing the same thing in .NET, well, the concept is pretty much similar, but it's a little bit more complicated because in .NET, we have the signature mechanism. And in .NET, we have a signature called strongName in which all of the assemblies have their own signatures, so I cannot just take the DLL, change it, and put it back in its location because the signature does not match, right? So what I thought in the beginning, in the beginning of my research, I was thinking about, well, I would just disable the signature mechanism, right? Or I can just find where the operating system is hiding the private key and maybe re-sign back everything, right? But I found not a better way of doing that. And the way of doing that, which is very simple, it's very funny how it happens, is that, well, the GAC, this is where the location of the DLL is stored. This is in C, Windows, assembly, GAC32. Here you have a directory for each assembly. So, for example, MSColib, which is one of the most important DLLs, MSColib can have many versions. So each version contains its own directory that says what is the version of the DLLs of here. You see the .NET 2.0 DLL for MSColib, and this is the signature of it. Well, it turns out that if you take the DLL and put it back to its location in this directory, and this contains the signature, right? It looks at the signature. It says, hey, I need to load the DLL containing this signature while I just load it from there. So no signatures are checked. And basically, what's so funny about this is that basically, if we look into it, well, basically, this mechanism here, even though that there was some signatures checked, basically, the attacker could disable them, lose anything, right? So basically, due to performance issues, the verification was disabled. So now all you have to do is just write your DLL to the same location, to the correct location that you want. And the last thing that you want to do is to avoid engine. Engine is a precompiled code, so we would like to throw away the cached version of the old, right? So you just disable the old code, the caching using engine uninstall and the previous DLL. Basically, from here on, you can remove traces with engine. Go read the white paper. It contains information about this kind of stuff. Up until now, we've talked about the techniques of changing the dotted language or the Java language. From now on, we're talking about more generic stuff. Basically, one of the important things is that we can extend the language. We can add features to the language. We can add new methods. I call it method or function injection because you're adding new methods to the language. For example, if you want to do the same thing again and again and again, instead of writing the same code, just wrap your code as a new method, right? And pass parameters to it. Just call your method. So basically, I've implemented a couple of methods. One of them is called send to URL. What it says is that it will send some data from an attack machine to the attackers. So the parameters is where to send it and what is the data. Reverse shell. Please open a reverse shell for me in IP and port. So specific stuff that I need to call for this function. Hide file. Inject class. Man in the middle, which returns a man in the middle socket. And in key log event handler. All of those are examples of things that can be injected into runtime. But when we're talking about managed code, usually managed code is implementing object-oriented concepts. And one of the interesting things about object-oriented is that we have the notion of inheritance. So basically, if you have a class that you want the class to contain code, to extend code of other classes, you're just inheriting from that class. And, well, all of the classes are inheriting from a class called object. So basically, we have something like a tree of classes. And object is the utmost class. So basically, if we want to inject code that will be inherited to all of the classes in the runtime, all we have to do is inject it into object. And we can do other interesting things. For example, we can inject into sub-tree, into a branch. For example, let's say that we want to inject only to this sub-tree. So all we have to do is inject into here. So basically, inheritance will do it for us. So we just need to look for . So a little bit about the development scenarios where we can do many interesting things. And I want to save time to show you some demos. So let's start with the first one. But the first one, here we're talking about stealing the authentication credentials from the runtime authentication mechanism. We're not talking about the application level authentication code. We're talking about the runtime method, a Boolean method that gets from the application username and password and returns back the true-force answer. So what we're going to see about here is that we're going to inject into an internal authentication method code that says something like, well, take the username and password that you now have. Well, this is an internal class members. Take it from the class and send it to the attacker using our own send to URL class. Right? So we've injected the code to send to your method. And now we are just calling it and saying, well, I want to send you to me the username and password of the user. And let's see a demo about that. Well, in our demo, we're going to see an attacked application. Well, think about a hosting application, a hosting management system in which you have many applications on the same machine. We are attacking all of them at once. So we're talking about a rich bank, a rich bank server, which we have many users. And the login page, if this is the login page, this is the login page code. The login page code calls the action of the button click is to call forms authentication, authenticate, sending the username and password, and calling the runtime method. So runtime method has been hijacked so that in the end of the original code, we can see a call to send to URL. And the data will be sent to the attacker. Well, in this demonstration, we're going to talk about an application and a server called rich bank. Well, rich bank, believe me, that they have lots and lots and lots of money. So this is the place where attackers would probably want to attack. So in this application, the low-level implementation was being hijacked so that what we're going to see now, we're going to put our user over here. And let's have the server. Let's have one attacker. There. And in our attacker, well, our attacker, let me just make sure that I'm running on the right machine. Yeah. Look at this. Well, when the attacker receives the data, data will be sent. It will be written into this directory called received input. So I'm going to put my attacker over here. So basically, the flow will be something like this. The user will enter his credentials. It will go through the application, through the runtime, and into the received input directory, right? This will be the flow. So let's take our attacker. And let me put here my credentials that I'm going to write something which is wrong. So this is blah, blah, blah, right? And as I'll log in, take a close look what happens over here. So logged in. Well, access is denied. Let's go back. And now... Now I will authenticate this as it used to be. Again. Right. So now let's go to the attacker's machine. Let's see what it takes. So I can see that the log file says that the user has tried to login with password blah, blah, and that the user has tried to login with password 166. So... And this was in a demo of hijacking the forms authentication. Thank you. If you're talking about another attack on the same method, well, this is another attack vector. Now we're attacking authenticate, but only now we are inserting a backdoor into the authenticate method. So that now... We are talking about adding this piece of code. This piece of code says, and it's very similar to what developers like to do. It says, if you have some specific magic password, this magic password will let you in into any account that you like. Right? And the code says, like, if the password is magic, it will let you in. If I will look at the same thing after disassembling it, editing the code, basically injecting this code, assembling it back, and decompiling it into C sharp, so we can have a better look at it, it looks something like this. Okay? So this is the if, basically. Now we can enter it into any account. Well, another example that we'll see later on, this is about reverse shelling. And in reverse shell, basically what I did, I took an implementation of netcat. Basically I could do it in a million ways of doing the same thing. What I did is, I took a coded version of netcat, pushed it back, the executable, into the runtime, and when something is executed, and netcat is being deployed to this, it executed. Well, you can do it in very other ways. For example, you can inject it into memory, so that you will not have traces. But basically, the idea is to execute code when some specific thing happens. And in our example, the code was injected into application run. Run is a method that each time an application is executed. Basically, this is like a main in a C++ application. And the code that was injected here, well, this is a code that says, as we can see, this is a pre-injection code. The code is injected into the beginning of the method. We can see code that says, well, call our own reverse shell method. Basically, I've injected reverse shell before that. And pass on the parameters, the attacker's machine IP, and the port. So this is all the attacker needs to do. When reverse shell has already been injected. So that all it has to do, just pass on the parameters to the stack and close the port. We'll see a demo of that later. Crypto attacks. Well, crypto attacks, those attacks are very important and very interesting. Because crypto, this is something which directly relates to security. And when someone attacks, your crypto libraries, basically, he's creating a false sense of security. Because you're trusting the crypto libraries, and for example, you think that you've done everything right. So basically, if someone, for example, let's talk about some examples, some attack scenarios. Key fixation. When someone fixates your key, you're thinking that you're encrypting with your chosen key, but you're encrypting with another key. Key stealing. For example, stealing the correct key from inside the crypto class using Centro Euro. Or algorithm downgrading. For example, the application asks for AES implementation. What it gets back is easy crackable death. Right? And an example code for that is that if this is the generate key method, this is the method that creates the key for the application. Basically, what I did is, I reverse engineered this method, throw away its own implementation, and now I have something that says, return always fixated key. Again, from the user point of view, he thinks everything is encrypted. Well, the data looks encrypted, right? If you look at the data, the data, it's looking encrypted. You will decrypt it, everything works fine, but you do not know that your key is not relevant. Well, DNS manipulation. In DNS manipulation, we are talking about taking the user to some place that he didn't want to go to. This is an example Java rootkit in which a code was injected into the DNS classes so that whenever resolving will be performed. For instance, for a server called www.forexserver.com, the resolving will be performed to the attacker's IP. Right? To the attacker's machine, www.attacker.com. Basically, it looks like this. This is the original code of get by name. This is Java's implementation of performing DNS resolving. .NET is get host addresses, basically the same. I've injected the code that something like this. So now, if the code comes to resolve s, well, I overwrite, if s equals forexserver, I will overwrite s and return s as it was supposed to. I hope that I have a couple of minutes for this demo, so let's start it very soon. This is the quote server. This will be our client. Well, now the victim, as opposed to the usual demonstration, is going to take backtrack. Backtrack is awesome, right? . But now we're going to see it twist the backtrack and use it as the victim. Think about what happens when you download OS from untrusted sources, right? Guys, stop downloading Kaiser OS from . Might contain... Your system might be hacked. So, I'm going to use, as a victim, a Linux machine. And the interesting thing is that class that I wrote and it executes as it's supposed to be on Windows machine, I've deployed the same class on Linux machine, right? So, and this is where our virtual machine comes into place so that my user... Let's put it over here. And now we're going to perform a man-in-the-middle attack. So, let's take our own attacker and the attacker has his own man-in-the-middle server. As you can see, he's waiting for a victim. Let's put this guy over here. Let's put this guy over here. So... Now I can see that we have clear separation. It's different machines, guys, different IPs. I'm not cheating. So, as you might see, as you can see, and take a close look, when I do a connect, connection's supposed to be happened to 4x code server to here. Take a close look, you will see that connection will be opened first over here. Well, it might be too fast, but I hope that it works out. Connect and... Yeah. But it is not the end of it. Well, basically, I could have stopped here because taking the user to the wrong place is bad enough. Right? But here, the attacker's mission was to make and to cheat, to fool the user. And with this, we are talking about both 4x server. So, I want to make the user looks like, for example, the British pound. It's something which is worth buying. Let's say this. And it's supposed to be this. And... Well, the user is going to see that. And they say, hey, great. Great British pound. Let's buy a couple of those. Give me 10,000 of those. Great. Transaction accepted and the user was fooled. So, this is the end of this demo about DNS manipulation. Let's take a look at other examples. Thank you. Thank you. Thank you. Thank you. So, stealing connection strings, this is something where the application... The application is performing a lot of interesting things. And one of the important things is timing. Well, in timing attacks, your attack is supposed to be executing when some specific thing happens. For example, stealing connection strings to databases is supposed to happen when an application opens a connection to the database. Right? You cannot just put some code in some very general place. You need to do it in some specific place. And I wanted to inject code that does something like this. Well, take this dot connection string and send it to the attacker. But the thing is that I cannot inject it into the constructor of the object. I need to inject it into a place that I know that where it is being called, the connection string will already be initialized. The right place to do that is in open. When the application code is open, it should still be initialized. Right? Permanent edge testing. The HTML and JavaScript injection is where the code is being injected into not necessarily code sections but code templates. For example, HTML blocks, JavaScript blocks and stuff like that. So we can inject, for example, permanent cross-site scripting. We can perform proxies, many in the middle, defacement attacks. And one of my favorites, calls to browser exploitation frameworks such as XSS Shields. Right? So, you all know XSS Shield, right? You know XSS Shield, guys? Great . Speaking into secure string, this is where we are stealing data from something which is called a secure string. This is a string that contains, this is a string which is encrypted in memory. Well, if the string is encrypted, this is because someone wanted to hide something which is very valuable. Let's steal it from there. And, this is the code that can do that. You think, again, send to URL. And the last one, we are talking about disabling security mechanisms. Here, we are talking about disabling the virtual machine own mechanisms such as Java, Just, .netcast. Basically, if we have some kind of code access security, this is like an ACL but for code, so that we can say what class can do and what method can call and everything and stuff like that. Basically, the application will not behave according to configuration. Again, if there will be some kind of auditing, security auditing will say, hey, everything is fine. I see this configuration is as it's supposed to be but the application will not behave as it should. Again, false sense of security. But, those are just examples. As you can see, sorry, you can implement what you want. If someone hacked your own virtual machine, you can perform and basically the sky is the limit. There are some advanced topics to mention. For example, most platform with classes can perform many interesting things. You can deploy classes, custom classes. You cannot, you don't need to tie the code to the specific machine, to the specific CPU. There are run times like enterprise service bus, web services stacks, application servers, as an instance, SQL Server 2005 contains an internal implementation of .NET Framework. You change the database code. And, we can also talk about the multiple change rootkits or second order rootkits in which we're having an OS level rootkit. So, for example, kernel level rootkit that hides the presence of MCR and MCR application. Right? Remember, MCRs are not targeting the OS, they're targeting the application. And, the last thing that I want to talk about, now I'm going to talk about .NET Exploit. This is a tool that I wrote in order to, in order to to show as a proof of concept that things like this can happen. And, basically, .NET Exploit is not necessarily an evil tool. .NET Exploit is a generic .NET Framework language modification tool. So, you can perform, you can change, basically, your language. It's an open source tool. You can download it, change it, modify it, add modules to it. You can even add more languages to .NET Exploit. So, basically, and you don't necessarily have to run it on Windows. You can actually run it on Linux using the Mono project. Well, .NET Exploit contains most of the attacks that I talked today and another couple of examples. I'm going to play with it. And, the concept with .NET Exploit is that you're developing a general purpose modules. Modules can be either a function. A function is a general purpose method. You can, you develop payloads. Basically, the separation between payload and method is that you don't necessarily have to mix them together. And, references is when you're injecting code that contains some DLLs that wasn't there before and an item. And, an item, it's very interesting because an item is the model that ties them all. An item looks something like this. An item is an XML that describes, basically, where we want to inject our code. So, basically, what is the target DLL? So, we can see that we are changing ms-colib and this is the location of ms-colib. We want to inject, for example, this piece of code. Right? And, the location of the code. So, this is the hooking point. This is where we want to inject our code. And, what is the mode? What is the mode of operation? Whether we want to inject it as a pre-injection, post-injection, or we want it to replace all of the code that was there before. And, let's see the last demo. The last demo is about the .NET exploit performing a very intensive task of injecting a reverse shell into the .NET frame of own implementation. And, the task is that we are performing a conditional reverse shell that only one specific application called sensitive application has been executed. The reverse shell will be opened back to the attacker. So, let's go to our machine. We are going .NET exploit. And, I'm going to load one of the items. There are many items here. The last one, conditional reverse shell. And, I'm going to start. So, now what it will do, now it will go to this directory, take this DLL, perform a decompilation of the DLL. After decompiling the DLL, it will inject the function reverse shell generic. After that, it will inject the function called reverse shell private generic. After that, inject the payload, which is conditional reverse shell form, in a mode which is pre-append, so that code will be injected at the beginning of the function. Basically, if I wanted it to be executed at the end of the function, all I had to do is change the configuration. So, now it's in pre-append. And, after it will finish, it will recompile it back. Basically, reassemble it back into a DLL. And, basically, it will generate a new DLL for me, so that this DLL will later be used to replace the framework on DLL, so that, basically, now I'm going to change the dotted language, so that now the injection will be performed into run. Remember run? Run is when applications are being executed. Run has been Now when run will be called, it will check whether the name of the application is a sensitive application. So, as it's done its operation, it asks me whether I want to generate deployers. Well, deployers are batch files. This is deploy and undeploy batch files that will be used in the modified machine, so that, well, we don't need to take .NET to the modified machine. All we have to do is to take the DLL and the batch file. So, I'll execute this, and so .NET support is finished, and it's gone .NET support attacker here, and we have the attacker side shell here, and well, now I'm going to run the sensitive application to show you that I didn't deploy it yet, so now I'm going to execute sensitive application to show you that nothing happens. A couple seconds. See that? Oops. That's the end. Yeah. So, and this is sensitive application. Nothing happened. Well, what I'm going to do now, I'm going to deploy the DLL. That's it. Now, I'm going to run the same executable, and if everything works as fine as supposed to be, every version will be open on the right side. Yeah. . Let's who we are. Yeah. . So, . . Well, . This is scary stuff, right? Someone messes up with run times. So, basically, code review on runtime that's been tampered with, does not mean anything. You should notsource the runtime. So basically, what we can do, I'm calling for action for, for example, antiviruses and tries to, for example, change my host file and the antivirus says, hey, some process is trying to do something to your operating system, I expect this antivirus to tell me that some process is trying to change my managed code environment. IT guys should perform file tampering detectors using, for example, tripwire, but do it using an external machine. Auditors, pentesters, forensics, look for your evidence inside virtual machines, know about this kind of shit of things. Developers, you should know that your application is secure as the underlying virtual machine, right? Virtual machine vendors like Microsoft, basically, this is not a direct responsibility of them, but although it's not a bulletproof solution, they should raise the bar a little bit. Today, it's too damn easy to do. And, of course, and your solutions. users, all of us, we should know about this kind of thing and we should verify our run times. Well, for more information about this research, you should look at this page. This is where the slides are, white paper, .NET exploit tool, source code, basically everything. It's important to mention Ken Thompson, who talked about C compiler backdoors. He talked, the first guy who talked about backdooring the compilers. And Dennis Cruz from the OWASP.NET group, who talked about the dangers of full trust application. Well, to summarize, we all seen that malicious code can be hidden inside the virtual machine, the application of the virtual machine, as an alternative place for hiding malware. We are not just talking about kernel, BIOS, places like that. We're talking about another place for backdoors. Very interesting attacks can be devised using the techniques like that, so be careful. And, well, it does not depend on any specific vulnerability because, basically, it's not restricted to any kind of machine, to any technology. We're not just talking about .NET, Java, or stuff like that, but a custom problem, a generic problem that we have. And the last thing we saw, .NET exploit, the generic language modification tool, that simplifies the process of .NET modification. But, you know, it's a little bit complicated. I want you guys to remember that .NET exploit is not necessarily an evil tool. I used it as a custom tool. It can be used to modify the framework, but it can also be used, basically, to modify the framework, create your own version of .NET framework, generate customized mod frameworks, tiny framework, secure framework, performance framework, stuff like that. So, guys, if you have any questions, I'll be right over there. Thank you very much. We'll see you over there at room 104. And thank you very much.