1 00:00:00,000 --> 00:00:09,400 I'm Joel Eriksson from the BitSec R&D team, and these are my colleagues, Carl Janmar, Klaus Nyberg, and Christer Oberg. 2 00:00:10,420 --> 00:00:16,300 This talk is about kernel vulnerabilities in general, and kernel mode exploitation in particular. 3 00:00:16,780 --> 00:00:26,080 We'll begin with a short introduction to the topic, followed by several real-world examples and demonstrations of kernel mode exploits that we have developed ourselves. 4 00:00:27,440 --> 00:00:30,380 So, why exploit kernel-level vulnerabilities? 5 00:00:31,180 --> 00:00:37,140 Well, first of all, the real reason behind most things in life, and perhaps especially here in Vegas, because it's fun. 6 00:00:38,180 --> 00:00:42,520 Also, there's not many people doing it yet, so still plenty of bugs to play with. 7 00:00:43,540 --> 00:00:53,660 Exploiting at the kernel level also means that we can bypass most defense mechanisms and any kinds of restrictions, such as file permissions, ACLs, secure levels, etc. 8 00:00:54,540 --> 00:00:56,060 And since the target operates... 9 00:00:56,080 --> 00:00:59,680 ...in the operating system itself, we don't rely on how the system is set up and configured. 10 00:01:02,520 --> 00:01:08,720 There are also a few reasons not to exploit kernel-level vulnerabilities from the exploit developer's point of view. 11 00:01:09,340 --> 00:01:15,180 Since any failed attempts will generally lead to system crash, the exploits need to be very reliable. 12 00:01:15,940 --> 00:01:22,820 Also, kernel debugging can be quite a pain to set up, especially for obscure or embedded operating systems. 13 00:01:23,240 --> 00:01:26,060 And of course, in general, we need at least some... 14 00:01:26,080 --> 00:01:27,420 ...knowledge about kernel internals. 15 00:01:28,780 --> 00:01:31,460 These are some of the common targets for attack in a kernel. 16 00:01:32,140 --> 00:01:40,880 For local exploits, there are quite a few attack vectors, such as all the system calls, IO control messages, and executable file format loaders, to mention a few. 17 00:01:41,440 --> 00:01:48,880 For remote exploits, we're generally restricted to drivers for network protocols and protocol handlers. 18 00:01:50,000 --> 00:01:53,680 Sometimes it may also be interesting with attacks that require physical access. 19 00:01:53,940 --> 00:01:56,060 For example, when we want to do live forensics... 20 00:01:56,060 --> 00:02:04,360 ...of a system that potentially uses disk encryption, or when we need to bypass a PIN or a password on an embedded device, such as a phone or a PDA. 21 00:02:05,060 --> 00:02:09,280 In this case, we also want to look at drivers for hardware interfaces, such as USB devices. 22 00:02:10,860 --> 00:02:18,500 As for the payload, we often want to do privilege escalation, which for a Unix-based system is usually as simple as altering a user ID field. 23 00:02:19,020 --> 00:02:23,260 In Windows, we may steal or duplicate an access token from a privilege process. 24 00:02:23,260 --> 00:02:32,580 If a userland process is restricted somehow, we can use our kernel-mode payload to bypass it, for instance by breaking out a changed root directory. 25 00:02:33,480 --> 00:02:40,980 The most powerful payload strategy, and especially useful for remote exploits, is to inject the backdoor directly into the kernel. 26 00:02:41,500 --> 00:02:43,500 And we will see examples of this later. 27 00:02:45,700 --> 00:02:50,520 Some of the things we often need to do in our payload is to make it reliable. 28 00:02:50,520 --> 00:02:53,720 It's automatically determining addresses and offsets. 29 00:02:54,180 --> 00:02:59,520 This can be done by simply parsing the L4P headers to resolve the symbols in memory. 30 00:03:00,060 --> 00:03:05,680 It may also be done by pattern matching, for instance by searching for certain instruction sequences. 31 00:03:06,400 --> 00:03:11,400 And as a last resort, we may simply hard-code the addresses and offsets for specific kernel releases. 32 00:03:13,940 --> 00:03:20,020 For local privilege escalation exploits, there are also some operating system and architecture-specific techniques... 33 00:03:20,020 --> 00:03:20,860 ...that can come in handy. 34 00:03:21,440 --> 00:03:27,680 Here are some examples of how to determine the address to the process or thread structure pointer on various systems. 35 00:03:31,480 --> 00:03:35,480 And as a golden rule for kernel exploits, we need to clean up any mess we create. 36 00:03:35,820 --> 00:03:42,840 If the bug we exploited was an overflow, which is often the case, we need to restore same values for any important data that was overwritten. 37 00:03:43,260 --> 00:03:48,480 For stack-based overflows, we might get away with restoring a stack frame beyond the stack data that were overwritten... 38 00:03:48,480 --> 00:03:52,560 ...and for heap-based overflows, we may need to repair the heap. 39 00:03:54,700 --> 00:03:58,200 Now over to our first real-world example, the GDI bug. 40 00:03:58,600 --> 00:04:05,660 GDI stands for Graphics Device Interface, and is used for handling all kinds of GUI objects, such as Windows fonts, etc. 41 00:04:06,320 --> 00:04:11,720 The data for these objects are stored in the memory section, which is shared between the user-mode processes and the kernel. 42 00:04:12,420 --> 00:04:16,460 This memory section is mapped read-only into GUI processes by default. 43 00:04:16,460 --> 00:04:20,340 But it turns out that the section can be remapped read-write. 44 00:04:21,220 --> 00:04:26,100 Crashing the system can be achieved by simply overwriting the entire table with trash. 45 00:04:26,840 --> 00:04:30,560 But that's not very interesting. So is there a way to exploit it? 46 00:04:32,720 --> 00:04:34,900 As for finding the bug, I didn't. 47 00:04:35,020 --> 00:04:39,000 The bug was made public in November last year, during the month of kernel bugs project. 48 00:04:39,960 --> 00:04:46,360 Microsoft was actually notified it over two years ago, but obviously didn't take it very seriously at the time. 49 00:04:47,040 --> 00:04:50,080 Perhaps because they didn't think it could be reliably exploited. 50 00:04:51,060 --> 00:04:58,000 When the bug had been public for about a month, and neither an exploit nor a patch had been released, I decided to look into it myself. 51 00:04:58,400 --> 00:05:00,680 And after a couple of days, I had a working exploit. 52 00:05:01,560 --> 00:05:09,100 It was finally patched in the middle of April this year, a couple of weeks after I demonstrated my exploit for it at Black Hat Europe. 53 00:05:11,500 --> 00:05:16,360 The first step in the analysis of this vulnerability was finding a reliable way to determine 54 00:05:16,460 --> 00:05:20,260 the GDI section handle, so we can remap it to gain write access to the section. 55 00:05:20,860 --> 00:05:23,680 My basic idea was to find it by pattern matching. 56 00:05:24,140 --> 00:05:29,220 If we know the size and contents of the GDI section, we can easily determine when we found it. 57 00:05:29,900 --> 00:05:31,600 This is the first thing we need to know. 58 00:05:31,820 --> 00:05:38,600 The GDI section contains an array of structs with these fields, and each entry in the table is 16 bytes large. 59 00:05:40,500 --> 00:05:45,520 Combined with the fact that the maximum number of GDI objects in Windows 2000 is 4000 hex, 60 00:05:45,520 --> 00:05:50,440 and in Windows XP is 10,000 hex, we can determine the minimum size for a valid GDI section. 61 00:05:53,360 --> 00:05:57,880 We may also be interested in knowing how the handle to a GDI object is interpreted. 62 00:05:58,280 --> 00:06:02,960 The lower 16 bits of the handle is actually used as the index into the GDI section table, 63 00:06:03,660 --> 00:06:10,240 and the upper 16 bits of the handle is used as a sanit check and must match the N upper field for the entry with this index. 64 00:06:10,980 --> 00:06:15,200 This is quite useful for us to know when we brute force the handle to the GDI section. 65 00:06:16,640 --> 00:06:18,240 My final method is this. 66 00:06:18,440 --> 00:06:25,340 We create the GDI object, calculate the index where it's supposed to be at by taking the lower 16 bits of the handle to this object, 67 00:06:25,580 --> 00:06:30,700 and we calculate the value that the N upper field should have by taking the upper 16 bits of the handle. 68 00:06:31,300 --> 00:06:35,020 And for each memory section that we're able to map, we check the section size, 69 00:06:35,300 --> 00:06:42,600 we get the entry in the table where our GDI object should be, and we check the process ID and the N upper fields. 70 00:06:42,600 --> 00:06:50,640 And, if you're as paranoid as I am, I also check the type field, which will have different values depending on what type of GDI object is created. 71 00:06:53,420 --> 00:07:01,880 Being able to overwrite pointers are always interesting for us exploit developers, and in the GDI section there are two for each GUI object. 72 00:07:02,360 --> 00:07:07,020 One is a user mode pointer, used in the process which owns the GUI object in question. 73 00:07:07,320 --> 00:07:09,960 The other is a kernel mode pointer, used in kernel context. 74 00:07:10,940 --> 00:07:16,140 By manipulating these pointers, we hope to be able to eventually achieve a write to an arbitrary memory address. 75 00:07:18,140 --> 00:07:22,860 If we decide to target the user mode pointer, we might be able to exploit it through a privileged process, 76 00:07:23,180 --> 00:07:26,740 but this would probably be very hard to do generically. 77 00:07:27,180 --> 00:07:30,780 And of course, exploiting it in kernel context is much more fun. 78 00:07:33,000 --> 00:07:36,440 So, I decided to attack the pkernel info pointer. 79 00:07:37,260 --> 00:07:39,940 Since the pkernel info pointer will point to a different GUI object, 80 00:07:39,960 --> 00:07:43,840 and a different type of struct, depending on which type of GDI object is being used, 81 00:07:44,020 --> 00:07:46,920 I realized I had to try creating different types of objects. 82 00:07:47,400 --> 00:07:55,300 It seemed quite likely that somewhere along the line, a call to a GDI-related syscall would eventually turn up writing to something in this struct. 83 00:07:57,200 --> 00:08:03,100 After a lot of test cases, and a lot of help from WinDBG and IDPro, I came up with this. 84 00:08:03,640 --> 00:08:08,480 When brush objects are destroyed with the NTGDIDeleteObjectApp syscall, 85 00:08:09,960 --> 00:08:12,600 the pointer at index 9 is written to with the fixed value 2. 86 00:08:13,200 --> 00:08:19,020 But only if the value at index 2 is set, and the value at index 0 is set to the object's own handle. 87 00:08:19,600 --> 00:08:24,960 As it turns out, this technique was reliable enough to be used for exploiting all of the vulnerable systems. 88 00:08:26,440 --> 00:08:29,580 There are still a couple of problems to solve before we have a full exploit, though. 89 00:08:30,220 --> 00:08:34,040 First, we need to find a suitable address to overwrite, preferably a function pointer. 90 00:08:34,680 --> 00:08:38,240 The data that is written to this function pointer will be the fixed value 2, 91 00:08:38,240 --> 00:08:44,120 which is quite enough for our purposes, since we can place the payload on any address in the exploit process, 92 00:08:44,920 --> 00:08:49,100 since we can dereference use model data in the kernel. 93 00:08:51,760 --> 00:08:54,280 But how do we find a suitable function pointer? 94 00:08:54,620 --> 00:08:58,240 To be suitable for us, it must be possible to reliably determine its address. 95 00:08:58,420 --> 00:09:01,340 It must also be called in the context of our exploit process. 96 00:09:01,920 --> 00:09:07,820 And to avoid a crash, we need to use a function pointer which is very unlikely to be called by any other process, 97 00:09:07,820 --> 00:09:09,260 while our exploit is executing. 98 00:09:10,260 --> 00:09:12,740 The obvious choice is a rarely used system call, 99 00:09:12,940 --> 00:09:16,780 which would be very easy to trigger a call to from within our exploit. 100 00:09:18,580 --> 00:09:21,220 There are actually two system call tables in Windows, 101 00:09:21,440 --> 00:09:25,500 one for the native NT API, and one for the Win32 subsystem. 102 00:09:27,340 --> 00:09:31,300 My first choice was overwriting a syscall in the native API table, 103 00:09:31,500 --> 00:09:36,340 which was quite convenient, since there were already documented methods to determine its address. 104 00:09:36,340 --> 00:09:40,380 And it worked great, except for under XP Service Pack 1. 105 00:09:42,520 --> 00:09:44,180 So, why didn't it work? 106 00:09:44,640 --> 00:09:49,600 Well, turns out that this syscall table is actually stored in a read-only memory section, 107 00:09:49,900 --> 00:09:54,460 but the read-only property of memory is not enforced in kernel context, 108 00:09:54,720 --> 00:09:57,720 except for under XP Service Pack 1, for some reason. 109 00:09:58,120 --> 00:09:59,760 I wanted something more reliable. 110 00:10:01,740 --> 00:10:03,520 When I looked at the other syscall table, 111 00:10:03,520 --> 00:10:07,940 I noticed that it's actually stored in the writable data segment of the Win32 module, 112 00:10:08,220 --> 00:10:09,800 which is perfect for us, 113 00:10:10,280 --> 00:10:13,080 but since there is no documented method to determine its address, 114 00:10:13,200 --> 00:10:14,660 I had to come up with the method myself. 115 00:10:16,400 --> 00:10:18,960 I had two IDs, based on pattern matching, 116 00:10:19,160 --> 00:10:21,620 and this one was not entirely reliable. 117 00:10:23,700 --> 00:10:30,040 The final method is to search the code for the call to the function that registers the Win32 syscall table, 118 00:10:30,300 --> 00:10:33,500 and extract the address from the arguments that are being called. 119 00:10:33,520 --> 00:10:34,240 And then push to the stack. 120 00:10:36,340 --> 00:10:37,300 As for the payload, 121 00:10:37,640 --> 00:10:41,880 I want to elevate the privileges of my exploit process. 122 00:10:42,200 --> 00:10:45,280 And unlike in Unix-based systems, this can be quite complicated. 123 00:10:45,900 --> 00:10:50,700 What we do is actually temporarily steal a so-called access token from a privileged process. 124 00:10:51,280 --> 00:10:55,320 And at first, I had some reliability issues with this. 125 00:10:56,880 --> 00:11:01,500 I solved this by restoring the original access token for the exploit process after I'm done. 126 00:11:01,500 --> 00:11:08,080 And the final result is a reliable exploit for all of the vulnerable Windows XP and Windows 2000 systems. 127 00:11:09,580 --> 00:11:11,260 Now time for a demonstration. 128 00:11:46,880 --> 00:11:49,220 To make it a little bit more interesting, 129 00:11:49,400 --> 00:11:57,180 I actually embedded the exploit for the GDI bug in another exploit for an Office XP bug that we found. 130 00:12:02,500 --> 00:12:12,220 And here I have the attacker, which is listening to port 8080. 131 00:12:13,240 --> 00:12:17,740 And here I have the victim opening an Office document. 132 00:12:20,600 --> 00:12:24,040 And if you look here at the attacker, we have a shell. 133 00:12:24,980 --> 00:12:27,520 And it's running with system privileges. 134 00:12:35,840 --> 00:12:43,380 And we can also see that we were an unprivileged user from the beginning. 135 00:12:43,840 --> 00:12:48,160 I also made a command line version of the exploit. 136 00:12:58,240 --> 00:13:03,420 So I can, for instance, change the administrator account password. 137 00:13:03,720 --> 00:13:06,340 And the administrator account here is called root. 138 00:13:08,160 --> 00:13:08,980 Worked fine. 139 00:13:10,280 --> 00:13:14,280 And here it doesn't. 140 00:13:14,800 --> 00:13:18,980 Okay, now over to my colleague Krister. 141 00:13:30,340 --> 00:13:30,900 Hi. 142 00:13:31,800 --> 00:13:34,060 I'm going to talk about NetBeast debug I found. 143 00:13:34,320 --> 00:13:38,820 It's very similar to NetBeast debug I found and presented on in Amsterdam. 144 00:13:40,140 --> 00:13:44,540 I found a bug using a fuzzing tool developed by my colleague here, Klas. 145 00:13:45,040 --> 00:13:52,300 And what I did was I wrote a script to generate sockets using random combinations of domain types and protocols. 146 00:13:52,300 --> 00:13:55,660 And then I attempted to bind them using a random socket address. 147 00:13:56,540 --> 00:13:58,860 And this, of course, led to a kernel crash. 148 00:14:01,700 --> 00:14:05,560 Having already found a very similar bug, it was very easy for me to track it down. 149 00:14:05,660 --> 00:14:07,280 I used the DDB debugger. 150 00:14:07,400 --> 00:14:11,680 And if we have time for it, I'm going to demonstrate DDB for you. 151 00:14:13,180 --> 00:14:18,540 You can also use GDB, of course, analyzing kernel bugs. 152 00:14:18,540 --> 00:14:22,720 You can dump a crash file to the file system and debug it offline. 153 00:14:23,020 --> 00:14:27,640 Or you can set up a serial connection between two machines and do live debugging. 154 00:14:29,700 --> 00:14:32,740 The bug is actually a straightforward buffer overflow vulnerability. 155 00:14:33,000 --> 00:14:38,620 What happens is that a call is made to be copied with a user-supplied length argument. 156 00:14:41,980 --> 00:14:43,660 So what are mbufs? 157 00:14:43,660 --> 00:14:49,480 It's basically a basic kernel memory unit used throughout the networking code in BSD. 158 00:14:50,260 --> 00:14:54,460 It stores things like sucked buffers and packed data. 159 00:14:54,680 --> 00:14:58,920 And the data can span several mbufs in a linked list. 160 00:15:04,900 --> 00:15:09,280 So basically I've exploited mbufs in two different ways on BSD. 161 00:15:09,560 --> 00:15:11,420 The first technique is an unlink. 162 00:15:13,660 --> 00:15:18,460 It's an exploitation technique, basically unlinking a mbuf from a W-linked list. 163 00:15:20,580 --> 00:15:24,440 But the second technique is even better because it's very, very hacker-friendly. 164 00:15:24,520 --> 00:15:25,520 It's very easy to exploit. 165 00:15:27,340 --> 00:15:29,960 They have something called external storage. 166 00:15:30,200 --> 00:15:34,160 Or they can contain external storage, and when they do, they can have a function pointer 167 00:15:34,940 --> 00:15:37,420 pointing to the function they want to be freed by. 168 00:15:37,540 --> 00:15:41,260 So if you control the function pointer, you can just point it to your payload, 169 00:15:41,260 --> 00:15:44,040 and the payload is executed when the buffer is freed. 170 00:15:46,300 --> 00:15:46,820 Okay. 171 00:15:47,840 --> 00:15:50,920 I don't need to talk about this because we're a bit short on time. 172 00:15:52,480 --> 00:15:56,160 So this is the macro that performs the unlinking of an mbuf. 173 00:15:57,120 --> 00:16:02,700 And what happens here is that if we can control these two pointers in this macro, 174 00:16:02,880 --> 00:16:05,540 we can achieve a memory overwrite. 175 00:16:07,000 --> 00:16:11,200 So for example, if the next drive pointer in our mbuf is pointing to the address, 176 00:16:11,260 --> 00:16:15,300 deadbeef and previous references to badcoded, 177 00:16:16,420 --> 00:16:21,660 it basically comes down to deadbeef is written to the address of badcoded plus an offset, 178 00:16:21,900 --> 00:16:22,920 and the other way around. 179 00:16:25,300 --> 00:16:27,920 So what targets do we have? 180 00:16:28,180 --> 00:16:31,120 Well, the obvious choice is obviously a return address on the stack, 181 00:16:31,280 --> 00:16:34,000 but we don't necessarily know where the return address is. 182 00:16:34,460 --> 00:16:37,860 Besides, we need it to return to whoever called us in the first place. 183 00:16:39,080 --> 00:16:41,180 There are a lot of function pointers we can use. 184 00:16:41,260 --> 00:16:44,960 The problem with them is usually that we don't necessarily know 185 00:16:46,160 --> 00:16:48,020 what they're supposed to point to, 186 00:16:48,120 --> 00:16:52,000 and we should always restore everything we're overwriting currently exploits, 187 00:16:52,040 --> 00:16:52,640 so that's no good. 188 00:16:54,240 --> 00:16:57,980 There is a system call table containing basically... 189 00:16:57,980 --> 00:17:01,840 It's an array of function pointers to the functions implementing the system calls. 190 00:17:02,440 --> 00:17:05,020 And the system calls, we can find 191 00:17:07,080 --> 00:17:09,940 the addresses of any given system call 192 00:17:11,260 --> 00:17:13,820 so if we overwrite a function pointer in this table, 193 00:17:13,920 --> 00:17:17,780 we can restore it afterwards because we know the original value. 194 00:17:18,020 --> 00:17:21,820 So what I do is I take a function pointer in this table, 195 00:17:21,920 --> 00:17:24,440 point it to my payload, execute a system call, 196 00:17:24,580 --> 00:17:26,000 and that executes my payload. 197 00:17:28,640 --> 00:17:30,740 Right, okay, when you're using the first technique, 198 00:17:30,900 --> 00:17:31,800 the unlinked technique, 199 00:17:32,640 --> 00:17:35,500 the mbuf is being put back into a memory pool, 200 00:17:35,600 --> 00:17:38,640 and the problem with this is that we're actually freeing an arbitrary pointer 201 00:17:38,640 --> 00:17:39,520 and not an mbuf, 202 00:17:39,520 --> 00:17:44,020 which means that the mb code in the kernel 203 00:17:44,020 --> 00:17:45,680 is going to be slightly confused and crash, 204 00:17:46,520 --> 00:17:48,420 unless we do something about it. 205 00:17:50,760 --> 00:17:53,280 The code is a bit tricky and complicated, 206 00:17:54,060 --> 00:17:56,060 and it changes from release to release, 207 00:17:56,240 --> 00:18:00,000 so the best way to clean things up 208 00:18:00,520 --> 00:18:03,420 is to just call a function called mbinit, 209 00:18:03,500 --> 00:18:05,300 which will reinitialize the entire thing. 210 00:18:09,520 --> 00:18:11,440 Okay, moving on to the second technique, 211 00:18:11,560 --> 00:18:14,220 when you're exploiting this function pointer, 212 00:18:14,480 --> 00:18:17,600 you're going down the same execution path 213 00:18:17,600 --> 00:18:19,320 as with the previous technique, 214 00:18:21,320 --> 00:18:24,060 but you don't want an unlinking to take place, 215 00:18:24,260 --> 00:18:26,520 so what you do is you take the next ref pointer 216 00:18:27,360 --> 00:18:29,700 and point it to your mbuf, 217 00:18:30,320 --> 00:18:32,300 and then take the ext3 pointer, 218 00:18:32,420 --> 00:18:33,460 point it to your payload, 219 00:18:33,640 --> 00:18:36,340 and that will execute a payload when m3 is called. 220 00:18:38,800 --> 00:18:40,480 Also, when you're using this technique, 221 00:18:40,660 --> 00:18:43,500 no attempt is made to put the mbuf back into a memory pool, 222 00:18:43,580 --> 00:18:44,840 so you don't have to clean anything up. 223 00:18:48,160 --> 00:18:50,680 And since this is a local kernel exploit, 224 00:18:50,840 --> 00:18:52,780 it's very, very easy to write a payload for it. 225 00:18:52,840 --> 00:18:54,380 All I need to do is find my process 226 00:18:54,380 --> 00:18:57,520 and escalate my privileges to get a root shell. 227 00:18:58,040 --> 00:19:01,200 To do that, I need to find my process pointer. 228 00:19:02,540 --> 00:19:04,060 You can do it in several ways. 229 00:19:04,160 --> 00:19:05,660 I've written a white paper about it, 230 00:19:06,340 --> 00:19:09,500 but essentially when you find your proc structure, 231 00:19:09,780 --> 00:19:11,120 you can find your credentials 232 00:19:11,120 --> 00:19:12,880 and just modify the user ID. 233 00:19:15,860 --> 00:19:20,180 Also, since the kernel can reference user space memory, 234 00:19:20,500 --> 00:19:25,600 I don't have to actually copy my payload into the kernel, 235 00:19:25,640 --> 00:19:27,900 because the kernel can read user space memory anyway. 236 00:19:41,720 --> 00:19:43,220 So, let's do that. 237 00:19:45,080 --> 00:19:46,040 . 238 00:19:50,220 --> 00:19:51,180 . 239 00:19:51,180 --> 00:19:51,440 . 240 00:19:51,440 --> 00:19:52,320 . 241 00:19:52,320 --> 00:19:53,740 . 242 00:19:53,740 --> 00:19:53,940 . 243 00:20:01,160 --> 00:20:02,120 . 244 00:20:02,120 --> 00:20:02,160 . 245 00:20:02,160 --> 00:20:02,480 . 246 00:20:02,480 --> 00:20:02,500 . 247 00:20:02,500 --> 00:20:03,340 . 248 00:20:03,340 --> 00:20:03,820 . 249 00:20:11,180 --> 00:20:26,220 Okay, so I've got a root shell now, and we can see that it's actually a patched kernel, 250 00:20:26,420 --> 00:20:30,940 so I'm not cheating, I'm not using an old vulnerability, it's a fully patched system. 251 00:20:41,420 --> 00:20:48,400 Actually, I was just told that I have some time so I can show you that debugging demo. 252 00:20:57,680 --> 00:21:00,400 So this is a real good example of why you should 253 00:21:00,400 --> 00:21:00,920 disable a root shell. 254 00:21:00,920 --> 00:21:03,620 You can disable the kernel debugger if you're working with somebody like me. 255 00:21:05,680 --> 00:21:12,900 So a user logged onto the console and has left the console and tried to lock his console 256 00:21:12,900 --> 00:21:18,060 with the lock command, and I'm trying some passwords but I can't get it. 257 00:21:22,980 --> 00:21:28,800 So I use a keyboard combination on the console to break into the debugger. 258 00:21:30,760 --> 00:21:36,300 And now I'm running the ps command in the debugger just to find the process ID. 259 00:21:44,800 --> 00:21:48,220 So I killed the lock command and continue execution. 260 00:21:57,300 --> 00:21:58,000 But... 261 00:21:58,800 --> 00:22:02,020 I don't know if you can see it, but I'm just a normal user here. 262 00:22:03,940 --> 00:22:05,660 So I'm going to write an exploit. 263 00:22:34,380 --> 00:22:35,920 Oops, shit. 264 00:22:47,320 --> 00:22:49,300 What happened there? 265 00:22:49,540 --> 00:22:50,420 Okay. 266 00:22:56,680 --> 00:22:57,560 Okay. 267 00:22:57,660 --> 00:22:57,680 Okay. 268 00:22:57,680 --> 00:22:58,160 Okay. 269 00:22:58,160 --> 00:22:58,780 Okay. 270 00:22:58,800 --> 00:23:07,840 Hold on. So I've compiled my exploit which is just trying to do a setUserId 271 00:23:07,840 --> 00:23:14,680 route which is obviously going to fail unless I do some magic in the debugger. 272 00:23:14,780 --> 00:23:20,420 So I've set up, executed it, set a break, I'm setting a breakpoint at a function 273 00:23:20,420 --> 00:23:24,300 that is going to handle my request to change my user ID. 274 00:23:37,160 --> 00:23:43,480 And I run it, and now the breakpoint here. So I'm going to set another breakpoint, continue, 275 00:23:46,820 --> 00:23:51,660 and now I'm just going to change the return value of this particular function, so I'm 276 00:23:51,660 --> 00:23:56,200 going to pretend that this function had a successful run. 277 00:24:00,220 --> 00:24:04,440 And now I continue, and I've got a root shell. 278 00:24:15,580 --> 00:24:22,840 Oh, by the way, if somebody wants to see the ODAs that I was going to do, just come up 279 00:24:22,840 --> 00:24:23,980 and talk to me afterwards. 280 00:24:24,480 --> 00:24:25,000 Okay. 281 00:24:25,880 --> 00:24:26,400 Okay. 282 00:24:28,260 --> 00:24:28,780 Okay. 283 00:24:32,600 --> 00:24:33,200 All right, next. 284 00:24:34,520 --> 00:24:35,120 Hello. 285 00:24:35,740 --> 00:24:41,040 I'm going to talk about my payload for the OpenBSD IP version-6. 286 00:24:43,020 --> 00:24:43,620 Oops. 287 00:24:48,500 --> 00:24:49,100 Vulnerability. 288 00:24:55,640 --> 00:24:58,780 This bug was found and researched by Alfred Rotega at Core. 289 00:24:58,800 --> 00:25:02,380 so he is the guy that should have credits for finding this bug. 290 00:25:02,580 --> 00:25:06,680 He released a proof of concept code that only executed a breakpoint 291 00:25:06,680 --> 00:25:09,280 but no actual exploit was ever released. 292 00:25:11,180 --> 00:25:14,560 This bug is triggered by sending specially crafted 293 00:25:14,560 --> 00:25:18,780 fragmented ICMP version 6 packets, which causes 294 00:25:18,780 --> 00:25:21,820 an mbuf structure to be completely overwritten. 295 00:25:23,040 --> 00:25:26,900 Krister already talked about taking control of the execution flow 296 00:25:26,900 --> 00:25:29,660 from there, so I won't take that again. 297 00:25:33,100 --> 00:25:34,700 ECX, EBX and ESI 298 00:25:34,700 --> 00:25:38,760 all points to the start of the overwritten mbuf, so a jump 299 00:25:38,760 --> 00:25:43,000 ESI takes us to the beginning of that mbuf. From there we jump 300 00:25:43,000 --> 00:25:46,180 200 bytes back to reach stage 1. 301 00:25:47,540 --> 00:25:49,560 My payload has three stages. 302 00:25:50,740 --> 00:25:53,360 The first stage, which installs a backdoor, 303 00:25:53,360 --> 00:25:57,460 a wrapper for the ICMP 6 304 00:25:57,460 --> 00:26:01,100 input function. The reason for using this is that we use 305 00:26:01,100 --> 00:26:05,220 ICMP 6 packets to trigger the vulnerability, so we know that we can 306 00:26:05,220 --> 00:26:09,060 reach a target system if the exploit succeeded. 307 00:26:10,320 --> 00:26:12,420 The second stage is the backdoor, 308 00:26:13,140 --> 00:26:17,140 the code that wraps ICMP 6 input and 309 00:26:17,140 --> 00:26:20,900 inspects incoming ICMP 6 packets 310 00:26:20,900 --> 00:26:24,720 for backdoor commands. I implemented four 311 00:26:24,720 --> 00:26:28,600 different backdoor commands, which we will talk more about later. 312 00:26:31,080 --> 00:26:32,240 Stage 1 313 00:26:35,540 --> 00:26:36,980 The first 314 00:26:36,980 --> 00:26:40,200 thing done by stage 1 is to try to locate stage 2. 315 00:26:40,640 --> 00:26:44,740 Stage 2 is sent as the payload 316 00:26:44,740 --> 00:26:48,240 in a previously sent ICMP echo request packet. 317 00:26:48,240 --> 00:26:52,140 So what we need to do is to find the mbuf 318 00:26:52,140 --> 00:26:56,060 chain for that packet and traverse it until the end and fetch the data 319 00:26:56,060 --> 00:26:58,460 pointer to get a pointer to our payload. 320 00:27:00,020 --> 00:27:04,320 When we trigger the vulnerability from within M3M 321 00:27:04,320 --> 00:27:08,160 there is actually a pointer on the stack at 322 00:27:08,160 --> 00:27:11,980 108 bytes from ESP to the 323 00:27:11,980 --> 00:27:15,880 previously sent packet. I do some checks as well in case 324 00:27:15,880 --> 00:27:19,880 another packet got, which is not 325 00:27:19,880 --> 00:27:20,560 contains our 326 00:27:25,940 --> 00:27:27,400 payload. Checking for 327 00:27:27,400 --> 00:27:31,300 mbuf flags and make sure that the pointer on the stack is valid. 328 00:27:33,340 --> 00:27:35,660 Stage 2 contains a symbol resolver 329 00:27:35,660 --> 00:27:39,720 so we use that one to resolve unit 6 330 00:27:39,720 --> 00:27:43,800 SV and check the value of the current ICMP 331 00:27:43,800 --> 00:27:45,220 6 input function. 332 00:27:49,260 --> 00:27:51,880 We check if the backdoor is already installed. 333 00:27:52,240 --> 00:27:55,960 This is done by comparing the first 4 bytes 334 00:27:55,960 --> 00:27:59,680 in the current function since our 335 00:27:59,680 --> 00:28:03,480 backdoor starts with a call to get the address of the current location 336 00:28:03,480 --> 00:28:07,340 to be able to extract the data pre-pended to 337 00:28:07,880 --> 00:28:11,820 this code. So it's enough to compare the 338 00:28:11,820 --> 00:28:15,600 first 4 bytes actually. We then resolve my lock 339 00:28:15,880 --> 00:28:19,400 and allocate kernel memory for stage 2 and copy the code there. 340 00:28:20,900 --> 00:28:23,620 It's enough to simply overwrite the function 341 00:28:23,620 --> 00:28:27,800 pointer since we came from a network interrupt so all the 342 00:28:27,800 --> 00:28:31,620 locks are in place. We then clean up the stack and return once the 343 00:28:31,620 --> 00:28:35,600 backdoor is installed. The symbol resolver 344 00:28:35,600 --> 00:28:39,760 part of stage 2 is really nice 345 00:28:39,760 --> 00:28:43,620 because we get rid of all the hard-coded addresses 346 00:28:43,620 --> 00:28:44,860 to all the symbols. 347 00:28:47,300 --> 00:28:49,000 We search for the ELF 348 00:28:49,000 --> 00:28:51,580 The ELF header is not mapped at the fixed address 349 00:28:51,580 --> 00:28:53,280 on OpenBSD as for example 350 00:28:53,280 --> 00:28:55,680 FreeBSD. So we search for the 351 00:28:55,680 --> 00:28:56,320 ELF header from 352 00:28:57,360 --> 00:28:58,580 the BSS segment. 353 00:28:59,800 --> 00:29:01,640 And then search for 354 00:29:01,640 --> 00:29:03,600 hashes of symbol strings in the Dunsom section 355 00:29:03,600 --> 00:29:05,420 pretty much like you do in any Windows 356 00:29:05,420 --> 00:29:05,940 shell code. 357 00:29:09,220 --> 00:29:11,520 The resolver code I use here was 358 00:29:11,520 --> 00:29:13,360 initially written by Krister for 359 00:29:13,620 --> 00:29:14,740 another project so 360 00:29:15,420 --> 00:29:17,580 it was modified a bit to fit 361 00:29:17,580 --> 00:29:18,300 into this code. 362 00:29:19,760 --> 00:29:21,820 The backdoor, as I said 363 00:29:21,820 --> 00:29:23,160 it listens for ICMP6 364 00:29:23,160 --> 00:29:25,460 packets which has magic 365 00:29:25,460 --> 00:29:26,840 bytes in the beginning of the payload 366 00:29:26,840 --> 00:29:29,340 indicating that this is a 367 00:29:29,340 --> 00:29:30,020 backdoor command. 368 00:29:31,680 --> 00:29:33,480 Once such a packet is spotted 369 00:29:33,480 --> 00:29:34,740 we simply copy 370 00:29:35,480 --> 00:29:37,280 the stage 3, the command 371 00:29:37,280 --> 00:29:39,720 to memory that we allocate 372 00:29:39,720 --> 00:29:41,720 and then wrap a system call 373 00:29:41,720 --> 00:29:43,320 with this memory block. 374 00:29:44,280 --> 00:29:45,520 And then call the 375 00:29:45,520 --> 00:29:47,580 real ICMP6 input function 376 00:29:47,580 --> 00:29:48,440 and return. 377 00:29:50,180 --> 00:29:51,220 Using syscalls 378 00:29:51,220 --> 00:29:53,520 from within the kernel makes it 379 00:29:53,520 --> 00:29:54,580 really easy to write 380 00:29:55,400 --> 00:29:57,220 kernel shell code since it's highly 381 00:29:57,220 --> 00:29:57,620 portable. 382 00:29:58,620 --> 00:30:01,460 The thing is that we need a process 383 00:30:01,460 --> 00:30:02,600 context to be able to 384 00:30:03,420 --> 00:30:04,840 use system calls. 385 00:30:06,140 --> 00:30:07,520 So we wrap a system 386 00:30:07,520 --> 00:30:09,180 call, wait for it to be called 387 00:30:09,180 --> 00:30:11,340 and then we fork from that process 388 00:30:11,340 --> 00:30:13,540 to create a node process to play with 389 00:30:15,860 --> 00:30:17,360 I took a look at the 390 00:30:18,480 --> 00:30:18,980 default 391 00:30:19,640 --> 00:30:20,560 installations and 392 00:30:21,200 --> 00:30:23,240 the good time of day was called quite 393 00:30:23,240 --> 00:30:24,900 frequently so I picked that one. 394 00:30:25,100 --> 00:30:26,040 It works great. 395 00:30:30,240 --> 00:30:31,420 The stage 3 command 396 00:30:31,420 --> 00:30:33,300 needs to know which syscall we 397 00:30:33,300 --> 00:30:35,520 wrapped so we simply prepend 398 00:30:35,520 --> 00:30:37,160 the index of that system call 399 00:30:37,160 --> 00:30:39,040 and the address to the real handler 400 00:30:40,080 --> 00:30:40,580 before 401 00:30:41,200 --> 00:30:43,380 stage 3 code found in the payload. 402 00:30:45,400 --> 00:30:47,420 I implemented four different 403 00:30:47,420 --> 00:30:49,220 commands. The traditional 404 00:30:49,220 --> 00:30:51,300 connectback, creating a 405 00:30:51,300 --> 00:30:53,180 TCP connection 406 00:30:53,180 --> 00:30:55,540 which spawns a shell so we get a raw shell. 407 00:30:56,780 --> 00:30:57,700 We might 408 00:30:57,700 --> 00:30:59,540 need to change the secure level 409 00:30:59,540 --> 00:31:01,440 to be able to do fun stuff 410 00:31:01,440 --> 00:31:03,020 like loading kernel modules 411 00:31:03,540 --> 00:31:05,540 so there is a command for 412 00:31:05,540 --> 00:31:07,280 setting the secure level to an arbitrary 413 00:31:07,280 --> 00:31:07,740 value. 414 00:31:09,680 --> 00:31:10,360 Depending 415 00:31:10,360 --> 00:31:13,340 on the system 416 00:31:13,620 --> 00:31:15,160 that we are attacking it might be 417 00:31:15,160 --> 00:31:17,560 stuff like firewall rules preventing us 418 00:31:17,560 --> 00:31:19,600 to set up a connectback connection. 419 00:31:19,860 --> 00:31:21,580 So there is a command to 420 00:31:21,580 --> 00:31:23,100 run arbitrary shell commands 421 00:31:24,000 --> 00:31:25,400 just like system 422 00:31:25,400 --> 00:31:27,320 in the C library. 423 00:31:28,960 --> 00:31:31,260 The output of this command would obviously 424 00:31:31,260 --> 00:31:33,260 be sent to the standard output and error 425 00:31:33,260 --> 00:31:35,400 of the process that we forked from so 426 00:31:35,400 --> 00:31:37,580 you better make sure to redirect it 427 00:31:37,580 --> 00:31:38,680 to device null or something 428 00:31:38,680 --> 00:31:40,280 when you type the command. 429 00:31:41,580 --> 00:31:43,060 The last command is 430 00:31:43,620 --> 00:31:45,540 the left over since I 431 00:31:45,540 --> 00:31:47,440 needed a way to uninstall 432 00:31:47,440 --> 00:31:49,000 the backdoor while developing testing 433 00:31:49,000 --> 00:31:49,900 and stuff like that. 434 00:31:52,100 --> 00:31:53,680 And you can use 435 00:31:53,680 --> 00:31:55,200 the traditional unix commands 436 00:31:55,200 --> 00:31:57,740 to send and receive files. 437 00:31:58,020 --> 00:31:58,820 There is no 438 00:31:59,760 --> 00:32:00,860 command implemented 439 00:32:00,860 --> 00:32:03,260 for that. It's enough with the 440 00:32:03,260 --> 00:32:04,840 connectback connection. 441 00:32:06,400 --> 00:32:07,720 The stage 3 commands 442 00:32:07,720 --> 00:32:09,640 are all implemented in similar ways. 443 00:32:09,860 --> 00:32:11,640 They all use the stage 2 resolver 444 00:32:11,640 --> 00:32:12,560 to resolve symbols. 445 00:32:13,620 --> 00:32:14,720 The first thing done 446 00:32:15,640 --> 00:32:17,500 is to reset the wrapped system call 447 00:32:17,500 --> 00:32:19,340 and then calls 448 00:32:19,340 --> 00:32:21,600 the real system call and saves the return value. 449 00:32:22,260 --> 00:32:23,580 After that it forks 450 00:32:23,580 --> 00:32:24,840 from the calling process 451 00:32:24,840 --> 00:32:26,660 to create the process 452 00:32:27,440 --> 00:32:29,100 that we own. 453 00:32:33,940 --> 00:32:35,400 Since we wrap a system call 454 00:32:35,400 --> 00:32:37,040 any process can call 455 00:32:37,040 --> 00:32:39,500 the bad system call with any privileges 456 00:32:39,500 --> 00:32:41,340 so we have to make sure that we 457 00:32:41,340 --> 00:32:43,260 really got root. We do this by setting 458 00:32:43,620 --> 00:32:44,020 the values right 459 00:32:44,020 --> 00:32:46,460 before continuing to execute. 460 00:32:55,390 --> 00:32:57,220 We will be attacking 461 00:32:57,220 --> 00:32:58,300 OpenBSD. 462 00:33:11,540 --> 00:33:12,920 We will be 463 00:33:13,620 --> 00:33:15,520 attacking OpenBSD 4.0 464 00:33:15,520 --> 00:33:17,000 so we resolve the MAC address 465 00:33:17,000 --> 00:33:18,100 of the target system. 466 00:33:25,260 --> 00:33:26,960 Now the backdoor is installed 467 00:33:26,960 --> 00:33:29,360 in kernel space and we 468 00:33:29,360 --> 00:33:30,700 create the connectback connection 469 00:33:31,800 --> 00:33:33,260 since there are no firewalls 470 00:33:33,260 --> 00:33:34,180 installed in the system. 471 00:33:35,340 --> 00:33:37,240 We check the current value of the 472 00:33:37,240 --> 00:33:37,980 secure level 473 00:33:41,940 --> 00:33:43,060 which is 2. 474 00:33:43,620 --> 00:33:45,360 Highest possible and 475 00:33:45,360 --> 00:33:47,320 we make a listing in the temp directory. 476 00:33:52,120 --> 00:33:53,240 With an exit 477 00:33:53,240 --> 00:33:54,280 the connectback shell 478 00:33:54,280 --> 00:33:56,820 and set the secure level to 479 00:33:56,820 --> 00:33:57,940 minus 1 480 00:33:59,860 --> 00:34:00,980 lowest possible 481 00:34:02,020 --> 00:34:03,040 and then 482 00:34:03,040 --> 00:34:04,140 just to demonstrate 483 00:34:04,140 --> 00:34:07,300 the implementation of the arbitrary 484 00:34:07,300 --> 00:34:09,300 shell command we grep for root 485 00:34:09,300 --> 00:34:10,640 in the master password file. 486 00:34:15,700 --> 00:34:16,180 And 487 00:34:17,680 --> 00:34:19,440 this is all done in kernel space. 488 00:34:19,680 --> 00:34:21,300 I don't modify any user 489 00:34:21,300 --> 00:34:22,720 land process or something like that. 490 00:34:22,860 --> 00:34:23,920 Everything is done in the 491 00:34:25,180 --> 00:34:26,420 within the kernel. 492 00:34:28,100 --> 00:34:29,260 And we can see that the 493 00:34:29,260 --> 00:34:30,260 secure level has changed. 494 00:34:33,120 --> 00:34:34,960 And the output from the grep command 495 00:34:34,960 --> 00:34:37,180 is in the file in the temp directory. 496 00:34:40,060 --> 00:34:41,480 And since we are 497 00:34:41,480 --> 00:34:43,340 nice people we uninstall 498 00:34:43,620 --> 00:34:45,320 the backdoor. 499 00:34:48,620 --> 00:34:51,300 Thank you. Time for Carl 500 00:34:51,300 --> 00:34:53,500 to talk about 501 00:34:53,500 --> 00:34:55,680 his FreeBSD 502 00:34:55,680 --> 00:34:55,940 stuff. 503 00:34:59,120 --> 00:35:04,120 What the fuck? 504 00:35:13,620 --> 00:35:14,200 Hello. 505 00:35:16,520 --> 00:35:18,460 My name is Carl Janmar. 506 00:35:18,600 --> 00:35:19,960 I'm going to present 507 00:35:19,960 --> 00:35:23,400 a kernel exploit for a vulnerability 508 00:35:23,400 --> 00:35:24,320 in FreeBSD. 509 00:35:24,760 --> 00:35:27,240 This vulnerability is within the 510 00:35:27,240 --> 00:35:29,200 wireless subsystem of FreeBSD. 511 00:35:29,360 --> 00:35:31,180 So this is a remote kernel 512 00:35:31,180 --> 00:35:31,580 exploit. 513 00:35:33,340 --> 00:35:34,940 This vulnerability 514 00:35:34,940 --> 00:35:36,920 is within an IOCTL. 515 00:35:37,160 --> 00:35:39,100 And this IOCTL 516 00:35:39,100 --> 00:35:40,760 is used when 517 00:35:41,480 --> 00:35:43,260 the station scans 518 00:35:43,620 --> 00:35:45,140 for access points in the vicinity. 519 00:35:46,400 --> 00:35:47,020 And 520 00:35:47,620 --> 00:35:49,080 there is an integer overflow 521 00:35:49,350 --> 00:35:51,300 in this IOCTL which 522 00:35:52,320 --> 00:35:53,560 makes it possible 523 00:35:53,560 --> 00:35:55,340 for an attacker to 524 00:35:56,140 --> 00:35:57,240 overwrite some 525 00:35:57,240 --> 00:35:58,700 stack memory. 526 00:35:59,380 --> 00:36:01,300 So there is a stack based buffer 527 00:36:01,300 --> 00:36:03,120 overflow here. And 528 00:36:03,860 --> 00:36:04,860 I can't go 529 00:36:04,860 --> 00:36:09,360 I can't go into all the details here because 530 00:36:09,360 --> 00:36:11,000 we have pretty limited time here. 531 00:36:11,480 --> 00:36:13,560 I don't do the presentation I did 532 00:36:13,620 --> 00:36:15,320 at Black Hat. It was a full 533 00:36:15,320 --> 00:36:16,920 presentation of the development 534 00:36:16,920 --> 00:36:19,040 and on the finding of the vulnerability. 535 00:36:20,120 --> 00:36:21,440 Here I'm just going 536 00:36:21,440 --> 00:36:23,460 to show the demo 537 00:36:23,460 --> 00:36:25,560 and a little bit of an introduction here. 538 00:36:26,240 --> 00:36:26,840 So 539 00:36:27,500 --> 00:36:28,700 what can we do? 540 00:36:30,080 --> 00:36:30,680 This 541 00:36:32,780 --> 00:36:33,380 stack 542 00:36:33,380 --> 00:36:35,560 based buffer overflow makes it possible 543 00:36:35,560 --> 00:36:37,340 for us to overwrite the 544 00:36:37,340 --> 00:36:38,440 saved return address. 545 00:36:39,280 --> 00:36:40,480 And this 546 00:36:41,120 --> 00:36:43,120 makes it possible for us to 547 00:36:43,620 --> 00:36:45,480 take control of the execution 548 00:36:45,480 --> 00:36:47,460 in kernel space. 549 00:36:47,980 --> 00:36:48,820 And 550 00:36:49,620 --> 00:36:51,720 the IOCTL which is vulnerable 551 00:36:51,720 --> 00:36:53,500 is used by 552 00:36:53,500 --> 00:36:54,900 several applications. 553 00:36:55,280 --> 00:36:57,560 For example, VPA Supplicant. 554 00:36:57,700 --> 00:36:59,540 And this application is 555 00:36:59,540 --> 00:37:01,780 needed in FreeBSD 556 00:37:01,780 --> 00:37:03,460 to authenticate to access 557 00:37:03,460 --> 00:37:05,420 points providing better encryption than web. 558 00:37:05,640 --> 00:37:06,800 For example, 559 00:37:07,020 --> 00:37:07,980 VPA PSK. 560 00:37:09,480 --> 00:37:11,660 So I think I just 561 00:37:11,660 --> 00:37:13,480 jump into the 562 00:37:13,620 --> 00:37:14,420 demonstration here. 563 00:37:18,460 --> 00:37:19,860 . 564 00:37:19,860 --> 00:37:21,000 . 565 00:37:21,000 --> 00:37:21,080 . 566 00:37:21,080 --> 00:37:21,440 . 567 00:37:21,440 --> 00:37:21,680 . 568 00:37:21,680 --> 00:37:21,740 . 569 00:37:23,800 --> 00:37:25,200 . 570 00:37:25,200 --> 00:37:27,240 . 571 00:37:27,240 --> 00:37:28,660 . 572 00:37:31,340 --> 00:37:32,740 . 573 00:37:32,740 --> 00:37:33,920 . 574 00:37:47,080 --> 00:37:47,780 . 575 00:37:48,480 --> 00:37:49,520 . 576 00:37:51,900 --> 00:37:53,300 . 577 00:37:53,300 --> 00:37:54,580 . 578 00:37:54,580 --> 00:37:54,700 . 579 00:37:54,700 --> 00:37:54,980 . 580 00:37:54,980 --> 00:37:55,020 . 581 00:37:55,020 --> 00:37:55,060 . 582 00:37:55,060 --> 00:37:56,540 . 583 00:37:56,540 --> 00:37:58,520 . 584 00:37:58,520 --> 00:37:58,720 . 585 00:37:58,720 --> 00:37:59,480 . 586 00:38:04,820 --> 00:38:06,020 . 587 00:38:06,020 --> 00:38:06,680 . 588 00:38:06,680 --> 00:38:07,280 . 589 00:38:07,340 --> 00:38:08,520 . 590 00:38:08,520 --> 00:38:09,060 . 591 00:38:09,060 --> 00:38:09,180 . 592 00:38:09,180 --> 00:38:09,400 . 593 00:38:09,400 --> 00:38:09,720 . 594 00:38:09,720 --> 00:38:09,740 . 595 00:38:11,320 --> 00:38:12,520 . 596 00:38:12,520 --> 00:38:12,540 . 597 00:38:12,540 --> 00:38:12,600 . 598 00:38:26,060 --> 00:38:26,720 . 599 00:38:26,720 --> 00:38:30,720 . . 600 00:38:35,180 --> 00:38:36,540 . 601 00:38:36,540 --> 00:38:38,560 . 602 00:38:38,560 --> 00:38:38,740 . 603 00:38:38,740 --> 00:38:39,660 . 604 00:38:39,660 --> 00:38:39,740 . 605 00:38:39,740 --> 00:38:39,760 . 606 00:38:39,760 --> 00:38:39,920 . 607 00:38:39,920 --> 00:38:39,940 . 608 00:38:39,940 --> 00:38:42,100 . 609 00:38:42,100 --> 00:38:42,760 . 610 00:38:56,720 --> 00:39:08,020 Here we have the FreeBSD machine, and we are opening the web browser here, and we will 611 00:39:08,480 --> 00:39:13,380 open Firefox and generate some encrypted traffic to the access point. 612 00:39:18,820 --> 00:39:23,980 And just to have a little bit of a look of the traffic here, we have Wireshark installed 613 00:39:23,980 --> 00:39:30,480 on the attacker, so we should be able to see the traffic here. 614 00:39:37,820 --> 00:39:38,340 Okay. 615 00:39:41,680 --> 00:39:42,200 Okay. 616 00:40:02,040 --> 00:40:03,660 It's a very difficult password. 617 00:40:04,140 --> 00:40:04,700 Okay. 618 00:40:04,800 --> 00:40:13,520 So now we have the web browser running, and we refresh this page a couple of times here, 619 00:40:14,480 --> 00:40:23,400 and we are going to generate some encrypted traffic here, because this is using TK IP, 620 00:40:23,400 --> 00:40:25,040 as encryption here. 621 00:40:25,880 --> 00:40:32,700 So from the attacker, we can't really see the traffic, or it's supposed to be that way. 622 00:40:34,440 --> 00:40:42,220 And if we look at Wireshark, here we have a filter which filters out all the traffic 623 00:40:42,220 --> 00:40:45,020 sent back and forth to this access point. 624 00:40:46,920 --> 00:40:50,060 And we want to locate some data traffic here. 625 00:40:50,520 --> 00:40:53,380 And here we are inspecting that. 626 00:40:53,380 --> 00:40:53,640 Let's see that frame. 627 00:40:56,120 --> 00:40:56,860 Let's see here. 628 00:40:57,020 --> 00:40:59,380 It's a little bit limited resolution here. 629 00:41:03,720 --> 00:41:14,520 Anyway, you see the TK IP here, and the payload itself is unreadable by us from here, 630 00:41:14,560 --> 00:41:15,740 from the attacker's point of view. 631 00:41:16,200 --> 00:41:23,280 So what we want to do now is to run this application. 632 00:41:23,280 --> 00:41:26,080 And this is the exploit. 633 00:41:26,480 --> 00:41:30,680 And we're going to search here for access points in the vicinity. 634 00:41:31,040 --> 00:41:34,500 And we do that by passively listening at all the beacon frames sent into there. 635 00:41:34,800 --> 00:41:37,420 We see three networks here. 636 00:41:37,960 --> 00:41:38,480 Whoops. 637 00:41:39,000 --> 00:41:40,640 It shows the wrong one. 638 00:41:40,820 --> 00:41:43,000 We want the XXX one, by the way. 639 00:41:43,800 --> 00:41:45,420 So we search again. 640 00:41:46,880 --> 00:41:47,920 And now... 641 00:41:47,920 --> 00:41:48,220 Shit. 642 00:41:50,160 --> 00:41:50,680 Okay. 643 00:41:50,760 --> 00:41:52,000 I have to take it easy this time. 644 00:41:56,740 --> 00:41:57,460 Yeah. 645 00:41:57,620 --> 00:41:58,700 Now we got it. 646 00:41:59,000 --> 00:41:59,600 Okay. 647 00:41:59,660 --> 00:42:03,780 So now we are a little bit intrusive here, because we are sending the authentication 648 00:42:03,780 --> 00:42:06,680 frames from the attacker. 649 00:42:07,260 --> 00:42:14,080 So we are deauthenticating all the clients associated to that network, because the management 650 00:42:14,080 --> 00:42:20,780 traffic in 802.11 is unauthenticated and unencrypted. 651 00:42:20,960 --> 00:42:21,820 And that... 652 00:42:21,820 --> 00:42:25,580 Then it makes it possible for us, an attacker, to do these kind of tricks. 653 00:42:26,960 --> 00:42:33,460 So now we have the MAC address of the access point and the client. 654 00:42:33,720 --> 00:42:36,280 Now we are mounting the attack. 655 00:42:37,980 --> 00:42:39,960 And we switch over to the target. 656 00:42:41,000 --> 00:42:45,940 And we will see here that it lost some connectivity here for a while. 657 00:42:46,220 --> 00:42:50,740 This is because we need to get the target into a searching state. 658 00:42:51,280 --> 00:42:51,800 Okay. 659 00:42:51,820 --> 00:42:53,860 To trigger this ICTL to be called. 660 00:42:56,040 --> 00:43:01,880 And it will be like this for a couple of seconds, 10 or something like that, 10, 20. 661 00:43:02,360 --> 00:43:05,680 And then it will have connectivity again. 662 00:43:05,920 --> 00:43:08,700 You just have to try again here. 663 00:43:10,140 --> 00:43:10,660 Okay. 664 00:43:10,720 --> 00:43:11,800 So now it's working again. 665 00:43:16,800 --> 00:43:20,720 But now we hopefully got our backdoor installed. 666 00:43:21,280 --> 00:43:21,800 Okay. 667 00:43:21,820 --> 00:43:29,140 And we upload a backdoor, a file server. 668 00:43:29,880 --> 00:43:33,320 So we are able to browse the target file system here. 669 00:43:36,080 --> 00:43:40,120 And this is implemented in the kernel. 670 00:43:40,440 --> 00:43:43,900 So it never touched the disk or anything like that. 671 00:43:48,780 --> 00:43:51,800 And what we want to do now is to show something. 672 00:43:51,820 --> 00:43:52,300 We want to show some traffic here. 673 00:43:52,460 --> 00:43:57,900 So what I do now is I open the copyright file from the target machine here. 674 00:43:58,940 --> 00:44:02,420 And we switch over to the wire shark here. 675 00:44:02,760 --> 00:44:10,220 And we will filter out some special beacon probe responses and probe requests here. 676 00:44:17,680 --> 00:44:18,280 So... 677 00:44:20,360 --> 00:44:21,560 Now we are... 678 00:44:21,560 --> 00:44:21,800 Okay. 679 00:44:21,800 --> 00:44:23,340 We are filtering these out. 680 00:44:29,580 --> 00:44:35,960 And if we look at the content here of this probe response, we see the file that we were 681 00:44:36,680 --> 00:44:37,320 opening here. 682 00:44:39,920 --> 00:44:42,220 And this is a probe response. 683 00:44:42,560 --> 00:44:47,860 And with the probe request coming back from the target, it is the payload. 684 00:44:49,620 --> 00:44:51,660 And the copyright file. 685 00:44:51,660 --> 00:44:52,820 That we were looking at. 686 00:44:53,280 --> 00:44:58,740 And this is included in the optional probe request field. 687 00:44:59,240 --> 00:45:05,020 So we are communicating with and to the backdoor in the management layer. 688 00:45:05,240 --> 00:45:09,960 So we don't send any TCP or IP traffic in any ways. 689 00:45:12,400 --> 00:45:19,060 And now we want to do something more here on the target machine here. 690 00:45:19,180 --> 00:45:19,720 So... 691 00:45:19,720 --> 00:45:23,780 So we browse to the home directory of the only user at this machine. 692 00:45:30,900 --> 00:45:31,260 Okay. 693 00:45:33,320 --> 00:45:36,760 And we create a file here. 694 00:45:37,560 --> 00:45:38,280 Oops. 695 00:45:43,080 --> 00:45:43,800 Okay. 696 00:45:47,980 --> 00:45:48,340 Okay. 697 00:45:49,200 --> 00:45:49,900 Let's see here. 698 00:45:56,400 --> 00:45:57,220 Just a second. 699 00:46:02,560 --> 00:46:03,320 Let's see here. 700 00:46:06,140 --> 00:46:06,580 It's... 701 00:46:06,580 --> 00:46:08,700 The keyboard is a little bit bad here. 702 00:46:08,960 --> 00:46:10,640 But I just want to shut it down here. 703 00:46:13,620 --> 00:46:14,200 Come on. 704 00:46:15,900 --> 00:46:16,660 Okay. 705 00:46:16,780 --> 00:46:20,460 We open up the file manager in GNOME here. 706 00:46:20,920 --> 00:46:22,880 We create a folder. 707 00:46:22,880 --> 00:46:31,740 And we want to create a file with a known content here. 708 00:46:31,740 --> 00:46:36,880 So we create an empty directory. 709 00:46:37,260 --> 00:46:39,720 And we fill it with something. 710 00:46:59,280 --> 00:47:00,180 Okay. 711 00:47:00,240 --> 00:47:01,040 And... 712 00:47:01,040 --> 00:47:01,720 And... 713 00:47:02,680 --> 00:47:05,680 On the attacker side here, we refresh the directory. 714 00:47:07,010 --> 00:47:07,640 There is... 715 00:47:07,640 --> 00:47:10,340 It pops up a new directory here, secret. 716 00:47:12,240 --> 00:47:16,580 And we see the content of this newly created file here. 717 00:47:18,140 --> 00:47:22,260 So now we can see that we can browse the target file system. 718 00:47:22,400 --> 00:47:24,960 We can also upload files to the target file system. 719 00:47:37,140 --> 00:47:37,840 Okay. 720 00:47:38,540 --> 00:47:42,060 So there is a new file created here. 721 00:47:45,720 --> 00:47:46,420 Awesome. 722 00:47:46,420 --> 00:47:58,060 One more time. 723 00:47:58,060 --> 00:47:58,600 Okay. 724 00:47:58,760 --> 00:47:59,520 Okay. 725 00:48:01,340 --> 00:48:02,700 So... 726 00:48:04,160 --> 00:48:05,520 Awesome. 727 00:48:05,520 --> 00:48:05,640 Wonderful. 728 00:48:16,980 --> 00:48:23,140 and we have a new file here and we switch over to the target 729 00:48:30,800 --> 00:48:41,660 yeah and we do a reload here and we just want to see the content here so we we 730 00:48:41,660 --> 00:48:49,040 can upload file as well and that's nice but what we want to do now is probably 731 00:48:49,040 --> 00:48:55,540 to just look at the passphrase used to authenticate to this network so we don't 732 00:48:55,540 --> 00:49:00,620 need to install this backdoor again because it is not very nice to do that 733 00:49:00,620 --> 00:49:05,900 so what we do is to look at the configuration file for VPA supplicant 734 00:49:09,680 --> 00:49:11,640 and now we have the passphrase 735 00:49:11,640 --> 00:49:17,880 for this network so we don't need to install this again so this is pretty 736 00:49:17,880 --> 00:49:18,740 much this 737 00:49:24,220 --> 00:49:31,020 any quick questions here or we move into the questions and answer room here 738 00:49:32,960 --> 00:49:38,560 108 I think it is any questions now directly fast 739 00:49:42,560 --> 00:49:45,400 okay thank you