1 00:00:00,000 --> 00:00:02,300 Thanks, everybody, for coming, despite the late hour. 2 00:00:02,880 --> 00:00:04,760 This is Owned Over Amateur Radio, 3 00:00:04,960 --> 00:00:07,000 and we're going to be talking about remote kernel exploitation. 4 00:00:09,100 --> 00:00:10,200 First, a little bit about me. 5 00:00:10,360 --> 00:00:11,160 My name's Dan. 6 00:00:11,360 --> 00:00:13,580 I am a security consultant at VSR in Boston, 7 00:00:14,220 --> 00:00:16,260 mostly doing app and network pen testing, 8 00:00:16,420 --> 00:00:17,480 code review, that sort of thing. 9 00:00:18,220 --> 00:00:19,400 I've published a few bugs. 10 00:00:20,160 --> 00:00:22,580 Mostly, I focus lately on the Linux kernel, 11 00:00:22,700 --> 00:00:25,720 and especially on Linux kernel exploitation and mitigation. 12 00:00:27,820 --> 00:00:29,100 So what are we going to talk about today? 13 00:00:29,560 --> 00:00:31,960 First, I was going to provide some motivation 14 00:00:31,960 --> 00:00:34,180 on why I wanted to give this talk 15 00:00:34,180 --> 00:00:36,080 and what I hope you guys will get out of it. 16 00:00:36,400 --> 00:00:38,400 And next, we'll just dive right into 17 00:00:38,400 --> 00:00:39,820 some of the technical details of 18 00:00:39,820 --> 00:00:41,640 what are some of the challenges associated 19 00:00:41,640 --> 00:00:44,660 with developing fully working remote kernel exploits. 20 00:00:45,360 --> 00:00:48,500 Next, we'll take a look at what some of the past work has been 21 00:00:48,500 --> 00:00:49,800 in remote kernel exploitation 22 00:00:50,220 --> 00:00:51,720 and try to draw some trends there 23 00:00:51,720 --> 00:00:54,700 and look at areas that haven't been covered as much. 24 00:00:55,260 --> 00:00:56,800 And then we'll get into the body of the talk, 25 00:00:56,900 --> 00:00:58,460 which is sort of a case study 26 00:00:58,460 --> 00:00:59,700 of an exploit that I wrote 27 00:00:59,700 --> 00:01:01,640 for a remote stack overflow 28 00:01:01,640 --> 00:01:02,980 in the Linux kernel's implementation 29 00:01:02,980 --> 00:01:04,740 of the ROSE amateur radio protocol. 30 00:01:05,560 --> 00:01:07,860 And this part of the talk will be in sort of two phases. 31 00:01:08,160 --> 00:01:09,220 In the first phase, 32 00:01:09,280 --> 00:01:11,200 I'll sort of explain exploitation of the vulnerability. 33 00:01:11,580 --> 00:01:12,840 And the second phase, 34 00:01:12,940 --> 00:01:15,780 I'll explain the details of the kernel backdoor 35 00:01:15,780 --> 00:01:18,020 that I installed during the exploitation phase. 36 00:01:18,520 --> 00:01:19,980 And then finally, we'll wrap up 37 00:01:19,980 --> 00:01:21,340 taking a look at some future work. 38 00:01:24,660 --> 00:01:27,040 I think remote kernel exploits 39 00:01:27,040 --> 00:01:27,800 sort of speak for themselves 40 00:01:27,800 --> 00:01:29,000 as to why they're useful. 41 00:01:29,160 --> 00:01:30,820 It's sort of this keys to the kingdom concept 42 00:01:30,820 --> 00:01:32,820 where you have instant remote root access 43 00:01:32,820 --> 00:01:35,100 to a machine that you previously had no interaction with. 44 00:01:35,640 --> 00:01:37,320 But especially when you compare them 45 00:01:37,320 --> 00:01:39,600 with the challenges that are facing you 46 00:01:39,600 --> 00:01:41,260 when you're trying to exploit client-side systems 47 00:01:41,260 --> 00:01:42,720 like browsers, for example. 48 00:01:42,940 --> 00:01:44,960 You know, if you have a browser exploit, 49 00:01:45,200 --> 00:01:47,560 you're frequently facing exploit mitigation technologies 50 00:01:47,560 --> 00:01:49,540 like ASLR and NX or DEP. 51 00:01:50,720 --> 00:01:53,060 And sometimes those require the existence 52 00:01:53,060 --> 00:01:55,080 of a second vulnerability to bypass. 53 00:01:55,500 --> 00:01:56,980 And at that point, you may be running 54 00:01:56,980 --> 00:01:59,680 inside a browser sandbox, for example, 55 00:01:59,700 --> 00:02:04,580 as IE9 and Chrome and most recently Safari now provide. 56 00:02:04,820 --> 00:02:06,460 So if you can leverage a third vulnerability 57 00:02:06,460 --> 00:02:07,740 to escape that sandbox, 58 00:02:07,980 --> 00:02:09,900 you may need to escalate privileges 59 00:02:09,900 --> 00:02:10,920 using a fourth vulnerability 60 00:02:10,920 --> 00:02:12,660 because you're running as an unprivileged user. 61 00:02:13,020 --> 00:02:15,600 And that seems like a lot of pain, 62 00:02:15,820 --> 00:02:17,660 so I prefer to skip all that. 63 00:02:20,220 --> 00:02:22,120 What I hope you guys will get out of this talk, 64 00:02:22,260 --> 00:02:23,880 this is not actually an amateur radio talk 65 00:02:23,880 --> 00:02:25,440 despite the really misleading title. 66 00:02:25,840 --> 00:02:26,780 We're going to talk about 67 00:02:26,780 --> 00:02:28,240 enough of amateur radio to understand 68 00:02:28,240 --> 00:02:29,340 the vulnerability that I'm using. 69 00:02:29,880 --> 00:02:31,960 But really, this is sort of a vehicle for me 70 00:02:31,960 --> 00:02:34,720 to talk about exploit development methodology. 71 00:02:35,120 --> 00:02:37,220 So hopefully, if you guys don't have any experience 72 00:02:37,220 --> 00:02:39,440 writing exploits, you'll hopefully get a sense of 73 00:02:39,880 --> 00:02:42,120 what are some of the building blocks that we can use 74 00:02:42,120 --> 00:02:43,720 to exploit these kinds of vulnerabilities? 75 00:02:43,920 --> 00:02:45,700 What are some of the steps that we need to go through? 76 00:02:48,200 --> 00:02:50,620 And I'll also be showing off a bunch of sort of 77 00:02:50,620 --> 00:02:53,700 exploitation techniques, which I think is far more 78 00:02:53,700 --> 00:02:56,500 interesting and useful than doing a study of an individual bug, 79 00:02:56,500 --> 00:02:58,180 because bugs come and go. 80 00:02:58,280 --> 00:02:59,620 They get fixed all the time. 81 00:03:00,320 --> 00:03:02,800 But exploit techniques and learning how to mitigate them 82 00:03:02,800 --> 00:03:05,900 are really defined lots of, you know, lots of bugs. 83 00:03:07,000 --> 00:03:09,300 And sort of the whole point of this is to take a look 84 00:03:09,300 --> 00:03:11,120 at this exploit and identify what the weak links 85 00:03:11,120 --> 00:03:13,120 in the chain are, what are the parts of the exploit 86 00:03:13,120 --> 00:03:16,900 that aren't really done so well, so that we can identify 87 00:03:16,900 --> 00:03:18,800 what are the easiest ways to protect against 88 00:03:18,800 --> 00:03:19,820 these kinds of exploits. 89 00:03:22,140 --> 00:03:24,200 So despite their advantages, remote kernel exploits 90 00:03:24,200 --> 00:03:25,380 are not trivial, right? 91 00:03:26,660 --> 00:03:29,480 And I've sort of identified three key points as to why 92 00:03:29,480 --> 00:03:32,800 there are some extra challenges associated with these 93 00:03:32,800 --> 00:03:33,600 kinds of exploits. 94 00:03:34,160 --> 00:03:36,620 The first of these is that the environment that you're 95 00:03:36,620 --> 00:03:37,920 working in is incredibly fragile. 96 00:03:38,680 --> 00:03:40,900 If you're dealing with a remote userland exploit, 97 00:03:41,100 --> 00:03:43,860 for example, like a web server or an FTP server or something 98 00:03:43,860 --> 00:03:47,080 like that, frequently if you fail, if you're dealing with 99 00:03:47,080 --> 00:03:49,820 some sort of memory corruption vulnerability and you 100 00:03:49,820 --> 00:03:52,720 miscalculate some offsets or your exploit fails for some 101 00:03:52,720 --> 00:03:54,960 other reason, frequently you'll crash the application 102 00:03:54,960 --> 00:03:55,540 or service. 103 00:03:56,500 --> 00:03:58,500 In some cases, it needs to be restarted manually. 104 00:03:58,680 --> 00:03:59,980 In others, it'll be restarted automatically. 105 00:04:00,620 --> 00:04:03,100 If you're dealing with a service that actually forks 106 00:04:03,100 --> 00:04:05,720 child processes for each connection, you may not even 107 00:04:05,720 --> 00:04:06,720 crash the service itself. 108 00:04:06,900 --> 00:04:08,940 You'll just crash the child process, and you essentially 109 00:04:08,940 --> 00:04:12,920 have very minimal consequences for failure and can continue 110 00:04:12,920 --> 00:04:14,260 to try to exploit it. 111 00:04:14,900 --> 00:04:17,520 In contrast, if you fail at a remote kernel exploit, 112 00:04:17,820 --> 00:04:20,120 in nearly every case, the kernel's gonna panic 113 00:04:20,120 --> 00:04:21,940 and the box will fall over. 114 00:04:22,280 --> 00:04:24,940 And not only will you have lost your chance to exploit 115 00:04:24,940 --> 00:04:25,380 that machine. 116 00:04:26,500 --> 00:04:29,920 You've lost any chance of doing so with any sense of stealth. 117 00:04:30,840 --> 00:04:33,580 It's a little bit noisy to crash an entire machine. 118 00:04:35,160 --> 00:04:40,060 The second main obstacle, in my opinion, for these kinds 119 00:04:40,060 --> 00:04:42,100 of exploits is that you have very little control over 120 00:04:42,100 --> 00:04:43,920 the environment that you're trying to exploit. 121 00:04:45,240 --> 00:04:47,600 And this is sort of a shared property of all remote 122 00:04:47,600 --> 00:04:48,420 exploits. 123 00:04:48,660 --> 00:04:50,720 If you're dealing with a local kernel exploit where you 124 00:04:50,720 --> 00:04:53,360 have an unprivileged account on the machine, you have a 125 00:04:53,360 --> 00:04:56,200 lot of sort of exploit primitives, sort of building blocks 126 00:04:56,200 --> 00:04:58,540 that you can use to make writing exploits easier. 127 00:04:59,140 --> 00:05:02,700 For example, it's very easy to trigger the allocation of data 128 00:05:02,700 --> 00:05:03,940 structures on the kernel heap. 129 00:05:04,080 --> 00:05:07,920 You can open files or sockets or create shared memory 130 00:05:07,920 --> 00:05:08,340 segments. 131 00:05:08,700 --> 00:05:12,460 And all of these resources have structures on the kernel heap. 132 00:05:12,600 --> 00:05:15,380 And you can sort of trigger these allocations in such a way 133 00:05:15,380 --> 00:05:17,280 as to massage the heap into a state that's 134 00:05:17,280 --> 00:05:18,220 conducive to exploitation. 135 00:05:19,400 --> 00:05:21,680 Likewise, you can trigger the calling of function pointers 136 00:05:21,680 --> 00:05:24,440 in the kernel by performing operations on these structures 137 00:05:24,440 --> 00:05:25,160 that you've allocated. 138 00:05:26,200 --> 00:05:28,760 And finally, there's this huge silver platter of information 139 00:05:28,760 --> 00:05:31,860 the kernel gives you, if you're a local user, through 140 00:05:31,860 --> 00:05:34,700 interfaces like on Linux, the proc file system, that will 141 00:05:34,700 --> 00:05:37,300 really help you find out where things are in kernel memory 142 00:05:37,300 --> 00:05:38,320 and help target your attacks. 143 00:05:38,920 --> 00:05:40,700 If you're dealing with a remote kernel exploit, you 144 00:05:40,700 --> 00:05:42,780 don't actually have any of those capabilities right away. 145 00:05:43,200 --> 00:05:45,740 But we may see how you can sort of build them up from 146 00:05:45,740 --> 00:05:47,480 other exploitation primitives you might have. 147 00:05:49,180 --> 00:05:51,740 And the final challenge, in my opinion, with writing these 148 00:05:51,740 --> 00:05:55,000 exploits is they frequently occur in what's known as 149 00:05:55,000 --> 00:05:55,620 interrupt context. 150 00:05:55,620 --> 00:06:01,120 So, you know, 10-second operating system 101, when a 151 00:06:01,120 --> 00:06:05,180 process makes a system call, it is executing kernel code in 152 00:06:05,180 --> 00:06:08,420 what's known as process context, where the threat of 153 00:06:08,420 --> 00:06:11,660 execution has a userland application, a process, 154 00:06:11,760 --> 00:06:12,780 associated with it. 155 00:06:13,420 --> 00:06:15,980 But in contrast, when you're dealing with asynchronous 156 00:06:16,740 --> 00:06:19,680 events, like receiving networking data, the kernel's 157 00:06:19,680 --> 00:06:21,020 running in what's known as interrupt context. 158 00:06:21,200 --> 00:06:24,360 It doesn't have a process associated with that threat of 159 00:06:24,360 --> 00:06:24,660 execution. 160 00:06:25,620 --> 00:06:28,840 And this is a very sort of delicate and difficult context 161 00:06:28,840 --> 00:06:32,680 to exploit, because the end goal here is usually to execute 162 00:06:32,680 --> 00:06:35,240 code in userland, because, you know, a shell is a really 163 00:06:35,240 --> 00:06:37,220 nice, convenient way to interact with the system, and 164 00:06:37,220 --> 00:06:38,240 that's sort of what everybody wants. 165 00:06:38,580 --> 00:06:42,400 So the challenge is, how do we get from this sort of hostile 166 00:06:42,400 --> 00:06:46,300 interrupt context environment to executing code in userland? 167 00:06:47,800 --> 00:06:50,600 And the answer is, we need to find a way to transition from 168 00:06:51,280 --> 00:06:54,460 interrupt context to kernel mode process context, in which 169 00:06:54,460 --> 00:06:55,600 we're still running kernel code. 170 00:06:55,620 --> 00:06:58,420 But we now have a process associated with us, and then 171 00:06:58,420 --> 00:07:01,680 finally from there to actually executing code in userland. 172 00:07:04,060 --> 00:07:06,800 So before I get into what I did, I thought it would be 173 00:07:06,800 --> 00:07:08,600 prudent to talk about what's been done before. 174 00:07:09,360 --> 00:07:13,460 So I studied, I looked up and researched every remote kernel 175 00:07:13,460 --> 00:07:18,080 exploit I could find anywhere, and I identified 18 exploits 176 00:07:18,080 --> 00:07:21,200 that have been talked about or published for 16 unique 177 00:07:21,200 --> 00:07:21,600 vulnerabilities. 178 00:07:22,020 --> 00:07:23,400 These were written by 19 people. 179 00:07:23,680 --> 00:07:25,480 Nine of them have full public source code. 180 00:07:25,620 --> 00:07:26,480 Many of them metasploit modules. 181 00:07:27,300 --> 00:07:30,140 Three of them have sort of partial or proof of concept 182 00:07:30,140 --> 00:07:33,460 source code, and the rest were sort of discussed in detail at 183 00:07:33,460 --> 00:07:34,460 conferences without code. 184 00:07:35,060 --> 00:07:37,540 And these exploits cover a wide range of platforms. 185 00:07:37,940 --> 00:07:40,960 Solaris and OSX have not had any weaponized remote kernel 186 00:07:41,420 --> 00:07:41,640 exploits. 187 00:07:42,240 --> 00:07:44,700 That's sort of future work, if you're into that sort of thing. 188 00:07:45,640 --> 00:07:47,840 Breaking these down by what operating systems they affect, 189 00:07:48,760 --> 00:07:51,000 half of the 16 vulnerabilities were in Windows. 190 00:07:51,420 --> 00:07:55,140 Only four of those were actually in the Windows core components. 191 00:07:55,960 --> 00:07:59,060 Three of them were in various wireless drivers, and one was in 192 00:07:59,060 --> 00:07:59,920 a semantic firewall. 193 00:08:00,980 --> 00:08:04,020 Three in NetWare, which I don't think anyone still uses 194 00:08:04,020 --> 00:08:04,400 NetWare. 195 00:08:04,940 --> 00:08:09,100 Three in various BSDs, and two in Linux, one of which was in a 196 00:08:09,100 --> 00:08:10,020 third-party driver. 197 00:08:11,240 --> 00:08:14,640 And breaking these down by vulnerability class as to what 198 00:08:15,280 --> 00:08:18,600 vulnerability was exploited, a full three-quarters of these, 199 00:08:18,680 --> 00:08:21,440 12 of the 16, were typical stack overflows. 200 00:08:22,760 --> 00:08:25,380 And I think this is probably because these vulnerability 201 00:08:25,620 --> 00:08:27,180 vulnerabilities are incredibly conducive to exploitation. 202 00:08:27,560 --> 00:08:28,760 They're very well understood. 203 00:08:28,980 --> 00:08:30,820 The steps of exploiting them are known. 204 00:08:31,920 --> 00:08:34,260 Three of these vulnerabilities were heap overflows, which are 205 00:08:34,260 --> 00:08:35,800 frequently much more difficult. 206 00:08:36,060 --> 00:08:39,120 And then one of these Windows SMB issue was actually an array 207 00:08:39,120 --> 00:08:39,760 indexing issue. 208 00:08:41,480 --> 00:08:43,520 I'm not sure there's actually enough data to draw meaningful 209 00:08:43,520 --> 00:08:47,860 conclusions about trends here, but 2007 was a busy year for 210 00:08:47,860 --> 00:08:48,400 kernel exploitation. 211 00:08:51,420 --> 00:08:55,260 So just a brief walkthrough of some of what are, in my opinion, 212 00:08:55,260 --> 00:08:57,780 the highlights of past work on remote kernel exploits. 213 00:08:58,480 --> 00:09:00,940 Barnaby Jack did the first work that I'm aware of. 214 00:09:01,420 --> 00:09:03,600 He started in 2004, 2005. 215 00:09:04,420 --> 00:09:08,480 And he exploited a remote stack overflow in a semantic firewall 216 00:09:08,480 --> 00:09:09,240 application. 217 00:09:09,640 --> 00:09:12,820 And he demonstrated a lot of really cool things, especially 218 00:09:13,120 --> 00:09:16,900 detailed shellcode examples for how to transition from running in 219 00:09:16,900 --> 00:09:18,780 the kernel to actually executing user-land code. 220 00:09:19,060 --> 00:09:23,820 And he also demonstrated a kernel backdoor that in many ways was 221 00:09:23,820 --> 00:09:25,080 sort of an inspiration for 222 00:09:25,260 --> 00:09:26,380 the one I ended up implementing. 223 00:09:28,040 --> 00:09:33,340 Next in 2006, Sinan Aren from Immunity, they announced they 224 00:09:33,340 --> 00:09:36,220 had Greenapple, which was a remote kernel exploit 225 00:09:36,220 --> 00:09:36,780 for Windows. 226 00:09:37,840 --> 00:09:41,040 And that's sort of the first commercially available remote 227 00:09:41,040 --> 00:09:42,200 kernel exploit that I'm aware of. 228 00:09:43,900 --> 00:09:46,820 Also, in 2006, H.D. Moore, Matt Miller, and Johnny Cash 229 00:09:46,820 --> 00:09:49,680 published three remote kernel exploits that were allied to 230 00:09:49,680 --> 00:09:51,740 Metasploit in various WiFi drivers. 231 00:09:52,800 --> 00:09:55,240 2007, there was an open BSD IPv6 one. 232 00:09:55,240 --> 00:09:59,960 vulnerability, which was really awesome. That was the first public remote kernel heap overflow 233 00:09:59,960 --> 00:10:04,560 that I'm aware of. They did some nice work on that. And they also bypassed userland NX 234 00:10:04,560 --> 00:10:13,040 protection, as in non-executable stack heap, etc. Final highlights. Immunity has a canvas 235 00:10:13,040 --> 00:10:20,780 exploit for MS08-2001, which is a Windows IGMPv3 vulnerability. And that was a really 236 00:10:20,780 --> 00:10:25,360 difficult to exploit Windows kernel pool overflow that people were questioning whether it was 237 00:10:25,360 --> 00:10:29,780 exploitable before they announced they had a reliable exploit. And then finally, in 2009, 238 00:10:30,560 --> 00:10:36,580 Scrakiu published an exploit for a Linux kernel vulnerability in the SCTP protocol, which is a 239 00:10:36,580 --> 00:10:43,100 remote Linux heap overflow. And I think one of the great contributions from this exploit is he 240 00:10:43,100 --> 00:10:50,360 introduced a really neat trick that leverages a 64-bit specific page mapping to easily 241 00:10:50,360 --> 00:10:50,760 translate a Linux kernel vulnerability into a Linux kernel vulnerability. And that's 242 00:10:50,780 --> 00:10:56,920 a transition from interrupt context to executing code directly in userland. Just sort of drawing 243 00:10:56,920 --> 00:11:02,640 some trends from all this work I did reading up on what's been done before. You know, three 244 00:11:02,640 --> 00:11:06,780 quarters of these issues were stack overflows, but none of these actually had to contend with 245 00:11:06,780 --> 00:11:13,080 having non-executable stacks in the kernel itself. Because the feature wasn't introduced at that 246 00:11:13,080 --> 00:11:19,820 point. So my exploit will try to address that. Next, none of the issues, neither of the two issues 247 00:11:19,820 --> 00:11:20,760 on Linux actually have a stack overflow. So I'm going to go ahead and talk a little bit about the 248 00:11:20,760 --> 00:11:20,920 stack overflows. And I think one of the things that's really interesting about the stack overflows 249 00:11:20,920 --> 00:11:24,780 is that they actually were stack overflows in interrupt context, which is sort of a particularly 250 00:11:24,780 --> 00:11:28,160 difficult context to exploit things in, because you need to do a bunch of cleanup. 251 00:11:29,540 --> 00:11:34,900 Scrakiu and Twiz published an article in Frac 64 called Notes on Kernel Exploitation, or something 252 00:11:34,900 --> 00:11:41,180 of that effect. And they sort of described the steps you need to go through to do this, but it was 253 00:11:41,180 --> 00:11:46,040 for a vulnerability introduced for the sake of demonstration. And I wanted to provide a real-life 254 00:11:46,040 --> 00:11:50,740 example. And the last observation is that six of the 18 apps that were used in the stack overflows 255 00:11:50,740 --> 00:11:56,940 were for issues in 802.11 code. So I think wireless drivers could probably use some improvement. 256 00:11:58,320 --> 00:12:05,140 And now we've gotten to the good stuff. Before we start talking about how to write this exploit or 257 00:12:05,140 --> 00:12:12,760 what the bug is, the target system that I'm going after, I'm using a 32-bit x86 physical address 258 00:12:12,760 --> 00:12:19,140 extension kernel. And the PAE component is significant because it means the kernel now has NX support. As 259 00:12:19,140 --> 00:12:20,720 in, the kernel stacks, and kernel stack, and kernel stack, and kernel stack, and kernel stack, and the 260 00:12:20,720 --> 00:12:26,720 kernel heap, kernel data are all now non-executable. So we can't just execute code on the kernel stack 261 00:12:26,720 --> 00:12:33,060 immediately without doing something first. They also, you know, these kernels have userland NX 262 00:12:33,060 --> 00:12:37,940 protection as well. So if we're going to somehow introduce code into a user process, we also need to 263 00:12:37,940 --> 00:12:42,240 do so in a way that honors page permissions. We can't execute code on a userland stack without 264 00:12:42,240 --> 00:12:47,740 modifying its permissions. And then finally, because we're on a 32-bit machine, we can't leverage 265 00:12:48,300 --> 00:12:50,620 Scrakiu's trick that was specific to AMD. 266 00:12:50,720 --> 00:12:54,640 So I'm going to use a T-64 to make that transition from interrupt context to userland. 267 00:12:56,310 --> 00:13:03,840 For actually doing testing, I just had two VMs. I chose Ubuntu 10.04. The attacker is just a desktop 268 00:13:03,840 --> 00:13:09,140 machine. The victim is Ubuntu server because that's a PAE build. For debugging, I just use KGDB. 269 00:13:09,520 --> 00:13:15,060 And for the actual networking, I was not sitting in my apartment doing, like, with radio equipment 270 00:13:15,060 --> 00:13:20,580 driving my girlfriend crazy. I was using BPQ, which is an implementation of AX25 amateur 271 00:13:20,720 --> 00:13:26,060 radio over Ethernet. So my VMs can talk to each other without me needing to buy radio hardware or get a 272 00:13:26,060 --> 00:13:32,480 license. And just because of the nature of the exploit, it's written entirely in x86 assembly, except 273 00:13:32,480 --> 00:13:38,780 for the code that sort of ties it all together and sends it over the wire. So this is the advisory 274 00:13:38,780 --> 00:13:43,040 that Debian put out for the vulnerability that I'm going to be exploiting. Dan Rosenberg, first, 275 00:13:43,120 --> 00:13:48,180 they spelled my name wrong. They spelled it right in actually five other issues in the same 276 00:13:48,180 --> 00:13:50,700 advisory and got it wrong in this one, which is some sort of a mistake. So I'm going to go ahead and 277 00:13:50,720 --> 00:13:55,980 assign. Reported two issues in the Linux implementation of the amateur radio x25 PLP protocol. 278 00:13:56,280 --> 00:14:01,400 A remote user can cause a denial of service by providing specially crafted facilities fields. 279 00:14:01,680 --> 00:14:09,420 This is a pretty interesting denial of service. So just a brief overview of the protocol we're 280 00:14:09,420 --> 00:14:13,380 going to be exploiting. Just enough detail to talk about so you understand the vulnerability that 281 00:14:13,380 --> 00:14:20,220 I'll be taking advantage of. ROSE is a fairly rarely used amateur radio protocol. And it's a network 282 00:14:20,220 --> 00:14:25,620 layer that sits on top of x25, which is sort of a more commonly used packet radio protocol. So in 283 00:14:25,620 --> 00:14:32,780 addition to 7 byte x25 addresses, ROSE nodes have 10 digit numeric addresses to identify them. And 284 00:14:32,780 --> 00:14:37,500 it supports only static routing and it does so using a Digipeter mechanism where a host can 285 00:14:37,500 --> 00:14:42,520 essentially say, all right, I'll accept packets from this x25 call sign and forward them along to 286 00:14:42,520 --> 00:14:50,200 this one. So when two hosts issue a connection to each other, they're going to have to do a 287 00:14:50,220 --> 00:14:53,400 call sign and forward to each other using ROSE. They exchange what are known as facilities. And 288 00:14:53,400 --> 00:14:59,120 this is sort of just a list of supported features for that connection. And one of these facilities, 289 00:14:59,340 --> 00:15:03,920 FAC National Digis, allows one host to give the other host a list of Digipeters just so it can 290 00:15:03,920 --> 00:15:09,120 figure out its routing stuff. And in the Linux kernel implementation, I noticed that when they 291 00:15:09,120 --> 00:15:13,760 went to parse this particular field in the ROSE frame, they read this length value directly from 292 00:15:13,760 --> 00:15:19,220 the frame and copied all this Digipeter data without any bounds checking into a statically sized 293 00:15:20,220 --> 00:15:25,600 stack. And this is the sad code. You can see at the top line, they're just reading that length 294 00:15:25,600 --> 00:15:30,980 value right out of the frame data, using it as an upper bound for this loop that then copies data 295 00:15:30,980 --> 00:15:37,560 in, in x25 address size of chunks, which are 7 bytes, into either the destination or source 296 00:15:37,560 --> 00:15:44,360 array. And those arrays are living on the stack. And you may also notice that there's a 297 00:15:44,360 --> 00:15:49,840 constraint here. The 7th byte of every x25 address is actually anded with a flag that 298 00:15:49,840 --> 00:15:55,480 indicates whether it's a source or destination Digipeter. And that means in our payload, we need 299 00:15:55,480 --> 00:16:00,660 to obey that constraint. Every 7th byte needs to be consistently greater or less than 0x80. 300 00:16:00,940 --> 00:16:05,780 Otherwise, you know, one 7-byte chunk might be copied into one array, and then the next one might 301 00:16:05,780 --> 00:16:10,720 be copied into a different array, and it would be very difficult to handle, and it would be a pain. 302 00:16:10,980 --> 00:16:17,240 So this sort of just required me to go through the exploit and manually just check that this 303 00:16:17,240 --> 00:16:18,280 constraint was satisfied. 304 00:16:19,920 --> 00:16:24,720 So now we've got a plan of attack. Um, we've got a vulnerability, and we, we want to actually, you 305 00:16:24,720 --> 00:16:29,020 know, exploit it. And the first step is to actually gain control of the instruction pointer, so we 306 00:16:29,020 --> 00:16:33,540 can control what the kernel's gonna do. Um, and from that point, we need to actually start 307 00:16:33,540 --> 00:16:38,940 executing code. Uh, next, I decided that my exploit would install a remotely triggerable kernel 308 00:16:38,940 --> 00:16:44,700 backdoor, because that sounded like fun. And finally, we will have to do some cleanup to, to make 309 00:16:44,700 --> 00:16:49,780 everything keep running. So first, triggering the bug was actually really the easy part. I 310 00:16:49,840 --> 00:16:56,140 took 10 minutes after I found it. Um, you just, what I did was essentially cannibalize the, the 311 00:16:56,140 --> 00:17:01,120 ROSE kernel module that already existed, so that it, whenever I made a connection to someone, it 312 00:17:01,120 --> 00:17:06,040 would send out my evil ROSE frame instead of a normal one. Um, and this evil ROSE frame just had 313 00:17:06,040 --> 00:17:11,180 this particular facility field that was vulnerable, followed by a too-big length value, and 314 00:17:11,180 --> 00:17:15,040 then a bunch of no-op instructions just for the sake of testing to see if I could actually trigger 315 00:17:15,040 --> 00:17:19,660 it. Uh, this is what the frame looks like. You have your header, total facility's length, 316 00:17:19,840 --> 00:17:24,700 which didn't actually matter, um, a null byte, fact-national is the specific type of facility, 317 00:17:25,000 --> 00:17:29,840 fact-national-digis is the vulnerable facility itself, and then this length value, which we're 318 00:17:29,840 --> 00:17:34,340 setting to OXFF, which is 255, which will, is more than enough to cause the overflow, and 319 00:17:34,340 --> 00:17:38,700 then a bunch of 90s. And so you recompile your ROSE module, and then you make a connection to 320 00:17:38,700 --> 00:17:43,720 your vulnerable host, and it causes a stack overflow on the soft IRQ stack, which is an 321 00:17:43,720 --> 00:17:48,320 interrupt handler that's receiving this data. Um, you can see on the, in the debugger, you know, 322 00:17:48,340 --> 00:17:49,820 our host has, we've overwritten, we've overwritten, we've overwritten, we've overwritten the 323 00:17:49,840 --> 00:17:53,720 save-return address on the stack, and then when that vulnerable function returned, it 324 00:17:53,720 --> 00:17:59,600 returned to all 90s, which is the, the value that we put there. So now we control the 325 00:17:59,600 --> 00:18:06,680 instruction pointer. Um, as most people who've written serious exploits know, um, getting 326 00:18:06,680 --> 00:18:11,080 control of the instruction pointer and actually executing code can be separated by a lot of 327 00:18:11,080 --> 00:18:17,220 work. Um, traditionally, if it were like 1995, we would just sort of return into shellcode that 328 00:18:17,220 --> 00:18:20,720 was stored in our buffer that was copied onto a stack, and then we'd be running code, and that's 329 00:18:20,720 --> 00:18:24,960 all you need to do. Uh, the first problem is we don't actually know where the soft IRQ stack lives 330 00:18:24,960 --> 00:18:30,520 in memory, because it's allocated at runtime, and it's gonna be different on each boot. Um, that's 331 00:18:30,520 --> 00:18:34,460 pretty easily solvable. You just sort of return to this trampoline function that will do like a 332 00:18:34,460 --> 00:18:39,440 jump ESP and jump into the stack wherever it is. Um, the second problem, though, is that since 333 00:18:39,440 --> 00:18:44,400 we're running a PAE kernel, the soft IRQ stack on which we caused our overflow is non-executable 334 00:18:44,400 --> 00:18:46,980 memory. So if we try to return there, the kernel will just crash. 335 00:18:48,540 --> 00:18:55,280 And this means we need to employ return-oriented programming. Um, so the basic idea of 336 00:18:55,280 --> 00:19:00,720 return-oriented programming is, because we've caused our stack overflow, we now control the 337 00:19:00,720 --> 00:19:04,680 return address, where this function's going to go after it return- is finished doing whatever 338 00:19:04,680 --> 00:19:10,060 it's doing, and we control a bunch of data on the stack past that saved return address. And we 339 00:19:10,060 --> 00:19:15,220 also notice that every return instruction will direct execution to the address that's on the 340 00:19:15,220 --> 00:19:17,200 stack, and then increment the stack pointer to the address that's on the stack, and then 341 00:19:17,220 --> 00:19:20,400 increment the stack pointer to the next place. So using this, we can actually just chain together 342 00:19:20,400 --> 00:19:25,740 little pieces of code at known locations in the kernel, uh, to do essentially arbitrary computation. 343 00:19:26,500 --> 00:19:32,360 Um, I say at known locations because this actually does rely on the fact that, uh, you know where 344 00:19:32,360 --> 00:19:37,140 stuff is in memory. And this is a-a fairly reasonable assumption in the kernel world. Uh, if 345 00:19:37,140 --> 00:19:42,020 you're running a distribution kernel, like Ubuntu or Debian, Fedora, um, they're shipping binary 346 00:19:42,020 --> 00:19:48,320 kernels, which means everyone with the latest version of Ubuntu has the same- has the same kernel 347 00:19:48,320 --> 00:19:53,320 image in memory, in terms of the code. So it-it's fairly reasonable to assume that if you know 348 00:19:53,320 --> 00:19:58,080 something about your target, then you-you essentially know where-where in memory certain 349 00:19:58,080 --> 00:20:03,960 instructions live. And there-there's no sort of randomization of the kernel at all. Um, to-to 350 00:20:03,960 --> 00:20:07,940 make this a little bit better, you can actually choose these gadgets, these little pieces of code 351 00:20:07,940 --> 00:20:11,580 that you're executing in such a way that they're more likely to appear across multiple kernel 352 00:20:11,580 --> 00:20:11,940 builds. 353 00:20:13,400 --> 00:20:20,160 So now, actually, looking at some code, um, what our route payload actually-what we wanted to do is 354 00:20:20,160 --> 00:20:25,520 to actually make the stack that we overflowed executable so that we can run code on it. And the 355 00:20:25,520 --> 00:20:28,980 kernel has a really nice convenient function that'll take care of all the hard work for us, called 356 00:20:28,980 --> 00:20:33,820 setMemoryX. And setMemoryX just takes two arguments. The first one is an address that you want 357 00:20:33,820 --> 00:20:37,540 to mark executable, and the second one is the number of pages from that point that you want to 358 00:20:37,540 --> 00:20:43,560 mark. Um, so we're in the kernel, so the calling convention to functions actually has the first 359 00:20:43,560 --> 00:20:49,440 three arguments to the functions in registers. So we just need to keep that in mind. Um, so what 360 00:20:49,440 --> 00:20:54,340 the ROPS dub does is, first, we actually want to load the stack pointer, which points into the 361 00:20:54,340 --> 00:20:58,660 stack that we want to mark executable, into the EAX register, because that's the first argument 362 00:20:58,660 --> 00:21:03,840 register to this function. We'll actually, um, align it to a page boundary, because setMemoryX 363 00:21:03,840 --> 00:21:07,520 will-will cry a little bit if-if you don't, um, have a lot of time to do that. So, um, the 364 00:21:07,520 --> 00:21:12,680 thing is page-aligned. Um, then I just chose arbitrarily, let's mark four pages from that point, 365 00:21:13,220 --> 00:21:19,600 um, into our second argument register, which is EDX. Return into setMemoryX, which is just gonna 366 00:21:19,600 --> 00:21:24,180 mark the SoftRQ stack executable, and from that point we can just return into a jump ESP 367 00:21:24,180 --> 00:21:30,180 instruc-instruction, at which point execution will jump into the SoftRQ stack and start running 368 00:21:30,180 --> 00:21:37,500 our code. So at this point, we are running shell code on the SoftRQ stack in kernel mode. Great. 369 00:21:37,520 --> 00:21:44,120 Um, but we've got a problem. Um, the amount of data that we could have copied into our overflowed 370 00:21:44,120 --> 00:21:49,500 region is limited to 255 bytes, just by nature of the particular-particular bug that we're 371 00:21:49,500 --> 00:21:53,900 exploiting. And we've already used a whole bunch of that to get up to the-the saveReturn 372 00:21:53,900 --> 00:21:59,080 instruction. Um, we've used more for our route payload. So we're-we're running very low on space, 373 00:21:59,300 --> 00:22:04,900 and kernel payloads can be quite big, so we really need to overcome that space constraint. Um, 374 00:22:06,100 --> 00:22:07,500 but it's useful to keep that in mind. So, um, we've got a problem. Um, we've got a problem. Um, 375 00:22:07,520 --> 00:22:11,040 but it's useful to keep in mind that that's just the part of the packet that copied into the 376 00:22:11,040 --> 00:22:16,700 overflow region. We have this rows frame that we sent that can be thousands of bytes big, living 377 00:22:16,700 --> 00:22:23,540 somewhere on the kernel heap. Um, and I found experimentally that, um, one of the parent 378 00:22:23,540 --> 00:22:28,480 functions to the function that we caused an overflow in actually has a pointer to this-to this 379 00:22:28,480 --> 00:22:32,980 rows frame, the entire rows packet that we sent over. So what we can do is, now that we're 380 00:22:32,980 --> 00:22:37,300 executing code, all we-all we need to do is walk up the stack, say, is this a kernel pointer? 381 00:22:37,520 --> 00:22:42,780 Yes, no, just, uh, heuristically. And if it is, you can follow it and look around in memory, and 382 00:22:42,780 --> 00:22:47,300 we'll put a tag in our rows frame so that we can find it. Um, and then, you know, we'll-we'll 383 00:22:47,300 --> 00:22:51,620 eventually just find our rows frame on the kernel heap, we'll mark it executable just by calling 384 00:22:51,620 --> 00:22:58,020 setMemoryX and then jump into it. So now we've overcome our space constraint. Uh, we can 385 00:22:58,020 --> 00:23:04,420 execute arbitrary length payloads running in kernel mode right now. Um, and the goal here is I 386 00:23:04,420 --> 00:23:07,500 want to install a kernel backdoor in the ICMP handler, because, uh, I don't know if you've ever 387 00:23:07,520 --> 00:23:16,000 done this. It's-it's badass. Um, so just some-some data structures, uh, to sort of explain what I 388 00:23:16,000 --> 00:23:20,820 had to do here. It's not very complicated. There's this sort of global array at a known location, you 389 00:23:20,820 --> 00:23:25,300 know, because it's-it's in kernel data, um, called the inet protos array. And this just is an 390 00:23:25,300 --> 00:23:30,840 array of pointers to these net protocol structures. There's one for sort of each IP protocol, which 391 00:23:30,840 --> 00:23:37,500 is redundant. Um, like, IP proto-the-the-there's a TCP one, there's UDP, ICMP. And the first 392 00:23:37,520 --> 00:23:43,640 member of this net protocol structure is a handler function pointer that just-that's what gets 393 00:23:43,640 --> 00:23:48,660 called when the kernel receives data for that protocol. So if we can overwrite that function 394 00:23:48,660 --> 00:23:55,280 pointer for the ICMP protocol, then whenever we receive ICMP data, it will call into our code, and 395 00:23:55,280 --> 00:24:02,880 we can-we can move on from there. Um, so hooking ICMP is pretty straightforward. Um, I decided to 396 00:24:02,880 --> 00:24:07,500 use the SoftRQ stack itself as a place to sort of put stuff, just for the explanation. So, um, 397 00:24:09,140 --> 00:24:14,780 it's a good place to put code, um, that we're gonna need later. It's, um, it's persistent. It's not 398 00:24:14,780 --> 00:24:19,600 gonna go away while the kernel's running. And it's a very safe place, because on Linux, kernel 399 00:24:19,600 --> 00:24:24,420 stacks are 8 kilobytes big by default, but the bottom 4 kilobytes is guaranteed to never be 400 00:24:24,420 --> 00:24:31,640 written into. Otherwise, the optional 4 kilobyte stack version would never work. Um, so anything in 401 00:24:31,640 --> 00:24:36,460 the bottom 4 kilobytes of the SoftRQ stack, outside of the metadata at the very bottom of it, is a 402 00:24:36,460 --> 00:24:37,480 great place to store data. 403 00:24:37,500 --> 00:24:43,060 So what we do is we copy our hook, and we'll explain what that does in the second part when I 404 00:24:43,060 --> 00:24:48,600 describe the backdoor, but for now it's just some code that we want to run into the SoftRQ stack 405 00:24:48,600 --> 00:24:53,760 just for safekeeping. Um, and then we want to actually install a hook so that execution will be 406 00:24:53,760 --> 00:24:59,540 redirected to it. Um, first we notice that the handler that I want to overwrite is in read-only 407 00:24:59,540 --> 00:25:06,600 memory, which is sort of a pain. Um, x86 has a nice little way out for this. Um, control register 408 00:25:06,600 --> 00:25:11,840 0 has a-a bit called the write protect bit, and if you flip this bit, then you can essentially write 409 00:25:11,840 --> 00:25:18,860 into read-only memory with no problem. Um, which comes in handy. Um, so what we do is we flip this 410 00:25:18,860 --> 00:25:23,080 bit, now we can write into read-only memory, we write the address of this hook that we just 411 00:25:23,080 --> 00:25:28,700 copied in into the ICMP handler function pointer, and then it looks something like this. Wow, those 412 00:25:28,700 --> 00:25:35,660 are really narrow arrows, I guess. Um, so whenever some, you know, whenever our kernel receives ICMP 413 00:25:35,660 --> 00:25:41,000 data, it will call that handler function pointer, and that will, execution will go to this hook that 414 00:25:41,000 --> 00:25:45,680 we installed, it'll run whatever code we choose to run there, and then presumably when we're done 415 00:25:45,680 --> 00:25:49,340 we're going to call the original ICMP function so that ping still works and stuff like that. 416 00:25:51,740 --> 00:25:57,380 Finally, the last phase of this exploitation component, um, is to actually make sure that the 417 00:25:57,380 --> 00:26:01,600 kernel keeps running, because all this work is-is sort of for nothing if-if you do it and then the 418 00:26:01,600 --> 00:26:05,640 kernel just collapses. Um, so the biggest problem here is that, um, the kernel is not running 419 00:26:05,660 --> 00:26:10,680 because we've wiped out a pretty big portion of the stack by causing this overflow, um, and if we 420 00:26:10,680 --> 00:26:16,120 don't do any cleanup then the kernel is just going to crash. Uh, the first bit of cleanup I needed 421 00:26:16,120 --> 00:26:24,240 to do has to do with-with some locks. So at the time of the exploit, um, the rose protocol was 422 00:26:24,240 --> 00:26:29,140 holding two spin locks just for mutual exclusion purposes and if we just sort of carried it on as if 423 00:26:29,140 --> 00:26:35,120 nothing happened then the rose stack would actually deadlock and-and the kernel would lock up. Um, 424 00:26:35,660 --> 00:26:40,580 The problem here is these spin locks live inside the rows kernel module, which is loaded 425 00:26:40,580 --> 00:26:42,700 at runtime, so we don't actually know where it is. 426 00:26:44,560 --> 00:26:46,940 Fortunately, it's actually pretty easy to find it. 427 00:26:47,320 --> 00:26:51,180 There's this global modules variable, which is the head of a linked list of loaded kernel 428 00:26:51,180 --> 00:26:51,560 modules. 429 00:26:52,220 --> 00:26:56,560 So what we can do is we just follow this linked list until we find the module named rows, 430 00:26:57,420 --> 00:27:02,580 and read this sort of module structure that is hanging off this linked list until we find 431 00:27:02,580 --> 00:27:04,660 where the data section of the rows module is. 432 00:27:04,660 --> 00:27:08,940 Now that we know where the data section of this module is, we can sort of scan it for 433 00:27:08,940 --> 00:27:13,800 this byte pattern that represents a distinctive signature of what these spin locks look like 434 00:27:13,800 --> 00:27:18,220 in memory, and that's unique, so that will always work. 435 00:27:18,460 --> 00:27:22,080 And then once we find them, we can release them by, I think it's incrementing them. 436 00:27:24,340 --> 00:27:27,440 The second bit of cleanup I needed to do has to do with the preemption count. 437 00:27:27,720 --> 00:27:34,380 So on Linux, every process has this variable called preempt count, which sort of encapsulates 438 00:27:34,380 --> 00:27:36,200 a bunch of information related to scheduling. 439 00:27:36,960 --> 00:27:43,400 And if the kernel calls an interrupt handler, as it did when our malicious rows frame was 440 00:27:43,400 --> 00:27:47,860 received, and returns from that interrupt handler, and the preemption count isn't what 441 00:27:47,860 --> 00:27:52,680 it expects it to be, in the past, the scheduler would panic and everything would fall over. 442 00:27:53,660 --> 00:27:58,240 More recently, they put in a check where if it's not what it expects it to be, it actually 443 00:27:58,240 --> 00:28:02,440 just complains a little bit and fixes it for you, which is really nice for exploitation 444 00:28:02,440 --> 00:28:04,360 and saved me a lot of trouble when I was first coming to Linux. 445 00:28:04,380 --> 00:28:05,020 Getting this up and running. 446 00:28:05,580 --> 00:28:09,480 But for the sake of completeness, we'll avoid that warning, because we don't want anything 447 00:28:09,480 --> 00:28:10,000 to be logged. 448 00:28:11,500 --> 00:28:13,540 It's really easy to find the preemption count. 449 00:28:14,420 --> 00:28:19,940 It just lives in this thread info structure, which is at the base of whatever process it 450 00:28:19,940 --> 00:28:20,960 is, kernel stack. 451 00:28:21,480 --> 00:28:25,780 So all we need to do is we know where the software queue stack is, we just find the 452 00:28:25,780 --> 00:28:30,460 base of it, and then this variable is at a known offset from that base, and we just decrement 453 00:28:30,460 --> 00:28:32,520 it appropriately, and that's all we need to do. 454 00:28:34,380 --> 00:28:38,420 Finally, we need to do this actual cleanup so the kernel will keep running. 455 00:28:39,920 --> 00:28:45,640 So recalling that stacks are sort of divided into frames, which represent function contexts 456 00:28:45,640 --> 00:28:51,620 essentially, our overflow has wiped out some number of frames, including all the metadata 457 00:28:51,620 --> 00:28:53,020 that's needed to keep things running. 458 00:28:54,020 --> 00:28:59,320 So what we need to do is we actually walk up the kernel stack until we match the signature 459 00:28:59,320 --> 00:29:03,340 that I prepare ahead of time that represents this is a frame boundary. 460 00:29:03,340 --> 00:29:08,140 This is a good place for us to put the stack pointer, and everything will keep running 461 00:29:08,140 --> 00:29:10,060 as normal once we return from there. 462 00:29:11,080 --> 00:29:15,500 It's sort of as if we magically teleported up to a few parent functions. 463 00:29:17,300 --> 00:29:19,100 So let's go over what we've done so far. 464 00:29:20,220 --> 00:29:22,000 That's the end of the exploitation phase. 465 00:29:22,180 --> 00:29:26,500 At that point, if you send your exploit over, it installs its hook, and the kernel keeps 466 00:29:26,500 --> 00:29:29,680 running, and it would never notice anything happening. 467 00:29:30,980 --> 00:29:32,420 So what we've done so far. 468 00:29:32,560 --> 00:29:33,320 We trigger our overflow. 469 00:29:33,800 --> 00:29:35,240 Gain control of the instruction pointer. 470 00:29:35,780 --> 00:29:39,960 And then we leverage return-oriented programming to mark the softRQ stack where the overflow 471 00:29:39,960 --> 00:29:44,480 took place executable, and then jump into a shell code stub on the softRQ stack. 472 00:29:45,220 --> 00:29:49,800 Next because we have this space limitation, we find the entire rows frame on the kernel 473 00:29:49,800 --> 00:29:51,940 heap, mark it executable, and jump into it. 474 00:29:52,840 --> 00:29:57,300 Next we install our kernel backdoor by hooking the ICMP handler, and then we do some cleanup 475 00:29:57,300 --> 00:29:59,040 that we need to do to keep the kernel running. 476 00:30:01,520 --> 00:30:02,900 Next we're going to talk about the backdoor. 477 00:30:06,040 --> 00:30:10,920 So now at this point, whenever an ICMP packet is received, our hook that we put in kernel 478 00:30:10,920 --> 00:30:11,960 memory is going to run. 479 00:30:12,440 --> 00:30:14,540 Now we want to talk about what that hook's going to actually do. 480 00:30:15,560 --> 00:30:19,460 So the first thing it does is it checks for this sort of arbitrary magic tag that I just 481 00:30:19,460 --> 00:30:21,260 made up in the ICMP header. 482 00:30:21,900 --> 00:30:25,400 And I decided that I wanted to have two distinct kinds of packets to handle. 483 00:30:25,640 --> 00:30:29,660 I wanted to have an install packet, and what I want that to do is sort of cause it to 484 00:30:29,660 --> 00:30:32,880 keep shell code that I put in the ICMP packet around for life. 485 00:30:32,900 --> 00:30:32,980 So we're going to do that a few weeks later. 486 00:30:33,140 --> 00:30:35,120 Just sort of let it sit in kernel memory somewhere. 487 00:30:35,340 --> 00:30:39,980 And then I wanted to have a trigger packet that causes that shell code to execute somehow. 488 00:30:40,280 --> 00:30:43,300 And this is user land shell code that I want to be dealing with. 489 00:30:44,140 --> 00:30:46,740 And these packets should be able to be sent independently. 490 00:30:46,960 --> 00:30:50,840 So you can sort of install a payload and come back a week later and cause it to trigger 491 00:30:50,840 --> 00:30:51,240 repeatedly. 492 00:30:54,340 --> 00:30:57,580 So we need to develop a strategy for how we're going to actually make this happen. 493 00:30:58,420 --> 00:31:02,880 The problem here is the ICMP handler that we've hooked is already running. 494 00:31:02,900 --> 00:31:04,040 It's also running in interrupt context. 495 00:31:05,040 --> 00:31:06,580 And we want to get to user land. 496 00:31:06,760 --> 00:31:08,080 We want to execute code in user land. 497 00:31:08,440 --> 00:31:15,400 So the first phase, we need to actually transition from interrupt context to kernel mode process 498 00:31:15,400 --> 00:31:19,640 context where we're still running kernel code, but it now has a process associated 499 00:31:19,640 --> 00:31:20,340 with our execution. 500 00:31:21,180 --> 00:31:25,600 In the second phase, we want to actually hijack that process that's now associated with our 501 00:31:25,600 --> 00:31:28,580 execution and cause it to execute our user land payload. 502 00:31:30,020 --> 00:31:31,460 So for the first phase. 503 00:31:31,460 --> 00:31:36,340 We check the magic tag when we receive an ICMP packet and if it's an install packet, 504 00:31:36,620 --> 00:31:39,820 then we'll just copy the payload that's in the packet into a safe place and we're going 505 00:31:39,820 --> 00:31:42,780 to keep using the software queue stack as a good place to store stuff. 506 00:31:44,120 --> 00:31:48,760 If we get a trigger packet, then we need to make that transition to process context. 507 00:31:49,600 --> 00:31:54,580 And in my opinion, the easiest way to do so is to hook a system call because whenever 508 00:31:54,580 --> 00:32:00,160 a process calls a system call, it will then be executing kernel code in process context, 509 00:32:00,200 --> 00:32:01,040 which is where we want to be. 510 00:32:02,400 --> 00:32:09,060 How to do this is, as it's been done before, I find the system call table at runtime by 511 00:32:09,640 --> 00:32:14,280 issuing an SIDT instruction, which is an x86 instruction that finds the base address of 512 00:32:14,280 --> 00:32:15,260 the interrupt descriptor table. 513 00:32:16,660 --> 00:32:21,660 And I just index into this table and pull out the handler for int 80, which is system 514 00:32:21,660 --> 00:32:21,900 call. 515 00:32:22,080 --> 00:32:27,140 So that's sort of the entry code for what happens when you call system call, when you 516 00:32:27,140 --> 00:32:27,800 make a system call. 517 00:32:27,940 --> 00:32:31,020 I scan this function for a byte pattern indicating it's making a call. 518 00:32:31,020 --> 00:32:32,060 It's making a call into another table. 519 00:32:32,200 --> 00:32:34,300 And this other table is the system call table. 520 00:32:34,620 --> 00:32:36,280 So you do that. 521 00:32:36,380 --> 00:32:37,960 Now I know where the system call table is. 522 00:32:38,120 --> 00:32:43,340 And the system call table is just sort of like a table of essentially function pointers 523 00:32:43,340 --> 00:32:48,600 that represent handlers for what happens when you make a system call, like close or open 524 00:32:48,600 --> 00:32:49,780 or et cetera. 525 00:32:52,060 --> 00:32:57,600 The system call table on Linux is read only, but we've already figured out how to get 526 00:32:57,600 --> 00:32:57,980 around that. 527 00:32:58,100 --> 00:33:00,140 We just flip that magic bit in CR0. 528 00:33:00,900 --> 00:33:01,000 And that's it. 529 00:33:01,020 --> 00:33:01,900 We can write to read only memory. 530 00:33:02,880 --> 00:33:07,480 So what we do is we just keep that system call handler, whatever one we want to hook 531 00:33:07,480 --> 00:33:10,660 for later, because we're going to need it, and we'll write the address of our hook code 532 00:33:10,660 --> 00:33:11,860 into the system call table. 533 00:33:12,080 --> 00:33:15,000 So now whenever someone calls that system call, it'll execute our code. 534 00:33:17,160 --> 00:33:21,660 Because we want the ICMP stack to keep working, then we just actually call the original ICMP 535 00:33:21,660 --> 00:33:24,420 handler that we kept around so the machine still pings. 536 00:33:25,900 --> 00:33:28,160 So now we want to move on to phase two. 537 00:33:28,280 --> 00:33:30,720 So what we've done is we've copied our userland payload. 538 00:33:31,020 --> 00:33:32,820 We want to execute eventually into kernel memory. 539 00:33:33,340 --> 00:33:37,520 And some process comes along, and it's going to call the system call that we chose to hook. 540 00:33:38,320 --> 00:33:42,540 And what we need to do now is hijack that process to execute our userland code. 541 00:33:44,600 --> 00:33:49,520 First of all, we're only really interested in processes that are running with root privileges. 542 00:33:49,800 --> 00:33:52,900 It would sort of suck if we went through all this trouble and got a connect back shell 543 00:33:52,900 --> 00:33:53,980 as a nobody user. 544 00:33:55,560 --> 00:34:00,600 So the challenge is, how do we actually check that this random process that we hijacked, 545 00:34:00,600 --> 00:34:02,080 is a root-owned process? 546 00:34:02,840 --> 00:34:08,620 And you could do this by actually following various pointers in metadata associated with 547 00:34:08,620 --> 00:34:09,100 that process. 548 00:34:09,420 --> 00:34:11,740 But each of these structures sort of is unstable. 549 00:34:12,000 --> 00:34:13,640 They change a lot between different kernel versions. 550 00:34:13,800 --> 00:34:16,240 You'd have to do it heuristically, and it's sort of a pain. 551 00:34:16,520 --> 00:34:20,380 It'd be really nice if we could just call getUID, because that's something we know and 552 00:34:20,380 --> 00:34:20,700 understand. 553 00:34:20,780 --> 00:34:23,880 It's a very simple interface that will immediately tell us what our user ID is. 554 00:34:25,180 --> 00:34:30,040 But the question is, is it possible to call system calls from kernel mode? 555 00:34:30,040 --> 00:34:34,840 I mean, logically, it doesn't really seem to make sense, because a system call is designed 556 00:34:34,840 --> 00:34:40,140 to be an interface that user applications can call to request services from the kernel. 557 00:34:40,300 --> 00:34:44,960 So what happens when you make a system call via int80 from kernel mode? 558 00:34:46,100 --> 00:34:49,380 I'm just curious, how many of you, if you had to guess, would think that you could do 559 00:34:49,380 --> 00:34:50,040 this without a problem? 560 00:34:52,640 --> 00:34:53,380 That's pretty good. 561 00:34:53,500 --> 00:34:57,420 How many of you think that some issues may arise if you try to make an int80 from kernel 562 00:34:57,420 --> 00:34:57,660 mode? 563 00:34:58,640 --> 00:34:59,900 How many of you have no clue? 564 00:35:00,040 --> 00:35:00,540 I don't know what I'm talking about. 565 00:35:01,660 --> 00:35:02,520 Thanks for being honest. 566 00:35:04,160 --> 00:35:07,860 It turns out that most system calls will work perfectly fine when you call them from the 567 00:35:07,860 --> 00:35:08,060 kernel. 568 00:35:08,420 --> 00:35:12,980 And the details of this, you just need to know some x86 trivia. 569 00:35:13,200 --> 00:35:17,820 But basically, the problem that I thought might arise has to do with the fact that when 570 00:35:17,820 --> 00:35:22,160 you transition from userland to kernel mode, you switch stacks to a kernel mode stack. 571 00:35:22,400 --> 00:35:23,760 And I thought that that might screw things up. 572 00:35:24,200 --> 00:35:27,160 But this stack switch only happens when you're changing privilege levels. 573 00:35:27,300 --> 00:35:30,020 So if you make a system call from kernel mode, you just skip it. 574 00:35:30,040 --> 00:35:32,680 You skip the stack switch and use whatever stack is still there. 575 00:35:34,040 --> 00:35:39,280 And this is just like any other interrupt that is intra-privilege level. 576 00:35:39,460 --> 00:35:43,280 As in, there are lots of interrupts that can be called from ring zero. 577 00:35:43,840 --> 00:35:45,640 And there's really no problems here. 578 00:35:46,100 --> 00:35:47,740 There are a few exceptions to this rule. 579 00:35:48,460 --> 00:35:53,400 Some system calls actually require the stack to be in a certain state using this per-thread 580 00:35:53,400 --> 00:35:54,120 register structure. 581 00:35:54,980 --> 00:35:58,680 And when you do it from kernel mode, these assumptions aren't really, are violated. 582 00:35:58,880 --> 00:35:59,960 So it won't work properly. 583 00:36:00,040 --> 00:36:02,700 And these are things like fork, execv, clone. 584 00:36:02,980 --> 00:36:07,060 But those are really things we don't really have much of an interest in calling from kernel 585 00:36:07,060 --> 00:36:07,460 mode anyway. 586 00:36:08,820 --> 00:36:10,360 So now back to the actual challenge. 587 00:36:10,580 --> 00:36:12,640 We wanted to see if our process is owned by root. 588 00:36:12,860 --> 00:36:18,320 All you need to do is load the EAX register with the syscall number for getuid and call 589 00:36:18,320 --> 00:36:18,560 in data. 590 00:36:18,920 --> 00:36:19,860 It's really easy. 591 00:36:20,900 --> 00:36:22,780 Then you can just check the return code. 592 00:36:22,960 --> 00:36:25,600 If it's zero, then we know our process is owned by root and we'll carry on. 593 00:36:26,820 --> 00:36:30,020 If it's not zero, then we'll just send that process away. 594 00:36:30,020 --> 00:36:32,240 If it's not zero, then we'll just send it back to the original syscall handler that 595 00:36:32,240 --> 00:36:32,600 we hooked. 596 00:36:32,760 --> 00:36:35,080 So it just does whatever it was intending to do and keeps going. 597 00:36:37,360 --> 00:36:41,120 Next we need to actually inject our userland payload into this process that we've now hijacked. 598 00:36:41,940 --> 00:36:46,040 So the kernel stack, as a result of that stack switch that I just mentioned, actually 599 00:36:46,040 --> 00:36:48,600 has a pointer to the saved userland stack pointer. 600 00:36:48,800 --> 00:36:58,580 So when the process enters kernel mode, the CPU pushes the userland stack pointer onto 601 00:36:58,580 --> 00:36:59,220 the kernel stack. 602 00:37:00,020 --> 00:37:03,940 When it returns from that system call, it knows to put its stack back to where it was. 603 00:37:04,480 --> 00:37:08,720 So let's put our payload on the userland stack because we can just read that pointer and 604 00:37:08,720 --> 00:37:09,140 know where it is. 605 00:37:09,780 --> 00:37:13,580 So what we do is we copy that userland payload that we installed earlier as part of that 606 00:37:13,580 --> 00:37:18,900 sort of install packet from kernel memory, wherever we put it, onto this process's userland 607 00:37:18,900 --> 00:37:19,180 stack. 608 00:37:21,680 --> 00:37:26,860 Because we have a modern system, the userland stack is non-executable memory, so we can't 609 00:37:26,860 --> 00:37:28,040 immediately execute code there. 610 00:37:28,040 --> 00:37:30,140 But that's easy enough to fix. 611 00:37:30,260 --> 00:37:35,480 We'll just call mprotect by loading the appropriate system call number and EAX and arguments and 612 00:37:35,480 --> 00:37:39,540 make an int80 from kernel mode to mark the userland stack executable. 613 00:37:41,160 --> 00:37:45,560 Now finally, sort of one of the last things we need to do is actually make sure that when 614 00:37:45,560 --> 00:37:50,060 this process that we're hijacking returns from the system call that it's in, it runs 615 00:37:50,060 --> 00:37:50,480 our code. 616 00:37:51,020 --> 00:37:56,540 So in addition to saving the userland stack pointer, the kernel saves the userland instruction 617 00:37:56,540 --> 00:37:57,880 pointer on the kernel stack. 618 00:37:58,040 --> 00:37:59,980 So that when it returns from the system call, it knows where to go. 619 00:38:00,320 --> 00:38:05,080 So we just need to overwrite this pointer on the stack with the address of this userland 620 00:38:05,080 --> 00:38:09,700 shell code that we just injected, and then when it returns, it'll run our code in userland. 621 00:38:11,140 --> 00:38:15,380 Because we want to do things perfectly and make sure nothing crashes, we actually, after 622 00:38:15,380 --> 00:38:19,480 we've done this, we'll jump to the original handler for that system call that we hijacked. 623 00:38:19,660 --> 00:38:24,140 So if we hooked close, for example, we want the close to still actually happen. 624 00:38:26,000 --> 00:38:27,580 Now the sort of... 625 00:38:27,580 --> 00:38:28,020 Okay. 626 00:38:28,040 --> 00:38:29,200 So that's the part where you get to use your imagination. 627 00:38:29,920 --> 00:38:33,400 Because we set this up this way, you can use whatever userland payload you want. 628 00:38:34,060 --> 00:38:35,260 Connect back shell is good. 629 00:38:35,400 --> 00:38:36,840 You can use meta-sploit payloads for all I care. 630 00:38:38,460 --> 00:38:43,580 One thing that I did do is that, regardless of what userland payload you provide, I prefix 631 00:38:43,580 --> 00:38:47,080 it with a stub that makes sure that the process you hijacked keeps running. 632 00:38:47,580 --> 00:38:48,320 And this... 633 00:38:48,320 --> 00:38:52,100 All this stub does is forks a new process, and then the child runs the shellcode that 634 00:38:52,100 --> 00:38:52,820 you injected... 635 00:38:52,820 --> 00:38:53,880 Wow, it's rowdy over there. 636 00:38:54,420 --> 00:38:56,420 The child runs the shellcode that you injected. 637 00:38:56,420 --> 00:39:01,500 and the parent process of the fork will jump to where it was originally going to go. So that, 638 00:39:01,520 --> 00:39:06,200 you know, if you're hijacking something important, it will keep doing whatever it was doing 639 00:39:06,200 --> 00:39:12,160 and be none the wiser. So now is the real fun part where I get to demo this and pray to the 640 00:39:12,160 --> 00:39:17,640 demo gods. So I've got two VMs up and running. Uh, this is awful. 641 00:39:26,720 --> 00:39:33,280 The password is password like all my machines. Um, so we're going to set up the rose server 642 00:39:33,280 --> 00:39:37,340 stack. This is just a little shell script to create the appropriate interfaces and, and find 643 00:39:37,340 --> 00:39:45,780 them. Uh, likewise on the client, just bring up the rose protocol stack. Um, I've aliased call 644 00:39:45,780 --> 00:39:51,960 to just make a rose call from this host elite one to the victim host loser one using the rose 645 00:39:51,960 --> 00:39:56,240 port associated with this host. So when I type that, um, we've loaded our, 646 00:39:56,420 --> 00:40:02,320 our kernel exploit into this attacker machine's, um, kernel. So whenever we make a call, 647 00:40:02,380 --> 00:40:08,680 it'll send our exploit over to the victim. So we'll do that and it's done. You don't have to clap 648 00:40:08,680 --> 00:40:14,400 yet cause I haven't really proven anything. Um, but you'll notice that absolutely nothing was 649 00:40:14,400 --> 00:40:19,860 logged. That's all just residual from bringing up the rose stack and you would have no idea 650 00:40:19,860 --> 00:40:26,320 that this happened to you, but that machine is now totally owned. So we will demonstrate the 651 00:40:26,320 --> 00:40:26,400 back end of the machine. We're going to show you the back end of the machine. We're going to 652 00:40:26,420 --> 00:40:30,920 show you the back door that I just installed as a part of running that exploit. Um, so I'm 653 00:40:30,920 --> 00:40:35,800 going to bring up a server that I wrote. This is actually an X 25 connect back shell, which was 654 00:40:35,800 --> 00:40:42,040 sort of a pain to write. Um, so this is just a server listening for X 25 connections and this is 655 00:40:42,040 --> 00:40:47,180 my little magic ping command that just builds your, your special ICMP packet. I'm going to 656 00:40:47,180 --> 00:40:53,020 install this X 25 shell code that I compiled. I'm going to trigger it by hooking syscall six, 657 00:40:53,220 --> 00:40:55,660 which is closed. It's just a good choice cause it gets called frequently. 658 00:40:55,660 --> 00:41:03,860 And the IP address of the victim. So we will send that packet over and wait a few seconds and pray 659 00:41:03,860 --> 00:41:19,940 to the demo gods. And we have a root shell. Now of course, once you've, once you've, um, 660 00:41:19,960 --> 00:41:25,480 compromised a host, you need to always check for the zero data text file. Um, living, living 661 00:41:25,480 --> 00:41:31,960 in the home directory because you've earned it. Well, that's really difficult to read. Um, well, 662 00:41:32,080 --> 00:41:37,660 the point is I also audited the user land utilities associated with this network stack and the 663 00:41:37,660 --> 00:41:43,000 X 25 Damon actually has a missing return code check on set you ID. So if you're actually 664 00:41:43,000 --> 00:41:49,860 handing out unprivileged shells using X 25, which I'm sure all of you do, um, you can actually 665 00:41:49,860 --> 00:41:54,960 make a connection, essentially fork bomb the machine and then make another connection and it'll 666 00:41:55,480 --> 00:41:58,980 fail the set you ID call and it will give you a root shell instead of an unprivileged shell. 667 00:41:59,440 --> 00:42:08,220 That's sort of a funny bug. All right. Um, this exploit has a lot of things that could use 668 00:42:08,220 --> 00:42:13,300 improvement. Uh, first off, the thing that really bothers me is that I hard coded a bunch of 669 00:42:13,300 --> 00:42:19,900 things. Um, there are some advantages to using hard coding and this is sort of a toss up between 670 00:42:19,900 --> 00:42:25,200 reliability and portability. You know, if you're hard coding something, uh, you're, you're reasonably 671 00:42:25,480 --> 00:42:30,440 sure that it's going to work every time on the machine that you targeted it for, uh, versus like a 672 00:42:30,440 --> 00:42:35,340 heuristic approach where you're doing signatures or something that will work on a wider variety of 673 00:42:35,340 --> 00:42:41,260 hosts, but may fail some of the time, even on hosts that you've tested. Um, on a physical address 674 00:42:41,260 --> 00:42:47,580 extension kernel, like the one I targeted, it's, it seems mostly unavoidable, um, that you have to 675 00:42:47,580 --> 00:42:52,800 use ROP. Um, so the, the goal is here really just to minimize the number of ROP gadgets that you use 676 00:42:52,800 --> 00:42:57,100 and minimize the amount of hard coding of other data structures that you have to do. If you're 677 00:42:57,100 --> 00:43:01,720 running a non PAE kernel, the situation is much better. Um, you can actually just get by with a 678 00:43:01,720 --> 00:43:06,760 single known instruction, like a jump ESP instruction, for example, because you can jump right 679 00:43:06,760 --> 00:43:12,660 into the stack because it's executable. Um, and it may be possible to do something with, with 680 00:43:12,660 --> 00:43:17,480 partial overwrites, like overwriting a, a portion of the frame pointer, a stack pointer, or doing 681 00:43:17,480 --> 00:43:21,280 some sort of spray approach where you don't even need to know any instructions. So the, the fact 682 00:43:21,280 --> 00:43:22,780 that it's PAE makes exploitation much easier. 683 00:43:22,800 --> 00:43:31,280 Um, the next sort of limitation, in my opinion, is using this magic little write protect bit is, is 684 00:43:31,280 --> 00:43:36,960 fun and easy. Uh, technically speaking, it's not the safest thing in the world. Um, it's a per CPU 685 00:43:36,960 --> 00:43:43,300 bit. So if you have a multiprocessor system, there's actually a, a, a small risk of flipping this 686 00:43:43,300 --> 00:43:47,320 bit so you can write to read-only memory. And then what if that thread gets scheduled out and 687 00:43:47,320 --> 00:43:51,260 scheduled back in on the other processor before you make the write? Then it would try to write to 688 00:43:51,260 --> 00:43:52,040 read-only memory and crash. 689 00:43:52,800 --> 00:43:57,020 I have never seen or heard of that ever happening. There, that's a very, very small race window. 690 00:43:57,240 --> 00:44:02,200 Um, but it, it's possible and it might be worth considering alt, alternative ways to write to 691 00:44:02,200 --> 00:44:07,160 read-only memory. Um, it might be possible to just leverage kernel data, uh, kernel functions that 692 00:44:07,160 --> 00:44:11,300 already exist that will sort of do this in a safe way. And then the challenge becomes finding 693 00:44:11,300 --> 00:44:12,000 those at run time. 694 00:44:13,460 --> 00:44:19,080 Now, sort of more general future work on the offensive side. Um, because these exploits really 695 00:44:19,080 --> 00:44:22,780 rely on knowing something about your, your target, um, it's, it's, it's, it's, it's, it's, it's, it's a 696 00:44:22,800 --> 00:44:26,900 challenge. Um, I think remotely being able to fingerprint a kernel, um, you know, identifying is 697 00:44:26,900 --> 00:44:31,740 this a distribution, what distribution is it, what version is it likely to be, um, is really essential 698 00:44:31,740 --> 00:44:35,980 in, in sort of gaining the information you need about your target to be able to build your exploit. 699 00:44:37,000 --> 00:44:41,960 Um, I'd also like to look at other, other fun packet families for exploitation. Uh, IRDA, 700 00:44:42,060 --> 00:44:48,260 Bluetooth, X25, um, are all less tested and probably have plenty of, of fun bugs. And of course 701 00:44:48,260 --> 00:44:52,120 finding that, that IP bug that breaks the entire internet is always future work. 702 00:44:53,260 --> 00:44:59,580 Um, on the defense side, um, I think it's pretty clear that the weakest link, the weakest link of 703 00:44:59,580 --> 00:45:03,700 this exploit is that you need to know things about the kernel. You need to know those, those known 704 00:45:03,700 --> 00:45:08,020 instruction locations. Uh, so if we rent, do something like randomizing the kernel base at boot, 705 00:45:08,120 --> 00:45:12,640 which is a sort of Linux kernel patch series that I have tinkered with and, and sort of started to 706 00:45:12,640 --> 00:45:18,420 try to get upstreamed, um, that really totally prevents all this code reuse. Um, and your 707 00:45:18,420 --> 00:45:22,780 exploit no longer works. In the absence of some sort of way of remotely disclosing the 708 00:45:22,800 --> 00:45:29,320 kernel memory, which is possible, but I've actually never heard of such a bug. Um, additionally, 709 00:45:29,580 --> 00:45:33,560 it's pretty clear that, that the more exotic networking protocols are, are not tested as 710 00:45:33,560 --> 00:45:40,300 rigorously and could probably use some work. Um, and next, um, it would be really nice if, if 711 00:45:40,300 --> 00:45:44,260 certain functions like set memory X were inlined so that you can't leverage them in return 712 00:45:44,260 --> 00:45:50,320 oriented programming. So it's not quite so easy to, to mark things executable. And finally, as 713 00:45:50,320 --> 00:45:52,780 sort of long-term work, it would be really good if there were sort of, you know, some sort of 714 00:45:52,800 --> 00:45:57,680 policies implemented in the kernel that prevented changing permission, changing page permissions 715 00:45:58,240 --> 00:46:01,960 after initialization. And I think the PAX team is actually working on something like this. 716 00:46:03,500 --> 00:46:13,800 So now we've got to questions. You guys have any questions? You're all just stunned. Yes? 717 00:46:15,800 --> 00:46:16,740 Sorry, what was that? 718 00:46:18,680 --> 00:46:22,400 Yeah, the, the bug was found through inspection. I actually had 719 00:46:22,400 --> 00:46:28,260 no real radio, amateur radio experience prior to that. I am not a licensed operator. Um, so I 720 00:46:28,260 --> 00:46:29,300 thought it was found through auditing. 721 00:46:36,120 --> 00:46:43,320 If I hooked getUID in my exploit, um, that would probably cause an infinite loop. Yeah. 722 00:46:44,940 --> 00:46:50,620 Because, yeah, because, yeah, exactly. You would, um, your hook would get called, and then you 723 00:46:50,620 --> 00:46:52,380 would call getUID in your hook and it would, um, you know, it would, it would, it would, it would, it 724 00:46:52,400 --> 00:46:55,740 would, it would, it would, it would, you know, call your hook again. Don't use that one, I guess. 725 00:46:57,180 --> 00:46:57,800 Good point. 726 00:47:02,360 --> 00:47:02,720 . 727 00:47:07,980 --> 00:47:09,440 I'm sorry, would you mind speaking up? 728 00:47:09,600 --> 00:47:09,820 . 729 00:47:18,480 --> 00:47:22,380 You mean, if I understand, did you, did you mean creating a USB device that would, that would, that would, you know, 730 00:47:22,380 --> 00:47:23,360 that sort of exploits itself. 731 00:47:24,800 --> 00:47:26,960 You need to get what on the system? 732 00:47:32,080 --> 00:47:35,580 Oh, to send the... 733 00:47:35,580 --> 00:47:37,340 Like, if you were doing with real radio hardware? 734 00:47:38,740 --> 00:47:40,040 How about we talk afterwards? 735 00:47:42,840 --> 00:47:43,900 Any other questions? 736 00:47:44,860 --> 00:47:46,000 I saw one over there. 737 00:47:51,240 --> 00:47:53,260 Can you just disable interrupts? 738 00:47:55,900 --> 00:47:56,340 Oh. 739 00:47:57,620 --> 00:47:59,300 That would probably help, yeah. 740 00:47:59,540 --> 00:48:01,040 For the write protect bit, you mean? 741 00:48:01,900 --> 00:48:03,740 Yeah, I think that would probably work, yeah. 742 00:48:05,220 --> 00:48:05,860 Good idea. 743 00:48:06,860 --> 00:48:07,300 John? 744 00:48:08,920 --> 00:48:09,360 No. 745 00:48:10,380 --> 00:48:11,760 No, I don't want to marry you, John. 746 00:48:12,100 --> 00:48:13,300 You said yes! 747 00:48:14,220 --> 00:48:14,940 For information! 748 00:48:16,680 --> 00:48:17,240 All right, cool. 749 00:48:17,440 --> 00:48:17,960 Thanks, guys.