1 00:00:00,580 --> 00:00:05,960 Okay, let's start. My name is Alfredo Ortega. I work as an explorer writer for Core Security. 2 00:00:08,780 --> 00:00:14,040 This talk will be about the OpenBSD bug. If you don't understand something that I am saying, 3 00:00:14,180 --> 00:00:23,660 just ask me and I will repeat. Okay. This is a bug that I discovered a couple of months 4 00:00:23,660 --> 00:00:31,500 ago. Well, like four months ago. And it's an interesting bug, and the exploit is interesting 5 00:00:31,500 --> 00:00:36,240 too. And got pretty much publicity, so I'm going to explain it. 6 00:00:38,880 --> 00:00:47,760 Okay. Oh. Let's start talking about how I discovered the bug. 7 00:00:52,160 --> 00:00:53,460 Okay. This is the factory. 8 00:00:53,660 --> 00:01:04,820 Okay. This is the history. I was assigned to do a research about a patch in the OpenBSD 9 00:01:04,820 --> 00:01:14,800 kernel, named the number eight patch, a reliability fix. This was, in fact, a hang of the kernel, 10 00:01:14,860 --> 00:01:23,600 an infinite loop in the kernel, caused by fragmented ICMP packets. So I give my boss 11 00:01:23,660 --> 00:01:28,400 command and tell me if I could reproduce this bug. 12 00:01:28,800 --> 00:01:36,840 So I started to trying to build a fuzzer. Do you know what a fuzzer is? It's a little 13 00:01:36,840 --> 00:01:42,840 program to send malformer packets and try to train to break the system to reproduce 14 00:01:43,410 --> 00:01:53,640 the bug. So... It really didn't... I really didn't know 15 00:01:53,660 --> 00:01:57,880 it. I didn't have very much information about the bug, so the only thing that I could do 16 00:01:57,880 --> 00:02:05,760 is to start trying and studying the patch, trying to make a couple of amended packets, 17 00:02:05,940 --> 00:02:13,340 and send it to a OpenBSD system, trying to make it to break, to lock in an infinite loop. 18 00:02:14,680 --> 00:02:22,260 So the fuzzer is a very simple program. I made it in Python. It only makes two packets. 19 00:02:22,260 --> 00:02:29,980 From the IPv6 protocol. The IPv6 protocol is, as you know, a very new protocol. It's 20 00:02:29,980 --> 00:02:36,520 not very much used. And it's got a lot of bugs. I will be presenting some this bug, 21 00:02:36,640 --> 00:02:40,920 and in the end maybe I will do some live demonstration about another vulnerabilities. 22 00:02:43,000 --> 00:02:52,240 I spent about two days trying to build in malformer packets, thinking how I could break 23 00:02:52,260 --> 00:03:06,300 the system and in the end I... In a looky packet, managed to break the system. I sent 24 00:03:06,300 --> 00:03:11,860 it to an OpenBSD virtual machine and the OpenBSD kernel just hung up. But it was not an infinite 25 00:03:11,860 --> 00:03:21,320 loop like the patch was seeing. It was a complete hang up. The system just hung up and threw 26 00:03:21,320 --> 00:03:26,640 a stack trace of the bug. I was thinking, this really is not the same bug that I was 27 00:03:26,640 --> 00:03:33,740 trying to find. Maybe it's a new bug. So the thing that I did was to download the latest 28 00:03:33,740 --> 00:03:41,440 version of OpenBSD kernel. It was at the time the 4.1 OpenBSD kernel. And trying to 29 00:03:41,440 --> 00:03:50,240 attack against that kernel. The attacks worked anyway. So in my hands I did have what is 30 00:03:50,240 --> 00:03:54,120 called a zero-day or unpatched vulnerability. 31 00:03:56,240 --> 00:04:01,540 In the time I was thinking it was a service and maybe it could result in code execution, 32 00:04:02,280 --> 00:04:10,740 but I was not really sure about it. So I reported to my boss. My boss reported to OpenBSD team 33 00:04:11,140 --> 00:04:19,060 and got fixed in about two days. They were very fast and fixed the bug. But they reported 34 00:04:19,060 --> 00:04:25,160 as a danger of service, of a reliability fix. And I was thinking that this was not 35 00:04:25,160 --> 00:04:32,340 a reliability fix. It really was an exploitable bug because of the stack trace. So I started 36 00:04:32,340 --> 00:04:40,580 researching how to exploit this bug. Let's see why the bug was hanging in the kernel. 37 00:04:44,060 --> 00:04:47,060 Okay, these are, let's see. 38 00:04:50,640 --> 00:04:56,980 In the, in the, a lot of Unix systems, the network packets are stored in a structure 39 00:04:57,300 --> 00:05:07,880 named mbufs. The mbufs are little packets of memory of a fixed length. They are about 40 00:05:07,880 --> 00:05:17,180 256 bytes long. They are ordered in a linked list in memory and they store network packets 41 00:05:17,180 --> 00:05:18,060 and... 42 00:05:19,060 --> 00:05:26,680 inside them. And if the network packet is too big to fit inside a mbuf, the mbuf got 43 00:05:26,680 --> 00:05:36,320 an external memory buffer. But the failure of the kernel was that the kernel was overwriting 44 00:05:36,320 --> 00:05:46,320 a lot of mbuf buffers in the way that it's showing there. Instead of writing into the 45 00:05:46,320 --> 00:05:54,260 first mbuf, mbuf1, the Open VSD game was overwriting a lot of these buffers. And not 46 00:05:54,260 --> 00:05:58,560 only the buffer but they either information inside the buffers and the couple of pointer 47 00:05:58,560 --> 00:06:02,480 to link the buffers to link touring. 48 00:06:03,280 --> 00:06:11,440 So when the Open V flooded system was trying to free one of these packets, it made it morning 49 00:06:11,440 --> 00:06:16,300 operation, that is operationist exchange of two pointers to fresh them. And then when 50 00:06:16,300 --> 00:06:18,060 with the node between them. 51 00:06:19,320 --> 00:06:23,660 And because of the pointer was overwriting with garbage, at the time it was garbage, 52 00:06:23,840 --> 00:06:30,680 the system was hanging, was making an illegal operation, and it totally hanged. 53 00:06:32,900 --> 00:06:38,740 This seemed like a very exploitable bug, because when you overwrite your pointers, you can 54 00:06:38,740 --> 00:06:48,820 use a very common technique, namely the mirror copy, or four-byte write. 55 00:06:49,240 --> 00:06:56,500 When you exchange your pointers and you can control the pointers, you can manage to write 56 00:06:56,500 --> 00:07:00,520 four bytes of data in any place of the memory. 57 00:07:01,060 --> 00:07:08,720 So I think if I am overwriting a linked list, it's almost sure that it is exploitable. 58 00:07:08,720 --> 00:07:14,920 So I started to disassemble the OpenBCD kernel to see if I could exploit the bug. 59 00:07:20,980 --> 00:07:27,980 Maybe it's not shown very well, but here is a disassembly of the function that was 60 00:07:27,980 --> 00:07:28,320 hanging. 61 00:07:29,000 --> 00:07:31,540 The function that was hanging was a free function. 62 00:07:33,980 --> 00:07:37,680 I see in the down, the free end function was crashing. 63 00:07:37,880 --> 00:07:38,320 Here. 64 00:07:42,600 --> 00:07:44,580 The end-free end function was crashed. 65 00:07:44,740 --> 00:07:48,520 That is the function that free an end-buff. 66 00:07:48,840 --> 00:07:50,580 So I disassembled this function. 67 00:07:52,660 --> 00:07:53,580 That is the result. 68 00:07:54,940 --> 00:07:59,740 I must say that the OpenBCD kernel is an open source kernel, and I really did have the 69 00:07:59,740 --> 00:08:05,700 C code of the source code of that function, but I am really more used to see it this way, 70 00:08:05,800 --> 00:08:06,760 to see it in assembly. 71 00:08:06,760 --> 00:08:15,100 To analyze the function in assembly, it's more easy for me to see it this way. 72 00:08:16,020 --> 00:08:24,960 The function started in the orange block, and we can see, if we could see, that the 73 00:08:25,560 --> 00:08:28,120 packet to free is stored in the register. 74 00:08:28,830 --> 00:08:35,100 I must clarify that this disassembler is for the Pentium and 32 bits only. 75 00:08:35,520 --> 00:08:36,740 OpenBCD run in assembly. 76 00:08:36,760 --> 00:08:42,700 There are a lot of architectures, but this exploit is only for Pentium at 32 bits. 77 00:08:44,660 --> 00:08:50,960 In the start, this function placed the packet to be freed in the one register, in the ASI 78 00:08:50,960 --> 00:08:56,700 register, and then it made a lot of operation using this register of reference. 79 00:08:58,580 --> 00:09:05,600 The point the kernel was breaking is making yellow. 80 00:09:08,240 --> 00:09:12,980 You can't see it very well, but it exchanges the pointers here. 81 00:09:13,360 --> 00:09:21,080 In the block in yellow, the pointers of the linked list are being exchanged. 82 00:09:21,720 --> 00:09:27,620 Of course, the linked list was overwriting, and it was trying to write in a position of 83 00:09:27,620 --> 00:09:32,300 memory that did not exist, so it broke exactly in the yellow block. 84 00:09:33,700 --> 00:09:34,900 I say, okay. 85 00:09:34,900 --> 00:09:41,060 Let's try to reach the yellow block with controller pointers, so I can write in any 86 00:09:41,060 --> 00:09:41,960 place of the memory. 87 00:09:42,320 --> 00:09:48,780 If I can write a value in any place of the memory, I can do a lot of things, like make 88 00:09:48,780 --> 00:09:59,500 my user process root, or open, I don't know, change the permission of the new process. 89 00:10:00,220 --> 00:10:04,820 There are not very much things that I could do, but some things, it could be done. 90 00:10:04,820 --> 00:10:06,800 It will be exploitable this way. 91 00:10:08,260 --> 00:10:11,280 While I was analyzing this, I realized something. 92 00:10:14,000 --> 00:10:19,320 I realized that in the next block, in the block next to them, to the yellow block, 93 00:10:19,780 --> 00:10:24,460 was a call in the referencing a pointer. 94 00:10:24,680 --> 00:10:31,660 It was getting a pointer from the block here in the arrow, in this part. 95 00:10:32,760 --> 00:10:33,160 Let's see. 96 00:10:34,720 --> 00:10:43,520 In this part, it's moving a value from the packet inside the EX register, and then, in 97 00:10:43,520 --> 00:10:46,100 the next block, it's jumping to this EX register. 98 00:10:46,520 --> 00:10:49,320 In fact, it's calling them, but it's the same as jumping. 99 00:10:49,760 --> 00:10:58,720 I could send a value here inside the packet, and make that open VCD jump exactly what 100 00:10:58,720 --> 00:11:02,360 I want, so I can control the flow execution. 101 00:11:03,680 --> 00:11:09,620 In a much easier way than trying to do the other trick of the yellow block, that writing 102 00:11:09,620 --> 00:11:16,600 in some part of the memory, it's much easier to jump to any place that I want, because 103 00:11:16,600 --> 00:11:22,240 I could send my code, and place my code, or my shell code, in some place of the memory, 104 00:11:22,440 --> 00:11:27,860 and make the kernel jump it, and I will get total control of the kernel. 105 00:11:28,500 --> 00:11:31,880 Of course, I will gain execution inside the kernel. 106 00:11:32,360 --> 00:11:37,700 It is not the ideal situation. 107 00:11:38,060 --> 00:11:43,760 The ideal situation was to gain control in a user process, because kernel exploit is 108 00:11:43,760 --> 00:11:48,680 much difficult to do than a user exploit, because in a user exploit, you got the kernel 109 00:11:48,680 --> 00:11:49,740 to do whatever you want. 110 00:11:49,880 --> 00:11:53,660 You can use the kernel to open a file or to open a connection. 111 00:11:54,000 --> 00:11:55,060 It's much easier. 112 00:11:55,200 --> 00:11:57,080 The kernel is made for that. 113 00:11:57,260 --> 00:11:57,620 You... 114 00:11:57,620 --> 00:12:00,320 When you do a user exploit... 115 00:12:00,320 --> 00:12:01,080 When... 116 00:12:01,080 --> 00:12:01,840 Only... 117 00:12:02,360 --> 00:12:07,300 A hundred instructions, you can make the machine do what you want. 118 00:12:07,540 --> 00:12:09,260 It's a very small exploit. 119 00:12:09,520 --> 00:12:12,200 But in kernel mode, you really don't have a kernel. 120 00:12:12,360 --> 00:12:15,280 You don't have an operative system to make use of. 121 00:12:16,500 --> 00:12:19,940 So it's almost like you are your own operative system. 122 00:12:21,000 --> 00:12:23,800 Anyway, I was gaining execution inside the kernel, 123 00:12:23,940 --> 00:12:25,760 and I was executing my call. 124 00:12:26,040 --> 00:12:30,720 So I told the OpenBSD people that, in fact, this bug was exploitable. 125 00:12:30,720 --> 00:12:32,960 I still didn't have the exploit. 126 00:12:33,140 --> 00:12:36,060 The exploit took me about a couple of weeks to make 127 00:12:36,060 --> 00:12:38,580 because it was a very difficult exploit, 128 00:12:38,740 --> 00:12:42,380 and I was helped by a lot of people from kernel security. 129 00:12:44,960 --> 00:12:51,600 But anyway, now I am in the situation that I can't jump to any place that I want in the memory. 130 00:12:51,740 --> 00:12:53,480 But where I want to jump? 131 00:12:54,180 --> 00:12:58,300 Of course, I cannot jump to the same kernel because the same kernel is not my call. 132 00:12:58,440 --> 00:13:00,320 I want to jump to my call. 133 00:13:00,720 --> 00:13:03,100 So I can't overtake the system. 134 00:13:03,740 --> 00:13:07,700 First, I must place the code in memory in some way. 135 00:13:10,180 --> 00:13:15,160 Well, in this transparency, there are markers, the source code in C, 136 00:13:15,340 --> 00:13:17,280 the equivalent of that function. 137 00:13:19,080 --> 00:13:20,180 Here's the assembly. 138 00:13:21,500 --> 00:13:25,160 And here's the part of the source code that makes the call. 139 00:13:25,680 --> 00:13:27,360 It's a little difficult to understand. 140 00:13:27,880 --> 00:13:29,420 It's marked in red. 141 00:13:29,480 --> 00:13:29,880 It's marked. 142 00:13:30,640 --> 00:13:37,080 It's the part of the source code that jumps to the reference pointer. 143 00:13:39,540 --> 00:13:44,680 As you can see, it's much easier to understand in assembly than it is in C. 144 00:13:44,960 --> 00:13:47,700 It's a lot of micro-expansions. 145 00:13:47,860 --> 00:13:52,300 I never will realize the bug looking only to the source code. 146 00:13:57,440 --> 00:13:58,460 Okay, that's better. 147 00:14:02,500 --> 00:14:10,740 Okay, in this drawing, you can see how the fragmented packets of ICMPv6 are placed in memory. 148 00:14:12,520 --> 00:14:21,540 In the right, we have the linker list of mbuf or mbuf chain with the correspondent headers. 149 00:14:22,420 --> 00:14:28,760 And the headers of the mbuf are pointer to the next mbuf, pointer to the last mbuf, pointer to the free function. 150 00:14:30,360 --> 00:14:40,160 And the packet that places in exactly that way in memory are overwriting a couple of mbufers, or mbuf. 151 00:14:41,520 --> 00:14:52,240 And the arrow here, this arrow marks the exact position of where the pointer to jump is placed in memory. 152 00:14:52,480 --> 00:14:54,520 So I must place a pointer here. 153 00:14:55,200 --> 00:14:59,860 This pointer will overwrite the free function. 154 00:14:59,880 --> 00:15:13,840 This pointer will overwrite the free function inside the header, and this function we call the pointer that I place there, here. 155 00:15:19,880 --> 00:15:21,920 Here it says trampoline. 156 00:15:22,240 --> 00:15:25,160 You can't really see it, but it says trampoline. 157 00:15:25,240 --> 00:15:28,860 Trampoline is a name for a position of memory that I want to jump. 158 00:15:28,960 --> 00:15:29,860 I want to jump to a... 159 00:15:29,880 --> 00:15:30,220 Trampoline. 160 00:15:30,960 --> 00:15:35,520 So I put this pointer in the header of the mbuf in exact position. 161 00:15:35,800 --> 00:15:38,160 You can be not even one byte... 162 00:15:40,020 --> 00:15:41,920 One byte and disalign. 163 00:15:41,980 --> 00:15:45,260 It must be exactly aligned to the pointer. 164 00:15:45,520 --> 00:15:47,000 But it's something very easy to do. 165 00:15:50,040 --> 00:15:53,980 Okay, let's continue. 166 00:15:54,280 --> 00:15:55,220 One more. 167 00:15:56,260 --> 00:15:56,880 Yes. 168 00:15:58,360 --> 00:15:58,980 Okay. 169 00:16:00,220 --> 00:16:00,780 Thanks. 170 00:16:02,080 --> 00:16:02,680 All right. 171 00:16:05,780 --> 00:16:06,340 If I could jump right to the machine andrà back. 172 00:16:06,340 --> 00:16:10,680 Oh, well, we can now jump to any place on the memory that we want. 173 00:16:10,900 --> 00:16:14,360 But where is the sharecall located? 174 00:16:14,860 --> 00:16:20,200 We know that the sharecall is located here. 175 00:16:20,400 --> 00:16:27,100 Here it say sharecall is placed next in the same packet because it's very easy to 176 00:16:27,100 --> 00:16:29,860 put the sharecode in the same packet that gives the одного jump over. 177 00:16:29,880 --> 00:16:29,960 row. 178 00:16:30,100 --> 00:16:33,660 So we got this portion of memory, we got our code. 179 00:16:34,160 --> 00:16:37,200 The shared code or the code that we want to execute. 180 00:16:38,440 --> 00:16:44,360 But we don't know where this is placed because the mbuf, the dynamic, align places and it 181 00:16:44,360 --> 00:16:46,280 could be in any place of the kernel memory. 182 00:16:47,180 --> 00:16:49,720 It's not in a fixed position, it will change. 183 00:16:49,800 --> 00:16:52,380 It will change from run to run and from kernel to kernel. 184 00:16:56,100 --> 00:16:57,460 But we know one thing. 185 00:16:57,460 --> 00:17:02,780 We know that the shared code is pointed to the ASI register. 186 00:17:03,180 --> 00:17:06,880 The ASI register points exactly where our shared code begins. 187 00:17:07,380 --> 00:17:08,220 Why is that? 188 00:17:08,520 --> 00:17:11,780 Well, because that is how the function was compiled. 189 00:17:12,100 --> 00:17:21,640 We remember that the packet in the beginning of the function was pointed to ASI, was pointed 190 00:17:21,640 --> 00:17:21,880 here. 191 00:17:22,120 --> 00:17:27,440 So if the packet is pointed to ASI and we do an immediate jump to ASI, the packet is 192 00:17:27,440 --> 00:17:28,880 pointed to somewhere that we want. 193 00:17:33,620 --> 00:17:42,780 We must jump to some place in memory that jumps back to the position of the ASI register. 194 00:17:43,540 --> 00:17:44,540 It's like a bouncing. 195 00:17:44,660 --> 00:17:49,920 We bounce in a point of the kernel memory that have an intrusion that jumps back to 196 00:17:49,920 --> 00:17:51,240 the ASI register. 197 00:17:51,640 --> 00:17:54,760 We must find a position of the kernel. 198 00:17:55,860 --> 00:17:56,540 Up. 199 00:17:56,740 --> 00:17:57,420 Down. 200 00:17:57,440 --> 00:17:57,520 Up. 201 00:17:57,520 --> 00:17:58,080 This is the kernel. 202 00:17:58,360 --> 00:18:04,240 We must find a position of the kernel that got an intrusion that jumps back to the ASI 203 00:18:04,240 --> 00:18:04,460 register. 204 00:18:04,960 --> 00:18:07,080 This intrusion is a very small intrusion. 205 00:18:07,240 --> 00:18:12,260 They are no more than two bytes long and it's placed thousands of times in the kernel. 206 00:18:12,420 --> 00:18:14,320 So it's very easy to find one intrusion. 207 00:18:14,480 --> 00:18:16,140 It could be in any place of the kernel. 208 00:18:16,420 --> 00:18:18,920 It only must be there and be executable. 209 00:18:19,560 --> 00:18:25,300 So we find one intrusion, it could be any, we find one intrusion that jumps to the ASI 210 00:18:25,300 --> 00:18:25,680 register. 211 00:18:25,680 --> 00:18:27,680 And we simply jump there. 212 00:18:27,940 --> 00:18:30,560 So we jump in this intrusion. 213 00:18:30,760 --> 00:18:35,340 That intrusion jumps back to our shellcode and we are executing our shellcode now. 214 00:18:35,740 --> 00:18:37,620 We have complete control of the system. 215 00:18:39,460 --> 00:18:41,500 I was thinking, okay, game over. 216 00:18:41,720 --> 00:18:42,660 It's over. 217 00:18:42,980 --> 00:18:44,040 But it's not over. 218 00:18:45,140 --> 00:18:49,460 Because as I was seeing, the kernel, you really can't do anything in kernel mode. 219 00:18:49,640 --> 00:18:51,900 I can't even open a file. 220 00:18:52,060 --> 00:18:53,580 I can't open a connection to the internet. 221 00:18:53,840 --> 00:18:55,660 Because I am running in kernel. 222 00:18:55,660 --> 00:19:02,500 And it's a very tricky, this is a really tricky part, to make the exploit work in kernel 223 00:19:02,500 --> 00:19:02,800 mode. 224 00:19:02,980 --> 00:19:06,460 Because it must be like a mini-operative system. 225 00:19:06,620 --> 00:19:07,240 It should be. 226 00:19:12,000 --> 00:19:18,560 Okay, there are a lot of ways to do this, but this is the way that we implement it and 227 00:19:18,560 --> 00:19:21,700 this way it really works pretty fine. 228 00:19:23,280 --> 00:19:25,640 In kernel mode, there are not... 229 00:19:25,640 --> 00:19:30,040 There are a lot of many things that you can do, but you can do very easily hook interruption. 230 00:19:30,300 --> 00:19:36,800 You can get the interruption table of the Pentium processor and you can hook, you can 231 00:19:36,800 --> 00:19:43,260 make that one interruption to assume to you, and you instead jump to the original interruption. 232 00:19:44,620 --> 00:19:53,100 So what Arwas did was to hook this particular interruption, the system call, to operate 233 00:19:53,100 --> 00:19:53,620 the system. 234 00:19:53,740 --> 00:19:54,880 Communicate with the user. 235 00:19:54,880 --> 00:19:58,940 The user process using an interruption in Unix. 236 00:19:59,100 --> 00:20:06,080 When in Windows, it's more or less similar, but in Unix, the interruption number used is 237 00:20:06,080 --> 00:20:08,420 always the 80 interruption. 238 00:20:08,940 --> 00:20:14,500 So I must hook this interruption, the 80 interruption, in the same way that the old 239 00:20:14,500 --> 00:20:18,620 element in a style resident program from DOS. 240 00:20:18,920 --> 00:20:23,620 In DOS, there were a kind of program, maybe you remember that. 241 00:20:23,740 --> 00:20:24,860 That hooked the... 242 00:20:24,880 --> 00:20:28,940 The interruption, the timer interruption, or the keyboard interruption, and in that 243 00:20:28,940 --> 00:20:30,880 way, it's still resident in memory. 244 00:20:31,460 --> 00:20:35,040 This is the same technique, but we hooked the system call interruption. 245 00:20:36,760 --> 00:20:38,580 This is the original system call. 246 00:20:38,880 --> 00:20:40,380 We got a user process here. 247 00:20:40,780 --> 00:20:46,500 The user process make a system call, I don't know, open a file, or kernel open an internal 248 00:20:46,500 --> 00:20:52,660 connection, and the kernel open the internal connection and returns to the user in the 249 00:20:52,660 --> 00:20:53,460 next instruction. 250 00:20:54,000 --> 00:20:54,860 And here is... 251 00:20:54,860 --> 00:20:56,980 Here is how the hook is made. 252 00:20:57,360 --> 00:21:03,420 The system process, the user process, sorry, jump to the hook that I have installed in 253 00:21:03,420 --> 00:21:09,840 the memory, and the hook make something that I want, and then return to the original system 254 00:21:09,840 --> 00:21:12,720 call, and the system call is made and returned to the user. 255 00:21:12,860 --> 00:21:18,580 So the user really don't know if he don't realize that it's calling my code. 256 00:21:18,780 --> 00:21:21,580 He thinks that it's calling the kernel, but it's not calling the kernel, it's calling 257 00:21:22,160 --> 00:21:23,740 my shellcode in memory. 258 00:21:28,900 --> 00:21:31,160 Okay, so it's calling my shellcode. 259 00:21:31,280 --> 00:21:32,860 What we do in this situation? 260 00:21:33,720 --> 00:21:37,180 Okay, now we can see every system call of the system. 261 00:21:37,280 --> 00:21:43,140 We can see every process and every operation of all the process of the system. 262 00:21:43,920 --> 00:21:45,480 This is a very useful thing. 263 00:21:45,720 --> 00:21:47,040 So I implemented... 264 00:21:47,040 --> 00:21:51,260 This is the cellular call of the operation of the hook, the interruption hook. 265 00:21:51,740 --> 00:21:52,260 Okay. 266 00:21:53,340 --> 00:21:53,860 Okay. 267 00:21:54,040 --> 00:21:54,420 Okay. 268 00:21:55,420 --> 00:22:01,520 First, we don't want to affect any user process, because we will... 269 00:22:01,520 --> 00:22:03,680 In this way, we will hack the machine. 270 00:22:04,200 --> 00:22:04,560 We... 271 00:22:04,560 --> 00:22:08,240 And not every user process are useful to us. 272 00:22:08,480 --> 00:22:12,000 Only the privileged user process are useful... 273 00:22:12,000 --> 00:22:15,120 The user process with a privilege of root. 274 00:22:16,040 --> 00:22:21,200 Because if we take over a process with no privileges, it will be very useful. 275 00:22:21,560 --> 00:22:24,400 We want to take over a user process. 276 00:22:24,400 --> 00:22:25,560 process with root privileges. 277 00:22:26,420 --> 00:22:34,020 So first we want to see if the process calling us is root. 278 00:22:34,720 --> 00:22:39,240 Of course, this is a very hard thing to do because we cannot simply get the process ID 279 00:22:39,580 --> 00:22:43,860 or the user's ID of the process because, again, we are in kernel mode. 280 00:22:44,340 --> 00:22:46,580 We must do a lot of tricks to do this. 281 00:22:47,260 --> 00:22:54,000 First, in user mode, you use a system call called getPid or getProcessID. 282 00:22:54,300 --> 00:22:55,480 Just simply have that. 283 00:22:55,900 --> 00:23:00,360 That's a system call, returns a number, and that number says if you are root or not. 284 00:23:01,200 --> 00:23:04,060 But now we must do a little magic here. 285 00:23:04,820 --> 00:23:12,240 We first search for this variable in the kernel memory because the kernel can be any kernel. 286 00:23:12,380 --> 00:23:16,560 It can be an OpenBSD 3 kernel or 4 or can be a custom component. 287 00:23:16,560 --> 00:23:22,520 And this variable, the current process variable, in fact it's an array, it's not a variable, 288 00:23:22,800 --> 00:23:24,400 could be any place in the memory. 289 00:23:24,680 --> 00:23:26,020 So we must search it. 290 00:23:26,160 --> 00:23:32,380 We must search through all the memory searching for patterns, for a specific pattern of memory 291 00:23:32,380 --> 00:23:35,580 that tells us where this variable is placed. 292 00:23:36,960 --> 00:23:43,240 These patterns are present in every OpenBSD version from 10 years ago and are very easy 293 00:23:43,240 --> 00:23:43,640 to find. 294 00:23:45,040 --> 00:23:51,600 Once that we got this current process variable, we can see inside this variable, in fact it's 295 00:23:51,600 --> 00:23:56,000 a structure, it's not a variable, what is the user ID of the process. 296 00:23:56,320 --> 00:23:59,760 So now we got the user ID of the process. 297 00:23:59,900 --> 00:24:05,880 And if the user ID is zero, the process is root and we can't take over this process. 298 00:24:07,620 --> 00:24:13,140 So if the process is root, we must attack this process. 299 00:24:13,140 --> 00:24:18,220 So we know that the process has full privilege of the system and it's much easier to execute 300 00:24:18,220 --> 00:24:21,700 code in user land or user mode than in kernel mode. 301 00:24:22,340 --> 00:24:25,420 So we got a process that this root is calling us. 302 00:24:25,540 --> 00:24:27,160 We must take over this process. 303 00:24:27,640 --> 00:24:33,480 First, we must execute code in this process. 304 00:24:33,660 --> 00:24:41,620 We could just overwrite the return pointer and the return pointer of the process should 305 00:24:41,620 --> 00:24:42,140 be in... 306 00:24:42,140 --> 00:24:46,060 Because we are kernel, we can overwrite any place in the memory. 307 00:24:46,420 --> 00:24:53,380 We could just overwrite the return address, but this is not a very good thing to do because 308 00:24:54,120 --> 00:25:00,000 maybe this process, the process that are calling us, the binary that are calling us, is the 309 00:25:00,000 --> 00:25:00,380 libc. 310 00:25:00,700 --> 00:25:05,240 The libc is a library that is very important in the system. 311 00:25:05,320 --> 00:25:11,320 We can't just overwrite the libc because the g system will crash within, because every 312 00:25:11,320 --> 00:25:13,160 process are using the libc. 313 00:25:13,600 --> 00:25:15,700 We cannot overwrite the binary. 314 00:25:15,900 --> 00:25:18,640 We must place our shellcode in another place. 315 00:25:19,450 --> 00:25:26,220 A good place to put our shellcode is the stack because the stack is one for every process 316 00:25:26,930 --> 00:25:34,140 and it's very easy to reserve memory on the stack, put our shellcode there, and execute 317 00:25:34,140 --> 00:25:35,440 our shellcode on the stack. 318 00:25:35,860 --> 00:25:37,860 But there is a problem with that approach. 319 00:25:38,460 --> 00:25:40,760 That is this protection. 320 00:25:40,940 --> 00:25:41,300 Okay. 321 00:25:41,320 --> 00:25:50,160 This protection is a very good protection that OpenBSD got that says that no place in 322 00:25:50,160 --> 00:25:52,360 the memory that is writable is executable. 323 00:25:52,660 --> 00:25:57,680 The memory can be or writable or executable but not bought. 324 00:25:58,000 --> 00:26:00,920 So that is exactly what we want to do. 325 00:26:00,960 --> 00:26:05,300 We want to write in the stack and execute in that place. 326 00:26:06,960 --> 00:26:11,300 So the OpenBSD kernel will not let us do that. 327 00:26:11,300 --> 00:26:13,600 We want to disable this protection. 328 00:26:13,900 --> 00:26:21,920 This protection can be disabled because we are kernel and we can modify every register 329 00:26:21,920 --> 00:26:24,380 of the Pentium processor because we've got complete control. 330 00:26:25,440 --> 00:26:28,600 So how we disable this protection? 331 00:26:28,860 --> 00:26:30,040 We extend the selectors. 332 00:26:30,140 --> 00:26:37,400 The selectors, OpenBSD implemented this protection, changing the selectors and making some selectors 333 00:26:37,400 --> 00:26:38,920 shorter, some selectors larger. 334 00:26:39,960 --> 00:26:41,280 And the space between the selectors is very large. 335 00:26:41,300 --> 00:26:49,580 The specific selector that is affecting that don't let us to execute our code in the stack 336 00:26:49,580 --> 00:26:51,880 is this selector, the code selector, of course. 337 00:26:52,780 --> 00:26:55,100 We must extend this selector. 338 00:26:55,340 --> 00:26:56,820 We extend this anyway. 339 00:26:57,020 --> 00:27:00,240 This is not very important, but this selector is very important. 340 00:27:00,440 --> 00:27:06,420 We must extend the code selector, or CS, to let us execute code in the stack. 341 00:27:08,420 --> 00:27:11,200 This extending the selector can be modified. 342 00:27:11,200 --> 00:27:18,760 It can be made in a user process, and user process can extend selector, but it don't 343 00:27:18,760 --> 00:27:20,680 have permissions to do that. 344 00:27:20,940 --> 00:27:24,160 But we are in kernel, so we can extend the selector. 345 00:27:24,760 --> 00:27:31,420 Once this protection is down, we simply copy the user mode in the stack and execute that. 346 00:27:32,920 --> 00:27:39,480 We modify the return address to the pointer of the stack, and when the system can restore, 347 00:27:39,760 --> 00:27:41,060 it will return to the stack. 348 00:27:41,200 --> 00:27:44,880 Instead of returning to the binary image of the process, it will return to the stack. 349 00:27:45,460 --> 00:27:50,100 And we'll execute there perfectly, because this protection is down. 350 00:27:51,120 --> 00:28:01,000 So now we are executing our shellcode in a user process, and it's much easier to do 351 00:28:02,360 --> 00:28:08,820 things in that place, like open a connection or, I don't know, adding a user, writing a 352 00:28:08,820 --> 00:28:09,200 file. 353 00:28:09,680 --> 00:28:10,600 I mean, kernel. 354 00:28:10,600 --> 00:28:15,140 Because now we are a user, and we can make use of the kernel. 355 00:28:17,120 --> 00:28:21,760 In the end, of course, we must restore the original interruption vector, because if 356 00:28:21,760 --> 00:28:30,600 we don't do this, every root process will be taken over, and we don't want that, because 357 00:28:31,820 --> 00:28:35,160 we want to take over only one process. 358 00:28:35,240 --> 00:28:36,160 We only need that. 359 00:28:36,240 --> 00:28:39,620 We don't need to take over all the root process of the machine. 360 00:28:39,620 --> 00:28:44,940 So we restore or remove the hook, restore the original interruption vector, and that 361 00:28:44,940 --> 00:28:50,940 is, now we got one process, the first process that are calling us, root, and executing all 362 00:28:50,940 --> 00:28:51,200 code. 363 00:28:51,580 --> 00:28:53,960 This process could be anyone. 364 00:28:54,400 --> 00:28:55,700 It can be the send mail process. 365 00:28:55,940 --> 00:28:59,340 It can be the Apache, I don't know how we say it, Apache web server. 366 00:29:00,820 --> 00:29:08,080 In fact, I was seeing that every time I send the exploit, the send mail process was the 367 00:29:08,080 --> 00:29:09,600 first that was taken over. 368 00:29:09,600 --> 00:29:16,960 Send mail make a lot of system calls, and it's root, and it's every, almost every time 369 00:29:16,960 --> 00:29:21,840 is the send mail process is the first that is attacked by this exploit. 370 00:29:24,400 --> 00:29:32,200 And if we are not root, if some other process call the kernel and yes, not root, we just 371 00:29:32,200 --> 00:29:36,320 continue with the original system call, and we don't modify it, because we are really 372 00:29:36,320 --> 00:29:39,380 done is interested in attack, in attacking a process. 373 00:29:39,380 --> 00:29:40,020 If we are not root, that is not root. 374 00:29:43,600 --> 00:29:44,240 Okay. 375 00:29:44,320 --> 00:29:45,060 This is a diagram. 376 00:29:46,780 --> 00:29:48,920 We got a little problem here. 377 00:29:49,240 --> 00:29:52,460 There should be a line here, and a line here too. 378 00:29:53,080 --> 00:30:00,540 This is a map of the memory of the Pentium 32-bit processor, and how OpenBSD managed 379 00:30:00,540 --> 00:30:00,860 it. 380 00:30:01,100 --> 00:30:08,140 We got four gigabytes long, and the OpenBSD system reserves the first part of the memory, 381 00:30:08,300 --> 00:30:09,360 and the memory. 382 00:30:09,380 --> 00:30:12,300 for executing binary code here. 383 00:30:12,500 --> 00:30:15,240 So the only executable code can be placed here, 384 00:30:15,460 --> 00:30:16,920 in this small part of the memory. 385 00:30:17,240 --> 00:30:18,480 This code will grow a little. 386 00:30:19,540 --> 00:30:23,200 It is viable, can extend a little further. 387 00:30:23,820 --> 00:30:27,040 But only this place of the memory is executable. 388 00:30:27,220 --> 00:30:30,600 And this place of the memory is not executable, 389 00:30:30,680 --> 00:30:31,480 but it's writable. 390 00:30:31,660 --> 00:30:34,000 Here is the data memory, the heap and the stack. 391 00:30:34,840 --> 00:30:37,740 So this is the operation that we do. 392 00:30:37,740 --> 00:30:41,360 We extend the code selector that only reached here originally, 393 00:30:41,780 --> 00:30:43,940 and we extend it from two here, 394 00:30:44,080 --> 00:30:46,000 all the way to the wall memory, 395 00:30:46,260 --> 00:30:50,580 so we can execute every code in this area, too. 396 00:30:51,480 --> 00:30:55,440 We also extend the data segment, just because. 397 00:30:56,880 --> 00:30:58,120 It's not really necessary. 398 00:30:59,280 --> 00:31:01,360 Well, so a little assembler. 399 00:31:01,660 --> 00:31:06,060 This is the implementation of the serial code that I was showing. 400 00:31:07,740 --> 00:31:11,520 It's maybe a little, this, it use some instruction 401 00:31:11,520 --> 00:31:14,080 that are not commonly used in user mode, 402 00:31:14,840 --> 00:31:17,520 like this one and this one, 403 00:31:17,640 --> 00:31:19,500 that store global description table 404 00:31:19,500 --> 00:31:21,280 and store local description table, 405 00:31:21,860 --> 00:31:24,840 because the selector are stored in these tables 406 00:31:25,900 --> 00:31:27,700 that the painting processor use 407 00:31:27,700 --> 00:31:31,660 to store the selector, let's say. 408 00:31:32,460 --> 00:31:35,340 So we first store the selector in some place in the memory, 409 00:31:35,460 --> 00:31:36,180 could be any place. 410 00:31:36,300 --> 00:31:37,720 We choose to store it in the memory, 411 00:31:37,720 --> 00:31:41,280 so in the ISP, in the stack itself. 412 00:31:42,620 --> 00:31:45,200 This section of the code are a lot of operation 413 00:31:45,200 --> 00:31:48,460 used to assemble the selector, 414 00:31:48,520 --> 00:31:52,160 because the selectors are not contiguous in memory, 415 00:31:52,380 --> 00:31:56,500 are a little, I don't know, like disassembled 416 00:31:56,500 --> 00:31:58,300 at some place in one byte, 417 00:31:58,480 --> 00:32:01,280 and some bytes later are another part of the selector. 418 00:32:01,460 --> 00:32:03,200 I don't know why this is. 419 00:32:03,280 --> 00:32:07,040 This is the Intel engineers, 420 00:32:07,720 --> 00:32:08,800 they made it that way, 421 00:32:08,860 --> 00:32:09,920 I don't know why, because, 422 00:32:10,080 --> 00:32:11,980 but you must assemble the selector 423 00:32:11,980 --> 00:32:13,740 using a lot of boolean operations, 424 00:32:14,340 --> 00:32:16,380 and these two final instructions 425 00:32:17,500 --> 00:32:19,040 extend the selectors, 426 00:32:19,640 --> 00:32:21,780 place it only a value 427 00:32:21,780 --> 00:32:24,140 in a specific place of the memory, 428 00:32:25,100 --> 00:32:27,680 then we must load again the selector. 429 00:32:27,780 --> 00:32:31,220 Here is not the part that loads the selector back 430 00:32:31,220 --> 00:32:32,380 into the painting processor. 431 00:32:32,700 --> 00:32:34,800 It's not showed, but it's next. 432 00:32:39,000 --> 00:32:43,160 Okay, but we are not really finishing it yet. 433 00:32:43,460 --> 00:32:45,800 I was saying this exploit is a little complex, 434 00:32:46,380 --> 00:32:49,800 because OpenBSD is a clever process system, 435 00:32:49,860 --> 00:32:51,460 and in the next context switch, 436 00:32:52,320 --> 00:32:54,420 we'll restore the selectors. 437 00:32:54,740 --> 00:32:58,400 So, if we are happily executing in the stack, 438 00:32:58,560 --> 00:33:01,160 but if the process, our context switches, 439 00:33:01,320 --> 00:33:02,600 switches back, 440 00:33:03,640 --> 00:33:05,320 the process will crash, 441 00:33:05,440 --> 00:33:07,440 because the protection, this protection W, 442 00:33:07,720 --> 00:33:08,220 WX or X, 443 00:33:08,320 --> 00:33:09,420 oh, this is bad, 444 00:33:09,900 --> 00:33:10,680 WX or X, 445 00:33:11,320 --> 00:33:12,900 will be enabled again, 446 00:33:13,100 --> 00:33:14,620 and the process will crash. 447 00:33:15,580 --> 00:33:17,120 The execution of the checker 448 00:33:17,120 --> 00:33:18,680 will be detected by the operating system. 449 00:33:19,200 --> 00:33:23,800 So, we must try to get a portion of memory 450 00:33:24,320 --> 00:33:26,480 that are execute, 451 00:33:26,800 --> 00:33:28,840 that are writeable and executable forever. 452 00:33:29,620 --> 00:33:30,580 How we do that? 453 00:33:30,800 --> 00:33:32,660 We can use two, 454 00:33:32,900 --> 00:33:34,660 we got two options to do that. 455 00:33:34,740 --> 00:33:37,700 In fact, we maybe got more than two options, 456 00:33:37,720 --> 00:33:40,560 but these are the two options that I think of. 457 00:33:41,560 --> 00:33:45,520 The first one is to use another system call, 458 00:33:46,060 --> 00:33:48,080 because I am executing the user mode, 459 00:33:48,880 --> 00:33:52,360 I can call any system call that I want, 460 00:33:52,500 --> 00:33:55,360 and I call this one, that is named and protect. 461 00:33:55,700 --> 00:33:59,620 This system call is used to give any portion of memory, 462 00:33:59,840 --> 00:34:04,260 any permission that I want. 463 00:34:04,400 --> 00:34:06,860 So, I just unprotect all the stack. 464 00:34:06,860 --> 00:34:12,240 I say to the operating system that I know I want to execute 465 00:34:12,240 --> 00:34:14,060 calling the stack using this. 466 00:34:14,160 --> 00:34:18,700 And the operating system just will make the whole stack 467 00:34:18,700 --> 00:34:22,340 executable, like it was in Windows 95, 468 00:34:23,520 --> 00:34:25,140 and will be executable forever. 469 00:34:27,000 --> 00:34:31,080 We now do a couple of things to fix the original process, 470 00:34:31,220 --> 00:34:33,620 because we don't want the same my process 471 00:34:33,620 --> 00:34:35,740 of the web server process to crash. 472 00:34:35,940 --> 00:34:36,840 We want it to, 473 00:34:36,840 --> 00:34:38,380 to make a new process, 474 00:34:38,500 --> 00:34:42,060 and to keep the original process attack to functioning, 475 00:34:42,200 --> 00:34:45,020 to work okay, to work normally. 476 00:34:46,460 --> 00:34:50,740 So, we first fork the process, make a clone of the process, 477 00:34:52,240 --> 00:34:56,740 and now we got two processes that are the same. 478 00:34:57,800 --> 00:35:01,060 In one of those processes, we fix all the stack, 479 00:35:01,160 --> 00:35:03,020 we fix all the things that we overwrite, 480 00:35:03,460 --> 00:35:05,580 and continues to execute normally. 481 00:35:05,840 --> 00:35:06,740 So, if we, 482 00:35:06,840 --> 00:35:08,860 if we attack the same my process, 483 00:35:09,040 --> 00:35:11,500 the same my process, we continue to execute, 484 00:35:12,560 --> 00:35:14,640 like if nothing was happening. 485 00:35:15,000 --> 00:35:18,500 And the forked process will be executing our code forever. 486 00:35:18,780 --> 00:35:22,660 Forever in a secure position of the memory, 487 00:35:23,560 --> 00:35:26,360 because we unprotected that memory, 488 00:35:26,680 --> 00:35:29,880 and it's over. 489 00:35:30,200 --> 00:35:33,500 Now we got our root processor executing our share code. 490 00:35:34,260 --> 00:35:36,460 There is another way to do this. 491 00:35:36,840 --> 00:35:39,340 That is to do another function call, 492 00:35:39,420 --> 00:35:41,640 that is called a map, or memory map. 493 00:35:41,900 --> 00:35:48,180 We just ask the system to give us a special person of memory 494 00:35:48,180 --> 00:35:51,740 that is not in the stack, but is writable and executable. 495 00:35:52,080 --> 00:35:56,740 So, we just copy or share code in that new portion of memory, 496 00:35:56,880 --> 00:35:57,820 and execute from there. 497 00:35:58,020 --> 00:36:00,260 And in the next context switch, 498 00:36:00,400 --> 00:36:03,080 there is nothing that can stop our execution, 499 00:36:03,400 --> 00:36:06,000 because it's a, it's a reserver, 500 00:36:06,000 --> 00:36:07,240 and a portion of memory. 501 00:36:09,000 --> 00:36:11,760 Okay, and this is the end of the exploit. 502 00:36:12,020 --> 00:36:15,960 We are now, got our root processor executing our code 503 00:36:16,280 --> 00:36:17,060 in user mode. 504 00:36:19,480 --> 00:36:21,660 This is a sample of what is, 505 00:36:21,900 --> 00:36:23,960 what looks like this exploit. 506 00:36:24,640 --> 00:36:27,580 Here is a terminal of OpenBSD, 507 00:36:28,380 --> 00:36:30,860 executing and asking for a login prompt. 508 00:36:31,440 --> 00:36:35,480 And I'm sending here the couple of packets. 509 00:36:36,720 --> 00:36:41,120 Inside the share code, I have inserted a breakpoint 510 00:36:41,400 --> 00:36:42,760 of an interruption tree. 511 00:36:43,140 --> 00:36:47,060 So, this blue part here, in fact, is the debugger of, 512 00:36:47,160 --> 00:36:49,180 the kernel debugger of OpenBSD. 513 00:36:49,920 --> 00:36:51,500 The DDB is called. 514 00:36:52,540 --> 00:36:55,840 We can see, maybe you can see here that it's not hanging. 515 00:36:55,980 --> 00:36:58,720 The kernel has stopped it, because it's a breakpoint. 516 00:36:58,860 --> 00:36:59,880 It's not a crash. 517 00:37:01,560 --> 00:37:05,100 Here, in the, in here, we ask the debugger to continue 518 00:37:05,100 --> 00:37:05,660 to execution. 519 00:37:05,820 --> 00:37:05,980 Okay. 520 00:37:05,980 --> 00:37:10,120 And here, the OpenBSD system is continuing with normal execution. 521 00:37:10,480 --> 00:37:11,800 But now, it's hooked. 522 00:37:12,100 --> 00:37:17,200 Now, we got all code hooked in the interruption, interruption 80. 523 00:37:17,960 --> 00:37:20,720 Now, I would like to do a live demo of this. 524 00:37:20,960 --> 00:37:22,140 I hope it will work. 525 00:37:22,200 --> 00:37:24,640 It may be not work, but to make it a little more interesting, 526 00:37:24,760 --> 00:37:25,940 I'm gonna do a live demo. 527 00:37:37,660 --> 00:37:38,980 . 528 00:37:38,980 --> 00:37:39,580 Sure. 529 00:37:42,620 --> 00:37:43,940 . 530 00:37:51,280 --> 00:37:51,940 . 531 00:37:51,940 --> 00:37:52,660 . 532 00:37:56,880 --> 00:37:58,200 . 533 00:37:58,200 --> 00:37:58,620 . 534 00:37:58,620 --> 00:37:58,840 . 535 00:37:58,840 --> 00:37:58,880 . 536 00:37:58,880 --> 00:37:59,200 . 537 00:38:00,580 --> 00:38:01,900 . 538 00:38:05,620 --> 00:38:12,200 Okay, now we have launched a virtual machine with the OpenBSD 4.0 Operative System, and 539 00:38:12,200 --> 00:38:18,260 we're going to launch another virtual machine using the Linux Operative System that will 540 00:38:18,260 --> 00:38:20,820 send the package to this virtual machine. 541 00:38:21,000 --> 00:38:23,860 The virtual machines are connected together with a host-only network. 542 00:38:23,860 --> 00:38:28,200 It's like a virtual network between the two virtual machines. 543 00:38:56,060 --> 00:39:01,740 Maybe we're going to have some problems with the resolution, I hope not. 544 00:39:03,100 --> 00:39:06,240 I think we're going to have some problems with the resolution. 545 00:39:20,240 --> 00:39:23,740 Could you please make the screen a little smaller? 546 00:39:23,740 --> 00:39:25,880 Because I can't see the top of the screen. 547 00:39:26,000 --> 00:39:27,380 I can't move the window. 548 00:39:29,080 --> 00:39:31,060 Okay, now the top, please. 549 00:39:34,280 --> 00:39:34,920 There you go. 550 00:39:35,600 --> 00:39:36,160 Let's see. 551 00:39:42,740 --> 00:39:43,320 That is. 552 00:39:52,200 --> 00:39:53,360 In the right side. 553 00:39:53,360 --> 00:39:59,580 In the right side is the shell code, the writing is in Python language, and I'm going to launch 554 00:39:59,580 --> 00:40:01,480 the shell code in the other window here. 555 00:40:12,620 --> 00:40:20,080 Okay, here we can see that the OpenBSD kernel has stopped because the attack works, and 556 00:40:20,080 --> 00:40:23,320 it stopped in a breakpoint because inside the shell code. 557 00:40:23,360 --> 00:40:30,100 I have placed it as a breakpoint, and we can ask the debugger just to continue with 558 00:40:30,100 --> 00:40:34,960 the execution, and the kernel, of course, will be hooked with our shell code. 559 00:40:40,980 --> 00:40:47,320 Now, the OpenBSD kernel has a hook in the interruption, and it's working perfectly normal, 560 00:40:47,460 --> 00:40:48,900 like if nothing has happened. 561 00:40:49,100 --> 00:40:52,800 But in fact, our shell code is inside the interruption vector. 562 00:40:52,800 --> 00:40:53,340 Okay. 563 00:40:53,340 --> 00:41:01,880 That was one of the live demonstration, but researching about the IPv6 protocol, the IPv6 564 00:41:01,880 --> 00:41:10,080 protocol is not very much used, and it's active by default in a lot of operating systems, 565 00:41:11,420 --> 00:41:17,860 and that is a receipt for a lot of failures and a lot of bugs and vulnerabilities. 566 00:41:18,380 --> 00:41:23,320 I will show another ones that I have discovered as a part of my research. 567 00:41:23,320 --> 00:41:27,480 Okay, using virtual machines. 568 00:41:27,840 --> 00:41:29,740 We will continue with this. 569 00:41:30,700 --> 00:41:34,400 These couple of vulnerabilities are for the Linux operating system. 570 00:41:38,100 --> 00:41:38,780 Clink. 571 00:41:38,780 --> 00:41:38,960 Clink. 572 00:41:39,280 --> 00:41:39,860 Clink. 573 00:41:40,460 --> 00:41:41,140 Clink. 574 00:41:41,140 --> 00:41:41,160 Clink. 575 00:41:41,160 --> 00:41:46,640 So, come on! 576 00:41:47,920 --> 00:41:48,600 Clink. 577 00:41:48,640 --> 00:41:48,880 Clink. 578 00:41:48,880 --> 00:41:49,240 Clink. 579 00:41:49,240 --> 00:41:49,340 Clink. 580 00:41:51,160 --> 00:41:51,500 Clink. 581 00:42:00,420 --> 00:42:04,460 We're going to use the Ubuntu distribution, it's one of the most used distribution of 582 00:42:04,460 --> 00:42:04,720 Linux. 583 00:42:11,000 --> 00:42:21,500 Okay, this is a Linux kernel, the latest one, the 2.6.22 kernel, and it's a custom kernel, 584 00:42:21,500 --> 00:42:30,020 kernel this one, okay, it's a custom kernel and I will send a couple of ICMP packets to 585 00:42:30,580 --> 00:42:32,500 him to see how he'll respond. 586 00:42:57,480 --> 00:43:01,640 Oh, here we can see this is Linux asking for a login. 587 00:43:15,620 --> 00:43:18,360 Sorry, I get confused, that was not the attack. 588 00:43:19,660 --> 00:43:20,140 Okay. 589 00:43:27,600 --> 00:43:30,100 Now we can see that the Linux kernel is hanged. 590 00:43:30,600 --> 00:43:36,340 This is because we have sent another couple of IPv6 packets, it's another protocol. 591 00:43:37,380 --> 00:43:40,940 But the Linux kernel you can see is hanged. 592 00:43:42,040 --> 00:43:43,240 I'm going to show you one thing. 593 00:43:46,940 --> 00:43:49,100 Maybe you can see the lights are blanking here. 594 00:43:49,420 --> 00:43:50,120 This is... 595 00:43:50,140 --> 00:43:57,240 This is how a Linux kernel, a Linux kernel for protection is show with, is Linux is 596 00:43:57,240 --> 00:44:03,220 hanged very, very few times, but when this hangs, it just blink the caps lock key. 597 00:44:03,520 --> 00:44:07,200 It's very strange to see the Linux kernel hanged, but it hangs sometimes. 598 00:44:09,400 --> 00:44:14,620 This is a denial of service attack, and in fact, it's not a server-based, so it's patched. 599 00:44:15,000 --> 00:44:19,720 It's patched, but it's in the very latest version of the Linux that has come out. 600 00:44:19,740 --> 00:44:20,120 Okay. 601 00:44:20,140 --> 00:44:25,160 I don't know, a couple of weeks ago, but it's not backported. 602 00:44:25,380 --> 00:44:30,860 You mean, you, maybe you have a Linux system over here. 603 00:44:31,100 --> 00:44:38,460 I'm going to attack a completely actualized Ubuntu system to see if they have patched 604 00:44:38,460 --> 00:44:38,840 this vulnerability. 605 00:44:39,940 --> 00:44:40,460 Okay. 606 00:44:41,380 --> 00:44:41,900 Okay. 607 00:44:42,300 --> 00:44:42,820 Okay. 608 00:44:43,140 --> 00:44:43,660 Okay. 609 00:44:44,100 --> 00:44:44,240 Okay. 610 00:44:45,460 --> 00:44:45,800 Okay. 611 00:44:46,600 --> 00:44:46,660 Okay. 612 00:44:47,000 --> 00:44:47,220 Okay. 613 00:44:49,920 --> 00:44:50,040 Okay. 614 00:44:52,320 --> 00:44:52,740 Okay. 615 00:44:52,840 --> 00:44:52,900 Okay. 616 00:44:53,120 --> 00:44:53,500 Okay. 617 00:44:53,500 --> 00:44:53,540 Okay. 618 00:44:53,780 --> 00:44:54,200 Okay. 619 00:44:54,200 --> 00:44:54,280 Okay. 620 00:44:54,280 --> 00:44:54,300 Okay. 621 00:44:54,300 --> 00:44:54,340 Okay. 622 00:44:54,340 --> 00:44:54,720 Okay. 623 00:44:54,720 --> 00:44:55,100 Okay. 624 00:44:55,100 --> 00:44:55,140 Okay. 625 00:44:55,740 --> 00:44:56,160 Okay. 626 00:44:58,860 --> 00:44:59,280 Okay. 627 00:45:00,020 --> 00:45:00,440 Okay. 628 00:45:00,440 --> 00:45:00,640 Okay. 629 00:45:00,760 --> 00:45:01,180 Okay. 630 00:45:01,180 --> 00:45:01,480 Okay. 631 00:45:01,600 --> 00:45:01,800 Okay. 632 00:45:02,200 --> 00:45:02,240 Okay. 633 00:45:02,740 --> 00:45:02,880 Okay. 634 00:45:03,280 --> 00:45:03,700 Okay. 635 00:45:04,760 --> 00:45:05,180 Okay. 636 00:45:34,520 --> 00:45:38,380 Okay, we're going to launch the last, the same library, the same packets. 637 00:45:41,560 --> 00:45:42,080 Okay. 638 00:45:45,120 --> 00:45:47,360 Well great, the Ubuntu system survived perfectly. 639 00:45:51,320 --> 00:45:56,720 But we're going to launch the first attack, there's some other attack, oh damn. 640 00:45:57,260 --> 00:46:02,860 So you got there a full patched Ubuntu system that is still have a vulnerability. 641 00:46:03,660 --> 00:46:07,560 All because the IPv6 was activated by default. 642 00:46:08,200 --> 00:46:15,640 So this talk is over now, but I want you to say only one thing, that is if you got a Unix 643 00:46:15,640 --> 00:46:17,000 system or a Linux system. 644 00:46:17,000 --> 00:46:23,380 And you got IP activated and you don't use it, please deactivate it, it's pretty easy 645 00:46:23,380 --> 00:46:23,660 to do. 646 00:46:23,720 --> 00:46:27,260 Because you can see, there are very bad people out there. 647 00:46:28,160 --> 00:46:30,780 And they can do things like this. 648 00:46:31,080 --> 00:46:32,080 So thank you. 649 00:46:32,500 --> 00:46:34,580 If you have any questions, you can ask them now. 650 00:46:36,140 --> 00:46:36,860 I don't know. 651 00:46:37,700 --> 00:46:40,600 What portion of the packet are you invading the shell for? 652 00:46:42,000 --> 00:46:44,400 What portion of the packet are you invading the shell for? 653 00:46:45,740 --> 00:46:46,560 Well, I... 654 00:46:47,000 --> 00:46:56,800 The ICMP packet has a data part that is supposed to be replicated in the answer of the ICMP 655 00:46:56,800 --> 00:46:57,180 packet. 656 00:46:57,540 --> 00:47:00,360 And I placed simply in that portion of the packet. 657 00:47:00,460 --> 00:47:03,080 It's a big packet, like a 1,000 byte length. 658 00:47:03,540 --> 00:47:09,220 And the shell code in fact is something like, I don't know, 700 bytes. 659 00:47:09,420 --> 00:47:12,700 It fits perfectly in the second ICMP payload. 660 00:47:13,620 --> 00:47:14,600 It's in that part. 661 00:47:16,080 --> 00:47:22,040 I could send the exploit in a lot of other ways, like, I don't know, floating the system 662 00:47:22,040 --> 00:47:22,920 with shell codes. 663 00:47:23,060 --> 00:47:25,860 The system will place the shell code any place in the memory. 664 00:47:26,080 --> 00:47:28,780 Maybe you're going to fill the memory with the shell code. 665 00:47:28,980 --> 00:47:33,740 And I can't just jump anywhere in the memory because the shell code surely will be there. 666 00:47:33,860 --> 00:47:42,880 Because if I send, I don't know, 10 megabytes of traffic to the OpenBSD system, it's going 667 00:47:42,880 --> 00:47:43,960 to put it in some way. 668 00:47:44,020 --> 00:47:44,580 In some way. 669 00:47:44,580 --> 00:47:45,240 Some place in the memory. 670 00:47:46,380 --> 00:47:46,820 Okay. 671 00:47:48,640 --> 00:47:52,080 If there is no more question, thank you very much. 672 00:47:52,260 --> 00:47:53,820 And that's all. 673 00:47:54,100 --> 00:47:54,940 Thank you for coming.