1 00:00:00,000 --> 00:00:00,860 Good morning. 2 00:00:02,460 --> 00:00:05,940 You know, one of the great things that I like about DEF CON, 3 00:00:06,140 --> 00:00:08,340 well, besides of the great talks and everything, 4 00:00:08,580 --> 00:00:14,620 well, I believe it's the first conference that starts at 10 a.m., right? 5 00:00:15,820 --> 00:00:16,840 Yeah, it's great. 6 00:00:17,140 --> 00:00:18,020 Well, you know what? 7 00:00:18,100 --> 00:00:21,720 I'm having some difficulties sleeping last couple of days 8 00:00:21,720 --> 00:00:23,600 due to some jet lag problems. 9 00:00:24,040 --> 00:00:28,360 Well, basically, my clock has been shifted about 10 hours. 10 00:00:29,240 --> 00:00:32,600 Last night, I woke up at about 3 a.m. 11 00:00:32,620 --> 00:00:35,040 Well, I thought to myself, it must be a beautiful day. 12 00:00:38,160 --> 00:00:40,560 So, basically, what we're going to talk about today, 13 00:00:40,600 --> 00:00:42,640 we're not going to talk about my jet lag problems. 14 00:00:42,780 --> 00:00:44,900 We're going to talk about managed code rootkits. 15 00:00:46,200 --> 00:00:47,660 My name is Erez Metula. 16 00:00:48,320 --> 00:00:52,000 I'm a software engineer working at 2B Secure, 17 00:00:52,160 --> 00:00:54,880 working as the application security department manager. 18 00:00:55,340 --> 00:00:57,060 And what we're going to see today, 19 00:00:57,160 --> 00:00:57,960 we're going to see, 20 00:00:58,440 --> 00:01:00,460 we're going to see injections into the managed code environment. 21 00:01:00,900 --> 00:01:04,480 And, basically, we're going to start with a simple example, 22 00:01:04,640 --> 00:01:06,080 a very trivial questions, 23 00:01:06,700 --> 00:01:08,140 which goes like this. 24 00:01:08,260 --> 00:01:13,340 Well, this is the software engineering 101 class, 25 00:01:13,400 --> 00:01:15,480 which talks about Hello World in Java. 26 00:01:15,700 --> 00:01:17,620 Well, basically, what does the following code should do? 27 00:01:19,000 --> 00:01:21,800 Supposed to print the string Hello World, right? 28 00:01:22,160 --> 00:01:24,780 So, let's run this code, and let's see what happens. 29 00:01:25,600 --> 00:01:27,580 So, basically, I'm having this class, 30 00:01:28,360 --> 00:01:30,080 the Hello World Dutch Java class. 31 00:01:30,320 --> 00:01:32,480 So, when I'm going to run this class, 32 00:01:32,800 --> 00:01:35,360 well, it gives me this strange behavior. 33 00:01:36,360 --> 00:01:39,500 Well, basically, the string that was supposed to be printed, 34 00:01:39,560 --> 00:01:41,100 the Hello World, was printed twice. 35 00:01:41,680 --> 00:01:43,820 And the reason for that to happen is that 36 00:01:43,820 --> 00:01:48,520 because the internal implementation of the managed code was modified. 37 00:01:48,860 --> 00:01:52,100 So, the code, basically, what the code is, 38 00:01:52,200 --> 00:01:54,200 what the application level code says, 39 00:01:54,300 --> 00:01:56,140 it's not necessarily what it's going to do. 40 00:01:56,620 --> 00:01:58,320 And this is a little bit of, 41 00:01:58,320 --> 00:02:00,140 it's a little bit of a problem when we're doing code reviews. 42 00:02:00,380 --> 00:02:01,720 Well, when we are doing code reviews, 43 00:02:01,920 --> 00:02:05,000 the malicious code might not be at the application level. 44 00:02:06,320 --> 00:02:10,600 But this was just a simple example of language modification. 45 00:02:11,720 --> 00:02:14,680 We're going to use this example of language modification 46 00:02:14,680 --> 00:02:15,980 and take this further and further, 47 00:02:16,140 --> 00:02:18,980 and that will be able to inject rootkits into runtime, 48 00:02:19,220 --> 00:02:22,120 into application virtual machine runtimes. 49 00:02:23,660 --> 00:02:25,340 And what we're going to talk about today, 50 00:02:25,420 --> 00:02:28,140 we're going to start with the managed code environment, 51 00:02:29,380 --> 00:02:30,420 execution model. 52 00:02:30,580 --> 00:02:32,180 We'll start with an overview about that. 53 00:02:32,320 --> 00:02:34,400 We're going to talk about managed code rootkits 54 00:02:34,400 --> 00:02:36,500 and how to implement managed code rootkits, 55 00:02:36,560 --> 00:02:38,760 what's so special about that. 56 00:02:39,040 --> 00:02:43,320 We'll see a couple of demos and a couple of attack scenarios 57 00:02:43,320 --> 00:02:46,740 so that we can understand that managed code rootkits 58 00:02:46,740 --> 00:02:49,860 can be very dangerous and they have their own advantages 59 00:02:51,440 --> 00:02:54,220 due to some very interesting techniques. 60 00:02:54,860 --> 00:02:57,560 And I'm going to expose to you a tool that I wrote 61 00:02:57,560 --> 00:02:58,300 called .NET. 62 00:02:58,320 --> 00:02:58,740 What is a .NET exploit? 63 00:02:59,280 --> 00:03:03,400 Well, a .NET exploit is a custom language modification tool. 64 00:03:03,600 --> 00:03:06,880 It enables you to change and to customize 65 00:03:06,880 --> 00:03:08,980 your own version of the .NET language. 66 00:03:09,980 --> 00:03:12,120 Well, it is a general purpose tool. 67 00:03:12,220 --> 00:03:16,580 I use it to show the attacks that I have demos for. 68 00:03:16,980 --> 00:03:20,100 But basically, you can use it for any purpose you like. 69 00:03:20,220 --> 00:03:21,940 You can even take it and it's an open source 70 00:03:21,940 --> 00:03:23,800 and customize it to other languages. 71 00:03:24,880 --> 00:03:26,660 So a little bit of background. 72 00:03:26,940 --> 00:03:28,080 It all started... 73 00:03:28,320 --> 00:03:31,460 with the idea of changing the language back in 2008. 74 00:03:32,820 --> 00:03:36,360 I played a little bit with the .NET language modification. 75 00:03:37,400 --> 00:03:40,200 Well, soon I realized that it might lead 76 00:03:40,200 --> 00:03:41,300 to some very interesting attack. 77 00:03:42,100 --> 00:03:46,140 I wrote a paper about it called .NET Framework Rootkits 78 00:03:46,140 --> 00:03:48,160 Backdoors Inside Your Framework. 79 00:03:48,740 --> 00:03:53,020 I presented it in Black Hat Europe and in CancerQuest. 80 00:03:53,900 --> 00:03:57,480 But .NET Rootkits was just a case study. 81 00:03:58,320 --> 00:04:01,040 And people actually thought that there is a problem 82 00:04:01,040 --> 00:04:03,340 with the .NET Framework and that the concept 83 00:04:03,340 --> 00:04:05,700 that I was talking about was .NET specific. 84 00:04:06,180 --> 00:04:07,380 Well, it wasn't. 85 00:04:07,600 --> 00:04:09,840 And it was really, really important to me 86 00:04:09,840 --> 00:04:13,580 to show you guys the general purpose case 87 00:04:13,580 --> 00:04:17,660 so that I'm also going to talk about Java Rootkits today. 88 00:04:18,340 --> 00:04:20,480 So I'm taking another language as an example 89 00:04:20,480 --> 00:04:23,000 to show you the general case study. 90 00:04:23,780 --> 00:04:25,500 So what is a managed code? 91 00:04:25,720 --> 00:04:28,020 Well, managed code is code that runs... 92 00:04:28,320 --> 00:04:32,000 and executes under the management of a virtual machine, 93 00:04:32,220 --> 00:04:34,500 an application-level virtual machine. 94 00:04:34,960 --> 00:04:39,260 For example, the JVM, the Java JVM, or the .NET CLR. 95 00:04:40,360 --> 00:04:45,240 Well, think about it as an operating system for applications. 96 00:04:45,280 --> 00:04:48,060 So basically, this is another language we are talking about. 97 00:04:48,100 --> 00:04:50,840 We're not talking about assembly language, 98 00:04:51,100 --> 00:04:53,960 but we are talking about a virtual language. 99 00:04:55,520 --> 00:04:58,020 We're talking about a high-level object, 100 00:04:58,320 --> 00:04:59,900 object-oriented intermediate language. 101 00:05:00,120 --> 00:05:01,540 Basically, it looks like assembly, 102 00:05:01,740 --> 00:05:05,480 but it has the characteristics of an object-oriented language. 103 00:05:05,780 --> 00:05:09,220 We can create objects, and we have classes, 104 00:05:09,320 --> 00:05:10,840 and inheritance, and stuff like that. 105 00:05:11,140 --> 00:05:13,320 Well, basically, it looks something like this. 106 00:05:14,140 --> 00:05:18,320 This is how Java bytecode looks like after disassembling. 107 00:05:18,500 --> 00:05:21,640 So as you might see, it looks kind of like an assembly code, 108 00:05:21,800 --> 00:05:22,620 but it's not. 109 00:05:23,400 --> 00:05:25,140 If I will execute this code, 110 00:05:25,180 --> 00:05:26,820 if I give the CPU this kind of code, 111 00:05:26,880 --> 00:05:28,300 it will not understand what I'm talking about. 112 00:05:28,300 --> 00:05:30,840 The CPU does not understand virtual languages. 113 00:05:31,260 --> 00:05:35,100 But basically, the magic that is being performed 114 00:05:35,100 --> 00:05:38,120 is being performed using the virtual machine 115 00:05:38,120 --> 00:05:41,020 that translates the high-level intermediate language 116 00:05:41,700 --> 00:05:44,080 to the machine-specific assembly code. 117 00:05:44,480 --> 00:05:47,340 So that if I'm having an executable, 118 00:05:47,920 --> 00:05:50,260 and sorry, guys, about my graphics. 119 00:05:50,380 --> 00:05:51,220 I suck in graphics. 120 00:05:52,440 --> 00:05:54,880 But what I wanted to show you here is that 121 00:05:54,880 --> 00:05:58,280 the same executable can be run under this code. 122 00:05:58,280 --> 00:05:58,900 It's a different platform. 123 00:05:59,120 --> 00:06:01,240 So we have a Windows machine, and a Linux machine, 124 00:06:01,360 --> 00:06:03,560 and a Mac, and a mainframe, and et cetera, et cetera. 125 00:06:03,900 --> 00:06:07,720 But for each machine, there is a specific virtual machine. 126 00:06:07,880 --> 00:06:10,940 So we have that for Windows, the virtual machine is in blue, 127 00:06:11,040 --> 00:06:13,640 and for the Linux box, it's in green. 128 00:06:14,060 --> 00:06:18,260 And basically, what happened here is that 129 00:06:18,260 --> 00:06:21,740 the executable is executed inside the virtual machine 130 00:06:21,740 --> 00:06:24,820 that translates the adjusting time code 131 00:06:24,820 --> 00:06:26,360 and gives that to the CPU. 132 00:06:26,640 --> 00:06:28,260 So basically, the virtual... 133 00:06:28,260 --> 00:06:30,280 The virtual machine acts as the bridge to the CPU. 134 00:06:31,320 --> 00:06:34,420 Well, a couple of examples of managed code run times. 135 00:06:34,580 --> 00:06:37,620 So we're talking about Java, JVM, .NET Framework, 136 00:06:37,680 --> 00:06:41,980 the PHP Z engine, the Flash Action Script, 137 00:06:42,120 --> 00:06:44,980 the virtual machine, the AVM, Python, Dalvik. 138 00:06:45,080 --> 00:06:46,320 Basically, there are lots of languages 139 00:06:46,320 --> 00:06:47,780 which are virtual machine-based. 140 00:06:48,280 --> 00:06:51,000 And today, we're going to discuss .NET and Java 141 00:06:51,000 --> 00:06:51,880 as the case studies, 142 00:06:52,080 --> 00:06:55,140 basically because they're very common languages. 143 00:06:55,380 --> 00:06:57,340 Many projects are written today using... 144 00:06:58,260 --> 00:06:59,140 .NET and Java. 145 00:06:59,320 --> 00:07:01,520 And because their model is very similar 146 00:07:01,520 --> 00:07:03,020 and very easy to understand. 147 00:07:03,800 --> 00:07:06,740 So a little bit of overview of Java execution model. 148 00:07:07,020 --> 00:07:08,520 Well, basically, we have three layers. 149 00:07:08,940 --> 00:07:11,500 As opposed to, for example... 150 00:07:11,500 --> 00:07:12,660 A code which... 151 00:07:12,660 --> 00:07:14,400 The quality of the following recording 152 00:07:14,400 --> 00:07:16,200 is not up to our usual standards. 153 00:07:16,420 --> 00:07:17,900 However, we are releasing this 154 00:07:17,900 --> 00:07:20,080 due to the importance of the material presented. 155 00:07:20,460 --> 00:07:21,520 It's unmanaged. 156 00:07:21,700 --> 00:07:24,260 For example, C of C++ code, 157 00:07:24,460 --> 00:07:26,260 in which you have the executable, 158 00:07:26,340 --> 00:07:27,960 which contains compiled code, 159 00:07:28,260 --> 00:07:29,180 find assembly code, 160 00:07:29,340 --> 00:07:30,720 and you have the OS. 161 00:07:31,240 --> 00:07:33,700 Basically, now we're talking about three layers, not two. 162 00:07:33,900 --> 00:07:34,960 We have the application. 163 00:07:35,260 --> 00:07:36,760 We have the runtime. 164 00:07:37,120 --> 00:07:38,760 In our example, this is the JVM, 165 00:07:38,760 --> 00:07:39,440 and we have the OS. 166 00:07:39,640 --> 00:07:41,820 So when the application source code is compiled 167 00:07:41,820 --> 00:07:44,040 and we have a bytecode, the class, 168 00:07:44,700 --> 00:07:46,480 it is hosted inside the JVM. 169 00:07:46,520 --> 00:07:49,680 The JVM loads the class libraries from JAWS 170 00:07:49,680 --> 00:07:50,960 based on the name. 171 00:07:51,160 --> 00:07:54,200 And when it generates using a just-in-time compiler, 172 00:07:54,500 --> 00:07:57,740 a code which is machine-specific, 173 00:07:58,260 --> 00:08:02,280 this is what the OS, the CPU, looks and sees and executes. 174 00:08:02,600 --> 00:08:04,720 But the .NET model is pretty much the same, 175 00:08:04,820 --> 00:08:07,320 so only that now we have assemblies. 176 00:08:07,340 --> 00:08:09,520 This is .NET mutation for compiled code. 177 00:08:09,640 --> 00:08:11,760 We're talking about DXCs and DLFs. 178 00:08:12,120 --> 00:08:14,700 And now that the code is being loaded, 179 00:08:15,740 --> 00:08:18,240 the libraries is being loaded from the GAC, 180 00:08:18,360 --> 00:08:19,580 the Global Assembly Cache. 181 00:08:19,680 --> 00:08:21,840 These were all the low-level code, 182 00:08:22,060 --> 00:08:25,600 all the low-level methods are being scoped. 183 00:08:25,900 --> 00:08:28,120 Well, think about it as a system call. 184 00:08:28,260 --> 00:08:30,460 Basically, this is where the code is located. 185 00:08:30,700 --> 00:08:32,560 This is where functions have been implemented. 186 00:08:33,220 --> 00:08:36,760 And again, the jitter is generating machine-specific code, 187 00:08:36,900 --> 00:08:39,500 and this is what the machine is executing. 188 00:08:40,880 --> 00:08:44,160 So what are Managed Code Rootkits, or MCRs? 189 00:08:44,440 --> 00:08:45,940 Well, Managed Code Rootkits, 190 00:08:46,000 --> 00:08:49,080 this is a user-mode, application-level rootkit 191 00:08:49,080 --> 00:08:51,680 hidden inside the Managed Code environment libraries. 192 00:08:52,480 --> 00:08:55,020 Well, I know that most of you guys think about, 193 00:08:55,080 --> 00:08:58,240 well, user-level mode, this is not like your nail level mode. 194 00:08:58,240 --> 00:08:59,620 Nail-level mode is awesome. 195 00:08:59,840 --> 00:09:02,660 Well, in nail-level mode, we can do many things. 196 00:09:02,900 --> 00:09:05,620 Well, there is a couple of great things that you can do in user-mode. 197 00:09:05,700 --> 00:09:08,760 In user-mode, well, although you are sacrificing 198 00:09:08,760 --> 00:09:11,560 a little bit of hiding, 199 00:09:12,580 --> 00:09:14,560 you can do very sophisticated attacks. 200 00:09:14,820 --> 00:09:19,280 And you can do very sophisticated logical attacks 201 00:09:20,100 --> 00:09:23,820 so that the target of the MCRs is the virtual machine 202 00:09:23,820 --> 00:09:26,640 that provides the services to the upper-level application. 203 00:09:27,120 --> 00:09:27,960 So basically, 204 00:09:27,960 --> 00:09:29,940 we are hiding information from the application, 205 00:09:30,260 --> 00:09:33,520 not in traditional rootkits when we are hiding from the OS 206 00:09:33,520 --> 00:09:35,140 or maybe from the CPU or stuff like that. 207 00:09:35,220 --> 00:09:36,600 We are hiding it from applications. 208 00:09:37,380 --> 00:09:41,640 So the influence that we have is on all of the applications 209 00:09:41,640 --> 00:09:44,500 that run on a specific virtual machine. 210 00:09:44,960 --> 00:09:46,760 And basically, what we can do, 211 00:09:46,780 --> 00:09:49,160 we can do stuff like regular rootkits. 212 00:09:49,180 --> 00:09:50,860 So, for example, we can hide files 213 00:09:50,860 --> 00:09:52,320 and we can hide processes 214 00:09:52,320 --> 00:09:54,680 and registry keys and stuff like that. 215 00:09:54,800 --> 00:09:57,820 We can also do some very interesting logical things. 216 00:09:58,840 --> 00:10:02,000 A little bit of advantages of MCRs. 217 00:10:02,120 --> 00:10:05,300 Well, first thing is that it is an overlooked place. 218 00:10:05,520 --> 00:10:08,620 No one looks at virtual machines for malicious code. 219 00:10:09,000 --> 00:10:12,720 No antivirus, IPSs, IDSs, stuff like that. 220 00:10:12,880 --> 00:10:15,120 They understand intermediate language. 221 00:10:15,420 --> 00:10:18,260 They don't know if you're writing your own malicious code. 222 00:10:18,340 --> 00:10:20,260 They do not understand it. 223 00:10:21,540 --> 00:10:24,220 Well, basically, they also cannot tell 224 00:10:24,220 --> 00:10:26,980 whether your application is doing something wrong. 225 00:10:27,120 --> 00:10:27,940 From here. 226 00:10:27,960 --> 00:10:29,040 From its point of view, 227 00:10:29,120 --> 00:10:31,340 the application can do whatever it wants. 228 00:10:31,480 --> 00:10:33,120 So basically, it cannot detect 229 00:10:33,880 --> 00:10:35,520 those kind of malicious behavior. 230 00:10:36,780 --> 00:10:37,860 Well, forensics. 231 00:10:38,680 --> 00:10:42,280 Forensics checklist does not cover virtual machines, right? 232 00:10:42,820 --> 00:10:45,560 So basically, if forensic guys over here, 233 00:10:45,720 --> 00:10:47,420 today you have another place, 234 00:10:47,480 --> 00:10:48,940 another place to look for so that 235 00:10:48,940 --> 00:10:52,820 it's not just the operating system binaries 236 00:10:52,820 --> 00:10:54,420 you look for, also for another places. 237 00:10:54,560 --> 00:10:56,240 And basically, another interesting thing 238 00:10:56,240 --> 00:10:58,700 is about developers. 239 00:10:59,020 --> 00:11:00,720 And developers backdoors. 240 00:11:00,780 --> 00:11:02,560 Now we're talking about malicious developers 241 00:11:03,240 --> 00:11:07,380 that they know that their code will be audited. 242 00:11:07,760 --> 00:11:10,660 And they know that some security guy 243 00:11:10,660 --> 00:11:13,180 will open their own code, 244 00:11:13,300 --> 00:11:14,620 maybe looking for backdoors. 245 00:11:14,800 --> 00:11:16,880 They will not hide it inside application library. 246 00:11:17,220 --> 00:11:20,220 They will hide it downstairs in a virtual machine. 247 00:11:21,420 --> 00:11:23,940 We're also talking about universal wordkits. 248 00:11:24,100 --> 00:11:26,160 Due to the fact that the virtual machine 249 00:11:26,160 --> 00:11:28,140 performs the translation for us, 250 00:11:28,240 --> 00:11:32,620 we can write code which is not machine-specific, right? 251 00:11:32,800 --> 00:11:34,780 The same code, the same malicious code 252 00:11:34,780 --> 00:11:38,080 will be translated to the machine-specific instruction set 253 00:11:38,080 --> 00:11:39,400 using the virtual machine. 254 00:11:39,600 --> 00:11:41,360 This is what I call universal wordkits. 255 00:11:41,680 --> 00:11:44,260 And we have large attack surface due to the fact 256 00:11:44,260 --> 00:11:46,680 that virtual machines are pre-installed 257 00:11:46,680 --> 00:11:47,860 on operating systems. 258 00:11:48,040 --> 00:11:50,080 We have Java and .NET are pre-installed 259 00:11:50,080 --> 00:11:51,540 in latest versions. 260 00:11:53,380 --> 00:11:55,100 We can deploy all of... 261 00:11:55,100 --> 00:11:57,360 Sorry, we can control all of the applications 262 00:11:57,360 --> 00:11:58,480 from only one place. 263 00:11:58,960 --> 00:12:01,680 Think about a scenario of, for example, 264 00:12:01,680 --> 00:12:03,620 a hosting web server 265 00:12:03,620 --> 00:12:05,260 in which you are controlling 266 00:12:05,260 --> 00:12:06,880 all of the application's behavior 267 00:12:06,880 --> 00:12:08,360 using only one injection. 268 00:12:10,320 --> 00:12:12,120 Well, another interesting thing is that 269 00:12:12,120 --> 00:12:14,740 the MCRs are becoming part... 270 00:12:14,740 --> 00:12:16,240 Sorry, the managed code becomes part 271 00:12:16,240 --> 00:12:17,400 of the operating system. 272 00:12:17,780 --> 00:12:20,420 Microsoft is pushing very hard for that. 273 00:12:20,820 --> 00:12:24,600 .NET will perform more and more things 274 00:12:24,600 --> 00:12:27,340 like, let's take an example, .NET PowerShell cmdlets. 275 00:12:28,600 --> 00:12:32,100 And the last thing is that we can perform 276 00:12:32,100 --> 00:12:33,380 some very sophisticated attacks 277 00:12:33,380 --> 00:12:34,500 as we're going to see today. 278 00:12:35,180 --> 00:12:38,260 So when we are talking about language modification 279 00:12:38,260 --> 00:12:39,280 and implementation, 280 00:12:40,880 --> 00:12:43,480 basically what we see here, we see the three layers. 281 00:12:43,660 --> 00:12:45,660 We see here the application level, 282 00:12:45,960 --> 00:12:48,280 the runtime level, and the OS level. 283 00:12:48,780 --> 00:12:51,140 So basically when an application calls 284 00:12:51,140 --> 00:12:53,100 some specific runtime method, 285 00:12:53,100 --> 00:12:55,400 basically the runtime method, 286 00:12:55,500 --> 00:12:57,360 and this is the implementation of the runtime method, 287 00:12:57,440 --> 00:12:58,580 it is being called and executed. 288 00:12:59,020 --> 00:13:02,220 In MCR, we're taking away this method, 289 00:13:02,400 --> 00:13:05,780 throwing away, and writing our own implementation. 290 00:13:06,760 --> 00:13:09,760 So now when the application calls runtime method, 291 00:13:09,880 --> 00:13:12,400 well, basically it does something different, right? 292 00:13:12,500 --> 00:13:15,100 So when a call comes to this method, 293 00:13:15,320 --> 00:13:17,040 well, it goes, generates the code, 294 00:13:17,180 --> 00:13:18,900 and the system will be hacked. 295 00:13:19,240 --> 00:13:20,360 No one can see it. 296 00:13:20,480 --> 00:13:22,480 You cannot detect it from the application level. 297 00:13:23,780 --> 00:13:26,280 If we're talking about an example, 298 00:13:26,440 --> 00:13:30,440 and in the beginning we saw the demo of Java 299 00:13:30,440 --> 00:13:33,180 write line twice towards print line. 300 00:13:33,260 --> 00:13:36,500 This is the Java version for printing a string. 301 00:13:36,760 --> 00:13:38,560 We can do the same thing in .NET. 302 00:13:38,720 --> 00:13:40,460 So basically this is the same code 303 00:13:40,460 --> 00:13:43,140 that was able to perform the same thing 304 00:13:43,140 --> 00:13:44,360 as the string twice. 305 00:13:44,440 --> 00:13:46,140 So I'm just giving it here as a reference. 306 00:13:46,420 --> 00:13:48,360 But basically this is the original code. 307 00:13:48,520 --> 00:13:51,340 What I did in order to make it able to print 308 00:13:51,340 --> 00:13:53,740 a string twice, I just doubled the code, 309 00:13:53,880 --> 00:13:55,520 and the modified code looks like this. 310 00:13:55,640 --> 00:13:57,400 So basically I took the same thing 311 00:13:57,400 --> 00:13:58,720 and doubled the code. 312 00:13:58,820 --> 00:14:03,100 I had to rearrange a little bit the addresses, right? 313 00:14:03,380 --> 00:14:06,320 Because basically I had to calculate, 314 00:14:06,620 --> 00:14:09,100 and this is a very intensive task now. 315 00:14:09,160 --> 00:14:11,080 I just had to calculate the three lines of code. 316 00:14:11,700 --> 00:14:13,220 When we're talking about injections 317 00:14:13,220 --> 00:14:15,420 of very sophisticated attacks, 318 00:14:15,520 --> 00:14:17,540 a very large amount of code, 319 00:14:17,680 --> 00:14:19,980 you have to do a very large amount of calculations. 320 00:14:21,540 --> 00:14:23,600 A little bit about the attack scenarios. 321 00:14:23,960 --> 00:14:27,980 Well, messing with the sandbox, 322 00:14:28,200 --> 00:14:29,880 messing with the application virtual machine 323 00:14:29,880 --> 00:14:32,120 usually requires administrator-level privileges. 324 00:14:33,040 --> 00:14:35,780 And basically we're talking about two main scenarios. 325 00:14:36,040 --> 00:14:37,840 One scenario, this is the scenario 326 00:14:37,840 --> 00:14:39,760 of housekeeping attack vector. 327 00:14:40,020 --> 00:14:42,520 Now we're talking about post-exploitation attacks 328 00:14:42,520 --> 00:14:45,080 in which the attacker has already managed 329 00:14:45,080 --> 00:14:46,620 to gain control of the system 330 00:14:46,620 --> 00:14:49,420 using some other kind of vulnerability. 331 00:14:49,420 --> 00:14:51,340 Now he has control of the system, 332 00:14:51,460 --> 00:14:52,880 and now he's thinking, 333 00:14:53,140 --> 00:14:54,260 what should I do next? 334 00:14:54,860 --> 00:14:58,340 So he can utilize MCRs to his purpose, right? 335 00:14:58,480 --> 00:15:00,400 This is another alternative attack vector 336 00:15:00,400 --> 00:15:01,140 so you can use it. 337 00:15:01,320 --> 00:15:02,760 But in the second scenario, 338 00:15:02,940 --> 00:15:05,060 we're talking about the trusted insider. 339 00:15:05,640 --> 00:15:07,280 This is one of the major problems 340 00:15:07,280 --> 00:15:08,680 that we're facing today in security 341 00:15:08,680 --> 00:15:10,920 in which those are the people 342 00:15:10,920 --> 00:15:12,540 that already have access to the system. 343 00:15:13,040 --> 00:15:14,960 Now we're talking about IT managers. 344 00:15:15,200 --> 00:15:17,540 We're talking about developers, DBAs. 345 00:15:17,600 --> 00:15:19,400 Those guys already have access 346 00:15:19,420 --> 00:15:20,800 to the administrative-level access. 347 00:15:20,920 --> 00:15:23,820 They don't have to steal this access, right? 348 00:15:24,160 --> 00:15:26,640 So they can take advantage of it 349 00:15:26,640 --> 00:15:28,840 and probably install an MCR. 350 00:15:29,180 --> 00:15:32,220 Think about a developer, for example, 351 00:15:32,380 --> 00:15:35,300 that is developing a very sensitive 352 00:15:35,300 --> 00:15:36,540 financing application, 353 00:15:37,920 --> 00:15:39,580 and he knows, for example, 354 00:15:39,620 --> 00:15:40,980 that he'll be reviewed, 355 00:15:41,100 --> 00:15:43,400 and he wants to enter some kind of code 356 00:15:43,400 --> 00:15:47,500 that says, hey, if you see my own bank account, 357 00:15:47,780 --> 00:15:49,400 well, give me a little bit 358 00:15:49,420 --> 00:15:50,960 of space, right? 359 00:15:51,540 --> 00:15:54,200 And those kind of backups are very common 360 00:15:54,200 --> 00:15:57,160 when we're talking about malicious developers. 361 00:15:58,960 --> 00:16:01,820 The implementation techniques can be divided 362 00:16:02,120 --> 00:16:05,140 basically into two parts. 363 00:16:05,320 --> 00:16:06,980 We have the non-invasive techniques. 364 00:16:07,120 --> 00:16:08,520 Those are the ones that are called 365 00:16:08,520 --> 00:16:09,580 by-design techniques. 366 00:16:10,100 --> 00:16:12,100 By-design techniques are techniques 367 00:16:12,100 --> 00:16:14,420 in which you're not hacking anything. 368 00:16:14,600 --> 00:16:16,920 You're just utilizing something 369 00:16:17,120 --> 00:16:18,500 which was there by design 370 00:16:18,500 --> 00:16:20,420 so that the virtual machine lets you 371 00:16:20,420 --> 00:16:23,920 change its meaning using its own controls 372 00:16:23,920 --> 00:16:25,460 and own mechanism. 373 00:16:26,160 --> 00:16:27,520 For example, AOP, 374 00:16:28,480 --> 00:16:30,980 AOP or aspect-oriented programming 375 00:16:31,460 --> 00:16:33,440 using dynamic weaving lets you 376 00:16:33,440 --> 00:16:35,120 inject code into applications. 377 00:16:36,000 --> 00:16:38,100 And configuration modifications, 378 00:16:38,260 --> 00:16:41,100 for example, setting an alternative 379 00:16:41,100 --> 00:16:43,860 evil class loader or, for example, 380 00:16:43,860 --> 00:16:46,160 loading a malicious agent in Java. 381 00:16:46,340 --> 00:16:47,160 This is how you do that. 382 00:16:47,160 --> 00:16:50,060 And maybe messing with the machine 383 00:16:50,060 --> 00:16:51,200 configuring in .NET. 384 00:16:51,560 --> 00:16:53,300 You can do that in all those techniques. 385 00:16:53,540 --> 00:16:56,040 But this is not something which is invasive 386 00:16:56,040 --> 00:16:57,780 if the application inquiries 387 00:16:57,780 --> 00:17:00,040 that the virtual machine knows about it. 388 00:17:00,420 --> 00:17:02,100 And what we're going to discuss today, 389 00:17:02,180 --> 00:17:03,980 we're going to discuss invasive techniques 390 00:17:03,980 --> 00:17:06,520 in which we are talking about direct modification 391 00:17:06,520 --> 00:17:08,080 of the intermediate language code 392 00:17:08,080 --> 00:17:10,480 so that the application would not know 393 00:17:10,480 --> 00:17:11,360 that something happened. 394 00:17:11,660 --> 00:17:13,340 Basically, the virtual machine 395 00:17:13,340 --> 00:17:15,640 lies to the application, right? 396 00:17:16,760 --> 00:17:19,400 So, when we're talking about Java techniques, 397 00:17:19,640 --> 00:17:23,000 Java rootkits, this is just an example 398 00:17:23,000 --> 00:17:24,080 of an invasion technique. 399 00:17:24,260 --> 00:17:26,280 There are many ways of performing the same thing. 400 00:17:26,500 --> 00:17:30,120 What I did here is I took the print stream class, 401 00:17:30,280 --> 00:17:32,780 this class which implements the print line, 402 00:17:32,960 --> 00:17:35,720 I extracted it from arty.jar, 403 00:17:35,860 --> 00:17:38,880 arty, which is the runtime jar 404 00:17:38,880 --> 00:17:42,720 containing all of the code of most of the Java runtime. 405 00:17:42,940 --> 00:17:45,520 I extracted it out, disassembled it, 406 00:17:45,640 --> 00:17:47,180 using Jasper disassembler, 407 00:17:48,140 --> 00:17:51,080 modified the code, recompiled it back, 408 00:17:51,320 --> 00:17:53,540 reassembled it back using Jasmin assembler, 409 00:17:53,620 --> 00:17:56,140 and deployed it back into the runtime, right? 410 00:17:57,100 --> 00:17:58,700 Well, basically, for more information, 411 00:17:58,780 --> 00:18:02,520 you can access this site and get a look at it. 412 00:18:02,860 --> 00:18:04,720 But the interesting thing is that 413 00:18:04,720 --> 00:18:07,760 you can change the .NET language by that 414 00:18:07,760 --> 00:18:09,560 and the application will know about it. 415 00:18:10,180 --> 00:18:12,720 But doing the same thing in .NET, 416 00:18:12,800 --> 00:18:14,920 well, the concept is pretty much similar, 417 00:18:14,920 --> 00:18:16,800 but it's a little bit more complicated 418 00:18:17,520 --> 00:18:22,220 because in .NET, we have the signature mechanism. 419 00:18:22,700 --> 00:18:25,300 And in .NET, we have a signature called strongName 420 00:18:25,790 --> 00:18:30,800 in which all of the assemblies have their own signatures, 421 00:18:30,960 --> 00:18:33,860 so I cannot just take the DLL, change it, 422 00:18:33,940 --> 00:18:35,260 and put it back in its location 423 00:18:35,260 --> 00:18:37,280 because the signature does not match, right? 424 00:18:37,920 --> 00:18:39,640 So what I thought in the beginning, 425 00:18:39,720 --> 00:18:41,000 in the beginning of my research, 426 00:18:41,240 --> 00:18:42,800 I was thinking about, well, 427 00:18:42,800 --> 00:18:46,020 I would just disable the signature mechanism, right? 428 00:18:46,200 --> 00:18:50,640 Or I can just find where the operating system 429 00:18:50,640 --> 00:18:52,400 is hiding the private key 430 00:18:52,400 --> 00:18:55,240 and maybe re-sign back everything, right? 431 00:18:55,900 --> 00:18:58,360 But I found not a better way of doing that. 432 00:18:58,600 --> 00:19:00,880 And the way of doing that, which is very simple, 433 00:19:00,940 --> 00:19:02,820 it's very funny how it happens, 434 00:19:02,980 --> 00:19:04,660 is that, well, the GAC, 435 00:19:04,760 --> 00:19:06,500 this is where the location of the DLL is stored. 436 00:19:06,760 --> 00:19:08,820 This is in C, Windows, assembly, GAC32. 437 00:19:09,320 --> 00:19:11,240 Here you have a directory for each assembly. 438 00:19:11,460 --> 00:19:12,300 So, for example, 439 00:19:12,300 --> 00:19:15,240 MSColib, which is one of the most important DLLs, 440 00:19:16,480 --> 00:19:18,040 MSColib can have many versions. 441 00:19:18,260 --> 00:19:20,560 So each version contains its own directory 442 00:19:21,050 --> 00:19:24,420 that says what is the version of the DLLs of here. 443 00:19:24,540 --> 00:19:28,460 You see the .NET 2.0 DLL for MSColib, 444 00:19:28,620 --> 00:19:30,420 and this is the signature of it. 445 00:19:30,660 --> 00:19:33,760 Well, it turns out that if you take the DLL 446 00:19:33,760 --> 00:19:37,200 and put it back to its location in this directory, 447 00:19:37,960 --> 00:19:40,800 and this contains the signature, right? 448 00:19:44,240 --> 00:19:45,500 It looks at the signature. 449 00:19:45,860 --> 00:19:48,020 It says, hey, I need to load the DLL 450 00:19:48,020 --> 00:19:50,400 containing this signature while I just load it from there. 451 00:19:50,560 --> 00:19:52,340 So no signatures are checked. 452 00:19:52,640 --> 00:19:55,340 And basically, what's so funny about this is that 453 00:19:56,780 --> 00:19:59,580 basically, if we look into it, 454 00:20:00,740 --> 00:20:03,540 well, basically, this mechanism here, 455 00:20:04,660 --> 00:20:06,880 even though that there was some signatures checked, 456 00:20:07,020 --> 00:20:08,660 basically, the attacker could disable them, 457 00:20:08,740 --> 00:20:09,760 lose anything, right? 458 00:20:10,100 --> 00:20:12,220 So basically, due to performance issues, 459 00:20:12,300 --> 00:20:14,940 the verification was disabled. 460 00:20:15,220 --> 00:20:18,560 So now all you have to do is just write your DLL 461 00:20:18,560 --> 00:20:20,900 to the same location, to the correct location that you want. 462 00:20:21,160 --> 00:20:24,580 And the last thing that you want to do is to avoid engine. 463 00:20:24,740 --> 00:20:27,360 Engine is a precompiled code, 464 00:20:27,560 --> 00:20:29,460 so we would like to throw away 465 00:20:29,460 --> 00:20:32,060 the cached version of the old, right? 466 00:20:32,280 --> 00:20:34,820 So you just disable the old code, 467 00:20:34,900 --> 00:20:39,100 the caching using engine uninstall and the previous DLL. 468 00:20:39,360 --> 00:20:41,620 Basically, from here on, you can remove traces 469 00:20:41,620 --> 00:20:42,380 with engine. 470 00:20:42,620 --> 00:20:44,040 Go read the white paper. 471 00:20:44,160 --> 00:20:46,840 It contains information about this kind of stuff. 472 00:20:48,820 --> 00:20:51,440 Up until now, we've talked about the techniques 473 00:20:51,440 --> 00:20:54,040 of changing the dotted language or the Java language. 474 00:20:54,680 --> 00:20:56,840 From now on, we're talking about more generic stuff. 475 00:20:57,240 --> 00:20:59,240 Basically, one of the important things is that 476 00:20:59,240 --> 00:21:00,660 we can extend the language. 477 00:21:00,860 --> 00:21:03,620 We can add features to the language. 478 00:21:03,880 --> 00:21:05,500 We can add new methods. 479 00:21:05,900 --> 00:21:08,540 I call it method or function injection 480 00:21:08,540 --> 00:21:11,600 because you're adding new methods to the language. 481 00:21:11,620 --> 00:21:14,940 For example, if you want to do the same thing 482 00:21:14,940 --> 00:21:15,760 again and again and again, 483 00:21:15,960 --> 00:21:19,160 instead of writing the same code, 484 00:21:19,480 --> 00:21:22,000 just wrap your code as a new method, right? 485 00:21:22,160 --> 00:21:23,560 And pass parameters to it. 486 00:21:24,600 --> 00:21:25,480 Just call your method. 487 00:21:26,160 --> 00:21:28,280 So basically, I've implemented a couple of methods. 488 00:21:28,400 --> 00:21:30,160 One of them is called send to URL. 489 00:21:30,700 --> 00:21:34,360 What it says is that it will send some data 490 00:21:34,360 --> 00:21:36,820 from an attack machine to the attackers. 491 00:21:36,880 --> 00:21:38,820 So the parameters is where to send it 492 00:21:38,820 --> 00:21:40,280 and what is the data. 493 00:21:41,160 --> 00:21:41,940 Reverse shell. 494 00:21:42,400 --> 00:21:45,820 Please open a reverse shell for me in IP and port. 495 00:21:45,960 --> 00:21:48,740 So specific stuff that I need to call for this function. 496 00:21:49,660 --> 00:21:50,460 Hide file. 497 00:21:51,580 --> 00:21:52,440 Inject class. 498 00:21:52,960 --> 00:21:55,440 Man in the middle, which returns a man in the middle socket. 499 00:21:56,000 --> 00:21:58,100 And in key log event handler. 500 00:21:58,220 --> 00:21:59,600 All of those are examples of things 501 00:21:59,600 --> 00:22:01,500 that can be injected into runtime. 502 00:22:02,300 --> 00:22:05,160 But when we're talking about managed code, 503 00:22:05,420 --> 00:22:07,140 usually managed code is implementing 504 00:22:07,140 --> 00:22:08,760 object-oriented concepts. 505 00:22:08,760 --> 00:22:12,400 And one of the interesting things about object-oriented 506 00:22:12,400 --> 00:22:16,840 is that we have the notion of inheritance. 507 00:22:17,360 --> 00:22:19,440 So basically, if you have a class 508 00:22:19,440 --> 00:22:21,460 that you want the class to contain code, 509 00:22:21,720 --> 00:22:23,220 to extend code of other classes, 510 00:22:23,220 --> 00:22:24,920 you're just inheriting from that class. 511 00:22:25,140 --> 00:22:28,620 And, well, all of the classes are inheriting 512 00:22:28,620 --> 00:22:30,380 from a class called object. 513 00:22:30,640 --> 00:22:34,120 So basically, we have something like a tree of classes. 514 00:22:34,400 --> 00:22:38,580 And object is the utmost class. 515 00:22:38,760 --> 00:22:41,140 So basically, if we want to inject code 516 00:22:41,140 --> 00:22:43,860 that will be inherited to all of the classes 517 00:22:43,860 --> 00:22:44,920 in the runtime, 518 00:22:45,260 --> 00:22:46,880 all we have to do is inject it into object. 519 00:22:48,380 --> 00:22:50,700 And we can do other interesting things. 520 00:22:50,740 --> 00:22:53,600 For example, we can inject into sub-tree, 521 00:22:54,200 --> 00:22:55,160 into a branch. 522 00:22:55,380 --> 00:22:57,740 For example, let's say that we want to inject 523 00:22:57,740 --> 00:22:59,640 only to this sub-tree. 524 00:23:00,360 --> 00:23:04,120 So all we have to do is inject into here. 525 00:23:05,640 --> 00:23:08,740 So basically, inheritance will do it for us. 526 00:23:08,760 --> 00:23:11,080 So we just need to look for . 527 00:23:12,620 --> 00:23:16,920 So a little bit about the development scenarios 528 00:23:16,920 --> 00:23:18,860 where we can do many interesting things. 529 00:23:19,160 --> 00:23:21,460 And I want to save time to show you some demos. 530 00:23:21,560 --> 00:23:23,480 So let's start with the first one. 531 00:23:23,720 --> 00:23:27,520 But the first one, here we're talking about 532 00:23:27,520 --> 00:23:30,000 stealing the authentication credentials 533 00:23:30,840 --> 00:23:34,140 from the runtime authentication mechanism. 534 00:23:34,800 --> 00:23:37,460 We're not talking about the application level 535 00:23:37,460 --> 00:23:38,620 authentication code. 536 00:23:38,760 --> 00:23:40,480 We're talking about the runtime method, 537 00:23:40,780 --> 00:23:43,720 a Boolean method that gets from the application 538 00:23:43,720 --> 00:23:44,560 username and password 539 00:23:44,560 --> 00:23:46,200 and returns back the true-force answer. 540 00:23:46,640 --> 00:23:48,840 So what we're going to see about here is that 541 00:23:48,840 --> 00:23:52,160 we're going to inject into an internal authentication method 542 00:23:53,140 --> 00:23:55,540 code that says something like, 543 00:23:55,700 --> 00:23:58,460 well, take the username and password that you now have. 544 00:23:58,540 --> 00:24:00,120 Well, this is an internal class members. 545 00:24:00,300 --> 00:24:03,500 Take it from the class and send it to the attacker 546 00:24:03,500 --> 00:24:07,400 using our own send to URL class. 547 00:24:07,800 --> 00:24:08,320 Right? 548 00:24:08,760 --> 00:24:11,340 So we've injected the code to send to your method. 549 00:24:11,640 --> 00:24:13,380 And now we are just calling it and saying, 550 00:24:13,500 --> 00:24:16,720 well, I want to send you to me the username and password of the user. 551 00:24:17,380 --> 00:24:19,460 And let's see a demo about that. 552 00:24:20,440 --> 00:24:24,300 Well, in our demo, we're going to see an attacked application. 553 00:24:24,900 --> 00:24:27,000 Well, think about a hosting application, 554 00:24:27,360 --> 00:24:30,060 a hosting management system in which you have many applications 555 00:24:30,060 --> 00:24:30,920 on the same machine. 556 00:24:30,980 --> 00:24:32,820 We are attacking all of them at once. 557 00:24:33,340 --> 00:24:37,920 So we're talking about a rich bank, a rich bank server, 558 00:24:37,920 --> 00:24:39,200 which we have many users. 559 00:24:39,480 --> 00:24:42,540 And the login page, if this is the login page, 560 00:24:42,540 --> 00:24:43,560 this is the login page code. 561 00:24:43,700 --> 00:24:46,840 The login page code calls the action of the button click 562 00:24:46,840 --> 00:24:49,220 is to call forms authentication, authenticate, 563 00:24:49,300 --> 00:24:50,420 sending the username and password, 564 00:24:50,580 --> 00:24:52,540 and calling the runtime method. 565 00:24:52,660 --> 00:24:55,460 So runtime method has been hijacked 566 00:24:55,460 --> 00:24:58,280 so that in the end of the original code, 567 00:24:58,440 --> 00:24:59,800 we can see a call to send to URL. 568 00:25:00,640 --> 00:25:02,560 And the data will be sent to the attacker. 569 00:25:03,540 --> 00:25:05,020 Well, in this demonstration, 570 00:25:05,160 --> 00:25:06,800 we're going to talk about an application 571 00:25:06,800 --> 00:25:08,520 and a server called rich bank. 572 00:25:08,760 --> 00:25:10,960 Well, rich bank, believe me, 573 00:25:10,980 --> 00:25:14,280 that they have lots and lots and lots of money. 574 00:25:14,580 --> 00:25:18,520 So this is the place where attackers would probably want to attack. 575 00:25:22,580 --> 00:25:24,920 So in this application, 576 00:25:25,300 --> 00:25:29,420 the low-level implementation was being hijacked 577 00:25:29,420 --> 00:25:31,380 so that what we're going to see now, 578 00:25:31,460 --> 00:25:34,760 we're going to put our user over here. 579 00:25:36,000 --> 00:25:38,640 And let's have the server. 580 00:25:46,100 --> 00:25:48,060 Let's have one attacker. 581 00:25:50,600 --> 00:25:51,080 There. 582 00:25:51,200 --> 00:25:53,300 And in our attacker, well, our attacker, 583 00:25:53,340 --> 00:25:56,100 let me just make sure that I'm running on the right machine. 584 00:25:57,520 --> 00:25:58,000 Yeah. 585 00:25:58,960 --> 00:25:59,740 Look at this. 586 00:26:01,400 --> 00:26:03,460 Well, when the attacker receives the data, 587 00:26:03,600 --> 00:26:04,660 data will be sent. 588 00:26:04,760 --> 00:26:07,200 It will be written into this directory called received input. 589 00:26:07,460 --> 00:26:10,020 So I'm going to put my attacker over here. 590 00:26:12,380 --> 00:26:15,680 So basically, the flow will be something like this. 591 00:26:15,780 --> 00:26:17,680 The user will enter his credentials. 592 00:26:17,980 --> 00:26:19,360 It will go through the application, 593 00:26:19,660 --> 00:26:20,460 through the runtime, 594 00:26:20,880 --> 00:26:23,740 and into the received input directory, right? 595 00:26:23,900 --> 00:26:24,880 This will be the flow. 596 00:26:26,760 --> 00:26:30,860 So let's take our attacker. 597 00:26:34,580 --> 00:26:38,200 And let me put here my credentials 598 00:26:38,200 --> 00:26:40,520 that I'm going to write something which is wrong. 599 00:26:40,640 --> 00:26:42,800 So this is blah, blah, blah, right? 600 00:26:43,840 --> 00:26:45,540 And as I'll log in, 601 00:26:45,600 --> 00:26:47,880 take a close look what happens over here. 602 00:26:48,100 --> 00:26:50,200 So logged in. 603 00:26:50,300 --> 00:26:51,320 Well, access is denied. 604 00:26:55,480 --> 00:26:56,360 Let's go back. 605 00:26:56,500 --> 00:26:57,680 And now... 606 00:27:00,860 --> 00:27:03,800 Now I will authenticate this as it used to be. 607 00:27:08,380 --> 00:27:08,900 Again. 608 00:27:10,400 --> 00:27:10,920 Right. 609 00:27:13,640 --> 00:27:17,040 So now let's go to the attacker's machine. 610 00:27:17,940 --> 00:27:19,260 Let's see what it takes. 611 00:27:19,900 --> 00:27:24,740 So I can see that the log file says that the user has tried to login with password blah, blah, 612 00:27:24,820 --> 00:27:28,340 and that the user has tried to login with password 166. 613 00:27:29,140 --> 00:27:29,660 So... 614 00:27:29,660 --> 00:27:33,380 And this was in a demo of hijacking the forms authentication. 615 00:27:37,900 --> 00:27:38,420 Thank you. 616 00:27:46,260 --> 00:27:49,240 If you're talking about another attack on the same method, 617 00:27:49,420 --> 00:27:50,780 well, this is another attack vector. 618 00:27:50,980 --> 00:27:53,080 Now we're attacking authenticate, 619 00:27:53,220 --> 00:27:57,840 but only now we are inserting a backdoor into the authenticate method. 620 00:27:58,240 --> 00:27:59,460 So that now... 621 00:27:59,660 --> 00:28:02,320 We are talking about adding this piece of code. 622 00:28:02,580 --> 00:28:04,080 This piece of code says, 623 00:28:04,180 --> 00:28:07,220 and it's very similar to what developers like to do. 624 00:28:07,340 --> 00:28:07,920 It says, 625 00:28:08,040 --> 00:28:11,320 if you have some specific magic password, 626 00:28:11,560 --> 00:28:15,460 this magic password will let you in into any account that you like. 627 00:28:16,180 --> 00:28:16,700 Right? 628 00:28:16,800 --> 00:28:18,360 And the code says, like, 629 00:28:18,380 --> 00:28:19,720 if the password is magic, 630 00:28:19,860 --> 00:28:20,780 it will let you in. 631 00:28:20,880 --> 00:28:24,480 If I will look at the same thing after disassembling it, 632 00:28:24,680 --> 00:28:25,820 editing the code, 633 00:28:25,900 --> 00:28:27,680 basically injecting this code, 634 00:28:27,820 --> 00:28:29,020 assembling it back, 635 00:28:29,020 --> 00:28:31,440 and decompiling it into C sharp, 636 00:28:31,620 --> 00:28:33,220 so we can have a better look at it, 637 00:28:33,320 --> 00:28:34,560 it looks something like this. 638 00:28:35,600 --> 00:28:36,040 Okay? 639 00:28:36,180 --> 00:28:38,440 So this is the if, basically. 640 00:28:39,200 --> 00:28:41,820 Now we can enter it into any account. 641 00:28:42,900 --> 00:28:45,840 Well, another example that we'll see later on, 642 00:28:45,900 --> 00:28:47,380 this is about reverse shelling. 643 00:28:47,560 --> 00:28:48,740 And in reverse shell, 644 00:28:48,860 --> 00:28:50,020 basically what I did, 645 00:28:50,040 --> 00:28:52,700 I took an implementation of netcat. 646 00:28:52,920 --> 00:28:56,720 Basically I could do it in a million ways of doing the same thing. 647 00:28:56,880 --> 00:28:57,540 What I did is, 648 00:28:57,540 --> 00:29:00,560 I took a coded version of netcat, 649 00:29:00,700 --> 00:29:01,640 pushed it back, 650 00:29:01,720 --> 00:29:02,440 the executable, 651 00:29:02,500 --> 00:29:03,320 into the runtime, 652 00:29:03,620 --> 00:29:05,440 and when something is executed, 653 00:29:05,580 --> 00:29:07,400 and netcat is being deployed to this, 654 00:29:07,520 --> 00:29:07,980 it executed. 655 00:29:08,340 --> 00:29:10,680 Well, you can do it in very other ways. 656 00:29:10,760 --> 00:29:11,100 For example, 657 00:29:11,100 --> 00:29:12,720 you can inject it into memory, 658 00:29:12,980 --> 00:29:14,460 so that you will not have traces. 659 00:29:14,640 --> 00:29:15,180 But basically, 660 00:29:15,380 --> 00:29:17,360 the idea is to execute code 661 00:29:17,360 --> 00:29:19,440 when some specific thing happens. 662 00:29:19,740 --> 00:29:20,980 And in our example, 663 00:29:21,880 --> 00:29:24,860 the code was injected into application run. 664 00:29:25,020 --> 00:29:26,960 Run is a method 665 00:29:26,960 --> 00:29:29,680 that each time an application is executed. 666 00:29:30,160 --> 00:29:32,940 Basically, this is like a main in a C++ application. 667 00:29:33,660 --> 00:29:35,440 And the code that was injected here, 668 00:29:35,680 --> 00:29:36,880 well, this is a code that says, 669 00:29:37,020 --> 00:29:37,760 as we can see, 670 00:29:37,840 --> 00:29:38,900 this is a pre-injection code. 671 00:29:38,980 --> 00:29:41,360 The code is injected into the beginning of the method. 672 00:29:42,280 --> 00:29:43,700 We can see code that says, 673 00:29:43,840 --> 00:29:47,100 well, call our own reverse shell method. 674 00:29:47,640 --> 00:29:49,740 Basically, I've injected reverse shell before that. 675 00:29:50,100 --> 00:29:51,740 And pass on the parameters, 676 00:29:52,000 --> 00:29:53,660 the attacker's machine IP, 677 00:29:53,820 --> 00:29:54,700 and the port. 678 00:29:55,180 --> 00:29:56,880 So this is all the attacker needs to do. 679 00:29:56,960 --> 00:29:59,300 When reverse shell has already been injected. 680 00:29:59,640 --> 00:30:02,460 So that all it has to do, 681 00:30:02,480 --> 00:30:04,560 just pass on the parameters to the stack 682 00:30:04,560 --> 00:30:07,560 and close the port. 683 00:30:08,720 --> 00:30:09,920 We'll see a demo of that later. 684 00:30:12,140 --> 00:30:12,940 Crypto attacks. 685 00:30:13,500 --> 00:30:15,280 Well, crypto attacks, 686 00:30:15,500 --> 00:30:18,120 those attacks are very important 687 00:30:18,120 --> 00:30:19,360 and very interesting. 688 00:30:19,460 --> 00:30:20,580 Because crypto, 689 00:30:20,680 --> 00:30:23,520 this is something which directly relates to security. 690 00:30:23,920 --> 00:30:26,840 And when someone attacks, 691 00:30:26,960 --> 00:30:28,340 your crypto libraries, 692 00:30:28,600 --> 00:30:29,160 basically, 693 00:30:30,040 --> 00:30:32,260 he's creating a false sense of security. 694 00:30:33,260 --> 00:30:35,460 Because you're trusting the crypto libraries, 695 00:30:35,700 --> 00:30:36,660 and for example, 696 00:30:36,720 --> 00:30:39,060 you think that you've done everything right. 697 00:30:39,500 --> 00:30:40,780 So basically, if someone, 698 00:30:40,960 --> 00:30:41,540 for example, 699 00:30:41,720 --> 00:30:43,120 let's talk about some examples, 700 00:30:43,140 --> 00:30:43,760 some attack scenarios. 701 00:30:44,180 --> 00:30:45,300 Key fixation. 702 00:30:46,160 --> 00:30:48,020 When someone fixates your key, 703 00:30:48,080 --> 00:30:49,780 you're thinking that you're encrypting 704 00:30:49,780 --> 00:30:51,900 with your chosen key, 705 00:30:52,020 --> 00:30:54,100 but you're encrypting with another key. 706 00:30:54,580 --> 00:30:55,460 Key stealing. 707 00:30:55,460 --> 00:30:56,220 For example, 708 00:30:56,400 --> 00:30:57,980 stealing the correct key 709 00:30:57,980 --> 00:31:00,420 from inside the crypto class 710 00:31:00,420 --> 00:31:01,920 using Centro Euro. 711 00:31:02,160 --> 00:31:03,980 Or algorithm downgrading. 712 00:31:03,980 --> 00:31:04,580 For example, 713 00:31:04,600 --> 00:31:07,400 the application asks for AES implementation. 714 00:31:07,980 --> 00:31:09,000 What it gets back 715 00:31:09,000 --> 00:31:10,580 is easy crackable death. 716 00:31:11,700 --> 00:31:12,340 Right? 717 00:31:12,860 --> 00:31:15,360 And an example code for that is that 718 00:31:15,360 --> 00:31:18,760 if this is the generate key method, 719 00:31:18,920 --> 00:31:20,280 this is the method that creates 720 00:31:20,280 --> 00:31:22,140 the key for the application. 721 00:31:23,220 --> 00:31:24,360 Basically, what I did is, 722 00:31:24,360 --> 00:31:26,780 I reverse engineered this method, 723 00:31:27,100 --> 00:31:28,800 throw away its own implementation, 724 00:31:29,220 --> 00:31:30,920 and now I have something that says, 725 00:31:31,100 --> 00:31:33,380 return always fixated key. 726 00:31:35,000 --> 00:31:37,760 Again, from the user point of view, 727 00:31:37,940 --> 00:31:39,740 he thinks everything is encrypted. 728 00:31:40,060 --> 00:31:41,720 Well, the data looks encrypted, right? 729 00:31:42,020 --> 00:31:43,400 If you look at the data, 730 00:31:43,460 --> 00:31:45,540 the data, it's looking encrypted. 731 00:31:45,820 --> 00:31:47,300 You will decrypt it, 732 00:31:47,380 --> 00:31:48,280 everything works fine, 733 00:31:48,440 --> 00:31:50,000 but you do not know that 734 00:31:50,000 --> 00:31:52,860 your key is not relevant. 735 00:31:55,420 --> 00:31:57,240 Well, DNS manipulation. 736 00:31:58,080 --> 00:31:59,040 In DNS manipulation, 737 00:31:59,320 --> 00:32:00,080 we are talking about 738 00:32:00,080 --> 00:32:02,540 taking the user to some place 739 00:32:02,540 --> 00:32:03,780 that he didn't want to go to. 740 00:32:04,900 --> 00:32:07,020 This is an example Java rootkit 741 00:32:07,020 --> 00:32:10,300 in which a code was injected 742 00:32:10,300 --> 00:32:11,900 into the DNS classes 743 00:32:11,900 --> 00:32:13,480 so that whenever resolving 744 00:32:13,480 --> 00:32:14,240 will be performed. 745 00:32:14,940 --> 00:32:15,920 For instance, 746 00:32:16,060 --> 00:32:20,380 for a server called www.forexserver.com, 747 00:32:21,260 --> 00:32:23,040 the resolving will be performed 748 00:32:23,040 --> 00:32:24,380 to the attacker's IP. 749 00:32:24,740 --> 00:32:25,200 Right? 750 00:32:25,200 --> 00:32:26,640 To the attacker's machine, 751 00:32:26,780 --> 00:32:28,360 www.attacker.com. 752 00:32:29,120 --> 00:32:30,480 Basically, it looks like this. 753 00:32:30,580 --> 00:32:33,500 This is the original code of get by name. 754 00:32:33,660 --> 00:32:35,080 This is Java's implementation 755 00:32:35,080 --> 00:32:38,220 of performing DNS resolving. 756 00:32:38,880 --> 00:32:40,300 .NET is get host addresses, 757 00:32:40,460 --> 00:32:41,200 basically the same. 758 00:32:41,820 --> 00:32:43,220 I've injected the code 759 00:32:43,220 --> 00:32:44,620 that something like this. 760 00:32:45,240 --> 00:32:48,440 So now, if the code comes to resolve s, 761 00:32:48,620 --> 00:32:49,740 well, I overwrite, 762 00:32:49,760 --> 00:32:51,540 if s equals forexserver, 763 00:32:51,540 --> 00:32:52,600 I will overwrite s 764 00:32:52,600 --> 00:32:55,160 and return s as it was supposed to. 765 00:32:57,660 --> 00:32:59,680 I hope that I have a couple of minutes 766 00:32:59,680 --> 00:33:00,760 for this demo, 767 00:33:00,840 --> 00:33:03,140 so let's start it very soon. 768 00:33:04,020 --> 00:33:05,220 This is the quote server. 769 00:33:06,580 --> 00:33:09,840 This will be our client. 770 00:33:10,460 --> 00:33:12,080 Well, now the victim, 771 00:33:13,660 --> 00:33:15,720 as opposed to the usual demonstration, 772 00:33:16,520 --> 00:33:18,100 is going to take backtrack. 773 00:33:19,460 --> 00:33:20,760 Backtrack is awesome, right? 774 00:33:21,820 --> 00:33:22,420 . 775 00:33:27,260 --> 00:33:29,240 But now we're going to see 776 00:33:29,240 --> 00:33:30,220 it twist the backtrack 777 00:33:30,220 --> 00:33:31,480 and use it as the victim. 778 00:33:32,480 --> 00:33:33,920 Think about what happens 779 00:33:33,920 --> 00:33:35,180 when you download OS 780 00:33:35,180 --> 00:33:37,320 from untrusted sources, right? 781 00:33:37,520 --> 00:33:38,940 Guys, stop downloading 782 00:33:38,940 --> 00:33:43,420 Kaiser OS from . 783 00:33:47,420 --> 00:33:48,620 Might contain... 784 00:33:50,060 --> 00:33:51,640 Your system might be hacked. 785 00:33:53,200 --> 00:33:54,720 So, I'm going to use, 786 00:33:54,880 --> 00:33:55,520 as a victim, 787 00:33:55,780 --> 00:33:56,760 a Linux machine. 788 00:33:57,080 --> 00:33:58,380 And the interesting thing is 789 00:33:58,380 --> 00:33:59,440 that class that I wrote 790 00:33:59,440 --> 00:34:00,720 and it executes 791 00:34:00,720 --> 00:34:01,760 as it's supposed to be 792 00:34:01,760 --> 00:34:03,180 on Windows machine, 793 00:34:03,360 --> 00:34:04,840 I've deployed the same class 794 00:34:04,840 --> 00:34:06,500 on Linux machine, right? 795 00:34:06,940 --> 00:34:08,520 So, and this is where 796 00:34:08,520 --> 00:34:11,440 our virtual machine comes into place 797 00:34:11,440 --> 00:34:13,980 so that my user... 798 00:34:14,500 --> 00:34:15,760 Let's put it over here. 799 00:34:15,900 --> 00:34:17,000 And now we're going to perform 800 00:34:17,000 --> 00:34:17,880 a man-in-the-middle attack. 801 00:34:18,960 --> 00:34:21,080 So, let's take our own attacker 802 00:34:21,620 --> 00:34:23,040 and the attacker has his own 803 00:34:23,040 --> 00:34:23,940 man-in-the-middle server. 804 00:34:25,560 --> 00:34:26,680 As you can see, 805 00:34:26,760 --> 00:34:28,160 he's waiting for a victim. 806 00:34:29,880 --> 00:34:31,280 Let's put this guy over here. 807 00:34:31,620 --> 00:34:32,980 Let's put this guy over here. 808 00:34:35,020 --> 00:34:35,500 So... 809 00:34:36,860 --> 00:34:38,080 Now I can see that 810 00:34:38,080 --> 00:34:39,960 we have clear separation. 811 00:34:40,360 --> 00:34:41,540 It's different machines, guys, 812 00:34:41,660 --> 00:34:42,540 different IPs. 813 00:34:42,540 --> 00:34:43,020 I'm not cheating. 814 00:34:44,760 --> 00:34:46,300 So, as you might see, 815 00:34:46,340 --> 00:34:47,000 as you can see, 816 00:34:47,040 --> 00:34:47,980 and take a close look, 817 00:34:47,980 --> 00:34:49,300 when I do a connect, 818 00:34:49,400 --> 00:34:50,600 connection's supposed to be 819 00:34:50,600 --> 00:34:52,680 happened to 4x code server to here. 820 00:34:53,920 --> 00:34:54,780 Take a close look, 821 00:34:54,840 --> 00:34:55,620 you will see that connection 822 00:34:55,620 --> 00:34:57,040 will be opened first over here. 823 00:34:57,200 --> 00:34:58,360 Well, it might be too fast, 824 00:34:58,460 --> 00:34:59,820 but I hope that it works out. 825 00:35:01,100 --> 00:35:01,820 Connect and... 826 00:35:03,580 --> 00:35:03,940 Yeah. 827 00:35:11,440 --> 00:35:12,620 But it is not the end of it. 828 00:35:13,320 --> 00:35:14,060 Well, basically, 829 00:35:14,260 --> 00:35:15,300 I could have stopped here 830 00:35:15,300 --> 00:35:16,800 because taking the user 831 00:35:16,800 --> 00:35:17,900 to the wrong place is bad enough. 832 00:35:17,900 --> 00:35:18,100 Right? 833 00:35:18,640 --> 00:35:19,180 But here, 834 00:35:19,260 --> 00:35:20,420 the attacker's mission was 835 00:35:20,420 --> 00:35:21,980 to make and to cheat, 836 00:35:22,060 --> 00:35:23,140 to fool the user. 837 00:35:23,340 --> 00:35:24,120 And with this, 838 00:35:24,160 --> 00:35:25,160 we are talking about 839 00:35:25,160 --> 00:35:26,300 both 4x server. 840 00:35:26,500 --> 00:35:27,780 So, I want to make 841 00:35:27,780 --> 00:35:29,240 the user looks like, 842 00:35:29,300 --> 00:35:30,640 for example, 843 00:35:32,260 --> 00:35:33,700 the British pound. 844 00:35:34,060 --> 00:35:36,380 It's something which is worth buying. 845 00:35:38,060 --> 00:35:40,320 Let's say this. 846 00:35:41,320 --> 00:35:43,240 And it's supposed to be 847 00:35:43,240 --> 00:35:44,000 this. 848 00:35:45,520 --> 00:35:46,120 And... 849 00:35:46,780 --> 00:35:47,380 Well, 850 00:35:47,500 --> 00:35:47,880 the user is going to 851 00:35:47,880 --> 00:35:48,320 see that. 852 00:35:49,820 --> 00:35:50,560 And they say, 853 00:35:50,660 --> 00:35:51,160 hey, great. 854 00:35:51,180 --> 00:35:52,340 Great British pound. 855 00:35:52,520 --> 00:35:54,180 Let's buy a couple of those. 856 00:35:55,760 --> 00:35:57,280 Give me 10,000 of those. 857 00:35:58,440 --> 00:35:58,960 Great. 858 00:35:59,840 --> 00:36:00,700 Transaction accepted 859 00:36:00,700 --> 00:36:02,780 and the user was fooled. 860 00:36:03,620 --> 00:36:04,760 So, this is the end 861 00:36:04,760 --> 00:36:05,900 of this demo 862 00:36:05,900 --> 00:36:07,840 about DNS manipulation. 863 00:36:08,200 --> 00:36:10,120 Let's take a look 864 00:36:10,120 --> 00:36:11,180 at other examples. 865 00:36:11,880 --> 00:36:12,520 Thank you. 866 00:36:13,280 --> 00:36:14,060 Thank you. 867 00:36:14,960 --> 00:36:15,480 Thank you. 868 00:36:17,340 --> 00:36:17,860 Thank you. 869 00:36:18,980 --> 00:36:20,400 So, stealing connection strings, 870 00:36:20,560 --> 00:36:21,060 this is something 871 00:36:21,060 --> 00:36:22,600 where the application... 872 00:36:23,220 --> 00:36:24,640 The application is performing 873 00:36:24,640 --> 00:36:25,780 a lot of interesting things. 874 00:36:26,300 --> 00:36:27,700 And one of the important things 875 00:36:27,700 --> 00:36:28,380 is timing. 876 00:36:28,740 --> 00:36:30,060 Well, in timing attacks, 877 00:36:30,480 --> 00:36:31,500 your attack is supposed 878 00:36:31,500 --> 00:36:32,500 to be executing 879 00:36:32,500 --> 00:36:34,580 when some specific thing happens. 880 00:36:34,860 --> 00:36:35,620 For example, 881 00:36:35,760 --> 00:36:36,820 stealing connection strings 882 00:36:36,820 --> 00:36:37,340 to databases 883 00:36:37,340 --> 00:36:39,020 is supposed to happen 884 00:36:39,020 --> 00:36:39,860 when an application 885 00:36:39,860 --> 00:36:41,240 opens a connection 886 00:36:41,240 --> 00:36:41,840 to the database. 887 00:36:42,120 --> 00:36:42,280 Right? 888 00:36:42,660 --> 00:36:43,760 You cannot just 889 00:36:43,760 --> 00:36:44,800 put some code 890 00:36:44,800 --> 00:36:46,920 in some very general place. 891 00:36:47,120 --> 00:36:47,860 You need to do 892 00:36:47,880 --> 00:36:49,260 it in some specific place. 893 00:36:50,400 --> 00:36:52,240 And I wanted to inject code 894 00:36:52,240 --> 00:36:53,580 that does something like this. 895 00:36:53,660 --> 00:36:56,040 Well, take this dot connection string 896 00:36:56,040 --> 00:36:57,140 and send it to the attacker. 897 00:36:57,480 --> 00:36:58,400 But the thing is 898 00:36:58,400 --> 00:36:59,360 that I cannot inject it 899 00:36:59,360 --> 00:37:00,100 into the constructor 900 00:37:00,100 --> 00:37:00,800 of the object. 901 00:37:00,980 --> 00:37:02,020 I need to inject it 902 00:37:02,020 --> 00:37:02,480 into a place 903 00:37:02,480 --> 00:37:02,920 that I know 904 00:37:02,920 --> 00:37:04,760 that where it is being called, 905 00:37:05,380 --> 00:37:06,640 the connection string 906 00:37:06,640 --> 00:37:08,140 will already be initialized. 907 00:37:08,920 --> 00:37:10,260 The right place to do that 908 00:37:10,260 --> 00:37:10,940 is in open. 909 00:37:11,200 --> 00:37:12,040 When the application 910 00:37:12,040 --> 00:37:12,800 code is open, 911 00:37:12,860 --> 00:37:13,660 it should still 912 00:37:13,660 --> 00:37:14,320 be initialized. 913 00:37:14,560 --> 00:37:14,960 Right? 914 00:37:17,100 --> 00:37:17,740 Permanent edge 915 00:37:17,740 --> 00:37:17,860 testing. 916 00:37:17,880 --> 00:37:17,960 The HTML 917 00:37:17,960 --> 00:37:19,020 and JavaScript injection 918 00:37:19,020 --> 00:37:20,880 is where the code 919 00:37:22,500 --> 00:37:23,560 is being injected 920 00:37:23,560 --> 00:37:25,560 into not necessarily 921 00:37:25,560 --> 00:37:26,300 code sections 922 00:37:26,300 --> 00:37:27,580 but code templates. 923 00:37:27,920 --> 00:37:28,620 For example, 924 00:37:29,720 --> 00:37:30,920 HTML blocks, 925 00:37:31,220 --> 00:37:32,120 JavaScript blocks 926 00:37:32,120 --> 00:37:33,320 and stuff like that. 927 00:37:33,460 --> 00:37:34,540 So we can inject, 928 00:37:34,620 --> 00:37:35,060 for example, 929 00:37:35,160 --> 00:37:36,460 permanent cross-site scripting. 930 00:37:36,680 --> 00:37:38,580 We can perform proxies, 931 00:37:38,580 --> 00:37:39,120 many in the middle, 932 00:37:39,320 --> 00:37:40,440 defacement attacks. 933 00:37:40,720 --> 00:37:42,000 And one of my favorites, 934 00:37:42,240 --> 00:37:43,320 calls to browser 935 00:37:43,320 --> 00:37:44,540 exploitation frameworks 936 00:37:44,540 --> 00:37:45,320 such as 937 00:37:45,320 --> 00:37:46,660 XSS Shields. 938 00:37:46,820 --> 00:37:47,500 Right? 939 00:37:47,560 --> 00:37:47,860 So, 940 00:37:47,880 --> 00:37:48,280 you all know 941 00:37:48,280 --> 00:37:49,040 XSS Shield, 942 00:37:49,120 --> 00:37:49,320 right? 943 00:37:50,500 --> 00:37:51,780 You know XSS Shield, 944 00:37:51,860 --> 00:37:52,080 guys? 945 00:37:53,080 --> 00:37:53,600 Great 946 00:37:53,600 --> 00:37:54,580 . 947 00:37:57,040 --> 00:37:58,480 Speaking into secure string, 948 00:37:58,620 --> 00:37:59,300 this is where we are 949 00:37:59,300 --> 00:38:00,580 stealing data 950 00:38:00,580 --> 00:38:02,500 from something 951 00:38:02,500 --> 00:38:03,020 which is called 952 00:38:03,020 --> 00:38:03,640 a secure string. 953 00:38:03,760 --> 00:38:04,400 This is a string 954 00:38:04,400 --> 00:38:05,280 that contains, 955 00:38:05,580 --> 00:38:06,720 this is a string 956 00:38:06,720 --> 00:38:07,500 which is encrypted 957 00:38:07,500 --> 00:38:08,060 in memory. 958 00:38:08,360 --> 00:38:08,800 Well, 959 00:38:09,000 --> 00:38:09,860 if the string 960 00:38:09,860 --> 00:38:10,540 is encrypted, 961 00:38:10,780 --> 00:38:11,380 this is because 962 00:38:11,380 --> 00:38:12,220 someone wanted 963 00:38:12,220 --> 00:38:12,660 to hide 964 00:38:12,660 --> 00:38:13,180 something 965 00:38:13,180 --> 00:38:14,120 which is very valuable. 966 00:38:14,940 --> 00:38:15,740 Let's steal it 967 00:38:15,740 --> 00:38:16,020 from there. 968 00:38:17,280 --> 00:38:17,800 And, 969 00:38:17,800 --> 00:38:18,580 this is the code 970 00:38:18,580 --> 00:38:19,100 that can do that. 971 00:38:19,140 --> 00:38:19,380 You think, 972 00:38:19,420 --> 00:38:19,580 again, 973 00:38:19,680 --> 00:38:20,180 send to URL. 974 00:38:20,480 --> 00:38:21,440 And the last one, 975 00:38:21,460 --> 00:38:22,180 we are talking about 976 00:38:22,180 --> 00:38:23,660 disabling security mechanisms. 977 00:38:24,260 --> 00:38:24,660 Here, 978 00:38:24,720 --> 00:38:25,320 we are talking about 979 00:38:25,320 --> 00:38:25,840 disabling 980 00:38:25,840 --> 00:38:27,700 the virtual machine 981 00:38:27,700 --> 00:38:29,260 own mechanisms 982 00:38:29,260 --> 00:38:30,060 such as 983 00:38:30,060 --> 00:38:30,480 Java, 984 00:38:30,640 --> 00:38:31,120 Just, 985 00:38:32,400 --> 00:38:32,800 .netcast. 986 00:38:33,480 --> 00:38:33,880 Basically, 987 00:38:35,040 --> 00:38:35,760 if we have 988 00:38:35,760 --> 00:38:36,640 some kind of 989 00:38:36,640 --> 00:38:37,600 code access security, 990 00:38:37,860 --> 00:38:38,860 this is like an ACL 991 00:38:38,860 --> 00:38:39,860 but for code, 992 00:38:40,380 --> 00:38:41,360 so that we can say 993 00:38:41,360 --> 00:38:42,500 what class can do 994 00:38:42,500 --> 00:38:43,280 and what method 995 00:38:43,280 --> 00:38:43,760 can call 996 00:38:43,760 --> 00:38:44,140 and everything 997 00:38:44,140 --> 00:38:44,840 and stuff like that. 998 00:38:45,140 --> 00:38:45,540 Basically, 999 00:38:47,800 --> 00:38:48,280 the application 1000 00:38:48,280 --> 00:38:49,040 will not behave 1001 00:38:49,040 --> 00:38:49,620 according to 1002 00:38:49,620 --> 00:38:49,980 configuration. 1003 00:38:50,780 --> 00:38:51,260 Again, 1004 00:38:51,480 --> 00:38:52,800 if there will be 1005 00:38:52,800 --> 00:38:53,420 some kind 1006 00:38:53,420 --> 00:38:54,880 of auditing, 1007 00:38:55,800 --> 00:38:56,760 security auditing 1008 00:38:56,760 --> 00:38:57,080 will say, 1009 00:38:57,140 --> 00:38:57,340 hey, 1010 00:38:57,360 --> 00:38:57,960 everything is fine. 1011 00:38:58,080 --> 00:38:58,740 I see this configuration 1012 00:38:58,740 --> 00:38:59,920 is as it's supposed to be 1013 00:38:59,920 --> 00:39:00,780 but the application 1014 00:39:00,780 --> 00:39:01,440 will not behave 1015 00:39:01,920 --> 00:39:02,680 as it should. 1016 00:39:03,580 --> 00:39:04,060 Again, 1017 00:39:04,580 --> 00:39:05,420 false sense 1018 00:39:05,420 --> 00:39:05,860 of security. 1019 00:39:07,420 --> 00:39:07,900 But, 1020 00:39:07,900 --> 00:39:08,780 those are just 1021 00:39:08,780 --> 00:39:09,360 examples. 1022 00:39:10,360 --> 00:39:11,540 As you can see, 1023 00:39:12,060 --> 00:39:12,540 sorry, 1024 00:39:12,660 --> 00:39:13,640 you can implement 1025 00:39:13,640 --> 00:39:14,380 what you want. 1026 00:39:14,460 --> 00:39:15,100 If someone hacked 1027 00:39:15,100 --> 00:39:16,300 your own virtual machine, 1028 00:39:16,460 --> 00:39:16,880 you can perform 1029 00:39:17,800 --> 00:39:18,280 and basically 1030 00:39:18,280 --> 00:39:19,640 the sky is the limit. 1031 00:39:21,760 --> 00:39:22,700 There are some 1032 00:39:22,700 --> 00:39:23,300 advanced topics 1033 00:39:23,300 --> 00:39:23,780 to mention. 1034 00:39:24,000 --> 00:39:24,480 For example, 1035 00:39:25,340 --> 00:39:26,460 most platform 1036 00:39:26,460 --> 00:39:27,020 with classes 1037 00:39:27,020 --> 00:39:27,860 can perform 1038 00:39:27,860 --> 00:39:29,220 many interesting things. 1039 00:39:29,340 --> 00:39:29,720 You can deploy 1040 00:39:29,720 --> 00:39:30,180 classes, 1041 00:39:30,340 --> 00:39:31,180 custom 1042 00:39:31,180 --> 00:39:31,700 classes. 1043 00:39:32,640 --> 00:39:33,460 You cannot, 1044 00:39:33,620 --> 00:39:34,580 you don't need 1045 00:39:34,580 --> 00:39:35,480 to tie the code 1046 00:39:35,480 --> 00:39:36,340 to the specific 1047 00:39:36,340 --> 00:39:37,320 machine, 1048 00:39:37,400 --> 00:39:37,860 to the specific 1049 00:39:37,860 --> 00:39:38,300 CPU. 1050 00:39:39,340 --> 00:39:40,080 There are 1051 00:39:40,080 --> 00:39:40,500 run times 1052 00:39:40,500 --> 00:39:41,640 like enterprise 1053 00:39:41,640 --> 00:39:42,320 service bus, 1054 00:39:42,580 --> 00:39:43,060 web services 1055 00:39:43,060 --> 00:39:43,380 stacks, 1056 00:39:43,600 --> 00:39:43,860 application 1057 00:39:43,860 --> 00:39:44,260 servers, 1058 00:39:47,800 --> 00:39:48,880 as an instance, 1059 00:39:49,500 --> 00:39:50,880 SQL Server 2005 1060 00:39:50,880 --> 00:39:51,960 contains an 1061 00:39:51,960 --> 00:39:52,800 internal implementation 1062 00:39:52,800 --> 00:39:53,840 of .NET Framework. 1063 00:39:53,960 --> 00:39:54,820 You change 1064 00:39:54,820 --> 00:39:55,620 the database code. 1065 00:39:56,720 --> 00:39:57,040 And, 1066 00:39:57,720 --> 00:39:58,660 we can also 1067 00:39:58,660 --> 00:39:59,200 talk about 1068 00:39:59,200 --> 00:39:59,720 the multiple 1069 00:39:59,720 --> 00:40:01,080 change rootkits 1070 00:40:01,080 --> 00:40:01,880 or second 1071 00:40:01,880 --> 00:40:02,620 order rootkits 1072 00:40:02,620 --> 00:40:03,540 in which we're having 1073 00:40:03,540 --> 00:40:04,560 an OS level 1074 00:40:04,560 --> 00:40:05,040 rootkit. 1075 00:40:05,140 --> 00:40:05,340 So, 1076 00:40:05,340 --> 00:40:05,940 for example, 1077 00:40:06,020 --> 00:40:06,540 kernel level 1078 00:40:06,540 --> 00:40:07,500 rootkit that hides 1079 00:40:07,500 --> 00:40:08,280 the presence 1080 00:40:08,280 --> 00:40:09,320 of MCR 1081 00:40:09,320 --> 00:40:10,140 and MCR 1082 00:40:10,140 --> 00:40:10,660 application. 1083 00:40:11,880 --> 00:40:12,160 Right? 1084 00:40:12,920 --> 00:40:13,560 Remember, 1085 00:40:13,720 --> 00:40:14,980 MCRs are not 1086 00:40:14,980 --> 00:40:15,960 targeting the OS, 1087 00:40:16,180 --> 00:40:16,780 they're targeting 1088 00:40:16,780 --> 00:40:17,380 the application. 1089 00:40:18,740 --> 00:40:19,180 And, 1090 00:40:19,860 --> 00:40:20,720 the last thing 1091 00:40:20,720 --> 00:40:21,120 that I want 1092 00:40:21,120 --> 00:40:21,720 to talk about, 1093 00:40:21,840 --> 00:40:22,420 now I'm going 1094 00:40:22,420 --> 00:40:23,120 to talk about 1095 00:40:23,120 --> 00:40:24,260 .NET Exploit. 1096 00:40:25,420 --> 00:40:26,260 This is a tool 1097 00:40:26,260 --> 00:40:26,820 that I wrote 1098 00:40:26,820 --> 00:40:27,920 in order to, 1099 00:40:29,180 --> 00:40:29,980 in order to 1100 00:40:29,980 --> 00:40:30,680 to show 1101 00:40:30,680 --> 00:40:31,300 as a proof 1102 00:40:31,300 --> 00:40:31,800 of concept 1103 00:40:31,800 --> 00:40:32,260 that things 1104 00:40:32,260 --> 00:40:32,640 like this 1105 00:40:32,640 --> 00:40:33,140 can happen. 1106 00:40:33,720 --> 00:40:34,160 And, 1107 00:40:34,200 --> 00:40:34,580 basically, 1108 00:40:34,740 --> 00:40:35,300 .NET Exploit 1109 00:40:35,300 --> 00:40:36,160 is not necessarily 1110 00:40:36,160 --> 00:40:36,800 an evil tool. 1111 00:40:37,900 --> 00:40:38,580 .NET Exploit 1112 00:40:38,580 --> 00:40:39,360 is a generic 1113 00:40:40,200 --> 00:40:41,080 .NET Framework 1114 00:40:41,080 --> 00:40:41,740 language 1115 00:40:41,740 --> 00:40:42,820 modification tool. 1116 00:40:43,100 --> 00:40:43,580 So, 1117 00:40:43,680 --> 00:40:44,920 you can perform, 1118 00:40:45,400 --> 00:40:46,400 you can change, 1119 00:40:46,440 --> 00:40:46,700 basically, 1120 00:40:46,760 --> 00:40:47,600 your language. 1121 00:40:47,840 --> 00:40:48,780 It's an open source 1122 00:40:48,780 --> 00:40:49,240 tool. 1123 00:40:49,400 --> 00:40:50,060 You can download it, 1124 00:40:50,180 --> 00:40:50,740 change it, 1125 00:40:50,840 --> 00:40:51,440 modify it, 1126 00:40:51,500 --> 00:40:52,360 add modules to it. 1127 00:40:53,440 --> 00:40:54,660 You can even add 1128 00:40:54,660 --> 00:40:55,380 more languages 1129 00:40:55,380 --> 00:40:56,160 to .NET Exploit. 1130 00:40:56,820 --> 00:40:57,300 So, 1131 00:40:57,340 --> 00:40:57,760 basically, 1132 00:40:57,980 --> 00:40:59,420 and you don't 1133 00:40:59,420 --> 00:41:00,280 necessarily have to 1134 00:41:00,280 --> 00:41:00,940 run it on Windows. 1135 00:41:01,060 --> 00:41:01,520 You can actually 1136 00:41:01,520 --> 00:41:02,260 run it on Linux 1137 00:41:02,260 --> 00:41:04,460 using the Mono project. 1138 00:41:06,500 --> 00:41:06,980 Well, 1139 00:41:07,060 --> 00:41:07,560 .NET Exploit 1140 00:41:07,560 --> 00:41:08,400 contains most 1141 00:41:08,400 --> 00:41:08,900 of the attacks 1142 00:41:08,900 --> 00:41:09,720 that I talked today 1143 00:41:09,720 --> 00:41:10,440 and another couple 1144 00:41:10,440 --> 00:41:10,860 of examples. 1145 00:41:11,740 --> 00:41:11,920 I'm going to play 1146 00:41:11,920 --> 00:41:12,280 with it. 1147 00:41:13,060 --> 00:41:13,600 And, 1148 00:41:13,620 --> 00:41:14,100 the concept 1149 00:41:14,100 --> 00:41:14,920 with .NET Exploit 1150 00:41:14,920 --> 00:41:16,000 is that you're developing 1151 00:41:16,000 --> 00:41:16,860 a general purpose 1152 00:41:16,860 --> 00:41:17,860 modules. 1153 00:41:18,740 --> 00:41:19,620 Modules can be 1154 00:41:19,620 --> 00:41:21,040 either a function. 1155 00:41:21,280 --> 00:41:22,020 A function is 1156 00:41:22,020 --> 00:41:22,900 a general purpose 1157 00:41:22,900 --> 00:41:23,260 method. 1158 00:41:24,640 --> 00:41:25,400 You can, 1159 00:41:25,480 --> 00:41:26,300 you develop 1160 00:41:26,300 --> 00:41:27,160 payloads. 1161 00:41:27,180 --> 00:41:27,720 Basically, 1162 00:41:27,800 --> 00:41:28,460 the separation 1163 00:41:28,460 --> 00:41:29,260 between payload 1164 00:41:29,260 --> 00:41:30,140 and method 1165 00:41:30,140 --> 00:41:30,580 is that 1166 00:41:30,580 --> 00:41:31,440 you don't necessarily 1167 00:41:31,440 --> 00:41:32,040 have to mix 1168 00:41:32,040 --> 00:41:32,480 them together. 1169 00:41:32,940 --> 00:41:33,480 And, 1170 00:41:33,560 --> 00:41:34,460 references is 1171 00:41:34,460 --> 00:41:34,780 when you're 1172 00:41:34,780 --> 00:41:35,320 injecting code 1173 00:41:35,320 --> 00:41:36,000 that contains 1174 00:41:36,000 --> 00:41:37,020 some DLLs 1175 00:41:37,020 --> 00:41:37,700 that wasn't there 1176 00:41:37,700 --> 00:41:38,020 before 1177 00:41:38,020 --> 00:41:39,280 and an item. 1178 00:41:39,780 --> 00:41:40,260 And, 1179 00:41:40,380 --> 00:41:40,760 an item, 1180 00:41:41,320 --> 00:41:42,500 it's very interesting 1181 00:41:42,500 --> 00:41:43,620 because an item 1182 00:41:43,620 --> 00:41:44,440 is the model 1183 00:41:44,440 --> 00:41:45,620 that ties them all. 1184 00:41:45,900 --> 00:41:46,600 An item looks 1185 00:41:46,600 --> 00:41:47,440 something like this. 1186 00:41:47,940 --> 00:41:49,240 An item is an XML 1187 00:41:49,760 --> 00:41:50,600 that describes, 1188 00:41:50,820 --> 00:41:51,360 basically, 1189 00:41:52,140 --> 00:41:53,080 where we want 1190 00:41:53,080 --> 00:41:53,520 to inject 1191 00:41:53,520 --> 00:41:54,180 our code. 1192 00:41:54,400 --> 00:41:54,540 So, 1193 00:41:54,600 --> 00:41:54,900 basically, 1194 00:41:54,900 --> 00:41:55,580 what is the 1195 00:41:55,580 --> 00:41:56,320 target DLL? 1196 00:41:56,480 --> 00:41:56,580 So, 1197 00:41:56,620 --> 00:41:57,160 we can see that 1198 00:41:57,160 --> 00:41:58,000 we are changing 1199 00:41:58,000 --> 00:41:58,700 ms-colib 1200 00:41:58,700 --> 00:41:59,240 and this is 1201 00:41:59,240 --> 00:41:59,600 the location 1202 00:41:59,600 --> 00:42:00,300 of ms-colib. 1203 00:42:00,980 --> 00:42:02,160 We want to inject, 1204 00:42:02,400 --> 00:42:02,900 for example, 1205 00:42:02,900 --> 00:42:03,840 this piece of code. 1206 00:42:04,520 --> 00:42:04,920 Right? 1207 00:42:06,080 --> 00:42:06,480 And, 1208 00:42:06,600 --> 00:42:07,620 the location 1209 00:42:07,620 --> 00:42:08,420 of the code. 1210 00:42:08,560 --> 00:42:08,800 So, 1211 00:42:08,820 --> 00:42:09,100 this is the 1212 00:42:09,100 --> 00:42:09,680 hooking point. 1213 00:42:09,800 --> 00:42:10,480 This is where we want 1214 00:42:10,480 --> 00:42:11,220 to inject our code. 1215 00:42:11,560 --> 00:42:11,960 And, 1216 00:42:12,360 --> 00:42:13,320 what is the mode? 1217 00:42:13,360 --> 00:42:13,880 What is the mode 1218 00:42:13,880 --> 00:42:14,260 of operation? 1219 00:42:14,580 --> 00:42:15,420 Whether we want 1220 00:42:15,420 --> 00:42:16,140 to inject it as a 1221 00:42:16,140 --> 00:42:17,240 pre-injection, 1222 00:42:17,260 --> 00:42:18,480 post-injection, 1223 00:42:18,560 --> 00:42:19,540 or we want it 1224 00:42:19,540 --> 00:42:20,240 to replace 1225 00:42:20,240 --> 00:42:21,200 all of the code 1226 00:42:21,200 --> 00:42:22,000 that was there before. 1227 00:42:23,820 --> 00:42:24,220 And, 1228 00:42:24,500 --> 00:42:25,360 let's see the last demo. 1229 00:42:25,540 --> 00:42:25,920 The last demo 1230 00:42:25,920 --> 00:42:26,320 is about 1231 00:42:26,320 --> 00:42:27,120 the .NET exploit 1232 00:42:27,120 --> 00:42:27,720 performing 1233 00:42:27,720 --> 00:42:28,800 a very intensive 1234 00:42:29,000 --> 00:42:29,880 task of 1235 00:42:29,880 --> 00:42:30,780 injecting 1236 00:42:31,100 --> 00:42:32,040 a reverse shell 1237 00:42:32,040 --> 00:42:33,260 into the .NET 1238 00:42:33,260 --> 00:42:33,620 frame of 1239 00:42:33,620 --> 00:42:34,160 own implementation. 1240 00:42:34,720 --> 00:42:35,300 And, 1241 00:42:35,420 --> 00:42:36,220 the task is that 1242 00:42:36,220 --> 00:42:36,920 we are performing 1243 00:42:36,920 --> 00:42:37,780 a conditional 1244 00:42:37,780 --> 00:42:38,620 reverse shell 1245 00:42:38,620 --> 00:42:39,580 that only 1246 00:42:39,580 --> 00:42:40,040 one specific 1247 00:42:40,040 --> 00:42:41,000 application 1248 00:42:41,000 --> 00:42:41,440 called 1249 00:42:41,440 --> 00:42:42,000 sensitive 1250 00:42:42,000 --> 00:42:42,500 application 1251 00:42:42,500 --> 00:42:44,300 has been 1252 00:42:44,300 --> 00:42:44,740 executed. 1253 00:42:44,980 --> 00:42:46,280 The reverse shell 1254 00:42:46,280 --> 00:42:46,600 will be 1255 00:42:46,600 --> 00:42:47,120 opened back 1256 00:42:47,120 --> 00:42:48,020 to the attacker. 1257 00:42:48,360 --> 00:42:48,880 So, 1258 00:42:50,060 --> 00:42:50,880 let's go 1259 00:42:50,880 --> 00:42:51,620 to our 1260 00:42:51,620 --> 00:42:51,960 machine. 1261 00:42:56,920 --> 00:42:57,720 We are going 1262 00:42:58,340 --> 00:42:59,120 .NET exploit. 1263 00:43:00,660 --> 00:43:01,220 And, 1264 00:43:01,480 --> 00:43:02,000 I'm going 1265 00:43:02,000 --> 00:43:02,500 to load 1266 00:43:02,500 --> 00:43:03,760 one of the items. 1267 00:43:03,880 --> 00:43:04,040 There are 1268 00:43:04,040 --> 00:43:04,820 many items here. 1269 00:43:05,020 --> 00:43:06,020 The last one, 1270 00:43:06,080 --> 00:43:06,460 conditional 1271 00:43:06,460 --> 00:43:07,040 reverse shell. 1272 00:43:07,380 --> 00:43:07,940 And, 1273 00:43:08,000 --> 00:43:08,260 I'm going 1274 00:43:08,260 --> 00:43:09,280 to start. 1275 00:43:09,720 --> 00:43:10,280 So, 1276 00:43:10,400 --> 00:43:11,400 now what it will do, 1277 00:43:11,460 --> 00:43:12,240 now it will go 1278 00:43:12,240 --> 00:43:13,380 to this directory, 1279 00:43:13,720 --> 00:43:15,300 take this DLL, 1280 00:43:15,880 --> 00:43:16,720 perform a 1281 00:43:16,720 --> 00:43:17,300 decompilation 1282 00:43:17,300 --> 00:43:18,220 of the DLL. 1283 00:43:18,560 --> 00:43:19,120 After 1284 00:43:19,120 --> 00:43:19,860 decompiling 1285 00:43:19,860 --> 00:43:20,380 the DLL, 1286 00:43:20,440 --> 00:43:20,920 it will inject 1287 00:43:20,920 --> 00:43:21,580 the function 1288 00:43:21,580 --> 00:43:22,320 reverse shell 1289 00:43:22,320 --> 00:43:22,480 generic. 1290 00:43:23,760 --> 00:43:24,440 After that, 1291 00:43:24,520 --> 00:43:24,900 it will inject 1292 00:43:24,900 --> 00:43:25,300 the function 1293 00:43:25,300 --> 00:43:25,520 called 1294 00:43:25,520 --> 00:43:25,980 reverse shell 1295 00:43:25,980 --> 00:43:26,500 private generic. 1296 00:43:27,160 --> 00:43:27,840 After that, 1297 00:43:27,880 --> 00:43:29,020 inject the payload, 1298 00:43:29,200 --> 00:43:29,980 which is conditional 1299 00:43:29,980 --> 00:43:30,940 reverse shell form, 1300 00:43:31,060 --> 00:43:31,760 in a mode 1301 00:43:31,760 --> 00:43:33,100 which is pre-append, 1302 00:43:33,180 --> 00:43:34,140 so that code 1303 00:43:34,140 --> 00:43:34,620 will be injected 1304 00:43:34,620 --> 00:43:35,120 at the beginning 1305 00:43:35,120 --> 00:43:35,900 of the function. 1306 00:43:36,600 --> 00:43:37,000 Basically, 1307 00:43:37,000 --> 00:43:37,640 if I wanted it 1308 00:43:37,640 --> 00:43:38,900 to be executed 1309 00:43:38,900 --> 00:43:39,440 at the end 1310 00:43:39,440 --> 00:43:39,920 of the function, 1311 00:43:40,060 --> 00:43:40,700 all I had to do 1312 00:43:40,700 --> 00:43:41,320 is change 1313 00:43:41,320 --> 00:43:41,900 the configuration. 1314 00:43:43,180 --> 00:43:43,580 So, 1315 00:43:44,480 --> 00:43:45,180 now it's 1316 00:43:45,180 --> 00:43:45,760 in pre-append. 1317 00:43:45,880 --> 00:43:46,040 And, 1318 00:43:46,040 --> 00:43:46,920 after it will finish, 1319 00:43:47,020 --> 00:43:47,400 it will 1320 00:43:48,360 --> 00:43:49,000 recompile it 1321 00:43:49,000 --> 00:43:49,160 back. 1322 00:43:49,420 --> 00:43:49,740 Basically, 1323 00:43:49,740 --> 00:43:50,560 reassemble it 1324 00:43:50,560 --> 00:43:51,540 back into a DLL. 1325 00:43:52,360 --> 00:43:52,880 And, 1326 00:43:52,980 --> 00:43:53,320 basically, 1327 00:43:53,400 --> 00:43:54,220 it will generate 1328 00:43:54,220 --> 00:43:55,760 a new DLL for me, 1329 00:43:55,900 --> 00:43:56,940 so that this DLL 1330 00:43:56,940 --> 00:43:58,460 will later be used 1331 00:43:58,460 --> 00:43:59,260 to replace 1332 00:43:59,260 --> 00:43:59,980 the framework 1333 00:43:59,980 --> 00:44:00,740 on DLL, 1334 00:44:00,980 --> 00:44:02,180 so that, 1335 00:44:02,260 --> 00:44:02,880 basically, 1336 00:44:02,960 --> 00:44:03,740 now I'm going 1337 00:44:03,740 --> 00:44:04,280 to change 1338 00:44:04,280 --> 00:44:05,040 the dotted language, 1339 00:44:05,300 --> 00:44:06,600 so that now 1340 00:44:06,600 --> 00:44:07,180 the injection 1341 00:44:07,180 --> 00:44:08,100 will be performed 1342 00:44:08,100 --> 00:44:08,860 into run. 1343 00:44:09,460 --> 00:44:10,400 Remember run? 1344 00:44:10,480 --> 00:44:11,200 Run is when 1345 00:44:11,200 --> 00:44:12,000 applications 1346 00:44:12,000 --> 00:44:13,060 are being executed. 1347 00:44:13,220 --> 00:44:14,660 Run has been 1348 00:44:16,040 --> 00:44:16,560 Now when run 1349 00:44:16,560 --> 00:44:17,160 will be called, 1350 00:44:18,100 --> 00:44:19,220 it will check 1351 00:44:19,220 --> 00:44:20,520 whether the name 1352 00:44:20,520 --> 00:44:21,100 of the application 1353 00:44:21,100 --> 00:44:21,740 is a sensitive 1354 00:44:21,740 --> 00:44:22,140 application. 1355 00:44:22,780 --> 00:44:23,300 So, 1356 00:44:23,320 --> 00:44:24,420 as it's done 1357 00:44:24,420 --> 00:44:25,020 its operation, 1358 00:44:25,380 --> 00:44:26,360 it asks me 1359 00:44:26,360 --> 00:44:26,940 whether I want 1360 00:44:26,940 --> 00:44:27,440 to generate 1361 00:44:27,440 --> 00:44:28,180 deployers. 1362 00:44:29,060 --> 00:44:29,580 Well, 1363 00:44:29,620 --> 00:44:30,280 deployers are 1364 00:44:30,280 --> 00:44:30,860 batch files. 1365 00:44:31,020 --> 00:44:31,860 This is deploy 1366 00:44:31,860 --> 00:44:33,060 and undeploy 1367 00:44:33,060 --> 00:44:33,580 batch files 1368 00:44:33,580 --> 00:44:34,340 that will be used 1369 00:44:34,340 --> 00:44:35,160 in the modified 1370 00:44:35,160 --> 00:44:35,520 machine, 1371 00:44:35,780 --> 00:44:36,700 so that, 1372 00:44:36,760 --> 00:44:37,100 well, 1373 00:44:37,140 --> 00:44:37,800 we don't need 1374 00:44:37,800 --> 00:44:38,560 to take .NET 1375 00:44:38,560 --> 00:44:40,260 to the modified 1376 00:44:40,260 --> 00:44:40,500 machine. 1377 00:44:40,740 --> 00:44:41,200 All we have 1378 00:44:41,200 --> 00:44:41,460 to do 1379 00:44:41,460 --> 00:44:42,100 is to take 1380 00:44:42,100 --> 00:44:42,500 the DLL 1381 00:44:42,500 --> 00:44:42,860 and the batch 1382 00:44:42,860 --> 00:44:43,040 file. 1383 00:44:43,300 --> 00:44:43,860 So, 1384 00:44:43,860 --> 00:44:45,020 I'll execute 1385 00:44:45,020 --> 00:44:45,400 this, 1386 00:44:45,720 --> 00:44:46,480 and so 1387 00:44:46,480 --> 00:44:47,460 .NET support 1388 00:44:47,460 --> 00:44:47,940 is finished, 1389 00:44:48,100 --> 00:44:48,760 and 1390 00:44:50,060 --> 00:44:50,760 it's gone 1391 00:44:51,760 --> 00:44:52,880 .NET support 1392 00:44:52,880 --> 00:44:53,580 attacker 1393 00:44:53,580 --> 00:44:54,000 here, 1394 00:44:55,160 --> 00:44:56,280 and we have 1395 00:44:56,280 --> 00:44:56,940 the attacker 1396 00:44:56,940 --> 00:44:57,240 side 1397 00:44:57,240 --> 00:44:57,820 shell 1398 00:44:59,180 --> 00:44:59,740 here, 1399 00:45:00,920 --> 00:45:01,480 and 1400 00:45:03,680 --> 00:45:04,240 well, 1401 00:45:05,620 --> 00:45:06,280 now I'm going 1402 00:45:06,280 --> 00:45:06,580 to run 1403 00:45:06,580 --> 00:45:07,020 the sensitive 1404 00:45:07,020 --> 00:45:07,460 application 1405 00:45:07,460 --> 00:45:08,160 to show you 1406 00:45:08,160 --> 00:45:08,600 that I 1407 00:45:09,540 --> 00:45:10,320 didn't deploy 1408 00:45:10,320 --> 00:45:10,600 it yet, 1409 00:45:10,700 --> 00:45:11,400 so now I'm going 1410 00:45:11,400 --> 00:45:11,780 to execute 1411 00:45:11,780 --> 00:45:12,360 sensitive application 1412 00:45:12,360 --> 00:45:13,060 to show you 1413 00:45:13,060 --> 00:45:13,700 that nothing 1414 00:45:13,700 --> 00:45:14,180 happens. 1415 00:45:16,200 --> 00:45:16,980 A couple 1416 00:45:16,980 --> 00:45:17,320 seconds. 1417 00:45:18,400 --> 00:45:19,080 See that? 1418 00:45:19,360 --> 00:45:19,760 Oops. 1419 00:45:20,380 --> 00:45:20,880 That's the 1420 00:45:20,880 --> 00:45:21,160 end. 1421 00:45:21,360 --> 00:45:21,840 Yeah. 1422 00:45:23,140 --> 00:45:23,620 So, 1423 00:45:23,740 --> 00:45:24,280 and this is 1424 00:45:24,280 --> 00:45:24,960 sensitive application. 1425 00:45:25,700 --> 00:45:26,180 Nothing 1426 00:45:26,180 --> 00:45:26,700 happened. 1427 00:45:27,160 --> 00:45:27,640 Well, 1428 00:45:27,700 --> 00:45:28,160 what I'm going 1429 00:45:28,160 --> 00:45:28,560 to do now, 1430 00:45:28,580 --> 00:45:28,800 I'm going 1431 00:45:28,800 --> 00:45:29,320 to deploy 1432 00:45:29,880 --> 00:45:30,720 the DLL. 1433 00:45:33,240 --> 00:45:33,800 That's it. 1434 00:45:33,800 --> 00:45:34,700 Now, 1435 00:45:34,800 --> 00:45:34,980 I'm going 1436 00:45:34,980 --> 00:45:35,360 to run 1437 00:45:35,360 --> 00:45:35,900 the same 1438 00:45:36,540 --> 00:45:37,100 executable, 1439 00:45:37,220 --> 00:45:38,040 and if 1440 00:45:38,040 --> 00:45:38,440 everything 1441 00:45:38,440 --> 00:45:39,200 works as 1442 00:45:39,200 --> 00:45:39,820 fine as 1443 00:45:39,820 --> 00:45:40,380 supposed to 1444 00:45:40,380 --> 00:45:40,580 be, 1445 00:45:40,720 --> 00:45:41,080 every 1446 00:45:41,080 --> 00:45:41,500 version 1447 00:45:41,500 --> 00:45:41,840 will be 1448 00:45:41,840 --> 00:45:42,120 open 1449 00:45:42,120 --> 00:45:42,920 on the 1450 00:45:42,920 --> 00:45:43,160 right 1451 00:45:43,160 --> 00:45:43,400 side. 1452 00:45:44,260 --> 00:45:44,360 Yeah. 1453 00:45:46,440 --> 00:45:47,000 . 1454 00:45:54,320 --> 00:45:54,880 Let's 1455 00:45:54,880 --> 00:45:54,980 who 1456 00:45:54,980 --> 00:45:55,160 we 1457 00:45:55,160 --> 00:45:55,240 are. 1458 00:45:57,000 --> 00:45:57,560 Yeah. 1459 00:45:57,640 --> 00:45:58,080 . 1460 00:46:00,720 --> 00:46:01,280 So, 1461 00:46:01,500 --> 00:46:01,760 . 1462 00:46:01,760 --> 00:46:02,120 . 1463 00:46:04,860 --> 00:46:05,420 Well, 1464 00:46:05,600 --> 00:46:06,100 . 1465 00:46:06,100 --> 00:46:06,620 This is scary 1466 00:46:06,620 --> 00:46:06,920 stuff, 1467 00:46:07,100 --> 00:46:07,280 right? 1468 00:46:08,700 --> 00:46:09,660 Someone messes 1469 00:46:09,660 --> 00:46:10,120 up with 1470 00:46:10,120 --> 00:46:10,940 run times. 1471 00:46:11,060 --> 00:46:11,360 So, 1472 00:46:11,360 --> 00:46:11,720 basically, 1473 00:46:11,820 --> 00:46:12,240 code review 1474 00:46:12,240 --> 00:46:13,280 on runtime 1475 00:46:13,280 --> 00:46:13,820 that's been 1476 00:46:13,820 --> 00:46:14,220 tampered 1477 00:46:14,220 --> 00:46:14,420 with, 1478 00:46:14,480 --> 00:46:15,120 does not 1479 00:46:15,120 --> 00:46:15,320 mean 1480 00:46:15,320 --> 00:46:15,740 anything. 1481 00:46:16,060 --> 00:46:16,500 You should 1482 00:46:16,500 --> 00:46:16,920 notsource 1483 00:46:16,920 --> 00:46:17,340 the runtime. 1484 00:46:17,700 --> 00:46:18,620 So basically, 1485 00:46:18,740 --> 00:46:19,720 what we can do, 1486 00:46:19,780 --> 00:46:20,260 I'm calling 1487 00:46:20,260 --> 00:46:20,720 for action 1488 00:46:20,720 --> 00:46:20,920 for, 1489 00:46:21,060 --> 00:46:21,520 for example, 1490 00:46:33,220 --> 00:46:33,780 antiviruses and 1491 00:46:35,320 --> 00:46:38,500 tries to, for example, change my host file 1492 00:46:38,500 --> 00:46:39,900 and the antivirus says, 1493 00:46:40,020 --> 00:46:41,960 hey, some process is trying to do something 1494 00:46:41,960 --> 00:46:42,980 to your operating system, 1495 00:46:43,820 --> 00:46:45,760 I expect this antivirus to tell me 1496 00:46:45,760 --> 00:46:47,900 that some process is trying to change 1497 00:46:47,900 --> 00:46:49,200 my managed code environment. 1498 00:46:50,040 --> 00:46:52,520 IT guys should perform file tampering detectors 1499 00:46:52,520 --> 00:46:54,600 using, for example, tripwire, 1500 00:46:54,780 --> 00:46:57,440 but do it using an external machine. 1501 00:46:57,860 --> 00:46:59,860 Auditors, pentesters, forensics, 1502 00:47:00,240 --> 00:47:03,420 look for your evidence inside virtual machines, 1503 00:47:03,420 --> 00:47:05,440 know about this kind of shit of things. 1504 00:47:11,640 --> 00:47:13,480 Developers, you should know that your application 1505 00:47:13,480 --> 00:47:16,580 is secure as the underlying virtual machine, right? 1506 00:47:17,600 --> 00:47:19,980 Virtual machine vendors like Microsoft, 1507 00:47:20,220 --> 00:47:24,080 basically, this is not a direct responsibility of them, 1508 00:47:24,620 --> 00:47:26,960 but although it's not a bulletproof solution, 1509 00:47:27,240 --> 00:47:28,700 they should raise the bar a little bit. 1510 00:47:28,840 --> 00:47:31,020 Today, it's too damn easy to do. 1511 00:47:32,120 --> 00:47:32,960 And, of course, 1512 00:47:32,960 --> 00:47:33,400 and your solutions. 1513 00:47:33,420 --> 00:47:37,220 users, all of us, we should know about this kind of thing and we should verify our run 1514 00:47:37,220 --> 00:47:44,480 times. Well, for more information about this research, you should look at this page. This 1515 00:47:44,480 --> 00:47:49,600 is where the slides are, white paper, .NET exploit tool, source code, basically everything. 1516 00:47:50,500 --> 00:47:55,260 It's important to mention Ken Thompson, who talked about C compiler backdoors. He talked, 1517 00:47:55,340 --> 00:48:00,540 the first guy who talked about backdooring the compilers. And Dennis Cruz from the OWASP.NET 1518 00:48:00,540 --> 00:48:03,900 group, who talked about the dangers of full trust application. 1519 00:48:06,020 --> 00:48:12,440 Well, to summarize, we all seen that malicious code can be hidden inside the virtual machine, 1520 00:48:12,560 --> 00:48:17,700 the application of the virtual machine, as an alternative place for hiding malware. We 1521 00:48:17,700 --> 00:48:22,680 are not just talking about kernel, BIOS, places like that. We're talking about another place 1522 00:48:22,680 --> 00:48:27,920 for backdoors. Very interesting attacks can be devised using the techniques like that, 1523 00:48:28,080 --> 00:48:28,860 so be careful. 1524 00:48:29,440 --> 00:48:35,360 And, well, it does not depend on any specific vulnerability because, basically, it's not 1525 00:48:35,360 --> 00:48:40,000 restricted to any kind of machine, to any technology. We're not just talking about 1526 00:48:40,000 --> 00:48:47,260 .NET, Java, or stuff like that, but a custom problem, a generic problem that we have. 1527 00:48:47,780 --> 00:48:53,460 And the last thing we saw, .NET exploit, the generic language modification tool, that 1528 00:48:53,460 --> 00:48:58,840 simplifies the process of .NET modification. But, you know, it's a little bit complicated. 1529 00:48:58,860 --> 00:49:03,880 I want you guys to remember that .NET exploit is not necessarily an evil tool. I used it 1530 00:49:03,880 --> 00:49:11,320 as a custom tool. It can be used to modify the framework, but it can also be used, basically, 1531 00:49:13,140 --> 00:49:18,740 to modify the framework, create your own version of .NET framework, generate customized mod 1532 00:49:18,740 --> 00:49:25,240 frameworks, tiny framework, secure framework, performance framework, stuff like that. 1533 00:49:25,380 --> 00:49:28,840 So, guys, if you have any questions, I'll be right over there. Thank you very much. 1534 00:49:28,840 --> 00:49:34,100 We'll see you over there at room 104. And thank you very much.