00:00:00.067 --> 00:00:06.073 Thanks for coming. I'm going to talk a little bit about having 00:00:08.442 --> 00:00:13.313 some fun with USB and little devices namely the BeagleBone 00:00:13.313 --> 00:00:17.885 Black. What I'm going to talk about in particular is a pocket 00:00:17.885 --> 00:00:23.524 sized device that can be used as a drop box, something you can 00:00:23.524 --> 00:00:27.261 battery power for days, as a remote hacking drone you can 00:00:27.261 --> 00:00:31.565 control from up to two miles away. As an airborne hacking 00:00:31.565 --> 00:00:36.870 drone that you can get by combining one of these devices 00:00:36.870 --> 00:00:43.043 with CR aircraft. As a hacking console. Is that better? All 00:00:43.043 --> 00:00:47.781 right. Now if I have to go to the chiropractic after this 00:00:47.781 --> 00:00:52.519 talk, I'll go to see Mr. Moss for some compensation. No, all 00:00:52.519 --> 00:01:00.360 right. Identify talked about all these things at past conferences 00:01:00.360 --> 00:01:04.765 and tonight I want to talk about some new functionality which is 00:01:04.765 --> 00:01:09.136 in yellow here. In particular I want to talk about how you can 00:01:09.136 --> 00:01:15.042 use devices such as the BeagleBone Black which is a USB 00:01:15.042 --> 00:01:20.213 based attack. And you can write protect the flash drive that you 00:01:20.213 --> 00:01:24.217 might want to use on somebody's system. Do some USB 00:01:24.217 --> 00:01:27.554 impersonation, this is something I talked about at DEFCON 20 00:01:27.554 --> 00:01:30.958 using a micro controller based device and I can show you how to 00:01:30.958 --> 00:01:36.997 do that and do it better with a BeagleBone Black. Using 00:01:36.997 --> 00:01:42.135 [indiscernible] shell scripting using UMC code. And also talked 00:01:42.135 --> 00:01:45.772 about something new, a script able hit device based upon the 00:01:45.772 --> 00:01:49.443 BeagleBone Black. So why should you care about any of this 00:01:49.443 --> 00:01:55.015 anyway? The BeagleBone Black running DEC Linux which is my 00:01:55.015 --> 00:02:00.787 custom pen testing drill, is nice and small. Very flexible. 00:02:00.787 --> 00:02:06.426 And you can be networked with other devices in order to do 00:02:06.426 --> 00:02:10.764 some pretty sophisticated pen tests. You can show up with a 00:02:10.764 --> 00:02:15.369 small bag full of devices and you can do some really cool 00:02:15.369 --> 00:02:18.739 stuff and it doesn't even cost you a lot of money. For less 00:02:18.739 --> 00:02:22.509 than the cost of your mac book you can have your little pen 00:02:22.509 --> 00:02:27.180 testing army and because these are so useful you might have one 00:02:27.180 --> 00:02:32.119 around with you and today I want to talk a little bit about how 00:02:32.119 --> 00:02:36.556 you might be able to exploit some brief physical access that 00:02:36.556 --> 00:02:40.627 you have to a target and see what kind of damage you can do 00:02:40.627 --> 00:02:47.534 in just a couple of seconds. So who am I? Some of you might have 00:02:47.534 --> 00:02:50.971 seen me around. I'm a professor at Bloomsburg University in 00:02:50.971 --> 00:02:57.044 Pennsylvania. I teach forensics, pen testing, fun stuff. Also an 00:02:57.044 --> 00:03:01.548 author, I wrote a book on Linux forensics which was released 00:03:01.548 --> 00:03:05.218 this morning, a pre-release for all the people at DEFCON. We 00:03:05.218 --> 00:03:10.691 love you. Everyone else has to wait a couple weeks and pay 00:03:10.691 --> 00:03:15.796 more. By the way, if you want to get a copy of this book, and a 00:03:15.796 --> 00:03:20.567 copy of the next hacker gadget book, come early tomorrow to the 00:03:20.567 --> 00:03:24.838 security booth because we're blasting through our copies. 00:03:24.838 --> 00:03:29.176 Also another book, hacking and penetration testing with low 00:03:29.176 --> 00:03:33.013 powered devices. Been programming for a while, since 00:03:33.013 --> 00:03:37.651 about 8. Been in assembly since I was ten. Hacking hardware 00:03:37.651 --> 00:03:43.323 since I was 12 or so. Also been known to fly little planes, do 00:03:43.323 --> 00:03:46.860 other aviation stuff. And write courses for pen tester academy 00:03:46.860 --> 00:03:52.432 and some other places. So what am I going to talk about? I'm 00:03:52.432 --> 00:03:58.138 going to give you a quick overview of the DEC clinic on 00:03:58.138 --> 00:04:02.776 the BeagleBone Black. The BB. And we'll talk about how you can 00:04:02.776 --> 00:04:08.782 export an attached USB drive. Talk about how you can write 00:04:08.782 --> 00:04:13.854 enable that exploited drive. This is some stuff that I talked 00:04:13.854 --> 00:04:18.492 about at black hat Europe in 2012 and I'm going to talk about 00:04:18.492 --> 00:04:22.229 USB mass storage device impersonation which we talked 00:04:22.229 --> 00:04:27.100 about at DEFCON 20. And also talk about something new, a 00:04:27.100 --> 00:04:34.307 script able USB hid keyboard. DEC Linux. DEC Linux is based on 00:04:34.307 --> 00:04:38.712 [indiscernible] optimized for the BeagleBone Black and other 00:04:38.712 --> 00:04:43.016 stuff. You can use it as a drop box hacking console. And here 00:04:43.016 --> 00:04:46.086 are a couple of devices running it. You can see I have a quad 00:04:46.086 --> 00:04:51.458 shot running it. That is what I call an air deck. So you can fly 00:04:51.458 --> 00:04:57.998 in and hack people and fly away. I have the hack tar. I have a 00:04:57.998 --> 00:05:02.536 nice little system hidden inside a guitar. One of my favorites is 00:05:02.536 --> 00:05:08.141 the Trojan Dolik (ph.) in this picture. He has a beagle bone 00:05:08.141 --> 00:05:13.580 running the DEC Linux off an adapter. It's a USB powered toy 00:05:13.580 --> 00:05:18.819 which is awesome. You find a Dr. Who fan at your target company, 00:05:18.819 --> 00:05:22.956 and you give them a present. That keeps on giving back to 00:05:22.956 --> 00:05:27.460 you. I have some lunchbox computers. I'm doing a demo lab 00:05:27.460 --> 00:05:34.167 tomorrow at noon if you want to see some of these toys in 00:05:34.167 --> 00:05:38.738 person. So I've added a few modules. The mesh deck that uses 00:05:38.738 --> 00:05:43.543 XP and ZIGB (ph.) networking to control your army of devices 00:05:43.543 --> 00:05:49.015 from up to two miles away. And also the four DEC to do forensic 00:05:49.015 --> 00:05:53.386 stuff. And today I wanted to talk about the U deck, the USB 00:05:53.386 --> 00:06:00.961 based attacks. First of all a little bit about USB on Linux. 00:06:00.961 --> 00:06:08.401 So USB on Linux is often done using gadgets. So there's a USB 00:06:08.401 --> 00:06:13.006 gadget composite device and it's a composite device so there are 00:06:13.006 --> 00:06:18.044 many devices in it such as mass storage, audio networking and 00:06:18.044 --> 00:06:24.217 all kinds of good stuff. If you have a version 4 or higher 00:06:24.217 --> 00:06:29.256 kernel, you can also have it as a hid, a keyboard and/or mouse. 00:06:32.125 --> 00:06:34.694 What about the BeagleBone Black. If you have a BeagleBone Black, 00:06:34.694 --> 00:06:41.101 by default it creates a G multi-device, a gadget 00:06:41.101 --> 00:06:46.206 multi-composite device and normally will export the brute 00:06:46.206 --> 00:06:50.310 partition. The reason it does this, is if you screw up the 00:06:50.310 --> 00:06:55.148 beagle bone, you want to be able to boot it some time in the 00:06:55.148 --> 00:06:59.419 future. So the way this is done is they export your boot 00:06:59.419 --> 00:07:03.890 partition so you can fix it so the thing actually boots again. 00:07:03.890 --> 00:07:10.297 It's also normally configured to set up ethernet other the USB. 00:07:10.297 --> 00:07:14.534 And typically what happens unless you change the default, 00:07:14.534 --> 00:07:19.939 the BeagleBone Black shows up as 182.168.7.2. And your PC has a 7 00:07:19.939 --> 00:07:25.945 dot 1 address. And some Linux distributions that you might run 00:07:30.183 --> 00:07:36.056 also will start a getty terminal process as well. Unfortunately 00:07:36.056 --> 00:07:43.630 the defaults will conflict with what we want to do. So another 00:07:43.630 --> 00:07:48.868 warning I will give you, never export a mounted file system 00:07:48.868 --> 00:07:52.939 unless it's read only on both ends. It's not cool to take your 00:07:52.939 --> 00:07:56.242 root file system or something else that you're writing with 00:07:56.242 --> 00:08:00.780 your OS and export it so that somebody else can also write it. 00:08:03.049 --> 00:08:08.054 So how does this work? In order to export a USB mass storage 00:08:08.054 --> 00:08:15.228 device, here is a little snippet of some shell script. First you 00:08:15.228 --> 00:08:20.867 need to stop the getty device or the getty process I should say 00:08:20.867 --> 00:08:24.904 if it's running. By the way on the DEFCON CD you should have 00:08:24.904 --> 00:08:28.475 all this stuff. So, you know, don't think you have to take 00:08:28.475 --> 00:08:31.711 pictures and type this stuff in later. It should be on the 00:08:31.711 --> 00:08:36.516 DEFCON CD and also available for download other places later. And 00:08:36.516 --> 00:08:42.856 then you have to uninstall the module that is the G 00:08:42.856 --> 00:08:48.194 multi-device using mod probe dash RG multi-and set up a 00:08:48.194 --> 00:08:53.400 couple of variables to store what's been exported and have a 00:08:53.400 --> 00:08:57.904 simple loop that say, hey, if there's something called DUB-SD 00:08:57.904 --> 00:08:59.906 something. If it's on the BeagleBone Black, that must be a 00:08:59.906 --> 00:09:05.845 thumb drive that you installed. So I go through there, it's a 00:09:08.548 --> 00:09:12.886 little bit of shell script magic. And if it's there, I 00:09:12.886 --> 00:09:19.559 unmount it and I add it to my list. Then I strip off some 00:09:19.559 --> 00:09:26.199 commas from that list and export it. So I set some variables for 00:09:26.199 --> 00:09:32.405 a vendor and a product ID. Now how many of you are familiar 00:09:32.405 --> 00:09:37.911 with bash scripting? How many of you are gurus of bash scripting? 00:09:40.380 --> 00:09:45.585 Who knows what the dollar sign double print uses these for? I 00:09:45.585 --> 00:09:51.090 don't see a single -- okay, I see one hand, one hand half way. 00:09:51.090 --> 00:09:54.294 Like I think, no but I don't want him to call on me. This is 00:09:54.294 --> 00:10:00.300 not school. For those of you that don't know, this puts bash 00:10:00.300 --> 00:10:07.407 in math mode. So you'll notice that vendor and product have 00:10:07.407 --> 00:10:10.710 been set up as integers and this allows you to do things like 00:10:10.710 --> 00:10:14.814 increment them. Otherwise these things get treated like strings. 00:10:14.814 --> 00:10:19.185 Just a little tip. Again, you can get all this code off the 00:10:19.185 --> 00:10:23.990 CD. So I echer (ph). Echer? Where the heck did that come 00:10:23.990 --> 00:10:28.061 from? Echo -- the translator should have fun with that one by 00:10:28.061 --> 00:10:35.668 the way -- the vendor ID to a temporary file as well as the 00:10:35.668 --> 00:10:40.740 product ID in case I want to mount this again as write able 00:10:40.740 --> 00:10:47.247 later. And then I run a mod pro command where I give it the G 00:10:47.247 --> 00:10:52.752 multi- and I give it file as an argument. This will take a list 00:10:52.752 --> 00:10:57.457 of comma separated partitions that you want to mount. I tell 00:10:57.457 --> 00:11:04.197 it CD ROM equals 0 which means I am not a CD ROM. And I set it to 00:11:04.197 --> 00:11:08.968 read only. And I give it read only for all of the partitions 00:11:08.968 --> 00:11:13.740 that I'm mounting. Say, yes, it's removable and set the 00:11:13.740 --> 00:11:18.378 vendor and product ID. Although honestly for this purpose, just 00:11:18.378 --> 00:11:21.447 to write protect it, I don't need to do that. But we'll see 00:11:21.447 --> 00:11:24.517 it later when we try to do an impersonation why this comes in 00:11:24.517 --> 00:11:30.523 handy. Let's try a demo. At the first every Friday night 00:11:33.826 --> 00:11:39.832 keynote. Okay. Doesn't look like we have any audio. Let's see if 00:11:43.303 --> 00:11:51.177 I can remember how this goes. All right. So here I have a 00:11:51.177 --> 00:11:56.649 shell. It's an exciting shell. Okay. All right. This is the 00:11:56.649 --> 00:12:00.386 default behavior. I plugged in the BeagleBone Black and it 00:12:00.386 --> 00:12:07.060 exported the root file system. And you'll notice that it just 00:12:07.060 --> 00:12:12.098 connected me to the network. So this is kind of what happens by 00:12:12.098 --> 00:12:18.104 default. I do. Please stand by. Is it this? It's not this. First 00:12:53.439 --> 00:12:59.979 I'm going to SSH into my beagle bone. I'm going to run a script. 00:12:59.979 --> 00:13:03.583 All right. Let's try that one again. In this video I want to 00:13:03.583 --> 00:13:08.154 show you what happens when you normally plug in a BeagleBone 00:13:08.154 --> 00:13:13.226 Black. Here I have a BeagleBone Black and I'm just going to plug 00:13:13.226 --> 00:13:17.497 it into my laptop here and it's going to load that USB 00:13:17.497 --> 00:13:20.900 multi-module. So it will take just a little bit. And what 00:13:20.900 --> 00:13:24.370 you'll see is my computer is going to display a message 00:13:24.370 --> 00:13:28.808 saying that it's connected another network device. As you 00:13:28.808 --> 00:13:33.880 can see it's also pulled up the boot partition from my EMMC. And 00:13:33.880 --> 00:13:38.217 there you have it. It's connected to wired connection 00:13:38.217 --> 00:13:41.521 two and here is my boot partition. There's not a lot on 00:13:41.521 --> 00:13:48.161 it. And it's done again so that you can recover a broken system. 00:13:48.161 --> 00:13:52.298 So you can go in there and fix something you screwed up on the 00:13:52.298 --> 00:13:56.736 boot. So here I am, on my computer if I do an LS USB I 00:13:56.736 --> 00:14:00.740 will notice here is that new Linux foundation, multifunction 00:14:00.740 --> 00:14:06.079 gadget. If I do an F con fig, I will see sure enough here is 00:14:06.079 --> 00:14:10.116 these two. It's statically assigned IPs and it will give 00:14:10.116 --> 00:14:17.090 you 7.1 on the PC side and 7.2 on the beagle bone side. If I do 00:14:17.090 --> 00:14:22.295 a ping, there it is. Great. That's the default. What if we 00:14:22.295 --> 00:14:27.200 want to export -- first I'm going to SSH into my beagle 00:14:27.200 --> 00:14:34.207 bone. I'm going to run a script. And again, what do you see? You 00:14:34.207 --> 00:14:40.947 see on my laptop that it was disconnected because that device 00:14:40.947 --> 00:14:44.717 has gone away. And what showed up on my other screen today is 00:14:44.717 --> 00:14:49.088 here is a melt able partition from that device. So this all 00:14:49.088 --> 00:14:53.426 worked. Let me go and open a shell on my Linux machine. If I 00:14:53.426 --> 00:14:59.432 do a mount I'm going to see, right here I have a read-only 00:14:59.432 --> 00:15:01.968 mount just as I want it. There you have it, I have exported a 00:15:01.968 --> 00:15:07.240 thumb drive that was plugged into my BeagleBone Black to a PC 00:15:07.240 --> 00:15:13.446 as read-only. Now one thing I should also point out in this 00:15:13.446 --> 00:15:18.017 demo, I'm running a series of scripts. You can very easily set 00:15:18.017 --> 00:15:21.287 up some buttons and things on the BeagleBone Black to do this. 00:15:21.287 --> 00:15:25.525 But just to make the demos a little simpler for this talk, I 00:15:25.525 --> 00:15:30.029 didn't do that. But it's very easily done. So now if you 00:15:30.029 --> 00:15:35.268 decide that you're ready to make it write able, maybe you're 00:15:35.268 --> 00:15:41.307 trying to exfiltrate some data, please do this after you kill 00:15:41.307 --> 00:15:46.212 antivirus. And I will leave it up to you to interpret the 00:15:46.212 --> 00:15:52.485 acronym DFIU. Those of you who have been to hacker jeopardy 00:15:52.485 --> 00:15:59.125 should know what that means. You can easily remount it using 00:15:59.125 --> 00:16:02.228 another bash script. And basically I just look for that 00:16:02.228 --> 00:16:06.999 temporary file and say, hey, let's redo that and make it 00:16:06.999 --> 00:16:13.005 write able. And it goes kind of like this. So now you've gone 00:16:15.675 --> 00:16:18.778 onto the system and used all the tools that you have on your 00:16:18.778 --> 00:16:20.947 thumb drive which were read only. You've killed antivirus, 00:16:20.947 --> 00:16:24.550 and all those other things and it's time to exfiltrate some 00:16:24.550 --> 00:16:31.390 data. How can you do that? Well, you just need to remount your 00:16:31.390 --> 00:16:37.063 drive as readable and write able, like so. Done. I go back 00:16:37.063 --> 00:16:42.702 to my PC. You'll notice the PC popped up this drive. I also 00:16:42.702 --> 00:16:48.374 will get reconnected on my ethernet. Here on my laptop. I 00:16:48.374 --> 00:16:52.678 mount and you will see that sure enough, there you have it. I now 00:16:52.678 --> 00:16:58.384 have a readable and write able partition that has been exported 00:16:58.384 --> 00:17:02.288 from the thumb drive attached to my BeagleBone Black and it was 00:17:02.288 --> 00:17:08.361 that simple. Let's have some fun now. Let's talk about USB mass 00:17:08.361 --> 00:17:13.065 storage impersonation. So some people may think they can block 00:17:13.065 --> 00:17:16.702 users from mounting unauthorized thumb drives. And typically 00:17:16.702 --> 00:17:21.040 they're going to do this using some end point security software 00:17:21.040 --> 00:17:27.346 and/or some rules such as UDEF rules to filter by VID (ph.) and 00:17:27.346 --> 00:17:31.684 PID (ph.). Now as I said before, I presented a micro controller 00:17:31.684 --> 00:17:36.022 based device at DEFCON 20 on how to do this. But you can do the 00:17:36.022 --> 00:17:40.493 same thing with a BeagleBone Black and some shell scripting. 00:17:40.493 --> 00:17:43.930 Now one important thing to note here is you can get a lot better 00:17:43.930 --> 00:17:47.300 performance through the micro controller based device that I 00:17:47.300 --> 00:17:53.806 showed, was only capable of full speed or 12 megabits per second 00:17:53.806 --> 00:17:58.778 versus high speed or 80 megabits per second that you can get with 00:17:58.778 --> 00:18:04.550 a BeagleBone Black. So basically you have a little bit of set up 00:18:04.550 --> 00:18:08.754 and again all this should be on the CD. I've got a usage 00:18:08.754 --> 00:18:15.695 statement. I declare as integers, vend and prod. That is 00:18:15.695 --> 00:18:20.366 where you get the declare -- I and a delay. And I parse some 00:18:20.366 --> 00:18:25.571 arguments and I snip that as just kind of boring stuff. And 00:18:25.571 --> 00:18:29.575 this is a picture, by the way of that device that I presented at 00:18:29.575 --> 00:18:35.581 DEFCON 20. So step two, you need to unmount the drive. So how do 00:18:40.853 --> 00:18:43.122 you do that. You check and see if the getty process is running 00:18:43.122 --> 00:18:49.128 and if it is, you stop it. You also unload G multi. Set up some 00:18:51.897 --> 00:18:55.968 variables and this looks very similar to our previous script 00:18:55.968 --> 00:19:00.339 with one important difference. And that comes upright about 00:19:00.339 --> 00:19:04.543 here. By the way, hopefully your unmounting is more graceful than 00:19:04.543 --> 00:19:09.048 this lady in this picture getting off this horse. So I 00:19:09.048 --> 00:19:15.221 have a file with the entire Linux mid PID database. So what 00:19:15.221 --> 00:19:21.761 you can do is spin through this file and see if it gets mounted 00:19:21.761 --> 00:19:27.733 or not. And if it gets mounted, it's not getting blocked, you 00:19:27.733 --> 00:19:35.274 just say, great. And there you go. So let's have a little demo 00:19:35.274 --> 00:19:39.412 of this. Now, let's have some fun with some USB impersonation. 00:19:39.412 --> 00:19:47.019 I'm going to go ahead and run LS USB and now I'm going to plug in 00:19:47.019 --> 00:19:53.159 a SanDisk drive. And I'm going to rerun LS USB, you can see 00:19:53.159 --> 00:19:58.664 that it mounted successfully. Here it is. So I want this to 00:19:58.664 --> 00:20:02.902 impersonate something else. How am I going to do that? I'm going 00:20:02.902 --> 00:20:07.039 to do that using my BeagleBone Black. So let me go ahead and 00:20:07.039 --> 00:20:12.445 unplug this and I'll plug in the BeagleBone Black. So now I've 00:20:12.445 --> 00:20:16.415 logged onto my BeagleBone Black and we're going to go ahead and 00:20:16.415 --> 00:20:19.618 run my script and I'm going to let it run through a couple of 00:20:19.618 --> 00:20:25.624 these. And you can see that it's mounted -- I'm not actually 00:20:30.830 --> 00:20:35.367 blocking in this case, but if you see my talk about DEFCON 20 00:20:35.367 --> 00:20:40.706 you know about how all that works and everything. Now if I 00:20:40.706 --> 00:20:48.447 go back to my Linux machine I will see that sure enough, if I 00:20:48.447 --> 00:20:54.453 run my LS USB, boom, my little SanDisk drive has suddenly 00:20:56.555 --> 00:21:01.026 become a Kingston drive. There you go. I was able to do this 00:21:01.026 --> 00:21:04.497 with a micro controller based device and some custom coding 00:21:04.497 --> 00:21:08.801 and now I've done the exact same thing with a little bit of shell 00:21:08.801 --> 00:21:15.007 scripting in a BeagleBone Black. All right. So again, a lot 00:21:15.007 --> 00:21:19.445 faster, 40 times faster. But now let's have some real fun. Let's 00:21:19.445 --> 00:21:24.483 do something completely new and show you how you can make a USB 00:21:24.483 --> 00:21:29.455 hid device, again, completely in bash script. You don't even have 00:21:29.455 --> 00:21:33.826 to write python, not that I don't love python. I'll show you 00:21:33.826 --> 00:21:39.131 some python script you can use with this. But how do you do 00:21:39.131 --> 00:21:43.769 this? Step one, you have to unload that G multi. And this 00:21:43.769 --> 00:21:49.141 should look kind of familiar by now. Now step two, you have to 00:21:49.141 --> 00:21:54.046 create something called a con fig file system. It's a special 00:21:54.046 --> 00:21:58.050 pseudo-file system, if you will. By the way this lovely little 00:21:58.050 --> 00:22:03.088 picture here talking about how you shouldn't mix con fig file 00:22:03.088 --> 00:22:08.527 system and separate gadgets. I didn't make this. There is 00:22:08.527 --> 00:22:12.131 enough people that know this is a problem that I actually found 00:22:12.131 --> 00:22:15.901 this little picture on the internet. So you have to 00:22:15.901 --> 00:22:23.475 configure a file system and you will probably have the base 00:22:23.475 --> 00:22:28.214 directory where this is mounted under CIS (ph.) kernel con fig. 00:22:28.214 --> 00:22:31.283 And if it's there, you might have something mounted. So you 00:22:31.283 --> 00:22:36.455 want to unmount it and then mount a new con fig file system 00:22:36.455 --> 00:22:41.293 to that place. And then you have to create a device. How does 00:22:41.293 --> 00:22:47.433 that work? You take that area and you make a directory for 00:22:47.433 --> 00:22:52.404 your keyboard device. And you echo vendor IDs, product IDs, 00:22:52.404 --> 00:22:58.410 pick your favorite. And you echo a device and a USB version as 00:23:00.512 --> 00:23:07.219 I've done here. You add a configuration. So here I have a 00:23:07.219 --> 00:23:11.590 configuration, I make a new directory. And I echo things 00:23:11.590 --> 00:23:14.460 like the maximum power and I create new directories, hid USB, 00:23:14.460 --> 00:23:20.466 0, and echo some more stuff like the subclass, protocol, report 00:23:24.703 --> 00:23:32.611 links, et cetera. And then I finalize it. So step five, you 00:23:32.611 --> 00:23:36.448 need a report descriptor. So those of you that know something 00:23:36.448 --> 00:23:42.254 about USB know that everything has descriptors to describe it. 00:23:42.254 --> 00:23:44.356 So they're used for a lot of things and there is something 00:23:44.356 --> 00:23:49.194 called a hid report descriptor that is used to define reports 00:23:49.194 --> 00:23:55.200 from keyboards, mice, joy sticks, et cetera. So you need 00:23:55.200 --> 00:23:58.671 one of these things. And what you have to do is create a SIM 00:23:58.671 --> 00:24:04.910 link for your configuration and activate it. So first you can 00:24:04.910 --> 00:24:10.182 copy this report descriptor. So I have it just as a BIN file and 00:24:10.182 --> 00:24:15.754 copy it into my con fig file system. Create a SIM link and 00:24:15.754 --> 00:24:21.760 echo HDRC .0.auto to a specific place and boom you have a 00:24:24.196 --> 00:24:30.202 device. So this is the eye test slide for this talk. No, I don't 00:24:32.571 --> 00:24:36.342 expect you to be able to read this. I just put this in here so 00:24:36.342 --> 00:24:40.212 when you get the slide deck you can see it. This is the details 00:24:40.212 --> 00:24:45.150 of what's in that binary file and descriptions for every 00:24:45.150 --> 00:24:51.790 single byte on what this report descriptor looks like. So that's 00:24:51.790 --> 00:24:56.195 boring. Let's have a demo. Now we're going to go ahead and 00:24:56.195 --> 00:24:59.965 create our hid device. First I'm going to run my script that we 00:24:59.965 --> 00:25:07.539 hid. If I go down to my Linux system I'm going to do an LS USB 00:25:07.539 --> 00:25:11.744 and I will see a new device. Now Linux is a little bit smarter 00:25:11.744 --> 00:25:15.547 than windows. For the Linux devices, it just comes up and it 00:25:15.547 --> 00:25:22.821 says 1337, 1337. Because it will actually look it up. If you give 00:25:22.821 --> 00:25:27.593 it a fake vendor and product ID, it will say, no, that's not 00:25:27.593 --> 00:25:33.966 right. I know that that's not right. So in general it's a lot 00:25:33.966 --> 00:25:39.972 smarter than windows. There you have it. If I do an LS USB -- V 00:25:45.511 --> 00:25:50.015 -- D on 1337.1337 you see it gives me a bunch of information 00:25:50.015 --> 00:25:55.888 and here it tells me this is in fact a hid and it's a keyboard. 00:25:58.557 --> 00:26:01.660 All right. So now we have a device but we're not quite ready 00:26:01.660 --> 00:26:05.464 to do anything useful with it. So in order to do something 00:26:05.464 --> 00:26:12.538 useful with this device, you have to send some reports. And 00:26:12.538 --> 00:26:15.741 the format for these reports is pretty simple. There is a 00:26:15.741 --> 00:26:21.980 modifier. So you have a shift key, control key, width shift 00:26:21.980 --> 00:26:27.553 key, et cetera and a reserved byte and a bunch of key codes 00:26:27.553 --> 00:26:30.789 and you're allowed to press up to 6 keys at a time. Why you 00:26:30.789 --> 00:26:35.594 would want to do this? I don't know. But it's fun. So how can 00:26:35.594 --> 00:26:40.065 you do this. Now, I should say this, you've created the device 00:26:40.065 --> 00:26:45.370 and you can just echo stuff to the device, again, on the 00:26:45.370 --> 00:26:50.309 command line. But who wants to do that. We like python, right. 00:26:50.309 --> 00:26:53.412 Python is every pen tester's friend. How can you do this in 00:26:53.412 --> 00:26:56.181 python to make it a little easier. Some prelims in the 00:26:56.181 --> 00:27:03.155 python code. You import a few things like Struct (ph.) and 00:27:03.155 --> 00:27:10.963 time and you define a few modifiers to different shift 00:27:10.963 --> 00:27:16.969 keys, et cetera. And then I create this little list of ASCII 00:27:16.969 --> 00:27:22.274 to key mappings so you can map key codes to ASCII codes. 00:27:22.274 --> 00:27:25.978 Because of course they're not the same. Why would they be the 00:27:25.978 --> 00:27:33.118 same? That would be easy. If it's easy then people don't get 00:27:33.118 --> 00:27:37.389 jobs, right. We have to make it hard. You have to be smart to do 00:27:37.389 --> 00:27:43.095 this stuff and then we get paid more money. So the next thing I 00:27:43.095 --> 00:27:48.934 do is I create a hit class and how many of you are familiar 00:27:48.934 --> 00:27:54.673 with python? Okay. So you know how to create classes in python. 00:27:54.673 --> 00:28:01.613 And here I have a constructure. You can pass the hid device file 00:28:01.613 --> 00:28:06.685 name. And I define a whole bunch of nice little helper functions 00:28:06.685 --> 00:28:12.457 such as send key. If you send a key, you to send two reports. 00:28:12.457 --> 00:28:15.994 Unless you want to fill the screen with the same key. You 00:28:15.994 --> 00:28:19.698 have to send a report that says I pressed a key and another 00:28:19.698 --> 00:28:23.602 report that says I stopped pressing the key. That's what 00:28:23.602 --> 00:28:27.105 you'll see here. It says write the report and then it sends out 00:28:27.105 --> 00:28:31.643 a nice zeroed out report which means I stopped pushing buttons. 00:28:31.643 --> 00:28:36.982 And then of course I defined some other helpful functions 00:28:36.982 --> 00:28:41.787 such as send a shifted key. Send a character. Send a string, et 00:28:41.787 --> 00:28:45.958 cetera. And I didn't show it here but I have a whole bunch of 00:28:45.958 --> 00:28:50.963 nice little hot key things such as please left the screen. 00:28:50.963 --> 00:28:54.700 Please flip the screen upside down if you're running windows, 00:28:54.700 --> 00:29:00.005 bring up a terminal. If you're running Linux, et cetera. So 00:29:00.005 --> 00:29:06.411 let's do a simple Linux attack. So here in my script I'm just 00:29:06.411 --> 00:29:10.782 going to type out your environment variables, I'm going 00:29:10.782 --> 00:29:16.855 to run nano and create a new file called hacked. And I'm just 00:29:16.855 --> 00:29:20.225 going to put in a couple of strings, you're so hacked. And 00:29:20.225 --> 00:29:25.564 I'm going to send some keys to exit nano and save the file, of 00:29:25.564 --> 00:29:30.168 course. And then I'm going to pass your password files and 00:29:30.168 --> 00:29:37.209 then I'm going to clear the screen. How does this look? I 00:29:37.209 --> 00:29:42.080 created the USB hid device. But we haven't done anything useful 00:29:42.080 --> 00:29:47.753 with it yet. In order to do that we can run our python script. 00:29:47.753 --> 00:29:51.623 I'm just going to go ahead and run the script I've attached to 00:29:51.623 --> 00:29:57.629 my Linux computer. And boom, I just ran a bunch of stuff. You 00:30:00.432 --> 00:30:07.105 didn't even see it it was so fast. If I do an LSTXT you'll 00:30:07.105 --> 00:30:12.210 notice that I created a new file, hacked. And another one 00:30:12.210 --> 00:30:18.216 called got your passwords. So if I [indiscernible] hacked, I see 00:30:20.886 --> 00:30:27.759 it says you are so hacked. And if I cat got your passwords, it 00:30:27.759 --> 00:30:33.999 in fact, brings up my password file. So there you have it. 00:30:33.999 --> 00:30:41.640 Pretty simple. All right. Now, hacking and attacking Linux is 00:30:41.640 --> 00:30:47.746 fun, but come on, windows is more fun, right? I mean windows 00:30:47.746 --> 00:30:51.850 isn't good for anything else. Might as well be good for an 00:30:51.850 --> 00:30:58.890 attack target. Let's do a simple little windows attack. Sodown, 00:30:58.890 --> 00:31:02.360 like I said here, what else is it good for anyway. Here what 00:31:02.360 --> 00:31:06.898 I'm going to do is create a hid device. I'm going to send the 00:31:06.898 --> 00:31:10.836 window hierarchy that says please run something and send 00:31:10.836 --> 00:31:17.008 the line, note back, please. And I'm going to again, put a bunch 00:31:17.008 --> 00:31:23.014 of text in a file. I'm going to send alt F. And then X which 00:31:26.218 --> 00:31:31.857 will save and exit. I'll hit enter to say yes please, save my 00:31:31.857 --> 00:31:37.863 file. I will send the line hacked TXT when it says what 00:31:37.863 --> 00:31:41.633 would you like to call that file. And I'm going to send the 00:31:41.633 --> 00:31:46.204 window upside down screen command which will flip your 00:31:46.204 --> 00:31:51.743 screen upside down and I'm going to lock the screen. So it's nice 00:31:51.743 --> 00:31:53.745 upside down locked screen potentially. Let's go ahead and 00:31:53.745 --> 00:31:59.751 run this. Now I'm going to go ahead and attack windows. And 00:32:18.770 --> 00:32:22.941 there you have it. By the way I sent a command to flip the 00:32:22.941 --> 00:32:26.511 screen which didn't work in this case because it's running in a 00:32:26.511 --> 00:32:30.715 virtual box but normally it would have. If I log back in and 00:32:30.715 --> 00:32:36.721 I look at my documents, I see a new file. So of course I can do 00:32:44.830 --> 00:32:47.766 some other fun stuff. But you know, I think you guys get the 00:32:47.766 --> 00:32:55.006 point. And given that it's late, just to let you know, if you 00:32:55.006 --> 00:33:00.312 have any questions, tomorrow at noon to 2 I'm doing a demo lab. 00:33:00.312 --> 00:33:05.217 Also you might find me chained to the security tube booth over 00:33:05.217 --> 00:33:11.156 in the vendor area. So one thing you can do there, yesterday I 00:33:11.156 --> 00:33:14.426 talked about this new device that came out called a catch 00:33:14.426 --> 00:33:20.298 wire. And the manufacturer has graciously donated some nice 00:33:20.298 --> 00:33:24.369 little bundles with their devices, running my pen testing 00:33:24.369 --> 00:33:27.973 Linux that we're giving away. So if you drop by the booth you can 00:33:27.973 --> 00:33:32.811 register to win free stuff which -- who likes free stuff? All 00:33:32.811 --> 00:33:39.584 right. I like free stuff, too. So you can get a nice gift set 00:33:39.584 --> 00:33:46.758 worth over 600 bucks. We have two of those to give away. And 00:33:46.758 --> 00:33:50.128 of course, you can always come by and say hello. I'll have all 00:33:50.128 --> 00:33:56.835 of my toys tomorrow. I'll have my lunchbox computers, I'll have 00:33:56.835 --> 00:34:01.373 a BeagleBone Black that's running this stuff. And a couple 00:34:01.373 --> 00:34:04.276 of catch wires as well if you want to see that. So everything 00:34:04.276 --> 00:34:07.579 that I talked about today, everything that I talked about 00:34:07.579 --> 00:34:12.350 yesterday. If you want to come and get touchy feely, it's that 00:34:12.350 --> 00:34:17.389 kind of conference, I'll let you touch my junk. If you want to 00:34:17.389 --> 00:34:21.559 come tomorrow at noon. Thanks for coming at 7 o'clock on a 00:34:21.559 --> 00:34:27.565 Friday. And I'll see you guys around. ...(applause)...