1 00:00:00,000 --> 00:00:05,060 Hi, folks. I think I'm going to start just a couple of minutes early because I got a lot of slides for you today. 2 00:00:06,560 --> 00:00:08,620 And, yeah, I'm going to try and keep up one slide per minute. 3 00:00:08,760 --> 00:00:15,940 But if it's unclear, of course, you know, shout out, just tell me to clear something up for you. 4 00:00:16,180 --> 00:00:20,700 Okay, so my talk from No Way to Oday, Weaponizing the Unweaponizable, 5 00:00:20,780 --> 00:00:23,220 I had to come up with a name that was going to be kind of catchy, 6 00:00:23,280 --> 00:00:26,020 and I think it actually turned out a little bit lame, but that's all right. 7 00:00:26,820 --> 00:00:27,820 I'm Joshua Wise. 8 00:00:27,820 --> 00:00:32,640 Joshua Wise, so, right, so here's, so kind of here's what I plan to talk about today quickly. 9 00:00:33,400 --> 00:00:38,060 I'm going to give you a quick little intro, figure out who I am, who you all are. 10 00:00:38,800 --> 00:00:42,800 We're going to talk about, briefly, we're going to talk about vulnerabilities kind of in the general case. 11 00:00:42,920 --> 00:00:46,820 I'm going to go across an old-style vulnerability that everybody here knows about, 12 00:00:46,880 --> 00:00:48,300 everybody learned about in CS 101. 13 00:00:49,300 --> 00:00:56,820 And we're just going to dissect it using these three points that I'm going to use kind of for the big one. 14 00:00:57,080 --> 00:00:57,480 Okay. 15 00:00:57,640 --> 00:00:57,800 Okay. 16 00:00:57,820 --> 00:01:01,220 And then I'm going to give, and then I'm going to give a case study of taking a very difficult vulnerability, 17 00:01:01,420 --> 00:01:03,440 or at least something that I think is a very difficult vulnerability, 18 00:01:04,060 --> 00:01:08,240 and I'm going to use this, I'm going to use these three points that I've developed 19 00:01:08,240 --> 00:01:12,800 to make something very difficult into something very doable to exploit. 20 00:01:14,420 --> 00:01:17,800 And briefly, I'm going to talk about kind of what went wrong, 21 00:01:17,980 --> 00:01:24,400 you know, things that could have been done differently that would have made this not, 22 00:01:24,600 --> 00:01:26,000 you know, that could have mitigated this. 23 00:01:26,060 --> 00:01:26,780 How did this happen? 24 00:01:28,000 --> 00:01:29,660 And I'm going to have a demo for you. 25 00:01:30,240 --> 00:01:33,280 And with any luck, I'm going to have time for a Q&A session. 26 00:01:33,360 --> 00:01:35,540 Otherwise, we're going to go to the Q&A room down the hall. 27 00:01:36,380 --> 00:01:38,520 So without further ado, let's begin. 28 00:01:40,500 --> 00:01:40,860 Okay. 29 00:01:40,900 --> 00:01:41,280 Who am I? 30 00:01:41,500 --> 00:01:43,040 I'm just some guy, you know. 31 00:01:44,460 --> 00:01:47,840 I kind of call myself an all-purpose embedded hacker. 32 00:01:48,060 --> 00:01:51,680 You know, I do, I've done HP IPAC stuff back in the day. 33 00:01:52,500 --> 00:01:55,920 At some point, I got roped into doing Android stuff. 34 00:01:55,980 --> 00:01:57,720 I'm one of the unrevoked guys. 35 00:01:57,820 --> 00:02:01,080 If you have a rooted Evo or rooted Incredible, you're probably running my code. 36 00:02:02,680 --> 00:02:04,640 And, right, so yeah, there you go, unrevoked. 37 00:02:05,340 --> 00:02:07,200 At some point, I kind of got roped into it. 38 00:02:07,260 --> 00:02:10,360 And that's, in a sense, that's where this presentation started off. 39 00:02:10,700 --> 00:02:14,200 I like to classify myself nowadays as a recovering software guy. 40 00:02:14,660 --> 00:02:15,960 I used to do software guy. 41 00:02:16,000 --> 00:02:17,620 Now I'm kind of trending towards ASIC design. 42 00:02:18,380 --> 00:02:20,100 And, of course, I'm buzzword compliant. 43 00:02:20,400 --> 00:02:25,200 I am working on my integrated master's and bachelor's in electrical and computer engineering 44 00:02:25,740 --> 00:02:27,140 at Carnegie Mellon University. 45 00:02:29,060 --> 00:02:30,240 Although, that doesn't really matter. 46 00:02:32,300 --> 00:02:35,340 Okay, so now that you know a little bit about who I am. 47 00:02:35,400 --> 00:02:36,600 Oh, by the way, I have a website, too. 48 00:02:36,660 --> 00:02:38,940 It's my first name, last name, concatenated.com. 49 00:02:39,920 --> 00:02:42,860 I think it's probably linked somewhere, too, although I didn't link in this presentation. 50 00:02:43,360 --> 00:02:44,720 A little bit about you now. 51 00:02:47,820 --> 00:02:49,040 So, that's a little bit about me. 52 00:02:49,100 --> 00:02:49,440 Who are you? 53 00:02:50,700 --> 00:02:56,380 So, hopefully, people here have a little bit of experience writing or running code in kernel space. 54 00:02:57,460 --> 00:02:57,800 Maybe. 55 00:02:57,800 --> 00:03:03,620 Maybe some of you guys have experience, in particular, with a Linux kernel and working kind of inside that infrastructure. 56 00:03:04,000 --> 00:03:07,280 All of you guys here are interested in security. 57 00:03:08,960 --> 00:03:14,600 And, in particular, you know, exploiting Linux kernel is what we're going to be doing today. 58 00:03:17,560 --> 00:03:19,180 Nobody here, I hope, is a script kitty. 59 00:03:20,240 --> 00:03:21,720 No code for you to compile here. 60 00:03:21,880 --> 00:03:27,300 I'm not going to be, I guess, I could potentially be convinced to release a binary that doesn't 61 00:03:27,300 --> 00:03:28,140 actually give you root. 62 00:03:28,500 --> 00:03:32,080 But I'm not releasing code today. 63 00:03:32,900 --> 00:03:38,640 But, however, in this presentation, there really should be enough, if you really wanted to reproduce this on your own, 64 00:03:38,740 --> 00:03:40,120 to be able to do that. 65 00:03:40,280 --> 00:03:45,000 So, that's kind of, hopefully, who you are. 66 00:03:46,400 --> 00:03:49,180 And, of course, you know, all of this is going to be all C-based. 67 00:03:49,360 --> 00:03:52,180 So, hopefully, you have a good understanding of what's going on inside the machine, 68 00:03:53,080 --> 00:03:56,200 even if you haven't worked inside of kernel space before. 69 00:04:00,160 --> 00:04:02,800 So, here's the vulnerability I'm going to be talking about today. 70 00:04:03,400 --> 00:04:06,780 So, we were looking through, we were looking through very early on. 71 00:04:06,860 --> 00:04:09,040 We were looking for ways to root the HTC Incredible. 72 00:04:09,660 --> 00:04:11,800 Because nobody had really come across that. 73 00:04:11,920 --> 00:04:13,860 Nobody had really solved that problem yet. 74 00:04:14,980 --> 00:04:17,240 And, we came across this exploit. 75 00:04:19,400 --> 00:04:21,360 CVE 2010-1084. 76 00:04:22,080 --> 00:04:27,280 So, this is what they called a kernel denial of service. 77 00:04:27,280 --> 00:04:37,580 You know, you could crash the kernel, and they wrote it as bad memory access with sysfs files allows attackers to cause a denial of service memory corruption. 78 00:04:37,860 --> 00:04:39,540 Okay, so it's a DOS attack, right? 79 00:04:39,660 --> 00:04:43,160 We're going to bring down the kernel, and so what, right? 80 00:04:43,860 --> 00:04:45,400 All of my stuff is transactional. 81 00:04:45,420 --> 00:04:46,560 All of my stuff is going to be saved. 82 00:04:46,640 --> 00:04:47,980 We're running journaling file systems. 83 00:04:48,180 --> 00:04:49,680 The machine crashes, so what? 84 00:04:51,040 --> 00:04:54,460 And, so this first showed up in 2.6.18. 85 00:04:55,740 --> 00:04:57,260 And, it got fucked. 86 00:04:57,280 --> 00:04:58,560 It got fixed in 2.6.23. 87 00:04:59,820 --> 00:05:01,420 That's a lot of kernels, you know? 88 00:05:01,620 --> 00:05:03,400 That's a lot of vulnerable kernels. 89 00:05:06,340 --> 00:05:09,840 To give you an idea of who's running things that aren't 2.6.23, 90 00:05:10,060 --> 00:05:13,240 if you're running an Android phone that hasn't been upgraded to Froyo yet, 91 00:05:13,760 --> 00:05:17,920 then you're running 2.6.29, and it hasn't been patched yet. 92 00:05:18,940 --> 00:05:24,480 This, every single Android phone that I know of that's not running Froyo is vulnerable to this. 93 00:05:24,760 --> 00:05:27,160 So, who here hasn't patched up to 2.6.23? 94 00:05:27,280 --> 00:05:28,020 Or, 2.6.33? 95 00:05:30,560 --> 00:05:31,220 You're brave. 96 00:05:31,360 --> 00:05:32,280 You're brave for admitting it. 97 00:05:35,820 --> 00:05:39,760 So, let's talk quickly about what's going on inside this vulnerability. 98 00:05:39,960 --> 00:05:41,120 How this vulnerability works. 99 00:05:41,340 --> 00:05:44,040 And, we're going to go into a whole lot more detail about it later. 100 00:05:45,040 --> 00:05:50,540 But, I'm going to kind of go for the brief overview from 10,000 feet of what's going on inside this 101 00:05:50,540 --> 00:05:53,660 that causes the machine to roll over and die. 102 00:05:53,660 --> 00:06:00,020 And, you know, how we can cause a crash even if we don't know how to exploit it yet. 103 00:06:00,660 --> 00:06:04,560 So, this one's really a standard one, okay? 104 00:06:06,000 --> 00:06:12,380 This lives inside the Bluetooth layer, inside this socket control layer called L2CAP. 105 00:06:12,480 --> 00:06:14,080 L2CAP is a subsystem of Bluetooth. 106 00:06:15,460 --> 00:06:22,800 And, the user can open sockets, can open L2CAP sockets just using the socket syscall. 107 00:06:22,800 --> 00:06:26,060 The same way you'd open any other socket, the same way you'd open a TCP socket. 108 00:06:26,720 --> 00:06:33,900 But, what makes this interesting is they decided they were going to export debug data about all active L2CAP sockets. 109 00:06:34,000 --> 00:06:39,700 Not through the interfaces that you'd get, you know, with netstat by looking through FDs, things like that, right? 110 00:06:39,880 --> 00:06:43,820 But, they decided, hey, this is the new Linux kernel. 111 00:06:44,020 --> 00:06:48,560 This is Linux 2.6 and we can provide debug info through sysfs. 112 00:06:49,820 --> 00:06:51,620 This is the new Linux kernel. 113 00:06:51,620 --> 00:06:55,100 And, it's not really sensitive information, really. 114 00:06:57,020 --> 00:07:00,040 So, everybody gets to read this debug info out of sysfs. 115 00:07:00,180 --> 00:07:07,840 You know, if you're running a machine with Bluetooth, then what do you really care about who's connected, about which connections are active, right? 116 00:07:08,040 --> 00:07:10,060 You're not really leaking sensitive data. 117 00:07:10,180 --> 00:07:11,760 It's a machine with Bluetooth, you know. 118 00:07:11,780 --> 00:07:13,500 You can walk around and see who else is in the room. 119 00:07:13,960 --> 00:07:14,980 So, what do they do? 120 00:07:15,060 --> 00:07:16,780 They take this buffer, okay? 121 00:07:17,000 --> 00:07:18,380 They take this buffer. 122 00:07:18,780 --> 00:07:21,600 And, for each Bluetooth connection. 123 00:07:21,600 --> 00:07:23,560 For each Bluetooth socket that the user has created. 124 00:07:23,640 --> 00:07:24,440 For each L2CAP socket. 125 00:07:24,620 --> 00:07:27,400 Actually, this exists pervasively throughout the Bluetooth stack. 126 00:07:27,620 --> 00:07:28,440 And, it was correct. 127 00:07:28,600 --> 00:07:30,780 And, the one that we're going to be looking at today is the L2CAP one. 128 00:07:31,800 --> 00:07:37,460 And, they just say, okay, I'm just going to keep appending onto this buffer that sysfs has allocated for us. 129 00:07:37,580 --> 00:07:40,660 For each socket, bam, we're just going to sprint F right onto the end of it. 130 00:07:41,080 --> 00:07:44,840 And, well, they didn't really bother to check for the end of it. 131 00:07:46,860 --> 00:07:48,820 So, how does this buffer kind of show up? 132 00:07:48,860 --> 00:07:49,480 How does this buffer live? 133 00:07:49,480 --> 00:07:51,320 Well, it gets. 134 00:07:51,960 --> 00:07:54,600 So, this isn't really a simple stack buffer overflow. 135 00:07:54,860 --> 00:07:57,480 Because, it gets the buffer from the frame allocator. 136 00:07:57,680 --> 00:07:57,900 Okay? 137 00:08:01,320 --> 00:08:03,780 And, we'll talk a little bit more about what that means in a moment. 138 00:08:05,960 --> 00:08:08,020 It's kind of a little bit of a twist. 139 00:08:08,100 --> 00:08:13,380 Because, we don't really control the contents of what's going through. 140 00:08:13,600 --> 00:08:13,720 Right? 141 00:08:13,760 --> 00:08:17,820 We only, we kind of get a fixed ASCII string that's sprint F'd on over there. 142 00:08:17,900 --> 00:08:18,080 Right? 143 00:08:18,080 --> 00:08:20,200 We really don't get a chance to control that. 144 00:08:20,400 --> 00:08:23,160 And, we don't really control how much we print either. 145 00:08:23,400 --> 00:08:28,460 Because, we don't really know how far into the string our target is going to land. 146 00:08:30,700 --> 00:08:33,360 So, let's take a step back here. 147 00:08:33,600 --> 00:08:37,180 And, I'm going to, we're going to analyze an old vulnerability. 148 00:08:37,900 --> 00:08:39,280 Everybody knows about this one. 149 00:08:39,320 --> 00:08:40,220 Everybody's favorite gets. 150 00:08:40,920 --> 00:08:43,900 And, we're going to think about it in terms of these three things that I mentioned. 151 00:08:43,960 --> 00:08:44,720 Let me go back here real quick. 152 00:08:46,780 --> 00:08:47,220 Target. 153 00:08:47,680 --> 00:08:48,080 Contents. 154 00:08:48,160 --> 00:08:48,460 Length. 155 00:08:48,600 --> 00:08:49,140 Remember that. 156 00:08:49,260 --> 00:08:51,080 We're going to be focusing a lot on that today. 157 00:08:51,160 --> 00:08:51,460 Target. 158 00:08:51,540 --> 00:08:51,940 Contents. 159 00:08:51,960 --> 00:08:52,240 Length. 160 00:08:53,020 --> 00:08:54,820 So, here's the old vulnerability. 161 00:08:55,120 --> 00:08:55,320 Okay? 162 00:08:57,260 --> 00:08:59,600 We have this program that was written for CS101. 163 00:09:00,260 --> 00:09:03,820 And, there's a, and it's set you at root because the professor is an idiot. 164 00:09:04,020 --> 00:09:08,340 And, told the student that in order to access the terminal, you have to be set you at root. 165 00:09:08,460 --> 00:09:08,900 I don't know. 166 00:09:09,240 --> 00:09:10,600 But, it happens. 167 00:09:10,720 --> 00:09:10,980 You know? 168 00:09:11,940 --> 00:09:14,040 So, we have our fixed length buffer. 169 00:09:14,340 --> 00:09:16,460 And, we're going to ask what the user's name is. 170 00:09:16,460 --> 00:09:18,920 And, we're going to gets on in there. 171 00:09:19,220 --> 00:09:20,660 And, we're going to print their name back. 172 00:09:20,780 --> 00:09:21,400 And, we're just going to say hello. 173 00:09:21,540 --> 00:09:25,460 This is, this is really easy to exploit vulnerability. 174 00:09:26,020 --> 00:09:28,020 Why is this so easy to export or exploit? 175 00:09:28,260 --> 00:09:30,200 Because it's got a controlled target. 176 00:09:30,380 --> 00:09:32,120 We know exactly where it's going to go. 177 00:09:32,180 --> 00:09:37,500 It's going to go onto the stack every single time relative to the same things every single time. 178 00:09:37,560 --> 00:09:38,140 Controlled target. 179 00:09:39,220 --> 00:09:41,680 It's very easy because it's a controlled length. 180 00:09:42,020 --> 00:09:45,840 We only have as many characters copied as I bang in on the keyboard. 181 00:09:45,840 --> 00:09:47,960 Or, into standard in or whatever it wants to be. 182 00:09:48,080 --> 00:09:48,160 Right? 183 00:09:48,820 --> 00:09:52,340 The length is exactly what I want it to be every single time. 184 00:09:52,520 --> 00:09:55,920 And, not only that, but the contents are controlled. 185 00:09:56,240 --> 00:09:59,200 I get to decide exactly what it's going to be every single time. 186 00:10:00,820 --> 00:10:02,760 So, let's go take a little look here. 187 00:10:03,080 --> 00:10:06,580 And, we're going to, I'm going to give you a little memory diagram of what's going on. 188 00:10:06,760 --> 00:10:09,840 And, I think this is kind of a useful visualization just as a refresher. 189 00:10:10,240 --> 00:10:15,220 I'm sure everybody here knows about how a stack smash works. 190 00:10:15,220 --> 00:10:17,460 But, I think it's going to be a very useful visualization. 191 00:10:17,880 --> 00:10:20,140 So, let's talk a little bit through this here. 192 00:10:20,520 --> 00:10:23,900 We have the user input something bad through gets. 193 00:10:24,720 --> 00:10:25,740 And, where does it go? 194 00:10:27,220 --> 00:10:28,780 Where in memory is this going to go? 195 00:10:29,480 --> 00:10:30,400 Let's take a look at this. 196 00:10:31,160 --> 00:10:32,640 I've drawn a nice little picture for you. 197 00:10:33,360 --> 00:10:38,560 By the way, by the way, these addresses, they're not really for any machine in particular. 198 00:10:38,820 --> 00:10:39,940 I just kind of made these up. 199 00:10:40,040 --> 00:10:40,200 Alright? 200 00:10:41,340 --> 00:10:43,940 Don't base any kind of exploit on this. 201 00:10:45,220 --> 00:10:45,620 Or do. 202 00:10:46,100 --> 00:10:46,980 And, it won't work. 203 00:10:50,080 --> 00:10:51,000 So, where's it going to go? 204 00:10:51,060 --> 00:10:52,120 We have the buffer here. 205 00:10:52,220 --> 00:10:54,980 And, by the way, lower addresses are towards the bottom of the screen. 206 00:10:56,540 --> 00:10:58,860 And, we have, so we have gets' stack frame. 207 00:10:58,940 --> 00:11:00,540 And, gets' is going to go stick things into buff. 208 00:11:00,920 --> 00:11:02,000 And, things go up. 209 00:11:03,740 --> 00:11:04,100 Alright? 210 00:11:07,060 --> 00:11:08,480 And, so here we go. 211 00:11:08,560 --> 00:11:11,820 So, we have the user that inputs something bad in here. 212 00:11:11,880 --> 00:11:13,800 Very, very long string full of the letter A. 213 00:11:13,800 --> 00:11:14,820 And, it gets' written. 214 00:11:15,240 --> 00:11:16,640 Normally, it would get' written into buff. 215 00:11:17,140 --> 00:11:20,180 And, this time it kind of gets' written through greeter's stack frame. 216 00:11:20,420 --> 00:11:22,440 And, then gets' written through greeter's return address. 217 00:11:22,840 --> 00:11:28,420 Greeter's return address gets' set, gets' reset to inside buff into that code that we've injected. 218 00:11:30,780 --> 00:11:31,580 And, owned. 219 00:11:36,180 --> 00:11:36,580 Right. 220 00:11:37,840 --> 00:11:40,280 Return address now contains the address of code in buff. 221 00:11:40,480 --> 00:11:42,100 Buff now contains code. 222 00:11:42,340 --> 00:11:43,720 Why did this work so well? 223 00:11:43,720 --> 00:11:43,960 Alright. 224 00:11:44,720 --> 00:11:46,000 Why did this work so well? 225 00:11:47,000 --> 00:11:47,980 Three controls. 226 00:11:48,840 --> 00:11:50,060 Attacker controlled target. 227 00:11:50,340 --> 00:11:53,620 Every single time return address gets' blasted. 228 00:11:54,320 --> 00:11:54,960 Right. 229 00:11:55,340 --> 00:11:56,220 Return address. 230 00:11:56,540 --> 00:12:01,200 Every single time return address is always on top of buff. 231 00:12:02,760 --> 00:12:04,040 Attacker controlled length. 232 00:12:04,640 --> 00:12:10,820 We always type in as many characters as we want get' blasted right up through there. 233 00:12:11,000 --> 00:12:13,700 We don't ever have to worry about blasting off the buffer. 234 00:12:13,720 --> 00:12:14,320 At the top of the stack. 235 00:12:14,520 --> 00:12:20,660 If we blast over C000, right, then we're done. 236 00:12:20,900 --> 00:12:21,940 Then we segfault. 237 00:12:22,120 --> 00:12:23,720 We're out of mapped frames. 238 00:12:23,980 --> 00:12:24,740 We're out of mapped pages. 239 00:12:24,840 --> 00:12:25,160 We're done. 240 00:12:26,660 --> 00:12:28,820 So, we don't ever have to worry about that. 241 00:12:29,140 --> 00:12:30,960 And, we have attacker controlled contents. 242 00:12:31,200 --> 00:12:35,680 We can write anything we want using gets' except for the null character and except for a new line. 243 00:12:35,960 --> 00:12:36,320 Okay. 244 00:12:36,940 --> 00:12:41,860 We want to overflow that buffer as long as our exploit code doesn't contain zero. 245 00:12:42,100 --> 00:12:43,700 And, as long as our exploit code doesn't contain zero. 246 00:12:43,700 --> 00:12:45,720 If our exploit code doesn't contain a new line, we're good. 247 00:12:46,820 --> 00:12:47,400 All right. 248 00:12:49,200 --> 00:12:49,940 Everybody ready? 249 00:12:50,180 --> 00:12:51,280 That makes sense to everyone? 250 00:12:51,860 --> 00:12:52,300 Okay. 251 00:12:53,200 --> 00:12:55,820 Let's talk about the meat of this presentation. 252 00:12:59,140 --> 00:13:02,180 So, here's what's going to go on in today's exploit. 253 00:13:02,460 --> 00:13:02,900 All right. 254 00:13:02,920 --> 00:13:04,840 In the exploit that I'm going to be talking about today. 255 00:13:06,060 --> 00:13:09,080 If you're following along at home, this is going to be in the L2CAP module. 256 00:13:09,300 --> 00:13:12,920 The function name is L2CAP sysfs show. 257 00:13:13,080 --> 00:13:13,680 And, you can see that. 258 00:13:13,680 --> 00:13:15,960 And, I think this bears a little bit of explaining. 259 00:13:16,240 --> 00:13:21,300 The sysfs stuff, whenever you open a sysfs file, it goes and allocates this buffer, right? 260 00:13:21,800 --> 00:13:24,140 Stir equals get zeroed page GFP kernel. 261 00:13:24,400 --> 00:13:28,740 Every time you open a sysfs file, it gets this buffer. 262 00:13:28,940 --> 00:13:29,160 All right. 263 00:13:29,280 --> 00:13:31,960 It doesn't necessarily run the print immediately. 264 00:13:32,400 --> 00:13:32,820 Okay. 265 00:13:33,160 --> 00:13:35,640 It doesn't call this show function immediately. 266 00:13:35,960 --> 00:13:41,080 But, as soon as you do the read, when you do the read for the first time, it calls this show function. 267 00:13:41,220 --> 00:13:42,480 L2CAP sysfs show. 268 00:13:43,560 --> 00:13:46,600 And, let me show you a little bit of what's inside here. 269 00:13:47,140 --> 00:13:49,840 For each L2CAP list, right? 270 00:13:50,200 --> 00:13:52,220 For each socket, and we're going to call it sock. 271 00:13:53,360 --> 00:13:55,780 String plus equals printf string. 272 00:13:57,180 --> 00:13:58,260 And, then a bunch of crap. 273 00:13:59,960 --> 00:14:00,900 What year is it? 274 00:14:02,180 --> 00:14:03,760 Guys, who does that still? 275 00:14:05,800 --> 00:14:06,200 Okay. 276 00:14:07,780 --> 00:14:08,560 This is a problem. 277 00:14:08,780 --> 00:14:10,160 This is a bit of a problem for us. 278 00:14:10,580 --> 00:14:13,060 We can see how this is going to crash the machine, right? 279 00:14:13,640 --> 00:14:17,980 This is always going to run off the end of that string if we have too much stuff in there. 280 00:14:18,100 --> 00:14:19,480 We said get zeroed page. 281 00:14:19,800 --> 00:14:21,640 That's going to be one page long. 282 00:14:22,760 --> 00:14:24,180 There's the overflow right there. 283 00:14:24,420 --> 00:14:24,480 Okay. 284 00:14:27,700 --> 00:14:30,180 But, you know, how do we control the target? 285 00:14:30,360 --> 00:14:30,980 How do we control? 286 00:14:31,960 --> 00:14:35,020 Well, we don't know what's going to be in the page after that. 287 00:14:35,180 --> 00:14:36,580 And, that says get zeroed page. 288 00:14:36,980 --> 00:14:39,200 I'm going to be talking a lot about pages and frames. 289 00:14:39,380 --> 00:14:39,640 Okay. 290 00:14:40,160 --> 00:14:41,340 I'll talk about that in a moment. 291 00:14:41,500 --> 00:14:43,780 But, how is the buffer allocated? 292 00:14:43,940 --> 00:14:44,840 How is that string allocated? 293 00:14:45,180 --> 00:14:47,600 The Sisyphus string comes from the frame allocator. 294 00:14:47,660 --> 00:14:49,220 That's that get zeroed page function. 295 00:14:50,600 --> 00:14:51,780 And, what comes after that? 296 00:14:51,920 --> 00:14:59,460 Well, some other poor bastard's frame that, you know, just kind of got unlucky and happens to be hanging out after the frame that we're going to smash. 297 00:15:00,620 --> 00:15:04,080 So, briefly, a little refresher on virtual memory for you guys. 298 00:15:06,080 --> 00:15:07,140 So, what's a frame? 299 00:15:07,860 --> 00:15:09,440 Don't confuse it with a stacked frame. 300 00:15:09,440 --> 00:15:13,260 I think we're pretty much done talking about stacked frames for today. 301 00:15:13,480 --> 00:15:13,740 Okay. 302 00:15:15,840 --> 00:15:21,280 A frame is a physical memory backing of a page. 303 00:15:22,520 --> 00:15:23,120 Okay. 304 00:15:23,400 --> 00:15:26,560 A page is a chunk of virtual memory. 305 00:15:27,000 --> 00:15:31,860 Pages do not necessarily have to have frames associated with them at all times. 306 00:15:32,040 --> 00:15:32,580 Okay. 307 00:15:32,840 --> 00:15:35,280 And, so, I've given you a little drawing here. 308 00:15:35,620 --> 00:15:39,420 So, we have two processes running on our little virtual system. 309 00:15:39,420 --> 00:15:43,560 One of them, and both of them, by the way, have stacked data and text. 310 00:15:43,800 --> 00:15:43,900 Okay. 311 00:15:44,020 --> 00:15:47,480 These are, and they each have one page for each. 312 00:15:47,680 --> 00:15:54,680 Each virtual memory address space, you know, virtual memory address space is composed of pages, physical memory composed of frames. 313 00:15:55,040 --> 00:15:58,940 So, here's what memory looks like to process A. 314 00:15:59,580 --> 00:16:04,620 Text is there, and it's backed by a physical memory frame. 315 00:16:04,860 --> 00:16:05,380 All right. 316 00:16:05,380 --> 00:16:08,380 Data is backed by a physical memory frame. 317 00:16:08,440 --> 00:16:10,400 Stack is backed by a physical memory frame. 318 00:16:10,840 --> 00:16:12,940 Process B is the same process. 319 00:16:13,220 --> 00:16:13,400 Okay. 320 00:16:13,540 --> 00:16:17,940 It's just the same program, which means that it can share the same text frame. 321 00:16:18,400 --> 00:16:18,840 Okay. 322 00:16:19,500 --> 00:16:22,500 So, the page, both of those pages, map to the same frame. 323 00:16:22,600 --> 00:16:23,620 And it's read only, so it's okay. 324 00:16:25,500 --> 00:16:29,800 Process B hasn't been run in a while, and data has gotten swapped out to disk. 325 00:16:29,940 --> 00:16:30,960 Sorry, Process B. 326 00:16:32,000 --> 00:16:33,360 Its stack is still in memory. 327 00:16:33,580 --> 00:16:34,340 All right. 328 00:16:34,340 --> 00:16:34,700 So, this is the process B. 329 00:16:35,380 --> 00:16:37,340 And so, what's important about this? 330 00:16:37,380 --> 00:16:46,760 What's important about this is that the Linux kernel has both physical frames, it has a whole bunch of physical memory mapped into the address space. 331 00:16:48,820 --> 00:16:59,600 And it has whoever used to be running, whatever user land process used to be running, it has their user address space also mapped in. 332 00:16:59,720 --> 00:17:04,060 And this is to make context switches faster, blah, blah, blah, take an OS course, right? 333 00:17:04,320 --> 00:17:05,080 All right. 334 00:17:05,380 --> 00:17:13,360 But the upshot of this, anyway, is that you need user memory to be accessible if you want to do things like read, write, iOctal. 335 00:17:13,920 --> 00:17:20,880 And you need kernel memory accessible if you want to do frame allocations, you know, to get a DMA buffer for the hard drive, for instance. 336 00:17:22,220 --> 00:17:22,660 Okay. 337 00:17:22,920 --> 00:17:24,340 So, that's right. 338 00:17:24,400 --> 00:17:25,440 So, that was controlled target. 339 00:17:25,720 --> 00:17:30,020 Now we know how the buffer allocation works a little bit. 340 00:17:31,260 --> 00:17:34,420 Let's talk about the next issue of our three controls. 341 00:17:34,500 --> 00:17:35,360 The issue is obvious. 342 00:17:35,380 --> 00:17:36,020 Crash is inevitable. 343 00:17:36,660 --> 00:17:38,540 Control number two is the length. 344 00:17:39,040 --> 00:17:39,480 Okay? 345 00:17:41,700 --> 00:17:45,900 So, we know that writes take place through that Sprintf to a strange place. 346 00:17:46,200 --> 00:17:48,080 And we can't stop it. 347 00:17:48,080 --> 00:17:52,620 We don't determine how long it goes because that Sprintf is just a fixed length format string. 348 00:17:52,900 --> 00:17:57,580 And even if the thing that we want to smash is in the middle, it will just kind of keep going off the end. 349 00:17:57,680 --> 00:18:02,160 So, we hope, we can't stop it before it overwrites something else important later on. 350 00:18:02,300 --> 00:18:02,740 Okay? 351 00:18:04,960 --> 00:18:06,580 And here's our third control. 352 00:18:08,040 --> 00:18:08,960 Controlled contents. 353 00:18:09,260 --> 00:18:09,620 Okay? 354 00:18:09,780 --> 00:18:11,320 What are the contents of the buffer? 355 00:18:11,440 --> 00:18:19,540 So, remember in our elementary exploit, the contents were the letter A a whole bunch of times, some shellcode, and then a return address. 356 00:18:20,080 --> 00:18:21,240 But we don't control that. 357 00:18:21,360 --> 00:18:21,540 Okay? 358 00:18:21,880 --> 00:18:25,720 No data comes directly from me in this exploit. 359 00:18:26,400 --> 00:18:27,200 No data. 360 00:18:27,900 --> 00:18:30,620 All of this data is formatted through Sprintf. 361 00:18:30,960 --> 00:18:32,720 So, what's the... 362 00:18:32,740 --> 00:18:33,440 What's going on here? 363 00:18:33,540 --> 00:18:34,700 We're zero for three. 364 00:18:34,780 --> 00:18:36,120 How are we going to exploit this? 365 00:18:37,020 --> 00:18:37,660 Well, okay. 366 00:18:39,660 --> 00:18:41,400 It's time to start controlling our environment. 367 00:18:41,600 --> 00:18:43,560 The environment is not... 368 00:18:43,560 --> 00:18:45,680 You know, the environment isn't set up for us to control. 369 00:18:45,740 --> 00:18:47,160 It's time for us to start taking control. 370 00:18:48,620 --> 00:18:48,940 And... 371 00:18:51,260 --> 00:18:52,120 So, let's go for it. 372 00:18:55,380 --> 00:18:56,820 How are we going to control the target? 373 00:18:59,880 --> 00:19:01,920 Well, let's go for an old-fashioned heap spray. 374 00:19:03,180 --> 00:19:03,620 The... 375 00:19:03,620 --> 00:19:05,260 What's the idea behind heap spray? 376 00:19:05,360 --> 00:19:08,280 The idea behind heap spray is that we're going to... 377 00:19:08,720 --> 00:19:10,680 We're going to scatter a whole bunch of things around memory. 378 00:19:10,880 --> 00:19:16,080 And we're going to just hope and pray that the things that we want to... 379 00:19:16,080 --> 00:19:19,220 The thing that we want to smash shows up after the buffer. 380 00:19:19,500 --> 00:19:24,620 And the way that's going to work is we're just going to litter memory with things that we could potentially smash. 381 00:19:25,560 --> 00:19:26,000 Um... 382 00:19:27,280 --> 00:19:28,100 So, uh... 383 00:19:28,900 --> 00:19:30,500 What are we going to spray across the heap? 384 00:19:30,540 --> 00:19:31,400 By the way, target practice. 385 00:19:31,540 --> 00:19:32,460 EMR Havel Heavy Industries. 386 00:19:32,720 --> 00:19:35,480 With EMR Havel, your target is our target. 387 00:19:37,120 --> 00:19:37,520 Um... 388 00:19:37,520 --> 00:19:40,280 So, the first idea for things that we could smash. 389 00:19:40,620 --> 00:19:41,460 A kernel stack. 390 00:19:41,960 --> 00:19:43,180 We know how to smash stacks. 391 00:19:43,520 --> 00:19:44,840 We've done that before. 392 00:19:45,160 --> 00:19:48,240 It worked, you know, it worked really well in that little easy gets exploit. 393 00:19:49,000 --> 00:19:49,400 Um... 394 00:19:49,400 --> 00:19:51,100 We know how to smash kernel stacks. 395 00:19:51,220 --> 00:19:52,960 We just overwrite a return pointer and let's go. 396 00:19:53,540 --> 00:19:54,280 So, uh... 397 00:19:56,820 --> 00:19:57,120 So... 398 00:19:57,120 --> 00:19:58,220 Let's take... 399 00:19:58,220 --> 00:20:01,360 Let's assume for a little while the best case scenario. 400 00:20:01,740 --> 00:20:01,940 Okay? 401 00:20:03,140 --> 00:20:03,700 Uh... 402 00:20:03,700 --> 00:20:05,040 The kernel stack, alright? 403 00:20:06,140 --> 00:20:06,700 Um... 404 00:20:06,700 --> 00:20:10,360 The kernel stack is going to be in the frame after the sysfs page. 405 00:20:10,480 --> 00:20:11,320 The heap spray worked. 406 00:20:11,540 --> 00:20:12,440 So it goes there. 407 00:20:12,900 --> 00:20:13,460 Alright? 408 00:20:14,400 --> 00:20:20,640 And the other best case scenario is that we know what process ID that kernel stack belongs to. 409 00:20:20,800 --> 00:20:21,320 Okay? 410 00:20:21,380 --> 00:20:23,720 So we know who to yield to to make this execute. 411 00:20:25,420 --> 00:20:26,380 Given that... 412 00:20:26,820 --> 00:20:27,120 Given those... 413 00:20:27,120 --> 00:20:30,500 Given those two kind of best case, what happens, right? 414 00:20:30,820 --> 00:20:32,820 What does a kernel stack even look like? 415 00:20:33,680 --> 00:20:34,160 Um... 416 00:20:35,280 --> 00:20:36,440 I got a picture for you. 417 00:20:38,120 --> 00:20:38,600 Like... 418 00:20:38,600 --> 00:20:41,200 So like other stacks, like every other stack in the world, 419 00:20:41,260 --> 00:20:42,600 a kernel stack has stack frames. 420 00:20:42,860 --> 00:20:44,980 Don't confuse these with physical frames. 421 00:20:45,120 --> 00:20:46,960 Kernel stacks live in physical frames, 422 00:20:47,140 --> 00:20:48,300 but they have stack frames. 423 00:20:49,460 --> 00:20:49,940 Um... 424 00:20:49,940 --> 00:20:52,800 Like other stacks, a kernel stack has stack frames. 425 00:20:53,140 --> 00:20:53,540 Alright? 426 00:20:54,520 --> 00:20:56,420 So what are we looking at here? We have... 427 00:20:56,820 --> 00:20:58,500 We have some guy's stack there, right? 428 00:20:58,560 --> 00:20:59,580 This is... 429 00:21:00,300 --> 00:21:02,560 There's a thread control block. The stack grows down. 430 00:21:02,840 --> 00:21:05,240 So we go down from the top of the stack frame. 431 00:21:05,560 --> 00:21:06,060 Okay? 432 00:21:06,500 --> 00:21:08,940 There's more stack frames, register save space, 433 00:21:09,280 --> 00:21:10,980 and then a return address. 434 00:21:11,240 --> 00:21:12,080 Return address! 435 00:21:12,300 --> 00:21:13,480 I like return addresses! 436 00:21:13,860 --> 00:21:15,500 I can trample on return addresses. 437 00:21:16,320 --> 00:21:16,840 Okay. 438 00:21:17,440 --> 00:21:18,940 There's a bit of a problem here. 439 00:21:19,680 --> 00:21:20,860 There's a bit of a problem. 440 00:21:23,020 --> 00:21:23,540 Um... 441 00:21:23,540 --> 00:21:25,980 Kernel stacks have another thing in them 442 00:21:25,980 --> 00:21:28,000 called the thread control block. 443 00:21:28,280 --> 00:21:29,700 A thread control block 444 00:21:29,700 --> 00:21:31,720 kind of describes... 445 00:21:31,720 --> 00:21:33,560 A thread control block describes 446 00:21:33,560 --> 00:21:36,000 what state the thread is in 447 00:21:36,000 --> 00:21:37,520 and threads, I guess in Linux, 448 00:21:37,600 --> 00:21:38,240 we call them processes. 449 00:21:38,580 --> 00:21:40,880 But a thread control block describes 450 00:21:40,880 --> 00:21:42,080 what state the thread is in. 451 00:21:42,140 --> 00:21:43,400 Whether it's runnable right now, 452 00:21:43,560 --> 00:21:45,840 who its children are, who its parent is, 453 00:21:46,100 --> 00:21:47,840 what address space it lives in. 454 00:21:47,900 --> 00:21:50,520 A kernel stack has a thread control block attached to it. 455 00:21:50,520 --> 00:21:52,020 Every thread has one kernel stack 456 00:21:52,020 --> 00:21:52,960 and one TCB. 457 00:21:53,120 --> 00:21:54,840 By the way, these addresses are bogus. 458 00:21:56,500 --> 00:21:57,900 So let's take a look. 459 00:21:58,180 --> 00:21:58,580 Okay? 460 00:21:59,200 --> 00:22:01,740 Let's take a look at what happens when we write 461 00:22:01,740 --> 00:22:03,680 when we're going to smash this string buffer. 462 00:22:04,940 --> 00:22:05,340 Um... 463 00:22:06,360 --> 00:22:07,800 So we have our sprintf. 464 00:22:07,820 --> 00:22:09,240 This is kind of a simplified sprintf 465 00:22:09,240 --> 00:22:11,000 and it's got all of our text 466 00:22:11,000 --> 00:22:13,020 and it's going to go from the string up. 467 00:22:14,560 --> 00:22:14,960 Um... 468 00:22:16,100 --> 00:22:17,860 So in order to get to that return address, 469 00:22:18,540 --> 00:22:20,380 we've got to hit the thread control block. 470 00:22:22,620 --> 00:22:23,100 Okay? 471 00:22:23,700 --> 00:22:25,540 Whenever we write, 472 00:22:25,660 --> 00:22:27,280 the thread control block is clobbered. 473 00:22:27,460 --> 00:22:28,820 So, by the way, 474 00:22:28,920 --> 00:22:30,620 this isn't the end of the world. 475 00:22:30,720 --> 00:22:31,100 Okay? 476 00:22:31,580 --> 00:22:32,820 This isn't the end of the world 477 00:22:32,820 --> 00:22:34,160 if we clobber the thread control block. 478 00:22:34,600 --> 00:22:35,780 And here's why not. 479 00:22:37,660 --> 00:22:40,140 If we have control of the data, 480 00:22:40,300 --> 00:22:41,980 then we can write something 481 00:22:41,980 --> 00:22:43,520 that would have been a valid 482 00:22:43,520 --> 00:22:45,720 thread control block into that spot. 483 00:22:45,900 --> 00:22:47,460 And it might not have been valid enough 484 00:22:47,460 --> 00:22:48,780 to keep the system running 485 00:22:50,680 --> 00:22:52,680 But it would be valid for long enough, 486 00:22:52,820 --> 00:22:53,340 you know, 487 00:22:53,980 --> 00:22:56,060 for us to switch to that thread 488 00:22:56,060 --> 00:22:59,000 and hit his return address 489 00:22:59,000 --> 00:23:00,280 and take control of the system. 490 00:23:00,460 --> 00:23:02,700 And then drop a rootkit 491 00:23:02,700 --> 00:23:04,020 and reboot the machine or whatever. 492 00:23:04,200 --> 00:23:04,380 Right? 493 00:23:06,960 --> 00:23:09,120 Well, we don't have control of the data. 494 00:23:09,340 --> 00:23:11,360 This time we just get ASCII characters 495 00:23:11,360 --> 00:23:12,580 and not even ASCII characters 496 00:23:12,580 --> 00:23:13,180 that we control. 497 00:23:14,540 --> 00:23:16,200 And best I can tell, 498 00:23:16,200 --> 00:23:17,360 a thread control block, 499 00:23:18,260 --> 00:23:20,040 well, you just can't do one of those 500 00:23:20,040 --> 00:23:22,420 with those specific ASCII characters. 501 00:23:22,760 --> 00:23:24,180 So this is dead in the water. 502 00:23:24,340 --> 00:23:24,600 Alright? 503 00:23:25,040 --> 00:23:26,920 This KStack idea, not gonna happen. 504 00:23:28,800 --> 00:23:29,960 Well, what else are we gonna do? 505 00:23:31,700 --> 00:23:32,620 There are other things 506 00:23:32,620 --> 00:23:33,440 that go in physical frames. 507 00:23:33,520 --> 00:23:35,780 But the big important thing, I think, 508 00:23:35,800 --> 00:23:37,120 that goes in physical frames 509 00:23:38,080 --> 00:23:40,520 is controlled by the slab allocator. 510 00:23:40,680 --> 00:23:41,020 Alright? 511 00:23:41,120 --> 00:23:43,300 The slab allocator is a central memory 512 00:23:43,300 --> 00:23:45,560 allocation structure in the kernel. 513 00:23:46,200 --> 00:23:48,220 And they switched to that actually 514 00:23:48,220 --> 00:23:49,980 probably late 2.4. 515 00:23:51,600 --> 00:23:54,060 And the idea behind the slab allocator is 516 00:23:54,060 --> 00:23:56,440 in a kernel you create a lot of objects 517 00:23:56,440 --> 00:23:57,720 that are about the same. 518 00:23:57,880 --> 00:23:58,300 Okay? 519 00:23:59,200 --> 00:24:01,320 You create a lot of objects that are about 520 00:24:01,320 --> 00:24:02,660 the same sort of thing. 521 00:24:03,080 --> 00:24:04,600 And so what we're gonna do 522 00:24:04,600 --> 00:24:07,080 is to reduce fragmentation of having 523 00:24:07,080 --> 00:24:09,200 a whole bunch of differently sized objects, 524 00:24:09,480 --> 00:24:10,760 we're gonna localize 525 00:24:10,760 --> 00:24:13,900 every object that's similar in memory. 526 00:24:14,060 --> 00:24:14,360 Okay? 527 00:24:16,200 --> 00:24:17,720 Every object of the same type 528 00:24:17,720 --> 00:24:19,120 we're just gonna pack into a frame 529 00:24:19,120 --> 00:24:21,980 and now we have frames full of these objects. 530 00:24:22,780 --> 00:24:23,260 Right. 531 00:24:23,340 --> 00:24:24,820 So these caches are frame sized. 532 00:24:25,080 --> 00:24:26,760 Sometimes they can be two frames long, 533 00:24:26,900 --> 00:24:27,920 but there you go, right? 534 00:24:28,180 --> 00:24:31,460 And so not only is this better 535 00:24:31,460 --> 00:24:33,020 in terms of memory fragmentation, 536 00:24:33,480 --> 00:24:35,340 but it's also better in terms of performance 537 00:24:35,340 --> 00:24:37,660 because of the algorithm that they use. 538 00:24:37,860 --> 00:24:39,380 So this was originally designed 539 00:24:39,380 --> 00:24:40,740 by the Sun Microsystems guys. 540 00:24:41,020 --> 00:24:43,440 I think it was probably Jeff Bonwick. 541 00:24:43,500 --> 00:24:44,440 Jeff Bonwick does everything. 542 00:24:47,520 --> 00:24:48,920 He's the guy who described this in a paper 543 00:24:48,920 --> 00:24:50,600 and they use it in the Solaris kernel 544 00:24:50,600 --> 00:24:52,340 and they have some paper showing 545 00:24:52,340 --> 00:24:54,080 like a ridiculous speed up 546 00:24:54,080 --> 00:24:54,980 under load in the kernel. 547 00:24:55,640 --> 00:24:57,900 So let me show you a little bit about 548 00:24:57,900 --> 00:24:59,360 inside the slab allocator here. 549 00:24:59,540 --> 00:25:01,120 What's inside of a slab? 550 00:25:02,360 --> 00:25:02,760 Okay? 551 00:25:03,020 --> 00:25:05,000 So, by the way, each of these lines 552 00:25:05,000 --> 00:25:05,960 is a frame boundary. 553 00:25:06,080 --> 00:25:07,300 I don't know if you can read that text there. 554 00:25:07,500 --> 00:25:09,880 But each of those lines is the boundary 555 00:25:10,740 --> 00:25:12,640 of one physical memory frame. 556 00:25:13,040 --> 00:25:14,820 And the way these slabs work 557 00:25:16,200 --> 00:25:17,160 is you have a fixed number of slots in them. 558 00:25:17,240 --> 00:25:19,700 In this case, these are huge objects. 559 00:25:19,940 --> 00:25:21,140 One kilobyte large. 560 00:25:22,960 --> 00:25:23,560 But 561 00:25:24,200 --> 00:25:26,800 you fit n of them into a frame. 562 00:25:27,120 --> 00:25:27,200 Okay? 563 00:25:28,340 --> 00:25:29,420 And so 564 00:25:29,420 --> 00:25:31,360 from somewhere outside in the world 565 00:25:31,360 --> 00:25:33,780 there's a pointer to the first 566 00:25:33,780 --> 00:25:35,340 free slot in each slab 567 00:25:35,340 --> 00:25:37,400 that has free slots. 568 00:25:37,880 --> 00:25:39,040 So when you want to do an allocation 569 00:25:39,040 --> 00:25:40,480 you go, okay, I'm going to follow 570 00:25:40,480 --> 00:25:42,260 this first free slab pointer 571 00:25:42,260 --> 00:25:44,860 to find a slot 572 00:25:46,200 --> 00:25:46,820 that I can allocate. 573 00:25:47,820 --> 00:25:49,700 And so now, where do we, now 574 00:25:49,700 --> 00:25:52,080 sooner or later we're going to have to update that pointer 575 00:25:52,080 --> 00:25:54,440 so each free slot has a pointer 576 00:25:54,440 --> 00:25:56,140 to the next free slot 577 00:25:56,140 --> 00:25:58,340 available. And since they're all the same 578 00:25:58,340 --> 00:25:59,860 it doesn't, we don't have to do any kind of 579 00:25:59,860 --> 00:26:02,200 best fit allocation, first fit, 580 00:26:02,340 --> 00:26:03,480 no, they're all the same 581 00:26:03,480 --> 00:26:06,140 so we just take the absolute next slot available 582 00:26:06,140 --> 00:26:08,260 or if there's nothing left 583 00:26:08,260 --> 00:26:09,680 right, the pointer goes to null 584 00:26:09,680 --> 00:26:11,480 there's nothing left available in this slab 585 00:26:12,580 --> 00:26:13,060 then 586 00:26:13,060 --> 00:26:16,180 then we just take this slab out of the list 587 00:26:16,200 --> 00:26:18,320 of slabs that we can allocate from. 588 00:26:19,180 --> 00:26:20,160 And the idea is that 589 00:26:20,160 --> 00:26:21,540 we want to fill slabs 590 00:26:21,540 --> 00:26:23,900 and we want to keep, and we want to empty 591 00:26:23,900 --> 00:26:26,240 slabs also. We want either full slabs 592 00:26:26,240 --> 00:26:28,060 or empty slabs so that we can release 593 00:26:28,060 --> 00:26:29,120 a frame back to the system. 594 00:26:30,320 --> 00:26:30,720 So 595 00:26:32,340 --> 00:26:33,780 where's the list of slabs available? 596 00:26:34,260 --> 00:26:35,820 Slab metadata is stored 597 00:26:36,580 --> 00:26:38,120 in a slab. It's a whole 598 00:26:38,120 --> 00:26:39,340 bunch of stuff of the same type. 599 00:26:39,600 --> 00:26:41,780 Well, where's the metadata for that stored? It's stored elsewhere 600 00:26:41,780 --> 00:26:42,640 in memory, blah blah blah. 601 00:26:44,360 --> 00:26:45,820 But, okay, so 602 00:26:47,160 --> 00:26:47,900 what's important 603 00:26:47,900 --> 00:26:50,040 about this slab thing to us? Why am I spending 604 00:26:50,040 --> 00:26:51,400 so much time talking about it? 605 00:26:51,680 --> 00:26:53,700 What's important about it to us? Well, 606 00:26:53,740 --> 00:26:56,240 there's no header on the front of a slab. 607 00:26:56,420 --> 00:26:58,040 The first thing in the 608 00:26:58,040 --> 00:26:59,840 frame in a slab 609 00:26:59,840 --> 00:27:01,400 is the object, alright? 610 00:27:01,760 --> 00:27:04,060 Very first thing, we can see it right here 611 00:27:04,060 --> 00:27:05,700 and my drawing is perfectly accurate 612 00:27:05,700 --> 00:27:07,420 because drawings are always accurate, 613 00:27:07,580 --> 00:27:09,360 is an in-use object, okay? 614 00:27:11,640 --> 00:27:13,200 This is convenient for us. 615 00:27:13,500 --> 00:27:14,620 This is really convenient. 616 00:27:18,820 --> 00:27:20,480 We can just kind of drop that string there. 617 00:27:20,560 --> 00:27:22,080 That would be a good place to drop that string, 618 00:27:22,200 --> 00:27:22,480 I think. 619 00:27:24,020 --> 00:27:25,160 Alright, who uses slabs? 620 00:27:25,660 --> 00:27:28,060 Well, I'm not sure if you can read that text from all the way 621 00:27:28,060 --> 00:27:29,360 in the back, so I'll read it for you. 622 00:27:30,380 --> 00:27:31,900 But every kernel 623 00:27:31,900 --> 00:27:33,660 subsystem uses slabs, alright? 624 00:27:34,820 --> 00:27:35,900 Every kernel subsystem 625 00:27:35,900 --> 00:27:36,640 uses slabs. 626 00:27:37,720 --> 00:27:39,920 So I've done a little grep 627 00:27:39,920 --> 00:27:41,180 inside of the Linux kernel 628 00:27:41,960 --> 00:27:43,960 for every time we call this the main 629 00:27:43,960 --> 00:27:45,040 slab entry point. 630 00:27:46,200 --> 00:27:47,240 Kmem cache alloc. 631 00:27:47,400 --> 00:27:49,660 Kmem cache alloc, and they call it cache alloc 632 00:27:49,660 --> 00:27:50,840 because they're allocating caches. 633 00:27:52,700 --> 00:27:53,540 They're allocating 634 00:27:54,000 --> 00:27:54,840 objects from a cache. 635 00:27:55,400 --> 00:27:57,880 So how many times does that show up? 636 00:27:58,140 --> 00:28:00,080 Well, there are 305 times in the 637 00:28:00,080 --> 00:28:02,460 Linux kernel that we call Kmem cache alloc. 638 00:28:02,640 --> 00:28:03,980 You know, that's not that they're all unique, 639 00:28:04,200 --> 00:28:06,040 but, so how many different types 640 00:28:06,040 --> 00:28:07,340 of slabs are there available? 641 00:28:08,580 --> 00:28:10,000 Well, the developers 642 00:28:10,000 --> 00:28:12,060 very nicely gave us some debug 643 00:28:12,060 --> 00:28:13,680 info that we can use, okay? 644 00:28:15,120 --> 00:28:16,180 And you can 645 00:28:16,200 --> 00:28:18,060 try this at home if you want 646 00:28:18,060 --> 00:28:19,300 on your own Linux machine. 647 00:28:19,760 --> 00:28:22,240 You can cat slash proc slash slab info. 648 00:28:22,440 --> 00:28:23,720 Actually, there's some very interesting 649 00:28:24,260 --> 00:28:25,100 data in there. 650 00:28:25,660 --> 00:28:28,180 And there are, as it 651 00:28:28,180 --> 00:28:29,840 turns out, on my machine sitting 652 00:28:29,840 --> 00:28:31,320 back in my dorm room at school, 653 00:28:32,600 --> 00:28:33,380 there are 654 00:28:34,240 --> 00:28:35,920 183 different types of slabs. 655 00:28:38,460 --> 00:28:39,460 Well, if any luck, 656 00:28:40,200 --> 00:28:42,180 one of those is going to be an easy target, right? 657 00:28:43,800 --> 00:28:45,900 I'm going to pick completely randomly something 658 00:28:46,200 --> 00:28:47,400 that just so happens to work. 659 00:28:48,820 --> 00:28:49,260 And 660 00:28:50,400 --> 00:28:51,820 let's hit file descriptors. 661 00:28:52,160 --> 00:28:53,540 It's very easy to create. 662 00:28:53,660 --> 00:28:55,040 Why did I choose this, by the way? 663 00:28:55,140 --> 00:28:57,600 It's very, very easy to create file descriptors. 664 00:28:57,720 --> 00:28:59,720 And each, you know, from a user space 665 00:28:59,720 --> 00:29:02,080 perspective, a file descriptor has a number, 666 00:29:02,200 --> 00:29:02,440 right? 667 00:29:04,620 --> 00:29:05,280 FD number. 668 00:29:06,180 --> 00:29:08,080 That's what you get back from the open sys call. 669 00:29:08,600 --> 00:29:09,040 But 670 00:29:10,160 --> 00:29:11,960 those numbers have to map to something 671 00:29:11,960 --> 00:29:13,140 in the kernel. And 672 00:29:13,140 --> 00:29:15,760 they get a whole structure associated with them. 673 00:29:16,200 --> 00:29:17,000 They're called struct file. 674 00:29:17,420 --> 00:29:20,160 And unsurprisingly, there are a lot of them in the kernel 675 00:29:20,160 --> 00:29:21,580 so it's really a good match 676 00:29:22,200 --> 00:29:24,180 for a slab allocator. 677 00:29:24,280 --> 00:29:25,540 So we store these struct files 678 00:29:26,080 --> 00:29:26,780 in slabs. 679 00:29:30,400 --> 00:29:31,880 What's a struct file look like? 680 00:29:32,280 --> 00:29:34,020 Well, I'm going to give you the first couple of 681 00:29:34,020 --> 00:29:35,620 fields there that are interesting to us. 682 00:29:35,820 --> 00:29:38,200 There's a union that's this linked list 683 00:29:38,200 --> 00:29:39,880 which the kernel guys decided to call 684 00:29:39,880 --> 00:29:40,220 fu. 685 00:29:42,800 --> 00:29:43,760 And really 686 00:29:43,760 --> 00:29:45,540 it's two pointers for all we care. 687 00:29:46,200 --> 00:29:48,040 There's this path 688 00:29:48,040 --> 00:29:50,040 structure that's saying 689 00:29:50,040 --> 00:29:52,100 this is the path on disk that we opened it. 690 00:29:52,260 --> 00:29:54,220 And morally, that's also kind of 691 00:29:54,220 --> 00:29:54,700 two pointers. 692 00:29:56,180 --> 00:29:58,040 There's this other pointer here 693 00:29:58,040 --> 00:29:59,020 called fop. 694 00:30:00,640 --> 00:30:01,800 Anybody know about this? 695 00:30:02,340 --> 00:30:02,940 This is the, 696 00:30:03,480 --> 00:30:05,420 so every time you open a file, 697 00:30:06,560 --> 00:30:08,040 files can have, files 698 00:30:08,040 --> 00:30:10,060 are many different things on a Unix machine. 699 00:30:11,780 --> 00:30:13,840 Such as pipes, 700 00:30:14,600 --> 00:30:15,980 such as special 701 00:30:16,200 --> 00:30:18,000 devices, and each special device has 702 00:30:18,000 --> 00:30:19,500 its own list of file operations 703 00:30:19,500 --> 00:30:21,980 that can be performed. Because not everything is the same. 704 00:30:22,040 --> 00:30:23,400 We're not running a plan 9 machine. 705 00:30:24,700 --> 00:30:25,980 So this is a pointer 706 00:30:27,980 --> 00:30:29,960 to the file operation structure 707 00:30:29,960 --> 00:30:31,820 for this specific file, 708 00:30:31,940 --> 00:30:33,580 for this specific FD that we have open. 709 00:30:35,180 --> 00:30:36,000 And what's, 710 00:30:36,000 --> 00:30:37,980 by the way, what's the file operation structure look like? 711 00:30:38,080 --> 00:30:39,260 Well, it's just an owner 712 00:30:39,880 --> 00:30:41,420 and a list of function pointers. 713 00:30:43,640 --> 00:30:44,520 So following 714 00:30:46,440 --> 00:30:47,320 fop, okay, 715 00:30:48,900 --> 00:30:49,780 is fcount, 716 00:30:49,920 --> 00:30:51,360 the number of times it's open, 717 00:30:51,460 --> 00:30:53,980 fflags, some generic BS about the 718 00:30:53,980 --> 00:30:56,320 file descriptor, and fmode, 719 00:30:56,340 --> 00:30:57,620 the mode that it was opened with, 720 00:30:57,780 --> 00:31:00,220 and then there's like a whole bunch more crap after that too. 721 00:31:00,700 --> 00:31:00,960 But, 722 00:31:02,740 --> 00:31:04,220 so let's take a best case 723 00:31:04,220 --> 00:31:06,080 scenario here. By the way, why is this 724 00:31:06,080 --> 00:31:06,640 the best case? 725 00:31:08,320 --> 00:31:10,040 This is the best case because it's at 726 00:31:10,040 --> 00:31:12,160 the beginning of a frame boundary. 727 00:31:12,360 --> 00:31:14,200 Okay? It's right there 728 00:31:14,200 --> 00:31:15,880 ready for us. Okay? 729 00:31:17,600 --> 00:31:18,180 This is 730 00:31:18,180 --> 00:31:19,980 why this is the best case for us. 731 00:31:20,160 --> 00:31:21,760 It's at the start of a slab. 732 00:31:21,980 --> 00:31:24,140 There is no slab metadata there. 733 00:31:24,620 --> 00:31:26,080 And, you know, just kind of 734 00:31:26,080 --> 00:31:26,820 for reference here, 735 00:31:28,520 --> 00:31:30,020 each block in here 736 00:31:30,500 --> 00:31:31,700 is one pointer size. 737 00:31:32,040 --> 00:31:33,320 Just so you know, right? 738 00:31:34,380 --> 00:31:35,580 To give you an idea of scale. 739 00:31:35,800 --> 00:31:38,140 By the way, nothing else in this presentation is to scale. 740 00:31:40,420 --> 00:31:42,080 So what's the really, really best case? 741 00:31:42,180 --> 00:31:44,020 Well, the really, really best case is that our string 742 00:31:44,020 --> 00:31:45,640 just so happened 743 00:31:46,200 --> 00:31:46,940 to line up 744 00:31:48,580 --> 00:31:50,080 before our struct file. 745 00:31:50,460 --> 00:31:52,280 Okay? It's at the start of a slab 746 00:31:52,280 --> 00:31:54,240 and it came from 747 00:31:54,240 --> 00:31:56,120 the same, and getZeroedPage 748 00:31:56,120 --> 00:31:57,580 comes from the same kernel pool 749 00:31:58,200 --> 00:32:00,220 that the slab allocator grabs from. 750 00:32:00,300 --> 00:32:02,160 The slab allocator uses getZeroedPage 751 00:32:02,160 --> 00:32:03,760 or something very much like it. 752 00:32:04,560 --> 00:32:05,940 And the sysfs 753 00:32:05,940 --> 00:32:07,940 buffer allocator uses getZeroedPage. 754 00:32:09,160 --> 00:32:09,920 By the way, 755 00:32:09,940 --> 00:32:11,960 I'm going to talk a little bit more about that frame allocation 756 00:32:11,960 --> 00:32:12,460 mechanism 757 00:32:14,220 --> 00:32:15,020 in a moment. 758 00:32:17,080 --> 00:32:18,000 Okay, so what's a 759 00:32:18,000 --> 00:32:19,100 struct file look like? 760 00:32:23,160 --> 00:32:24,120 This is what it is, 761 00:32:24,220 --> 00:32:25,140 right? But, 762 00:32:25,240 --> 00:32:27,240 and I've darkened this time 763 00:32:27,240 --> 00:32:29,580 the parts that the kernel can survive 764 00:32:29,580 --> 00:32:30,520 for a little while 765 00:32:31,520 --> 00:32:32,820 with being smashed. 766 00:32:33,700 --> 00:32:35,460 It's not, you know, the kernel 767 00:32:36,120 --> 00:32:37,500 isn't going to survive forever. 768 00:32:37,680 --> 00:32:40,000 If you do a lot of operations on this file, 769 00:32:40,580 --> 00:32:41,540 it's going to be bad. 770 00:32:41,720 --> 00:32:43,660 If you exit the program, it's going to be bad. 771 00:32:43,840 --> 00:32:46,060 If you don't clean it up later, it's going to be bad. 772 00:32:46,200 --> 00:32:47,440 The kernel's probably going to crash. 773 00:32:47,800 --> 00:32:50,140 But there's only one 774 00:32:50,140 --> 00:32:52,080 pointer in here. There's only one 775 00:32:52,680 --> 00:32:54,000 member of this struct 776 00:32:54,000 --> 00:32:55,880 that really matters, 777 00:32:56,040 --> 00:32:56,360 you know? 778 00:32:57,320 --> 00:32:58,440 And that's fop. 779 00:33:00,160 --> 00:33:02,020 Great news! That's really 780 00:33:02,020 --> 00:33:02,980 good news, okay? 781 00:33:04,940 --> 00:33:06,140 That means that 782 00:33:06,140 --> 00:33:08,240 we can pave over 783 00:33:08,240 --> 00:33:10,280 this struct file if we want. 784 00:33:10,480 --> 00:33:11,860 Okay? We can pave over 785 00:33:11,860 --> 00:33:14,100 the beginning of it, we can pave over the 786 00:33:14,100 --> 00:33:16,100 end of it, as long as we get some 787 00:33:16,200 --> 00:33:17,620 thing that we're okay with 788 00:33:17,620 --> 00:33:19,320 in that file operation structure. 789 00:33:20,400 --> 00:33:22,200 Okay? As long as we get something 790 00:33:22,200 --> 00:33:23,940 that we're okay with in that file operation 791 00:33:23,940 --> 00:33:26,120 structure, the rest of the struct file can be 792 00:33:26,120 --> 00:33:26,540 smashed. 793 00:33:28,000 --> 00:33:28,900 For a little while. 794 00:33:30,160 --> 00:33:31,200 Okay, we're one for three. 795 00:33:31,780 --> 00:33:33,980 Let's kind of get back to why 796 00:33:33,980 --> 00:33:35,820 we're doing this here. What are the three controls 797 00:33:35,820 --> 00:33:37,480 that we're going for? We're going for 798 00:33:39,160 --> 00:33:39,600 length, 799 00:33:41,020 --> 00:33:42,300 we're going for contents, 800 00:33:42,800 --> 00:33:44,060 attacker-controlled contents, 801 00:33:44,900 --> 00:33:46,180 we're going for an attacker-controlled 802 00:33:46,200 --> 00:33:46,460 target. 803 00:33:47,820 --> 00:33:50,280 The length is not an issue anymore. 804 00:33:50,580 --> 00:33:50,900 Alright? 805 00:33:51,620 --> 00:33:53,880 We still don't have control over the length, 806 00:33:54,040 --> 00:33:56,220 but we found some place that it doesn't matter. 807 00:33:56,440 --> 00:33:58,220 We can go over by a little bit. 808 00:33:58,360 --> 00:33:59,920 Not, you know, we can't go over 809 00:33:59,920 --> 00:34:01,940 into many, many struct files, 810 00:34:02,160 --> 00:34:04,020 but if we kind of 811 00:34:04,020 --> 00:34:05,900 open the number of sockets very, very 812 00:34:05,900 --> 00:34:08,080 carefully, we can go over by a little 813 00:34:08,080 --> 00:34:10,160 ways without causing the system to blow 814 00:34:10,160 --> 00:34:11,160 up and die immediately. 815 00:34:14,560 --> 00:34:15,700 So what's next? 816 00:34:16,200 --> 00:34:16,400 We don't have length. 817 00:34:16,940 --> 00:34:18,220 Let's try and control the content. 818 00:34:20,140 --> 00:34:20,660 Alright. 819 00:34:21,860 --> 00:34:23,600 So here's the code 820 00:34:24,080 --> 00:34:25,440 that we're going to try and exploit again 821 00:34:25,440 --> 00:34:26,560 for your reference here. 822 00:34:26,580 --> 00:34:28,000 String plus equals sprintf, 823 00:34:28,080 --> 00:34:30,380 str, and then a bunch of format string 824 00:34:30,380 --> 00:34:31,520 for those of you in the back. 825 00:34:33,020 --> 00:34:35,740 So we can't write arbitrary content 826 00:34:35,740 --> 00:34:36,440 with this, right? 827 00:34:36,960 --> 00:34:39,320 ba2str always produces a MAC address 828 00:34:39,320 --> 00:34:39,980 for us. 829 00:34:41,980 --> 00:34:43,940 %d always produces a decimal. 830 00:34:45,660 --> 00:34:46,180 %x 831 00:34:46,200 --> 00:34:47,640 always produces a hexadecimal. 832 00:34:47,780 --> 00:34:50,020 All of this is controlled by 833 00:34:50,020 --> 00:34:51,760 them, not controlled by us. 834 00:34:52,520 --> 00:34:54,140 The good news is that we can 835 00:34:54,140 --> 00:34:55,980 open sockets with the properties 836 00:34:55,980 --> 00:34:57,100 that we want, right? 837 00:34:57,740 --> 00:35:00,100 So it's very easy to predict the content. 838 00:35:01,660 --> 00:35:04,020 So if we open a bunch of sockets directed to 839 00:35:04,020 --> 00:35:06,060 nobody, bound to no socket, 840 00:35:06,220 --> 00:35:07,760 with no data pending, 841 00:35:08,180 --> 00:35:09,600 blah, blah, blah, blah, blah, 842 00:35:09,720 --> 00:35:11,800 then if we cat this file, we're going to get 843 00:35:11,800 --> 00:35:14,100 a lot of stuff that looks a lot like that. 844 00:35:14,280 --> 00:35:14,400 Okay? 845 00:35:16,200 --> 00:35:16,340 So we've got a bunch of sockets 846 00:35:16,340 --> 00:35:16,900 with no MAC address, null MAC address, 847 00:35:17,080 --> 00:35:18,780 two, zero, hex, blah, blah, blah, 848 00:35:18,840 --> 00:35:19,580 repeated a bunch. 849 00:35:20,560 --> 00:35:21,800 How many times is that repeated? 850 00:35:22,060 --> 00:35:24,740 That's repeated as many times as we want. 851 00:35:25,380 --> 00:35:25,780 Okay? 852 00:35:27,880 --> 00:35:28,720 What does this mean? 853 00:35:28,960 --> 00:35:29,740 What does this mean? 854 00:35:31,940 --> 00:35:33,320 Data, all right, so data, 855 00:35:34,220 --> 00:35:35,940 this means that data that looks like that 856 00:35:35,940 --> 00:35:38,460 is going to end up in the file structure. 857 00:35:38,660 --> 00:35:39,880 If we go down this path, 858 00:35:40,140 --> 00:35:41,420 data that looks like that 859 00:35:41,420 --> 00:35:43,160 is going to end up in the file structure. 860 00:35:46,200 --> 00:35:47,620 So we'd better make the most of it. 861 00:35:47,920 --> 00:35:50,040 And, what does that mean for fop? 862 00:35:50,320 --> 00:35:51,980 Well, it means that a substring of that, 863 00:35:52,080 --> 00:35:54,360 four characters of those, if you're on a 32-bit machine, 864 00:35:54,680 --> 00:35:56,240 four characters of that is going 865 00:35:56,240 --> 00:35:58,420 to end up in fop, no matter what happens. 866 00:35:58,600 --> 00:35:58,840 All right? 867 00:36:02,240 --> 00:36:04,340 Well, what can go in fop? 868 00:36:04,400 --> 00:36:05,900 Anyway, what does it make sense 869 00:36:05,900 --> 00:36:06,960 to put in fop? 870 00:36:07,280 --> 00:36:09,380 And can we have this 871 00:36:10,100 --> 00:36:11,080 go in fop? 872 00:36:11,260 --> 00:36:14,180 The stuff, one of those substrings, 873 00:36:14,200 --> 00:36:15,580 okay? One of those substrings. 874 00:36:16,200 --> 00:36:17,980 Can we put that in fop safely? 875 00:36:18,700 --> 00:36:20,100 The only thing 876 00:36:20,100 --> 00:36:20,780 that matters 877 00:36:21,740 --> 00:36:24,040 from right now is to make 878 00:36:24,040 --> 00:36:25,920 sure that something that makes sense 879 00:36:26,580 --> 00:36:28,020 shows up in 880 00:36:28,020 --> 00:36:28,460 fop. 881 00:36:30,020 --> 00:36:32,040 Something, it's the only thing we care 882 00:36:32,040 --> 00:36:33,860 about in struct file. Without something 883 00:36:33,860 --> 00:36:35,580 that makes sense showing up in fop, 884 00:36:35,700 --> 00:36:36,880 the gig is blown. 885 00:36:37,820 --> 00:36:40,020 All right? We're done without it. 886 00:36:40,060 --> 00:36:41,360 So we'd better make it good. 887 00:36:41,580 --> 00:36:42,540 How are we going to do this? 888 00:36:44,020 --> 00:36:44,580 Well, 889 00:36:46,400 --> 00:36:48,560 fop is just kind of a pointer into the kernel's 890 00:36:48,560 --> 00:36:49,380 address space, okay? 891 00:36:50,540 --> 00:36:52,160 fop is a pointer into the kernel's 892 00:36:52,160 --> 00:36:54,100 address space. It's dereferenced by 893 00:36:54,100 --> 00:36:56,160 the kernel, and since the kernel thinks 894 00:36:56,160 --> 00:36:57,420 that it controls it usually, 895 00:36:57,660 --> 00:36:59,800 it doesn't do any checking on it. That's okay. 896 00:37:00,100 --> 00:37:02,000 That's all right, because the kernel is 897 00:37:02,000 --> 00:37:03,140 supposed to be controlling this. 898 00:37:05,880 --> 00:37:08,240 What's interesting about that? The kernel's 899 00:37:08,240 --> 00:37:09,820 address space is a strict 900 00:37:09,820 --> 00:37:11,900 superset of the user's address space 901 00:37:11,900 --> 00:37:12,500 on x86. 902 00:37:14,100 --> 00:37:16,120 On x86, it is a strict subset 903 00:37:16,200 --> 00:37:17,220 of the user's address space. 904 00:37:18,820 --> 00:37:19,980 And so that 905 00:37:19,980 --> 00:37:21,940 means that it would be okay 906 00:37:22,700 --> 00:37:24,080 if fop was 907 00:37:24,080 --> 00:37:25,360 a pointer into user memory. 908 00:37:25,600 --> 00:37:28,020 It would be okay. It doesn't 909 00:37:28,020 --> 00:37:29,600 have to be a pointer into kernel memory. 910 00:37:30,500 --> 00:37:31,960 So let's come up with a little bit of a 911 00:37:31,960 --> 00:37:33,720 game plan here to 912 00:37:33,720 --> 00:37:35,880 get this pointing to something reasonable in 913 00:37:35,880 --> 00:37:36,320 user memory. 914 00:37:38,000 --> 00:37:39,820 We're going to take this string 915 00:37:39,820 --> 00:37:41,380 that we saw a moment ago, 916 00:37:41,520 --> 00:37:43,760 that string, and we're going to map 917 00:37:44,360 --> 00:37:46,180 all of the substrings of it 918 00:37:46,200 --> 00:37:47,560 to become something 919 00:37:48,200 --> 00:37:49,920 valid of an fop target. 920 00:37:50,300 --> 00:37:50,720 Okay? 921 00:37:51,780 --> 00:37:53,420 So for each of these, 922 00:37:54,500 --> 00:37:56,020 so the first substring 923 00:37:56,020 --> 00:37:57,040 is 00 colon 0. 924 00:37:57,280 --> 00:37:59,920 And in ASCII that's going to be hex blah blah blah 925 00:37:59,920 --> 00:38:02,160 we trim off the end 926 00:38:02,160 --> 00:38:03,980 and make sure that that address points to a 927 00:38:03,980 --> 00:38:05,000 valid fop target. 928 00:38:05,480 --> 00:38:07,900 Okay? 0 colon 00, right? And we're just 929 00:38:07,900 --> 00:38:09,560 going to keep walking through the string 930 00:38:09,560 --> 00:38:12,120 for every member there, bam bam bam 931 00:38:12,120 --> 00:38:13,360 bam bam. We're just going to keep 932 00:38:14,000 --> 00:38:14,860 throwing it along there. 933 00:38:18,440 --> 00:38:19,880 And we're done, right? 934 00:38:20,560 --> 00:38:21,280 We have 935 00:38:21,280 --> 00:38:22,200 this string 936 00:38:24,420 --> 00:38:25,180 sitting here. 937 00:38:25,320 --> 00:38:26,820 We now have data written there. 938 00:38:27,540 --> 00:38:29,000 And we've mapped that there. 939 00:38:29,160 --> 00:38:30,600 This is mapped in user space. 940 00:38:30,760 --> 00:38:31,700 We're using mmap. 941 00:38:32,120 --> 00:38:33,540 We control that. 942 00:38:33,800 --> 00:38:35,540 We have, I don't know if you can read that 943 00:38:35,540 --> 00:38:37,740 from way out back there, but 944 00:38:37,740 --> 00:38:39,960 the pointer's inside there. So owner is null. 945 00:38:40,140 --> 00:38:42,180 That's okay for an fop structure. 946 00:38:42,740 --> 00:38:44,400 And let's think about some of those 947 00:38:44,400 --> 00:38:45,920 other pointers. Some of those function pointers 948 00:38:46,200 --> 00:38:48,040 maybe llseq should go to 949 00:38:48,040 --> 00:38:49,400 attacker ring 0. 950 00:38:49,720 --> 00:38:51,980 Maybe read should go to attacker 951 00:38:51,980 --> 00:38:52,660 ring 0. 952 00:38:53,820 --> 00:38:54,780 We're done, right? 953 00:38:55,360 --> 00:38:56,560 Well, not so fast. 954 00:38:57,940 --> 00:38:59,980 In reality, it probably looks a little more 955 00:38:59,980 --> 00:39:00,560 like that. 956 00:39:02,540 --> 00:39:03,900 Maybe there's going to be another 957 00:39:03,900 --> 00:39:05,560 frame in the way there. And now 958 00:39:05,560 --> 00:39:07,900 instead of having fop point 959 00:39:07,900 --> 00:39:09,640 to this structure, we have just 960 00:39:09,640 --> 00:39:12,080 some random bogus crap pointing 961 00:39:12,080 --> 00:39:14,160 to this structure. fop has not been touched. 962 00:39:15,100 --> 00:39:16,020 We haven't 963 00:39:16,200 --> 00:39:16,800 done yet. Okay. 964 00:39:17,600 --> 00:39:18,460 Three controls. 965 00:39:20,480 --> 00:39:21,560 Length, content, 966 00:39:22,260 --> 00:39:22,800 target. 967 00:39:24,320 --> 00:39:25,440 Contents aren't controlled, 968 00:39:25,720 --> 00:39:27,460 but we've predicted them. We've got length 969 00:39:27,460 --> 00:39:28,740 and we've got contents handled. 970 00:39:30,700 --> 00:39:31,720 Let's hit up the target. 971 00:39:33,800 --> 00:39:34,740 Let's be buddies. 972 00:39:37,080 --> 00:39:38,040 So how are we going to 973 00:39:38,040 --> 00:39:39,900 control the relative placement of these frames? 974 00:39:43,300 --> 00:39:45,180 We know that we're going to 975 00:39:46,200 --> 00:39:47,000 The whole idea behind this is 976 00:39:47,000 --> 00:39:47,860 the heap spray, remember? 977 00:39:48,020 --> 00:39:49,520 We talked about that before. 978 00:39:49,780 --> 00:39:52,260 But we can't allocate that many FDs. 979 00:39:52,820 --> 00:39:55,400 We can allocate 16,000 FDs, 980 00:39:55,400 --> 00:39:56,840 but that isn't going to get close 981 00:39:56,840 --> 00:39:59,500 to the 128 meg of RAM in the VM 982 00:39:59,500 --> 00:40:00,980 that I'm going to be using today 983 00:40:00,980 --> 00:40:02,080 to demo this for you. 984 00:40:02,220 --> 00:40:04,040 And it's not even getting anywhere near 985 00:40:04,040 --> 00:40:06,120 the 4 gig of RAM that a small 986 00:40:06,120 --> 00:40:07,560 server nowadays has. 987 00:40:10,460 --> 00:40:12,180 So heap sprays are hard now. 988 00:40:12,320 --> 00:40:15,620 So let's talk a little bit about 989 00:40:16,200 --> 00:40:16,760 how memory gets allocated. 990 00:40:16,960 --> 00:40:18,700 I promised you earlier that I was going to talk about this. 991 00:40:22,240 --> 00:40:23,720 Physical frames are allocated 992 00:40:23,720 --> 00:40:26,080 using this concept called the buddy allocator. 993 00:40:27,020 --> 00:40:29,140 The buddy allocator is called that 994 00:40:29,140 --> 00:40:31,080 because it pairs up frames 995 00:40:31,980 --> 00:40:33,840 and it pairs up groups of frames 996 00:40:33,840 --> 00:40:36,020 and it calls them buddies and merges them. 997 00:40:37,420 --> 00:40:40,000 And this is a really, 998 00:40:40,040 --> 00:40:41,300 really old algorithm. 999 00:40:41,480 --> 00:40:42,500 This is from 1963. 1000 00:40:44,520 --> 00:40:45,760 According to Neuth, 1001 00:40:46,200 --> 00:40:47,380 who was the one who wrote about it, 1002 00:40:47,500 --> 00:40:49,960 Markowitz was the guy who wrote it down 1003 00:40:49,960 --> 00:40:51,320 and I think it was actually invented 1004 00:40:51,320 --> 00:40:52,600 in the late 50s. 1005 00:40:53,440 --> 00:40:55,240 So this is a really old algorithm, 1006 00:40:55,420 --> 00:40:57,600 but it turns out that if we use 1007 00:40:57,600 --> 00:40:58,900 things like slab, 1008 00:40:59,140 --> 00:41:01,680 this goes really well 1009 00:41:02,080 --> 00:41:02,600 with slab. 1010 00:41:06,680 --> 00:41:08,120 Because we're not having 1011 00:41:08,120 --> 00:41:09,700 all of that fragmentation and memory 1012 00:41:09,700 --> 00:41:10,400 of different sizes. 1013 00:41:12,860 --> 00:41:14,800 So the implementation of this 1014 00:41:14,800 --> 00:41:15,860 lives in Linux, MM, 1015 00:41:16,720 --> 00:41:17,880 PageAlloc.c. 1016 00:41:18,860 --> 00:41:20,720 This is 4,000 lines 1017 00:41:20,720 --> 00:41:22,200 of really, 1018 00:41:22,260 --> 00:41:24,360 really, really well-tuned code 1019 00:41:24,360 --> 00:41:26,100 tuned to the weird 1020 00:41:26,100 --> 00:41:28,040 cache infrastructures of 1021 00:41:28,040 --> 00:41:29,500 Alpha, x86, 1022 00:41:29,940 --> 00:41:31,200 Arm, Itanic, 1023 00:41:31,920 --> 00:41:33,680 run in goddamn 1024 00:41:34,200 --> 00:41:34,740 fear. 1025 00:41:36,400 --> 00:41:37,700 You don't want to read it. 1026 00:41:38,240 --> 00:41:40,620 Get a copy of Understanding the Linux Kernel. 1027 00:41:40,760 --> 00:41:42,340 It's got a good description of it. 1028 00:41:42,560 --> 00:41:43,980 That book is 1029 00:41:43,980 --> 00:41:45,220 my god now. 1030 00:41:48,480 --> 00:41:50,160 But what's important about 1031 00:41:50,160 --> 00:41:51,080 the buddy allocator anyway? 1032 00:41:52,300 --> 00:41:54,340 So with a run-of-the-mill 1033 00:41:54,340 --> 00:41:56,180 frame allocator that's just grabbing frames, 1034 00:41:56,420 --> 00:41:57,900 there's no real ordering 1035 00:41:57,900 --> 00:41:58,800 to those frames. 1036 00:41:59,480 --> 00:42:01,720 If it's just grabbing a whole bunch of frames, 1037 00:42:01,860 --> 00:42:03,420 there's no real ordering to it. 1038 00:42:05,760 --> 00:42:07,900 So this is going to inject 1039 00:42:07,900 --> 00:42:09,440 determinism predictability 1040 00:42:10,200 --> 00:42:11,560 into frame allocation 1041 00:42:12,200 --> 00:42:14,020 that otherwise we'd just be 1042 00:42:14,020 --> 00:42:16,160 picking frames at random. We'd really have no way 1043 00:42:16,200 --> 00:42:18,000 to determine what frames 1044 00:42:18,000 --> 00:42:19,020 are going to be next. 1045 00:42:19,540 --> 00:42:21,280 And the reason why it does this is 1046 00:42:21,280 --> 00:42:24,260 it can allocate groups of frames 1047 00:42:24,260 --> 00:42:25,200 of different sizes 1048 00:42:26,060 --> 00:42:27,520 and when it's able, 1049 00:42:27,720 --> 00:42:30,080 it'll try and put a bunch of frames 1050 00:42:30,080 --> 00:42:32,020 one-off frames together 1051 00:42:32,020 --> 00:42:34,200 so that it leaves as much memory 1052 00:42:35,060 --> 00:42:35,960 wide open 1053 00:42:35,960 --> 00:42:37,400 for big groups as possible. 1054 00:42:38,340 --> 00:42:39,700 The implementation details 1055 00:42:40,400 --> 00:42:42,100 totally beyond the scope of this talk. 1056 00:42:43,160 --> 00:42:44,300 I guess if I hadn't 1057 00:42:44,300 --> 00:42:46,180 talked about slab earlier, I could talk about it. 1058 00:42:46,200 --> 00:42:47,700 But I really think slab is cooler. 1059 00:42:48,780 --> 00:42:50,140 So you guys can go look up 1060 00:42:50,140 --> 00:42:51,140 the body allocator on your own. 1061 00:42:51,860 --> 00:42:52,620 Alright, what are we going to do? 1062 00:42:53,140 --> 00:42:53,880 How are we going to make this work? 1063 00:42:56,260 --> 00:42:57,820 We're going to try and use this 1064 00:42:58,300 --> 00:42:59,440 localizing technique here. 1065 00:43:01,060 --> 00:43:01,380 And 1066 00:43:03,060 --> 00:43:03,700 in brief, 1067 00:43:03,880 --> 00:43:05,100 we're going to go fill up memory 1068 00:43:05,100 --> 00:43:07,720 and that means that everything that would have caused a 1069 00:43:07,720 --> 00:43:09,380 discontinuity, it's going to get paged out. 1070 00:43:09,480 --> 00:43:10,400 It's going to get paged to disk. 1071 00:43:12,060 --> 00:43:13,980 Every other program on the system, paged to disk. 1072 00:43:14,300 --> 00:43:15,480 What are we going to do to generate 1073 00:43:16,200 --> 00:43:16,680 contiguous chunks? 1074 00:43:17,380 --> 00:43:18,580 Well, we're going to free stuff. 1075 00:43:18,720 --> 00:43:20,520 We're going to do this little alloc-free-alloc dance 1076 00:43:21,340 --> 00:43:23,840 to get contiguous chunks of memory. 1077 00:43:24,900 --> 00:43:25,940 And what are we going to do 1078 00:43:25,940 --> 00:43:27,920 to allocate chunks of memory for our struct files? 1079 00:43:28,180 --> 00:43:29,900 Well, we're going to free a little bit in there. 1080 00:43:31,260 --> 00:43:32,340 And that's going to happen. 1081 00:43:32,840 --> 00:43:33,700 We're going to 1082 00:43:34,460 --> 00:43:35,820 allocate our buffer page. 1083 00:43:36,720 --> 00:43:37,880 Allocate our buffer frame, 1084 00:43:38,080 --> 00:43:38,900 I guess I should say. 1085 00:43:40,240 --> 00:43:41,600 And how are we going to do this? 1086 00:43:41,660 --> 00:43:44,000 Remember, this happens when sysfs opens 1087 00:43:44,000 --> 00:43:44,920 the file. 1088 00:43:46,560 --> 00:43:48,580 And the write hasn't happened yet. 1089 00:43:48,620 --> 00:43:49,520 You can do the allocation 1090 00:43:50,600 --> 00:43:52,280 without causing the smash to happen. 1091 00:43:52,380 --> 00:43:53,280 This is critical. 1092 00:43:55,460 --> 00:43:56,440 Alright, we're going to pick up 1093 00:43:56,440 --> 00:43:58,540 more memory for struct files here. 1094 00:43:58,980 --> 00:44:00,320 Ready, aim, fire. 1095 00:44:01,540 --> 00:44:02,260 What do we do? 1096 00:44:02,740 --> 00:44:04,860 Memory starts off kind of looking like this. 1097 00:44:05,000 --> 00:44:05,960 It's fragmented. 1098 00:44:05,960 --> 00:44:08,020 There's other people's memory 1099 00:44:08,020 --> 00:44:08,820 all around. 1100 00:44:10,260 --> 00:44:10,720 Luckily, 1101 00:44:12,160 --> 00:44:14,080 we can allocate about as much memory as we want. 1102 00:44:14,200 --> 00:44:15,960 And that's exactly what we're going to do. 1103 00:44:16,200 --> 00:44:18,120 All of the system's memory 1104 00:44:19,060 --> 00:44:20,540 minus the stuff that the kernel needs 1105 00:44:20,540 --> 00:44:21,560 goes to us now. 1106 00:44:22,420 --> 00:44:23,820 You know, there's a lightly used machine 1107 00:44:23,820 --> 00:44:25,480 that nobody's really paying attention to 1108 00:44:25,480 --> 00:44:26,260 if you rootkit it. 1109 00:44:26,420 --> 00:44:28,340 So it's not really using 1110 00:44:29,820 --> 00:44:31,540 there's not a whole lot of other stuff using memory. 1111 00:44:31,740 --> 00:44:32,960 So everything gets paged out 1112 00:44:32,960 --> 00:44:34,240 and we're going to do 1113 00:44:34,240 --> 00:44:36,660 our little free and allocate dance 1114 00:44:36,660 --> 00:44:38,260 to make that all contiguous. 1115 00:44:38,340 --> 00:44:39,880 You couldn't really see a change there. 1116 00:44:40,060 --> 00:44:43,100 But now the frame allocator has those all kind of lined up 1117 00:44:43,100 --> 00:44:44,540 such that if we free four in a row, 1118 00:44:46,200 --> 00:44:48,220 we get four physical free frames in a row. 1119 00:44:48,560 --> 00:44:49,720 So what are we going to do next? 1120 00:44:49,820 --> 00:44:50,940 We're going to set up our files, 1121 00:44:51,160 --> 00:44:52,280 our buffer in our files, 1122 00:44:53,240 --> 00:44:53,760 and... 1123 00:44:57,380 --> 00:44:57,900 own. 1124 00:44:58,800 --> 00:44:59,800 We're three for three. 1125 00:45:01,420 --> 00:45:01,940 Remember, 1126 00:45:02,040 --> 00:45:02,620 three controls. 1127 00:45:02,820 --> 00:45:05,220 Attacker-controlled length, attacker-controlled contents, 1128 00:45:05,360 --> 00:45:06,420 attacker-controlled target. 1129 00:45:07,240 --> 00:45:09,520 We made these controlled by us 1130 00:45:09,520 --> 00:45:12,120 by deterministically permuting memory. 1131 00:45:13,080 --> 00:45:14,040 And what happened? 1132 00:45:14,160 --> 00:45:14,980 We owned the machine. 1133 00:45:16,360 --> 00:45:17,420 What went wrong? 1134 00:45:17,920 --> 00:45:18,920 What went wrong? 1135 00:45:20,360 --> 00:45:22,080 I'm going to leave this up here for you. 1136 00:45:22,780 --> 00:45:23,820 I'll let you read it. 1137 00:45:27,560 --> 00:45:28,660 There's a comment here 1138 00:45:28,660 --> 00:45:31,240 right after we do the read dance. 1139 00:45:31,960 --> 00:45:33,360 Right after the read happens. 1140 00:45:33,900 --> 00:45:35,720 This code works fine with 1141 00:45:35,720 --> 00:45:36,700 page size return, 1142 00:45:37,000 --> 00:45:39,840 but it's likely to indicate truncated result 1143 00:45:39,840 --> 00:45:40,740 or overflow. 1144 00:45:42,000 --> 00:45:43,020 So what do we do? 1145 00:45:43,120 --> 00:45:44,640 What does the kernel do when there's an overflow? 1146 00:45:46,200 --> 00:45:46,980 Let's struggle along. 1147 00:45:48,820 --> 00:45:49,300 Guys? 1148 00:45:50,900 --> 00:45:51,380 Guys? 1149 00:45:56,640 --> 00:45:57,260 Demo time? 1150 00:46:00,860 --> 00:46:02,320 I have a VM here. 1151 00:46:03,100 --> 00:46:04,740 I can't actually see it. 1152 00:46:05,220 --> 00:46:06,400 So we're going to have to hope. 1153 00:46:06,540 --> 00:46:08,080 How do I get out of keynote here? 1154 00:46:10,160 --> 00:46:10,800 There we go. 1155 00:46:11,800 --> 00:46:14,260 So I've got GDB attached to my VM here. 1156 00:46:14,860 --> 00:46:16,180 I'm kind of doing this blank. 1157 00:46:16,200 --> 00:46:17,680 Because I can't see the screen very well. 1158 00:46:18,240 --> 00:46:19,360 And here's what I'm going to do. 1159 00:46:19,700 --> 00:46:20,560 I'm going to... 1160 00:46:20,560 --> 00:46:21,200 Where's my mouse? 1161 00:46:23,740 --> 00:46:24,640 So here's my VM. 1162 00:46:24,740 --> 00:46:25,380 It's alive here. 1163 00:46:29,160 --> 00:46:30,380 And I'm going to 1164 00:46:31,120 --> 00:46:31,920 stop the VM 1165 00:46:31,920 --> 00:46:32,600 and I'm going to break 1166 00:46:33,160 --> 00:46:34,260 target ring zero. 1167 00:46:34,560 --> 00:46:35,460 Can everybody see that? 1168 00:46:36,220 --> 00:46:36,620 Okay. 1169 00:46:37,840 --> 00:46:40,100 Well, the people in front will be able to see it 1170 00:46:40,100 --> 00:46:41,140 and I'll narrate otherwise. 1171 00:46:41,140 --> 00:46:41,460 Sorry. 1172 00:46:43,520 --> 00:46:43,920 Oh. 1173 00:46:44,320 --> 00:46:45,580 I can do a little zoom thing. 1174 00:46:45,740 --> 00:46:46,120 Does that work? 1175 00:46:46,600 --> 00:46:47,560 Oh, look at that. 1176 00:46:49,080 --> 00:46:49,620 Damn it. 1177 00:46:51,700 --> 00:46:52,500 All right. 1178 00:46:53,200 --> 00:46:53,600 Sorry. 1179 00:46:56,360 --> 00:46:57,520 I'm a little pressed for time. 1180 00:46:57,640 --> 00:46:59,920 So I'm not going to spend much time playing with that there. 1181 00:47:00,340 --> 00:47:00,920 All right. 1182 00:47:00,960 --> 00:47:01,740 So here I am. 1183 00:47:01,780 --> 00:47:03,140 And now the VM is running again. 1184 00:47:03,180 --> 00:47:04,060 It says continuing there. 1185 00:47:04,060 --> 00:47:07,980 So now I'm going to run my exploit. 1186 00:47:10,840 --> 00:47:11,460 Uh-oh. 1187 00:47:15,640 --> 00:47:16,560 Can I type? 1188 00:47:16,760 --> 00:47:17,220 Yes. 1189 00:47:19,340 --> 00:47:21,360 And let's go watch that... 1190 00:47:22,380 --> 00:47:24,100 Can I get these both at the same time? 1191 00:47:30,040 --> 00:47:30,720 All right. 1192 00:47:30,740 --> 00:47:32,200 Now we've got my screen here 1193 00:47:32,200 --> 00:47:33,480 and we're stopped 1194 00:47:33,480 --> 00:47:34,040 in the middle of the screen. 1195 00:47:34,060 --> 00:47:34,580 We're in the debugger. 1196 00:47:34,660 --> 00:47:35,820 We're stopped in GDB here. 1197 00:47:36,100 --> 00:47:38,000 And I'm going to do a little backtrace for you. 1198 00:47:38,160 --> 00:47:39,840 What are we looking at in this backtrace? 1199 00:47:41,880 --> 00:47:43,880 If I had any clue where my pointer was, 1200 00:47:44,020 --> 00:47:44,560 I would... 1201 00:47:46,660 --> 00:47:46,980 Yeah? 1202 00:47:48,220 --> 00:47:48,540 No. 1203 00:47:49,280 --> 00:47:50,660 I would be showing you. 1204 00:47:50,760 --> 00:47:51,740 I would be zooming in for you. 1205 00:47:51,900 --> 00:47:53,320 Oh, yeah. There we go. 1206 00:47:53,740 --> 00:47:54,280 Look at that. 1207 00:47:54,320 --> 00:47:55,760 That looks like a kernel stack, doesn't it? 1208 00:47:56,180 --> 00:47:57,480 How do we know that's a kernel stack? 1209 00:47:57,620 --> 00:47:59,740 That address there is... 1210 00:48:04,060 --> 00:48:04,720 I can't really read it. 1211 00:48:05,800 --> 00:48:06,920 And that's... 1212 00:48:06,920 --> 00:48:08,480 That's kernel memory, okay? 1213 00:48:08,780 --> 00:48:10,240 Let's print something else. 1214 00:48:11,040 --> 00:48:12,640 File arrow fop. 1215 00:48:13,480 --> 00:48:14,340 Did that work? 1216 00:48:16,580 --> 00:48:17,860 What's that file operations? 1217 00:48:18,260 --> 00:48:19,740 That's in user memory, okay? 1218 00:48:20,780 --> 00:48:21,640 That address. 1219 00:48:21,800 --> 00:48:23,540 That address is an ASCII string. 1220 00:48:23,860 --> 00:48:26,180 We have now injected stuff into the kernel. 1221 00:48:26,420 --> 00:48:26,980 Okay? 1222 00:48:28,780 --> 00:48:29,760 And, uh... 1223 00:48:29,760 --> 00:48:31,520 Let's finish it off here. 1224 00:48:32,940 --> 00:48:33,500 Continue. 1225 00:48:42,140 --> 00:48:42,740 Yeah, well... 1226 00:48:42,740 --> 00:48:43,540 That's what we get, huh? 1227 00:48:45,760 --> 00:48:46,580 I have no idea... 1228 00:48:46,580 --> 00:48:46,620 Oh. 1229 00:48:53,240 --> 00:48:53,640 That's it. 1230 00:49:03,240 --> 00:49:03,540 Um... 1231 00:49:04,860 --> 00:49:05,820 What's the conclusion? 1232 00:49:06,140 --> 00:49:07,520 The conclusion is 1233 00:49:07,860 --> 00:49:09,520 things that are hard to exploit 1234 00:49:10,060 --> 00:49:11,580 can be made easier 1235 00:49:11,580 --> 00:49:13,740 by thinking about controlling 1236 00:49:13,740 --> 00:49:14,500 your environment. 1237 00:49:17,580 --> 00:49:19,940 If we think carefully about control, 1238 00:49:20,040 --> 00:49:21,440 that's what all of this is about, 1239 00:49:21,560 --> 00:49:22,760 controlling execution, 1240 00:49:23,140 --> 00:49:26,040 if we think about it in terms of attacker-controlled 1241 00:49:26,040 --> 00:49:26,440 length, 1242 00:49:27,260 --> 00:49:28,820 attacker-controlled contents, 1243 00:49:29,160 --> 00:49:30,780 attacker-controlled target, 1244 00:49:30,780 --> 00:49:32,720 these three things. 1245 00:49:34,560 --> 00:49:36,060 Just because it's not easy, 1246 00:49:36,180 --> 00:49:37,420 that doesn't mean that it's impossible. 1247 00:49:37,800 --> 00:49:37,840 Okay? 1248 00:49:38,380 --> 00:49:40,920 Kind of in this whole thing here, 1249 00:49:41,060 --> 00:49:42,760 we've conjured the world 1250 00:49:42,760 --> 00:49:44,320 to be the way we want it to be. 1251 00:49:44,860 --> 00:49:46,280 This isn't trivial to do. 1252 00:49:46,580 --> 00:49:47,060 Okay? 1253 00:49:47,300 --> 00:49:49,600 It requires kind of an intimate understanding 1254 00:49:49,600 --> 00:49:50,300 of the kernel, 1255 00:49:50,460 --> 00:49:53,300 but this isn't something that's impossible to do. 1256 00:49:53,920 --> 00:49:56,040 If we kind of sit down with a book 1257 00:49:56,580 --> 00:49:57,500 understanding the Linux kernel, 1258 00:49:57,620 --> 00:50:00,120 if we take a problem-focused approach 1259 00:50:00,780 --> 00:50:01,780 and solve, 1260 00:50:02,920 --> 00:50:04,060 then we can do it. 1261 00:50:04,880 --> 00:50:06,580 There's another little conclusion here, 1262 00:50:06,720 --> 00:50:08,820 and I guess this kind of 1263 00:50:08,820 --> 00:50:10,300 brings us back full circle here. 1264 00:50:11,380 --> 00:50:12,400 Dear phone vendors, 1265 00:50:13,080 --> 00:50:14,240 we will win. 1266 00:50:15,160 --> 00:50:16,720 We have physical access. 1267 00:50:17,160 --> 00:50:19,000 Root on these phones will be ours. 1268 00:50:20,100 --> 00:50:20,700 Please, 1269 00:50:21,500 --> 00:50:23,100 stop your crusade 1270 00:50:23,100 --> 00:50:24,480 from keeping me 1271 00:50:25,100 --> 00:50:26,760 that's keeping me from using 1272 00:50:26,760 --> 00:50:27,660 my own phone. 1273 00:50:34,240 --> 00:50:36,560 Thank you. 1274 00:50:36,620 --> 00:50:37,080 Thank you. 1275 00:50:37,300 --> 00:50:37,840 Thank you. 1276 00:50:37,840 --> 00:50:38,040 Any questions? 1277 00:50:41,980 --> 00:50:43,380 . 1278 00:50:45,940 --> 00:50:47,340 . 1279 00:50:47,340 --> 00:50:47,420 . 1280 00:50:47,420 --> 00:50:47,480 . 1281 00:50:47,480 --> 00:50:48,040 . 1282 00:50:48,420 --> 00:50:49,120 . 1283 00:50:54,640 --> 00:50:55,340 . 1284 00:50:55,340 --> 00:50:56,800 . 1285 00:51:01,320 --> 00:51:02,180 . 1286 00:51:07,140 --> 00:51:08,000 . 1287 00:51:08,000 --> 00:51:09,120 . 1288 00:51:09,120 --> 00:51:09,220 . 1289 00:51:09,220 --> 00:51:09,960 . 1290 00:51:09,960 --> 00:51:10,500 . 1291 00:51:10,500 --> 00:51:10,600 . 1292 00:51:10,600 --> 00:51:10,860 . 1293 00:51:11,960 --> 00:51:12,820 . 1294 00:51:12,820 --> 00:51:12,920 . 1295 00:51:12,920 --> 00:51:13,240 . 1296 00:51:13,240 --> 00:51:13,540 . 1297 00:51:30,780 --> 00:51:32,460 . 1298 00:51:32,460 --> 00:51:32,620 . 1299 00:51:32,620 --> 00:51:35,320 . 1300 00:51:35,320 --> 00:51:36,220 . 1301 00:51:38,140 --> 00:51:39,540 . 1302 00:51:39,540 --> 00:51:39,640 . 1303 00:51:39,640 --> 00:51:39,680 . 1304 00:51:39,680 --> 00:51:39,700 . 1305 00:51:39,700 --> 00:51:41,140 . 1306 00:51:41,140 --> 00:51:41,240 . 1307 00:51:41,240 --> 00:51:42,820 . 1308 00:52:00,780 --> 00:52:01,120 . 1309 00:52:01,800 --> 00:52:02,240 . 1310 00:52:02,240 --> 00:52:02,340 . 1311 00:52:02,340 --> 00:52:02,380 . 1312 00:52:02,380 --> 00:52:02,800 . 1313 00:52:02,800 --> 00:52:03,520 . 1314 00:52:03,520 --> 00:52:03,560 . 1315 00:52:03,560 --> 00:52:04,180 . 1316 00:52:04,180 --> 00:52:04,280 . 1317 00:52:04,280 --> 00:52:04,340 . 1318 00:52:04,340 --> 00:52:04,620 . 1319 00:52:05,540 --> 00:52:06,100 . 1320 00:52:06,100 --> 00:52:07,220 . 1321 00:52:07,220 --> 00:52:07,320 . 1322 00:52:07,320 --> 00:52:07,420 . 1323 00:52:07,420 --> 00:52:07,440 . 1324 00:52:08,320 --> 00:52:08,880 . 1325 00:52:08,880 --> 00:52:08,940 . 1326 00:52:09,920 --> 00:52:10,480 . 1327 00:52:10,480 --> 00:52:12,280 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .