1 00:00:00,042 --> 00:00:09,202 A couple of guys are here. I want to stand in front of you and talk about the PCI express. 2 00:00:09,208 --> 00:00:15,208 Joe and Miles, give them a round of applause. (  Applause  ) >> Hey, how's it going? Ok, who 3 00:00:19,958 --> 00:00:30,078 here went to Mike Osman's RF Reflectors NSA Playset Talk? Ok, who went to Josh Jatko and Teddy 4 00:00:30,083 --> 00:00:39,958 Reed's ITC Implant Talk? Who went to Dean Anlooki's GSM talk? Okay. Who here bought any NSA 5 00:00:39,958 --> 00:00:48,538 Playset kit from Vendor Village? You don't have to say if your employer sent you to buy one for 6 00:00:48,583 --> 00:00:56,020 research purposes, you know. So this is Stupid PCIe Tricks featuring NSA Playset PCIe. It 7 00:00:56,020 --> 00:01:00,040 didn't really start out as an NSA Playset talk, but it fights right in because this is a 8 00:01:00,042 --> 00:01:05,782 capability that they've got to have. It's got to be on one of the pages rejected or missing. 9 00:01:06,360 --> 00:01:12,040 I'm Joe Fitzpatrick. I have an electrical engineering education with focus on CS and Infosec. I 10 00:01:12,042 --> 00:01:16,000 spent eight years doing security research, speed debut and tool development for CPUs including 11 00:01:16,000 --> 00:01:21,375 hardware pen testing of CPUs and security training for functional validators worldwide. I also 12 00:01:21,375 --> 00:01:26,250 teach a really cool class, software exploitation via hardware hacking, aka SEx via 13 00:01:26,250 --> 00:01:30,167 HEx, so if any of you are interested, you should google look for that. It's somewhat 14 00:01:30,167 --> 00:01:37,667 safe. It's work safe. And our mandatory meeting, "if Joe Fitz, he sitz". If you missed the hot 15 00:01:37,667 --> 00:01:43,667 tub at Tour Camp, you should go next time. It runs in two years. >> I'm Miles Crabill, I'm a 16 00:01:46,375 --> 00:01:54,292 current student and hardware Newbie, but interested in computer science and met up with 17 00:01:54,292 --> 00:01:59,500 Joe last year and have been working with him on the last couple months on this NSA 18 00:01:59,500 --> 00:02:04,917 Playset PCIe stuff. I didn't come in with much hardware experience SP and I've pretty 19 00:02:04,917 --> 00:02:11,000 much been learning as I went. It's been a great time. So I couldn't show this, of course. 20 00:02:11,000 --> 00:02:18,250 >> Miles has been great because he makes it all look presentable. I'm a hardware guy 21 00:02:18,250 --> 00:02:25,250 and not a coder. So a slight disclaimer, I didn't do really good research, I didn't cite a 22 00:02:25,250 --> 00:02:29,167 lot of people, but there are tons of people who have done PCIe work and other stuff so, 23 00:02:29,167 --> 00:02:35,208 the difference is in line with the NSA Playset goals, we try to make it accessible and 24 00:02:35,208 --> 00:02:39,708 inexpensive. We want any 10 years olds to start doing DAM attacks and memory jumps and 25 00:02:39,708 --> 00:02:46,792 lock screen bypasses. Miles will give us the run-down of what the heck is PCIe, because even 26 00:02:46,792 --> 00:02:52,500 though you might know it, you may not know the next layer in detail. >> Okay. So what is 27 00:02:52,500 --> 00:02:59,375 PCIe? Well, the answer is that PCIe is PCI extending on this old specification. It's been 28 00:02:59,375 --> 00:03:05,583 around forever. It's for fast IO, right? If you have a video card or something like that, 29 00:03:05,583 --> 00:03:11,417 network card, sound card, anything really that goes in an extension, it'll probably on 30 00:03:11,417 --> 00:03:19,250 your motherboard, whether you're on a laptop, desktop, most modern computers use PCI and so 31 00:03:19,250 --> 00:03:26,250 this is how you get fast stuff going on the hardware level. So there are also things that don't 32 00:03:26,250 --> 00:03:34,042 match up. As you see here, they don't look exactly the same. However, PCIe is backwards 33 00:03:34,042 --> 00:03:40,042 compatible with PCI and PTIX. On the lower level you have packets that are being transmitted 34 00:03:42,292 --> 00:03:48,292 across lanes, and so a lane is four wires. When you see on a PCI card something like XX 4 or 35 00:03:51,083 --> 00:03:57,250 X 16, that's the number of lanes and it corresponds to throughput, so the amount of 36 00:03:57,250 --> 00:04:04,125 data you're able to transfer. Most video use X 16, because they're transferring a lot of 37 00:04:04,125 --> 00:04:10,125 data. PCI enables DAM access. So PCI hierarchy. The root complex is the highest node in the 38 00:04:15,042 --> 00:04:19,542 hierarchy and pretty much everything else descends from there. You see the switch 39 00:04:19,542 --> 00:04:26,458 connected to the root complex, and PCI devices will connect to the switch and other PCI devices 40 00:04:26,458 --> 00:04:31,125 can be connected to other PCI devices so you get a whole mess when you try underwriting this 41 00:04:31,125 --> 00:04:37,667 stuff. So switching. This is the inside of the switch. From the upstream you have the bus, and 42 00:04:37,667 --> 00:04:43,667 then you have these virtual PCI to PCI bridges, and then these actually interface with the real 43 00:04:46,167 --> 00:04:54,083 devices that you have connected, the real PCI devices. So the layers of PCI building up from 44 00:04:54,083 --> 00:05:00,083 the bottom, you have RxTX on the physical layer of things, the logical side and electrical side 45 00:05:02,125 --> 00:05:08,000 data and then up to the transaction where you're actually working with packets. I 46 00:05:08,000 --> 00:05:14,333 don't know how well you can see this, but this is the actual PCI spec stuff in the top like 47 00:05:14,333 --> 00:05:20,333 device I.D. and vendor I.D. is how you would identify a device. So diving into that we have 48 00:05:22,708 --> 00:05:27,458 LSPCI output, just checking out a specific device. You can see this highlighted area is the 49 00:05:27,458 --> 00:05:30,417 vendor I.D. of a device, and so you can see this highlighted area is the vendor ID of the 50 00:05:30,417 --> 00:05:35,625 device and so this is how you would check the manufacturer. They all have codes associated 51 00:05:35,625 --> 00:05:41,583 and then this would be the device I.D. so this is like per a specific product or family of 52 00:05:41,583 --> 00:05:49,083 products. Then the revision, so you can see that all of this is just right in these bytes that 53 00:05:49,083 --> 00:05:55,083 you can access through LSPCI. And this is your class. Device class. Yes. So you can see that 54 00:05:58,333 --> 00:06:04,333 this is a PCI bridge that's 0604. It's just the code that's assigned to this type of device. 55 00:06:09,125 --> 00:06:15,125 And so enumeration, as I said before, it gets pretty messy because it's depth first, 56 00:06:15,125 --> 00:06:21,542 traversal of the tree hierarchy and everything like switches and PCI‑ to‑ PCI bridges show up 57 00:06:21,542 --> 00:06:28,750 multiple times. And so any kind of LSPCI VD output is just a headache to look out. It's huge. 58 00:06:28,750 --> 00:06:34,750 So  ‑ ‑ >> Okay. I'm back on. Routing PCIe. So we talked a little bit about what PCIe is 59 00:06:44,125 --> 00:06:51,667 from a conceptual level. The fundamental difference is PCI was 32 bits in parallel, a big 60 00:06:51,667 --> 00:06:55,708 flat parallel bus with multiple devices sitting on it. PCI express is this high‑ speed 61 00:06:55,708 --> 00:07:01,250 serial with differential signaling. When you route high‑ speed signaling and high speed 62 00:07:01,250 --> 00:07:07,292 differential signals you have some rules to follow, okay? If you wanted to make your own PCI 63 00:07:07,292 --> 00:07:12,042 express device, you have to follow the step by step complicated mandatory and 64 00:07:12,042 --> 00:07:17,208 inflexible rules to routing PCIE. For every single one of these. Number one, route your 65 00:07:17,208 --> 00:07:23,208 pairs at roughly equal length. That's pretty much it. They made this spec to make it easier for 66 00:07:28,542 --> 00:07:32,417 designing boards, because routing 32 lines in parallel along with the cloth, they have 67 00:07:32,417 --> 00:07:37,542 to be equal lengths. That's a pain in the ass. They said ok, we'll do each pair on it's own, 68 00:07:37,542 --> 00:07:42,000 TX pair and RX pair, and as long as each pair is the same length, the next line over can be a 69 00:07:42,000 --> 00:07:44,583 different length, the next line over can be a different length, which works well when you have a 70 00:07:44,583 --> 00:07:49,458 long card. It doesn't matter. All of that is taken care of by the physical layer of the PCIE. 71 00:07:49,458 --> 00:07:54,458 There's some specs, right? You have to have board traces and 12 inches or less, cards are 72 00:07:54,458 --> 00:07:59,167 supposed to be 13 1/2 total. 2 chips on one board supposed to be 15 inches. And if you follow 73 00:07:59,167 --> 00:08:07,083 the rules, your board might work. If you don't follow these rules, it might still work. So 74 00:08:07,083 --> 00:08:14,583 PCI express 1 X, the lowest common denominator, is 2.5GHz TX, 2.5GHz RX and 100MHz Clock. 75 00:08:14,583 --> 00:08:17,333 That is a common clock and that's actually optional. The device can actually generate 76 00:08:17,333 --> 00:08:22,708 it's own clock. It depends on the system and device. You can do it with the clock. But we'll 77 00:08:22,708 --> 00:08:29,417 throw it in there, just for, you know, because we have room. If we wanted to make a table to 78 00:08:29,417 --> 00:08:34,458 connect this, what do we need? We need something that can do high‑ speed, and PCI express 79 00:08:34,458 --> 00:08:38,875 specifies actually like external cabling and it's really expensive. I don't like 80 00:08:38,875 --> 00:08:44,500 expensive things, because I'm cheap. This is a cross‑ section of the USB 3 cable. If you look 81 00:08:44,500 --> 00:08:50,458 inside, you've got the red and the black are ground to BCC, and the green and white are your old 82 00:08:50,458 --> 00:08:57,000 school USB, USB 2.0 wires, right? Those are designed go up to 240 megabytes, right? That's 83 00:08:57,000 --> 00:09:02,208 what USB megabyte was and that's plenty to carry our clock. You have the two level pockets, the 84 00:09:02,208 --> 00:09:06,500 red, blue, and the purple and orange and those hold the high speed lanes and those go at 5 85 00:09:06,500 --> 00:09:11,167 gigahertz. Right? So we have this cable we can get them for a couple of bucks at pretty much 86 00:09:11,167 --> 00:09:16,583 any store and they carry exactly what they need, they carry 5 gigahertz, 5GHz and 500MHz. 87 00:09:16,583 --> 00:09:22,083 That's actually more than we need. I threw together this little PCB. It looks like a PCIe 88 00:09:22,083 --> 00:09:28,542 card. There's a dotted line in a middle. That's because I'm cheap again. And you can get a 5x5 cm 89 00:09:28,542 --> 00:09:34,292 board for one price and I wanted two boards, but I didn't want to have to pay for two boards, so I 90 00:09:34,292 --> 00:09:39,583 put them on the same board. Cut them in half if you want or use as is. You can see those red and 91 00:09:39,583 --> 00:09:44,208 blue lines those are the top and bottom layers where I just connect the wires together and I 92 00:09:44,208 --> 00:09:48,833 actually did a really bad job of this. You can do your own production stuff, do your own. 93 00:09:48,833 --> 00:09:53,375 You can actually buy these premade from several manufacturers on eBay and all 94 00:09:53,375 --> 00:09:58,208 express and other places in China, but that's no fun. So I made my own. This is what the 95 00:09:58,208 --> 00:10:03,000 board looks like, and I have the cool silk solder mask, silver lettering because that's really 96 00:10:03,000 --> 00:10:09,000 important when you make PCB to have your logo on there. I call it PEXternalizer. There's the 97 00:10:11,208 --> 00:10:15,417 board cut in half at the other end and assembled on the populated board. They're a 1X 98 00:10:15,417 --> 00:10:22,167 PCI express socket up there and the end looks kind of mundged up and molten, that's because I 99 00:10:22,167 --> 00:10:28,333 just got my soldering iron and ran through that to open it up so I could put a 16 X card in. 100 00:10:28,333 --> 00:10:33,542 Here's a quick screen shot basically. This PCI express wireless adapter in, and it's 101 00:10:33,542 --> 00:10:39,917 connected and running, and I can connect to wireless networks. That's all well and good, but 102 00:10:39,917 --> 00:10:45,708 that's old news. What else can we do? What devices can we add PCI express to that don't 103 00:10:45,708 --> 00:10:51,792 generally have it? Have you seen this? Intel Galileo. It's an arduino board, but it actually 104 00:10:51,792 --> 00:10:59,167 has a mini PCIe board on the back. What can you do with that? It's supposed to only work with 105 00:10:59,167 --> 00:11:05,333 WiFi adapters, but that's no fun. Anybody can put a WiFi adapter in an arduino. Yeah, 106 00:11:05,333 --> 00:11:10,792 make light flash. Oh, I'm not wearing that shirt. Oops. Makers make lights flahs. Hackers make 107 00:11:10,792 --> 00:11:18,208 other people's lights flash. I made another version of the board, a mini‑ PCIE version. 108 00:11:18,208 --> 00:11:24,208 I'll show you pictures. We'll look over. I'll actually show you. Oh, whoa. So we've got here 109 00:11:32,500 --> 00:11:38,500 a nice  ‑ ‑ oh, there. It's upside graphics card backwards. We've got our Intel Galileo and 110 00:11:41,292 --> 00:11:47,667 flip on the other side we have the mini PCIe card with the USB header. Again it's USB header 111 00:11:47,667 --> 00:11:53,375 it's just USB header and cable because they're cheap. On the other end I have the populated 112 00:11:53,375 --> 00:11:58,333 thingy‑ do which has a little power regulator on the end. We don't have the power supply and 113 00:11:58,333 --> 00:12:04,833 cables and extra VGA to hook it up and show you, but basically we plug  ‑ ‑ stay still. I'm 114 00:12:04,833 --> 00:12:10,833 looking at the screen. Whoo! Anybody sick yet? Pop it in the slot. >> Oh, gosh. >> There we 115 00:12:29,125 --> 00:12:35,125 go. So you got that, right? You got it. There we go. You have more than 12 inches. Yeah. Do 116 00:12:40,750 --> 00:12:48,042 you think it still works? Yeah, it still works. And so here's a screen shot. Whoa, here we go. 117 00:12:48,042 --> 00:12:55,083 Actually when we tried it out, we used a bigger graphics card because bigger is better, right? 118 00:12:55,083 --> 00:13:02,500 So wired them up PCIe that tiny Arduino and that nice big burly graphics card hovering over it 119 00:13:02,500 --> 00:13:08,708 and if we hook it and we look, I had to do a little bit of custom building of that, which is 120 00:13:08,708 --> 00:13:12,625 annoying because of the software and I hate software. If you do all this PCIe, same tools as 121 00:13:12,625 --> 00:13:18,208 before. It's on the Galileo board already. You see a whole bunch of 8086, 8086, 8086. 122 00:13:18,208 --> 00:13:25,750 Anybody knows who vendor I.D. that is? All the way down at the bottom is the 10de. Who do you 123 00:13:25,750 --> 00:13:32,250 think that might be? Invideos. So, ya know. Sneak it in there and put it Invidy with Intel in 124 00:13:32,250 --> 00:13:38,250 bed a little longer. Here we go. I hooked you up to my full HD display, to say, hey, I have X 125 00:13:41,000 --> 00:13:46,125 running. There's no keyboard input or anything like that, but at this point it's a software 126 00:13:46,125 --> 00:13:50,958 problem and I'm a hardware guy. It's someone else's problem, right? So let's move on. The 127 00:13:50,958 --> 00:13:56,625 other device I played around with, and I don't have it here to show off is not fully working 128 00:13:56,625 --> 00:14:01,958 yet. This is a Pogoplug. It's a network storage device. It has an Ethernet port and USB port 129 00:14:01,958 --> 00:14:08,000 and you plug it in. It shares it with the whole world. It doesn't tell you about that part. If we 130 00:14:08,000 --> 00:14:12,958 look at two versions of the PCE, the cheap and expensive one. The big difference in the upper left 131 00:14:12,958 --> 00:14:18,750 corner is an extra chip that's a USB‑ 3 chip. You want USB 3 on your very slow network storage 132 00:14:18,750 --> 00:14:24,250 device. The way it's connected is PCI express. If you see on this one, the purple wires on 133 00:14:24,250 --> 00:14:30,000 the left hand side, those are my PCI express lanes. I have TX and Rx pairs and then I've got a 134 00:14:30,000 --> 00:14:36,000 clock line. He took it with my phone through my magnifying glass, but you see on the left 135 00:14:38,083 --> 00:14:45,042 we have a couple tiny little resistors that have it over it. Can you see it? You can't? Oh, 136 00:14:45,042 --> 00:14:48,833 no. You can. So you see right there, there's a couple resistors because the resistance 137 00:14:48,833 --> 00:14:53,000 loaders, you have to put on the clock lines, and over here's they're still very small, but 138 00:14:53,000 --> 00:14:57,542 you see that little brown spot right there and there? Those are capacitors that are soldered to 139 00:14:57,542 --> 00:15:02,792 the tip of USB connector and then the wire is soldered to the other edges side. It looks 140 00:15:02,792 --> 00:15:07,958 pretty fancy. But a year and a half ago I sucked at soldering and still do. You find a friend 141 00:15:07,958 --> 00:15:14,667 who can do it. Thanks, Kenny. He's not here, but you know. Those of you who know Kenny, he 142 00:15:14,667 --> 00:15:21,083 does good work. Again, that goes out to a USB connector, which is the same Pen out as this chain 143 00:15:21,083 --> 00:15:26,750 again. So my plan there is to get it working and see if I can compile those drivers for ARM 144 00:15:26,750 --> 00:15:34,417 instead. So introducing SLOTSCREAMER. This is where we get into the NSA Playset side of 145 00:15:34,417 --> 00:15:40,875 things. It reset our timer. Oh, its 2:16. We're good. Introducing SLOTSCREAMER, its in 146 00:15:40,875 --> 00:15:46,917 all CAPS because it's cool to have things in all CAPS. I've had some critiquing because the 147 00:15:46,917 --> 00:15:51,500 name sounds too good, it's not random and silly enough for NSA Playset because it actually is a 148 00:15:51,500 --> 00:15:56,125 device that goes in a slot. I apologize. Again, I mentioned before I didn't do a lot of 149 00:15:56,125 --> 00:16:00,750 research or citation, but I was at Black Hat and I saw this awesome slide which was from 150 00:16:00,750 --> 00:16:04,417 Steven Weiss talking about protecting date in-use from firmware and physical attacks, 151 00:16:04,417 --> 00:16:08,333 which is kind of what we're about to do. I figured I'd throw his slide in here. Thank you to 152 00:16:08,333 --> 00:16:12,917 all of these people for all the work they have done, because I wouldn't have done this if it 153 00:16:12,917 --> 00:16:18,917 wasn't done before me including all the citations. So it's also really cool to go into someone 154 00:16:22,250 --> 00:16:28,250 else's talk and see my name on it. Whoo. This is my first time talking at DEF CON. (  Applause  155 00:16:37,417 --> 00:16:43,417 ) >> It's Miles' first time, too. I'm glad we could have our first time together Miles. (  156 00:16:46,833 --> 00:16:51,917 Applause  ) >> A lot of people are playing with this doing these PCI Express attacks, but a 157 00:16:51,917 --> 00:16:56,417 lot of them are using FPGAs. FPGAs are expensive and they're difficult and they're hard and 158 00:16:56,417 --> 00:17:00,958 you have to download like 28 bytes of software to get them working. Which who cares about 159 00:17:00,958 --> 00:17:06,958 that software stuff. So I looked around and found this cool it'll ASIC. It's a PLX technology. 160 00:17:10,208 --> 00:17:16,792 It's a USB 3380 its aPCI‑ to‑ USB bridge that works. It's a USB device port. You can plug it 161 00:17:16,792 --> 00:17:21,792 into your system and load drivers and make it look like a mass storage control. You can 162 00:17:21,792 --> 00:17:26,250 use this configure differently and make a PCI express device work over the USB. You can have 163 00:17:26,250 --> 00:17:31,000 an attached graphics adapter, right? Right? This is a block diagram, one side you have PCI 164 00:17:31,000 --> 00:17:36,708 Express, the other side you have USB. That's all there is to it. You know, every chip that is 165 00:17:36,708 --> 00:17:41,375 configurable is configurable in ways they didn't intend, so that's what I did. They have 166 00:17:41,375 --> 00:17:47,167 this PCI out end point. An endpoint is something that shows up from USB, so from USB  ‑ ‑ 167 00:17:47,167 --> 00:17:52,667 I'm going really fast, aren't I? Am I going too fast? I apologize. >> We have a lot of 168 00:17:52,667 --> 00:17:58,667 slides. >> We're on 49 of 92. Okay. We're actually going a little fast. Let's slow down. 169 00:18:03,833 --> 00:18:09,833 PCI out. Okay. It's actually good, because I thought we wouldn't have enough time, and I 170 00:18:14,542 --> 00:18:18,917 was going to tell them to go away. Since he came at the right time. How is it going? >> Good. 171 00:18:18,917 --> 00:18:26,250 >> What's all this? >> We heard this track was going a little bit fast, so we thought we would 172 00:18:26,250 --> 00:18:32,250 mellow it out a bit. That's why we're here. How are they doing? (  Cheers and applause  ) >> I 173 00:18:46,958 --> 00:18:52,042 guess they really want you to slow down. The slides are a bit of an eye‑chart, although when 174 00:18:52,042 --> 00:18:58,042 you had the picture of the device up, the board. I got the detail on that. >> All right. 175 00:19:01,000 --> 00:19:07,000 New speakers to DEF CON. >> Cheers. (  Applause  ) >> I did that for all of you. Hold on. 176 00:19:27,625 --> 00:19:33,625 Thank you. Can I continue now? PCI out end point. This shows up on the USB side of things, 177 00:19:40,208 --> 00:19:48,167 right? This is a packet format. We need to write a bunch of bytes for USB so this guy and 178 00:19:48,167 --> 00:19:51,958 actually fills out what's called a PCI master control register and the PCI master address 179 00:19:51,958 --> 00:19:59,708 register. What happens is when these registers get filled up, the chip, this guy, receives the 180 00:19:59,708 --> 00:20:06,833 data from the USB side. He takes it into his little hardware stuff. Don't worry about it, 181 00:20:06,833 --> 00:20:12,333 it's hardware. You guys wouldn't understand and he generates a PCI Express packet. Which goes 182 00:20:12,333 --> 00:20:17,667 out over PCI Express to the root complex, the root complex processes it, does whatever you 183 00:20:17,667 --> 00:20:24,333 want or whatever you told it to and sends back a response. Once we enabled it, so this comes out 184 00:20:24,333 --> 00:20:28,583 of the spec, sorry for the eye chart, if we look down here we have this little end point 185 00:20:28,583 --> 00:20:33,792 enabled bit. So you think something silly like this would be off by default. But look 186 00:20:33,792 --> 00:20:39,625 actually oh, Others = 1, it's on by default. How convenient. This makes sense because if you look 187 00:20:39,625 --> 00:20:44,250 at the drivers for this device, the standard Linux drivers for USB gadget events, which lets 188 00:20:44,250 --> 00:20:48,208 you use it as a device port so you can turn your computer into a mass storage controller, they 189 00:20:48,208 --> 00:20:52,208 have this little section where they explicitly disabled these dedicated end points. And I 190 00:20:52,208 --> 00:20:56,958 think in another kernel version they have like, for security reasons, we need to disable 191 00:20:56,958 --> 00:21:02,042 these end points, which is great. I like when I see things like that in documentation. I 192 00:21:02,042 --> 00:21:09,417 talked to PLX service engineers asking about this. We don't do that. That's not what it's for. 193 00:21:09,417 --> 00:21:15,417 We can try it and see if it works. Didn't really say what would happen if I turned it on 194 00:21:18,083 --> 00:21:23,375 in this mode, but I heart undefined behavior. Is that sticker still on there? At least 195 00:21:23,375 --> 00:21:29,375 it's not on my shirt. Thank you, Mike, for the shirt. Anyway. So let's enable it. We're still not 196 00:21:37,417 --> 00:21:44,792 going too fast. I showed you the three registers here. If we look inside, this is the PCI master 197 00:21:44,792 --> 00:21:49,750 control register. Basically what we do is we need to write bits that will end up in here and do 198 00:21:49,750 --> 00:21:55,000 these things that it says and this bits 5 to 4 two bits, we can basically say, do a memory 199 00:21:55,000 --> 00:22:00,708 read and memory write, or an IO read, an IO write or conf read or config write, or PCI express 200 00:22:00,708 --> 00:22:05,750 message. Let me explain for a second what each of these are. Memory read/memory write is 201 00:22:05,750 --> 00:22:10,333 exactly that. PCI express devices need to have the memory maps so they can read and write 202 00:22:10,333 --> 00:22:14,875 to buffers in the main memory. So if you want to read some memory, we can do that. If we 203 00:22:14,875 --> 00:22:18,750 want to write to memory, and we can do that. IO read and write, really nobody uses this anymore, 204 00:22:18,750 --> 00:22:23,167 it's all legacy stuff, but we might as well try it because all of the Legacy stuff wasn't 205 00:22:23,167 --> 00:22:29,167 tested as well as all of the new stuff. Configuration read and write, those are when we are 206 00:22:44,500 --> 00:22:47,542 actually directly accessing PCI Express devices. So when you enable things on the graphic 207 00:22:47,542 --> 00:22:51,417 cards you do a configuration write to a bunch of registers on the card. That's what maps to 208 00:22:51,417 --> 00:22:54,875 the table of class codes and stuff Miles talked about briefly before. Another eye chart. This 209 00:22:54,875 --> 00:22:59,417 is all well and good, but we need to have this device just work. We want to plug it in a 210 00:22:59,417 --> 00:23:03,292 socket and have it do stuff. We don't want it to deal with loading drivers, because who is 211 00:23:03,292 --> 00:23:07,375 going to load drivers to a fax machine? No one clicks on silly things, right? So we can modify 212 00:23:07,375 --> 00:23:13,458 the firmware. Basically there's a little chip on the POX board. Where is my board? That will 213 00:23:13,458 --> 00:23:18,750 hold configuration data, and when the chip turns on and powers up, it will read this 214 00:23:18,750 --> 00:23:25,333 data and set the registers right. You think, okay, a lot of work put into this custom 215 00:23:25,333 --> 00:23:31,333 firmware that I made, I've been talking all about it, you think I did a lot of work? I'm lazy. 216 00:23:33,500 --> 00:23:38,625 It's these. How many bytes is that? That's it. That's the content of the E prompt. To 217 00:23:38,625 --> 00:23:44,625 decode it for you to those that speak XXD. Basically I have two registers I wrote to. The first 218 00:23:46,708 --> 00:23:52,708 register that 497000049, right, that's the content of the what ports to a register and I slap 219 00:23:59,500 --> 00:24:05,875 the bit to enable USB. When the device turns on, first thing it does is enable USB. Second thing 220 00:24:05,875 --> 00:24:11,875 I do is this E414BC16. That's the vendor ID and device I.D. of the Broadcom secured digital 221 00:24:15,083 --> 00:24:20,375 card reader. Because it's a secured digital card readers everyone trusts them. If I tell 222 00:24:20,375 --> 00:24:24,708 them I'm one of them, they'll turn everything on. They'll turn on bus master even if they don't 223 00:24:24,708 --> 00:24:30,375 need to. That's pretty much all that I did to configure this chip to make it do my bidding. 224 00:24:30,375 --> 00:24:36,375 So let's attack the PCIe. >> So as Joe said, who wants to load a driver? We have this whole 225 00:24:44,500 --> 00:24:49,625 category of target side software where we have to make sure the target has all the stuff we need 226 00:24:49,625 --> 00:24:55,625 to get the attack roll, but no, no, nothing. So on the attacker side, we actually do have some 227 00:24:58,083 --> 00:25:03,833 stuff. So what we do is use high USB, which is a nice Python library for interacting with 228 00:25:03,833 --> 00:25:09,833 devices over USB to interact with the PCI end points on the swat screen, the USB 3380. So 229 00:25:12,750 --> 00:25:18,750 this is just a little snippet of code showing a dirty PCI memory read and write by PyUSB. At the 230 00:25:22,292 --> 00:25:28,292 top you see read where we're actually making a packet to send and you can see this OXCF and 231 00:25:31,792 --> 00:25:37,792 the F denotes the read, and down at the bottom here you see the 4F means that it's a write and 232 00:25:44,667 --> 00:25:50,667 so now we have a demo. >> Well you  ‑ ‑ >> So you do the whole switches of screens here. 233 00:25:53,167 --> 00:26:00,750 Basically we have this little device here. It's a Nook Intel makes them, they're tiny and 234 00:26:00,750 --> 00:26:06,750 they compute. We hook up this device to a little board. It's upside‑ down. >> Oh, no. It's 235 00:26:23,417 --> 00:26:29,417 still on my screen. >> I stepped on the power strip. You're flaky power strip. I saw the light. 236 00:26:37,125 --> 00:26:43,125 There we go. I have to reboot my Nook. Luckily it boots fast. Oh. I'm sorry. Please. I won't step 237 00:26:52,583 --> 00:26:58,583 on it again. I promise. What time is it? 2:27. Are you ready in no. We need to unplug and 238 00:27:00,583 --> 00:27:06,583 play it. That's not it. That is it. You just need to mirror your screens. I didn't recognize the 239 00:27:11,958 --> 00:27:16,042 picture. It's not my desktop. I never got around to changing the default desktop anyway. That's 240 00:27:16,042 --> 00:27:22,042 my fault. There you go. There we go. Patience, patience. So I'm using Python, and I'll stay away 241 00:27:32,250 --> 00:27:38,250 from the power strip. I'll step back from here. Can you see that? It's backwards, isn't it? 242 00:27:43,958 --> 00:27:51,917 >> Yeah. >> I'm sorry. It's a crypto challenge. So what I'm going to do is basically I wrote 243 00:27:51,917 --> 00:27:58,750 this little sampler in init PCI and I'm going to hit enter and it actually worked. Whoohoo! So 244 00:27:58,750 --> 00:28:04,583 it initialized the link from this PC to the hacker's hack device over PCI. It found two 245 00:28:04,583 --> 00:28:11,708 endpoints 0x0e and 0x0e out. Those actually line up to what I showed you on the chart before. 246 00:28:11,708 --> 00:28:17,792 I'm sure you all wrote those down. Then I'm going to read PCI and so I give it an address and 247 00:28:17,792 --> 00:28:22,042 how many byes to read and right there and I just get a whole bunch of, it's Python software 248 00:28:22,042 --> 00:28:27,333 you see, Fs and 0s and Bs and some strings and stuff. So yeah I just read memory. This is off 249 00:28:27,333 --> 00:28:33,333 of this guy on PCI. Whoo. It's not the greatest demo, but you know, we're getting there. All 250 00:28:41,167 --> 00:28:47,167 right. >> Okay. And so how many of you have heard of inception, not the movie? That's a few. 251 00:28:57,000 --> 00:29:03,000 There's a cool utility that Carston wrote that exploits the DNA features of fire wire to 252 00:29:06,375 --> 00:29:11,958 basically patch some  ‑ ‑ you might see here there's some selections that you can choose 253 00:29:11,958 --> 00:29:18,250 to target with signatures. So it can identify based on the signatures certain operating 254 00:29:18,250 --> 00:29:26,167 systems and inject code into it bringing it up. For example the OSX one makes all passwords 255 00:29:26,167 --> 00:29:32,167 nothing. So what we have instead of inception, we have into PCIe, which is an extension that 256 00:29:34,417 --> 00:29:40,417 we're  ‑ ‑ >> It's an anagram. >> I didn't know that. Yeah, so, we extended inception to PCIE 257 00:29:47,875 --> 00:29:54,417 and we're still working on it. Ironing out bugs and that kind of thing, but that's the goal. 258 00:29:54,417 --> 00:30:00,542 >> This is right from Carson's documentation. What we're doing is hopping through memory and 259 00:30:00,542 --> 00:30:04,958 looking for the page that contains whatever authentication or password. You did a whole 260 00:30:04,958 --> 00:30:09,750 process up in the password. Yes, you got it right and no you didn't at the very end. It has a 261 00:30:09,750 --> 00:30:14,875 signature, which is listed as a chunk of memory data. It looks for that signature at a certain 262 00:30:14,875 --> 00:30:19,500 offset in every 4k page. So it doesn't matter if you have ASLR or anything within a 4k page it 263 00:30:19,500 --> 00:30:25,958 always ends up the same spot. Then you go and patch it, and the patch goes to offset. 264 00:30:25,958 --> 00:30:32,083 Basically just change the jump to an up or something like that. You bypass, so when you type in 265 00:30:32,083 --> 00:30:36,458 blah, blah, blah enter, no matter what blah, blah, blah is it lets you bypass the locked 266 00:30:36,458 --> 00:30:42,458 screen. (  Applause  ) >> We didn't do the work there. Other people have been doing the 267 00:30:48,125 --> 00:30:53,958 Spyware stuff for a long time. Don't clap. We just imported into this PCI Express interface, 268 00:30:53,958 --> 00:30:59,542 which is great because you don't require drivers. Firewire require that the host offers 269 00:30:59,542 --> 00:31:05,750 install drivers, and you're supposed to talk about this later on. >> So you see here the 270 00:31:05,750 --> 00:31:10,250 chunk, which is actually the signature that you're trying to look for to identify in this 271 00:31:10,250 --> 00:31:16,250 case OS X 2.9. So earlier this week Joe and I were in a hotel room taking dumps together. As 272 00:31:20,167 --> 00:31:27,208 you can see from this little highlighted into PCIe business and all of the SLOTSCREAMERS on 273 00:31:27,208 --> 00:31:33,208 the desk. I decided after taking all those dumps, Jason stool analysis, you've heard of 274 00:31:35,208 --> 00:31:41,208 volatility is a cool analysis framework, so this is the demessage log of the attack 275 00:31:44,125 --> 00:31:50,167 straight off of the victim. You can see my solarized color scheme there. So at the top you 276 00:31:50,167 --> 00:31:57,500 can see the thunderbolt first being recognized when plugged in, and then some PCI 277 00:31:57,500 --> 00:32:04,125 configuration going on. And I decided, hey SHTHS why not do more analysis because the 278 00:32:04,125 --> 00:32:11,250 utility has all these nice scripts? This is just another dump. This is a MAC that we're 279 00:32:11,250 --> 00:32:17,375 dumping apple dot something, something, something. And various other  ‑ ‑ >> I was 280 00:32:17,375 --> 00:32:22,958 looking around for the files, and I find some of Miles' cookies in his dumps . >> Here 281 00:32:22,958 --> 00:32:28,958 you can see, I don't know if its major version or minor version what it means, but I'm running 282 00:32:36,583 --> 00:32:42,042 10.9.4.6 OS X. I had the perfect amount of memory, 4 gigs, on this machine not for not 283 00:32:42,042 --> 00:32:49,125 actually using things because these kind of attacks are a little limited because of PCIe 284 00:32:49,125 --> 00:32:56,458 is at 32 bit addresses and so we can't actually go over the 4 gig over the threshold. However, if 285 00:32:56,458 --> 00:33:01,333 you know what you're doing, 4 gigs is for our assessment. >> You know what thunderbolt is. 286 00:33:01,333 --> 00:33:08,292 It's fun stuff. It's basically PCI Express out of your system. Kind of that whole USB crap, but 287 00:33:08,292 --> 00:33:14,167 without the sketching boards and stuff. When you have Thunderbolt, you have two chips, 288 00:33:14,167 --> 00:33:19,250 and it's straight from the thunderbolt device programming guide, and you have a chip 289 00:33:19,250 --> 00:33:26,000 inside your Macintosh and you have a chip on your device. The chip takes PCI Express in 290 00:33:26,000 --> 00:33:31,500 display port in and they crunch it together into some other physical layer really fast to 291 00:33:31,500 --> 00:33:36,250 transport mechanism, and the other side extracts what it needs to, right? You can also 292 00:33:36,250 --> 00:33:40,958 even pass the stuff through. You can connect a display port to something else, daisy chained 293 00:33:40,958 --> 00:33:47,875 along the end or fun stuff like that. Of course, we try to plug our device into the PCI express 294 00:33:47,875 --> 00:33:52,375 thunderbolt enclosure, and in line with the NSA Playset, we decided to give that a new name. 295 00:33:52,375 --> 00:33:59,667 So HALIBUTDUGOUT is the slotscreamer when inserted into a thunderbolt enclosure. And 296 00:33:59,667 --> 00:34:03,458 you'll see the little logo for Great Scott Gadgets, he's awesome, he sent me a bunch of 297 00:34:03,458 --> 00:34:06,792 hardware when he heard what I was working on and that kind of motivated me to keep working on 298 00:34:06,792 --> 00:34:12,792 this. Thank you, Mike. So I'm forgetting what's next. In my mind there's a gap here. Again, 299 00:34:19,083 --> 00:34:24,500 we talk about DMI. People have showed off the DMI for a long time and they're inaccessible 300 00:34:24,500 --> 00:34:29,375 they didn't give full disclosure on exactly how to do it all or the code for the FPJ or anything 301 00:34:29,375 --> 00:34:35,958 like that. So in line with the NSA Playset, there's a little page, click on there. We have 302 00:34:35,958 --> 00:34:41,542 all of the utilities and firmware available for you to download and do this yourself. 303 00:34:41,542 --> 00:34:48,000 The hardware itself is this  ‑ ‑ right now I'm using a reference board, and you don't even have 304 00:34:48,000 --> 00:34:53,708 to solder to make it work, right? You buy the reference board from a sketchy company in 305 00:34:53,708 --> 00:34:58,208 China, H.W. tools.net. I sent thousands of dollars and they sent me cards and they're pretty 306 00:34:58,208 --> 00:35:02,375 reliable. And I've talked to their tech support a few times. They're pretty good with that. 307 00:35:02,375 --> 00:35:09,042 That's a device on there. Its got the chip on there. Instead of that, there's a little bit of 308 00:35:09,042 --> 00:35:14,542 hardware hacking. You have to find a jumper. Do you remember what jumpers are? You have to 309 00:35:14,542 --> 00:35:18,625 put it over the first set of pins to connect the E prong with that chip right there. And then 310 00:35:18,625 --> 00:35:23,458 you have to go and flash it yourself. We sold a bunch of these in the vendor area 311 00:35:23,458 --> 00:35:28,250 yesterday all preflashed and ready to go for all of you wants to go back to the undisclosed 312 00:35:28,250 --> 00:35:34,708 employers to show off what you learned at DEF CON. All the software is on the NSA play set 313 00:35:34,708 --> 00:35:40,333 get DAIB hub. We put it all up there, did you make it all private? It will be up there 314 00:35:40,333 --> 00:35:46,833 very soon, but now that we've got all of you basically enabled to dump people's memories and 315 00:35:46,833 --> 00:35:53,083 check out their dumps and modify and do all that stuff, what could be done to fix this, 316 00:35:53,083 --> 00:35:57,375 right? Part of the NSA Playset mission is like ok state actor has had this capability for a 317 00:35:57,375 --> 00:36:02,083 long time. Forensics has had this ability. Now that all of you have this ability, maybe 318 00:36:02,083 --> 00:36:08,125 they'll actually fix it. I started with an anti‑ Apple, anti‑ Thunderbolt slant to this, 319 00:36:08,125 --> 00:36:14,292 but it actually came out pretty good. In Linux, if you look for this Bus Master enable bit, any 320 00:36:14,292 --> 00:36:18,875 device plug in the system gets Bus Master enabled turned on. Welcome to the show. What memory 321 00:36:18,875 --> 00:36:24,125 would you like? There really isn't a software remediation for this, right? You can't just not 322 00:36:24,125 --> 00:36:28,542 load the Fire wire drivers like you could with the regular inception attack. You can use an 323 00:36:28,542 --> 00:36:34,542 IOMMU. Are you familiar with virtualization? How about virtualization of hardware? 324 00:36:36,625 --> 00:36:42,625 Virtualization on the left, you just have software VMs that run a code and interfaced with an 325 00:36:45,625 --> 00:36:50,375 extraction layer. On the other side you've got  ‑ ‑ whether you use BTD or an IOMMU of some 326 00:36:50,375 --> 00:36:54,958 sort, where you can actually assign a device to a specific software VM, you can actually 327 00:36:54,958 --> 00:36:59,125 have two graphic cards plugged into your system, each running native drivers in a separate VM 328 00:36:59,125 --> 00:37:05,042 and no one knows the difference. All that memory DMA access is remapped. If you configure a BTD 329 00:37:05,042 --> 00:37:11,042 write like Apple does 10.8.2 on IP version they actually configure BT later, unless you 330 00:37:13,083 --> 00:37:17,125 change the argument and turn BT off, which is good for a demonstration. You can go and 331 00:37:17,125 --> 00:37:23,125 modify memory. Why those limitations? Why haven't they rolled them back to IP bridge? 332 00:37:25,750 --> 00:37:32,792 Any system with thunderbolts should have BTD on to protect you against certain things. Any 333 00:37:32,792 --> 00:37:37,375 system that has an express card. Any system you leave anywhere you don't see that someone can 334 00:37:37,375 --> 00:37:41,375 open it up and pop a card in. You should be careful. Your operating system vendor should 335 00:37:41,375 --> 00:37:47,542 be writing and providing this stuff by default. It's just important. Until then what 336 00:37:47,542 --> 00:37:53,542 solution do we have? Abstinence, right. Miles would ever plug into sketchy into your display 337 00:37:55,917 --> 00:38:01,917 port/Thunderbolt port? >> Of course not. >> What's plugged in there right now? >> It's just a 338 00:38:25,708 --> 00:38:31,708 VGA cable. >> Where does it go? What's this? Oh, oh. >> Whoops. >> I have the power cord out, 339 00:38:35,792 --> 00:38:41,250 too. We have five minutes. Okay. So yeah, yeah. Miles plugged in this little cable that looks 340 00:38:41,250 --> 00:38:46,667 pretty simple. It's like one of those stupid $30 Apple adapters. But actually we look at the 341 00:38:46,667 --> 00:38:51,708 other end and its really just a thunderbolt cable going to the thunderbolt enclosure attached 342 00:38:51,708 --> 00:38:56,167 to an adapter. So this is how you could basically one of these yourself. We call this 343 00:38:56,167 --> 00:39:02,208 ALLOYVIPER. We need a new name, because it's a cosmetic change to commercial products. So  ‑ ‑ 344 00:39:02,208 --> 00:39:08,875 actually this one has a list price of 300,000, maybe a little less if you buy them in bulk. 345 00:39:08,875 --> 00:39:15,667 It's actally pretty pricey because one cable alone is 50 bucks. So you take one of these 346 00:39:15,667 --> 00:39:22,875 Thunderbolt cables and you go to radio shack and GED get one of these module telephone Jack and 347 00:39:22,875 --> 00:39:28,958 use these little metal thingies. Thank you. I can push buttons now. You can get heat shrink 348 00:39:28,958 --> 00:39:34,875 tubing, open everything up and thread your thunderbolt cable through that. Close it up, get 349 00:39:34,875 --> 00:39:39,000 your heat shrink tubing, thread the Thunderbolt cable through that. Put the metal enclosure on 350 00:39:39,000 --> 00:39:45,167 the end, and that's pretty much it. You basically say here, I already got an adapter for you. 351 00:39:45,167 --> 00:39:51,167 Thanks for presenting. My apology to Joe Grand. You were here last. My apology to Miles, 352 00:39:51,167 --> 00:39:58,292 that dump I did was actually not your Nook. I didn't find any cookies in your dump, though. 353 00:39:58,292 --> 00:40:01,792 And basically on the other end, you put a standard adapter, look, I'm using the laser 354 00:40:01,792 --> 00:40:07,625 pointer on the screen. I apologize. Right here I can point at this one. Is this 355 00:40:07,625 --> 00:40:15,375 better? This is a screen that was used on the corner and draws it on the projector. It's the 356 00:40:15,375 --> 00:40:20,375 disclosure. Pay no attention to the man behind the curtain. When you plug this in, it defines the 357 00:40:20,375 --> 00:40:25,125 display port to the adapter on the other end and It just passes it through. That's what we've 358 00:40:25,125 --> 00:40:28,958 been presenting the whole time. That's why it stopped when I stepped on the power cable. 359 00:40:28,958 --> 00:40:33,875 Sorry. I thought I almost blew the cover. So some acknowledgements, this is an 360 00:40:33,875 --> 00:40:39,833 incomplete list. Thanks for all the NSA Playset Crew for working together on some awesome talks 361 00:40:39,833 --> 00:40:43,750 and working together getting things up there and running. Carsten for his work on 362 00:40:43,750 --> 00:40:48,000 inception again he built inception based on many many prior works before his. Again 363 00:40:48,000 --> 00:40:52,250 Great Scott Gadgets, thank you motivating me to get it started. Thanks for Dean for telling me, 364 00:40:52,250 --> 00:40:58,125 you haven't submitted that to DEF CON yet? I'm like oh I haven't done any work on it yet. 365 00:40:58,125 --> 00:41:04,875 Just submit it. You'll get it done. Don't worry. Snare and Sam did a talk just last year using 366 00:41:04,875 --> 00:41:11,458 FPGA board, which is basically the exact same thing as this, but you know. It's expensive. 367 00:41:11,458 --> 00:41:16,458 And everyone else who I forgot to. And Miles for fixing my ugly software code. So any questions? 368 00:41:16,458 --> 00:41:22,625 (  Applause  ) What's your question? (  Inaudible question  ) >> Did you have a question? 369 00:41:22,625 --> 00:41:29,583 Yes? (  Inaudible question  ) >> I don't know anything about the mitigation in Windows 8.1. So 370 00:41:29,583 --> 00:41:35,333 the questions are what mitigations are built into Windows 8.1. I don't know. I 371 00:41:35,333 --> 00:41:42,917 haven't tried it yet. I haven't tried it with 8.1 before. You want an NSA Playset pin. I'm 372 00:41:42,917 --> 00:41:48,917 sorry. >> Anybody that has questions can come to the microphone right here so 373 00:42:11,792 --> 00:42:17,792 everybody can hear the question as well. Thank you. >> It doesn't matter what operating 374 00:42:20,667 --> 00:42:27,958 system they're running or anything because you don't need any drivers? You just go ahead 375 00:42:27,958 --> 00:42:33,958 and plug and play? >> Yeah. No drivers needed unless you've got to figure something out in those 376 00:42:36,667 --> 00:42:42,667 Mac versions that we mentioned. >> Is it 4 gigs? Because why isn't it 2 gigs? >> Why 4 gigs? 377 00:42:46,375 --> 00:42:52,375 PCIe has 32 bit DMA natively. That's just... >> Can you offset? >> You can offset it. 378 00:42:54,583 --> 00:43:01,375 You need to change the DMA offset register which requires some device side drivers or 379 00:43:01,375 --> 00:43:06,625 software. Again, you have access to the 40 bits of memory. You can do it with memory and a lot 380 00:43:06,625 --> 00:43:13,083 of stuff there and inject whatever code you want and do fun stuff. >> Thanks for doing 381 00:43:13,083 --> 00:43:20,792 this. >> We have time for two more questions. >> Did you look into USB DMA 3. >> It will 382 00:43:20,792 --> 00:43:26,750 require drivers, though. >> I don't know. Most likely. I don't know. >> I'm more interested in 383 00:43:26,750 --> 00:43:34,500 the  ‑ ‑ running the VMs with certain PCIe. Is the information you presented going to be up on 384 00:43:34,500 --> 00:43:40,667 your website? >> I'm sorry. I can't really hear everything. >> I'm looking for the information 385 00:43:40,667 --> 00:43:47,667 on building external PCIe connected to virtual machines. Have you discussed that a little 386 00:43:47,667 --> 00:43:53,750 bit? >> Using the  ‑ ‑ >> Yes. >> Let me just make an announcement. Somebody dropped 387 00:43:53,750 --> 00:43:59,083 their iPhone in this section. Everybody please check and make sure you have your iPhone on you 388 00:43:59,083 --> 00:44:05,708 if you have such a device. >> I work in building a virtual machine connecting external 389 00:44:05,708 --> 00:44:13,583 PCIe. The information you presented, will they be up on the website? >> I'm sorry. I 390 00:44:13,583 --> 00:44:19,583 thought  ‑ ‑ I can't hear what you are saying. I'm sorry. Yeah. (  Inaudible question  ) >> 391 00:44:35,792 --> 00:44:38,917 We'll talk offline. He wanted to know how to connect external devices to a virtual machine 392 00:44:38,917 --> 00:44:44,917 with PCIe. I think we have one more moment. I guess not. No more questions? Okay. (  393 00:44:51,042 --> 00:44:55,667 Applause  )