00:00:00.234-->00:00:04.338 >>So uh you know it takes a lot to talk in front of all you guys. And uh we got two newbs 00:00:04.338-->00:00:09.343 today. So let's give it up for Michael and Colin. [applause] [presenter whistles] >>Okay, 00:00:23.023-->00:00:28.028 guys. >>So cheers if you got 'em. >>What's in the glass? >>Whiskey. >>Whiskey. [clinks 00:00:36.503-->00:00:38.505 their glasses] [applause] >>Alright, welcome everybody. We're going to be talking today 00:00:38.505-->00:00:43.310 about barc0wned and barcode scanner hacking. First quick introduction, even though you 00:00:43.310-->00:00:47.447 probably don't care who we are, I'm Michael. I'm obsessed with barcode scanners. As you can 00:00:47.447-->00:00:54.054 see, I have way too many of them. Um, Colin? >>Hey, I'm Colin. I do stuff on the web, 00:00:54.054-->00:00:59.693 professionally. [Michael laughs]. >>He's what we call a webmaster. [Colin laughs] >>So 00:00:59.693-->00:01:06.099 something we kind of notice and we may take for granted is that car codes are everywhere. You 00:01:06.099-->00:01:11.171 might not notice them in real life, but they really will, they really kind of permeate 00:01:11.171-->00:01:16.843 everything we buy, everything we use. And you may think oh there's some obvious ones. 00:01:16.843-->00:01:21.415 There's a lot of non-obvious ones. Like, there's 3 barcodes on that USPS label, there's one 00:01:21.415-->00:01:27.621 on Intel CPUs, there's some on most printers that print color, even hospital wristbands. And as 00:01:27.621-->00:01:34.361 a result, because those barcodes are everywhere, it means the scanners are everywhere. And so 00:01:34.361-->00:01:38.432 these scanners are basically just kind of hiding all over the place. If you go to almost any 00:01:38.432-->00:01:43.203 store, you'll find them, if you go to an airport, you'll find them. But they're really an, 00:01:43.203-->00:01:48.141 they're an attack victor. So before we get into that, let's just talk about barcodes and 00:01:48.141-->00:01:54.014 kinda what they are. So normally they decode to text. These are just a couple of different types 00:01:54.014-->00:01:59.486 of barcodes called symbologies. Don't to care what they are, just have to know that they 00:01:59.486-->00:02:03.991 decode to text. Some of them have restrictions like the UPC on the right where it can only 00:02:03.991-->00:02:10.197 decode to certain numbers. Some like PDF417 can hold a lot of data. And others like QR are 00:02:10.197-->00:02:15.202 really good at being viewed at weird angles. But the thing is, these scanners are mostly the 00:02:17.270-->00:02:19.339 same. These manufacturers, this one, most of these are pictures. Most of these are symbol 00:02:19.339-->00:02:21.908 scanners and most of them are vulnerable to attack. They sell, I mean, look at this. These are 00:02:21.908-->00:02:26.913 about like ten years apart. They look exactly the same. The scanner, the equipment inside 00:02:32.019-->00:02:34.021 are pretty much, the controller inside is based on running the same software, the same 00:02:34.021-->00:02:37.124 features, year to year. Most of them will act as an HIE device. They act a keyboard, they type 00:02:37.124-->00:02:42.129 in the keys, and buffer by, key by key, they type the buffer out. So with all these market 00:02:49.836-->00:02:56.176 scanners everywhere acting as keyboards. What could we do if we could change the text or send 00:02:56.176-->00:03:01.114 arbitrary keystrokes or do things like Windows key R? What could we do with proper 00:03:05.886-->00:03:10.891 permission and a legal sanction PAN test? So it's not a bug what this is. A lot of manufacturers 00:03:13.760-->00:03:18.765 will add a lot of special features in. Code 128, that's what that barcode right 00:03:20.967-->00:03:25.305 there,that was one of the first slide. It says FARC underneath that but there's a hidden 00:03:25.305-->00:03:30.811 character. That one in the red right there, right after the start code, is FNC3, which is 00:03:30.811-->00:03:35.682 our best friend in some of these examples. It tells the scanner this isn't a normal barcode. 00:03:35.682-->00:03:40.620 This is a programming barcode. A lot of scanners support this, it is a little manufacturer 00:03:40.620-->00:03:45.258 specific. And if this is starting to sound familiar, it's because this is basically 00:03:45.258-->00:03:50.464 In-band signaling. If you guys haven't seen the blue locks on the left, that's that's 00:03:50.464-->00:03:55.469 basically what this is just modernized. We haven't learned our lessons from decades ago. So 00:03:57.737-->00:04:02.776 why does this programming exist that we can do this from? It mainly exists for legacy 00:04:02.776-->00:04:07.781 systems. So in this example, we have a legacy system we called Cyberdyne cat ERP. And we used 00:04:10.150-->00:04:16.123 it to track and herd our cats. A novel, a noble goal. It's a little too, it was made a long 00:04:16.123-->00:04:19.759 ago, nobody wants to replace it, nobody wants to modify it, it's way too expensive. It's probably 00:04:19.759-->00:04:23.296 4 trillion or something. But we've been told to make it faster. So we wanna make it 00:04:23.296-->00:04:27.768 faster with barcodes. This is actually a real fake example. There is actually a C sharp 00:04:27.768-->00:04:32.105 program running in the background that we uh create just to show this off cuz I 00:04:32.105-->00:04:39.012 don't know how to program in Fortran. So here we have my cat Java. Um, he's a domestic short 00:04:39.012-->00:04:44.017 hair, he's born like 2005ish. And our system wants those three inputs. And so normally we would 00:04:46.186-->00:04:52.626 have to look at the label on the cat, grab their name, type it in manually, press tab, type in the 00:04:52.626-->00:04:58.999 breed, press tab, type in the year, and finally we hit F12 to save. Well that takes a lot of 00:04:58.999-->00:05:04.571 work, there's a lot of room for error, and it's generally just kind of slow. So what if we 00:05:04.571-->00:05:11.511 solved that by bar coding our cats because how could that go wrong? So we create a barcode 00:05:11.511-->00:05:17.817 like the one on the upper right that says DSH, domestic short-hair, 2005 Java. Now we've 00:05:17.817-->00:05:22.889 got this barcode. We can't modify the ERPA to know barcodes. It's just like I 00:05:22.889-->00:05:27.561 expect a keyboard and that's it. And so these rules that we generate, they're gonna go a 00:05:27.561-->00:05:33.300 little bit like this. So first we got a cursor and we've got a buffer of the actual scanned 00:05:33.300-->00:05:39.105 barcode. And you see, we've got, we're starting at right before D or on D. So we move the cursor 00:05:39.105-->00:05:45.712 forward a little bit and now we move it forward 7 characters. 7 characters are a defined length 00:05:45.712-->00:05:50.584 for how big those two fields can be. And then the rest of the barcode is the cat's name. So we 00:05:50.584-->00:05:54.321 could have a name that's 8 characters long, 12 characters long, doesn't matter. And now 00:05:54.321-->00:06:00.193 we're at this cursor point, we send that info and we press tab. And you see it types it for us 00:06:00.193-->00:06:06.867 and moves to the next field. Now we go back because the next field is DSH or breed, which is 00:06:06.867-->00:06:13.206 DSH. The cursor moves back to the front, we type in 3 characters and we hit tab. 00:06:13.206-->00:06:16.343 Again, it doesn't matter what those characters are, we're just typing 3 characters from the 00:06:16.343-->00:06:22.182 buffer. And then same thing, the buffer's, cursor's already moved forward for us, so all we do is 00:06:22.182-->00:06:27.621 type 4 characters and we hit F12. And it saves it for us. So all you have to do is do one 00:06:27.621-->00:06:33.293 quick scan on this legacy system that nobody knows how to modify and we can actually automate 00:06:33.293-->00:06:37.264 that. That's why these rules exist, that's why manufacturers added them 20 or so years ago. 00:06:37.264-->00:06:42.269 And so we're back at that, we've put our barcode on our cat, uh, which is a very successful 00:06:44.271-->00:06:51.011 endeavor, I might add. And we're gonna just do a scan. So this is what the scan looks like, simple 00:06:51.011-->00:06:56.016 as that. It's extremely fast, a lot less error prone. But of course, we can make our own 00:06:58.718-->00:07:03.290 malicious rules, we can make our own malicious programming. So we can do all sorts of things. We 00:07:03.290-->00:07:08.361 can specify criteria for these rules. So we can say just do it on everything, do it on certain 00:07:08.361-->00:07:14.868 barcodes, ones that have a certain text to it, or a certain symbologies, like EPC. Or, and 00:07:14.868-->00:07:18.905 then once we're done with that, we can specify actions. So you can see here on the left that 00:07:18.905-->00:07:24.911 is, er the right, that is the actual programming barcode for that cat ERP system. So if you 00:07:24.911-->00:07:30.083 scan that with this scanner, it'll do that. A lot of these scanners can actually support 00:07:30.083-->00:07:34.487 multiple rules, as we'll see later. They do have a size limit, but it's fairly 00:07:34.487-->00:07:38.725 expansive. You can't write a novel on power show, like you can't write in the hundreds of 00:07:38.725-->00:07:44.397 characters, but you can get a lot in. These are some of the actions we can do, some of the 00:07:44.397-->00:07:50.270 ideas. So we can modify and replace text on the fly. We can just ignore text, so you scan 00:07:50.270-->00:07:55.575 something that doesn't actually give you any text. We can add extra characters at the end, we 00:07:55.575-->00:08:01.448 can do special keys, like Windows control alt, and we can just do nothing. We can soft 00:08:01.448-->00:08:05.418 brick scanners by scanning a rule that says do nothing, and the scanner is dead until you 00:08:05.418-->00:08:09.756 reset it to default. There's a classic attack you guys have probably heard of it, of like, 00:08:09.756-->00:08:14.127 you know, into the Wal-Marts, where you put a sticker over the barcode with a different barcode 00:08:14.127-->00:08:19.399 for something cheaper, but it's super obvious like that. This is a digital equivalent of that. We 00:08:19.399-->00:08:24.404 can change those barcodes on the fly, make your 200 dollar item ring up as 10 bucks. So this 00:08:26.406-->00:08:33.380 culminates in our tool called barcOwned. BarcOwned is an attack IDE developed by Colin in 00:08:33.380-->00:08:39.419 JavaScript. We developed payloads in JSON and it makes it really easy to rap-rapidly 00:08:39.419-->00:08:44.190 design them. See, these barcode scanners they don't give you a lot of feedback, if you give it 00:08:44.190-->00:08:50.196 something invalid, they just go, they give a nuh, a bad beep instead of a good beep. And 00:08:50.196-->00:08:54.534 that's all. You don't have any feedback, there's no out put, there's no logs. Trying to do 00:08:54.534-->00:09:01.107 these barcodes manually is possible but literally spent the past year working on that. So 00:09:01.107-->00:09:07.580 this makes it easy for you guys to just write some JSON, it's little harder than Ducky Script. 00:09:07.580-->00:09:13.052 You know, Ducky Script, it it's kinda basic. This allows you to do a lot more, but um, but this 00:09:13.052-->00:09:16.990 takes away all the complexity of doing those barcodes. And you don't have to decipher any 00:09:16.990-->00:09:22.462 manuals. Right now so far as simba-symbol, which I think is like 40 percent of the market, 00:09:22.462-->00:09:27.934 um, most of the scanners support this like Honeywell, NCR. And it's open source under the MIT 00:09:27.934-->00:09:32.272 license. Here on the right you can see just a simple this-is-how-we-run calculator. 00:09:32.272-->00:09:37.277 So let's show the demo. [laughter] >> Hmm, first demos. Run calc. This is the barcOwned 00:09:48.121-->00:09:53.259 website, BarcOwned dot com, it's live right now. Quick home page right there and it takes us into 00:09:53.259-->00:09:59.999 a quick ID. First thing we're gonna do is run calc. I know this text is a little small but 00:09:59.999-->00:10:05.004 don't worry about it. So you see on the bottom we have exclamation point calc. What we, 00:10:07.574-->00:10:13.313 that basically defined as a rule where if a barcode starts with exclamation point, we go press 00:10:13.313-->00:10:19.118 Windows key R, we press enter, and when we run, we type in that command and press enter. So this 00:10:19.118-->00:10:25.825 basically allows us to easily build new payloads by just having a simple rule. So this is 00:10:25.825-->00:10:30.497 an example. Let's scan it, this this scanner is fresh, it's reset to default. Here's what it 00:10:30.497-->00:10:37.003 looks like just by itself. Types in exclamation point calc. And here's what happens if we scan 00:10:37.003-->00:10:42.008 that programming barcode. You hear it had a programming noise? [applause and cheers] >>Full 00:10:49.048-->00:10:54.053 screen calc, my favorite [chuckles]. So let's go and try another demo. Next one is wrung 00:11:02.595-->00:11:08.001 command. And so we, that's what the quick iteration looks like. We just go back, click some 00:11:08.001-->00:11:11.271 things up here. We can change things up up here. We can change all this text really easy on the 00:11:11.271-->00:11:16.276 fly. So what we're gonna do is were just gonna run this one. This one has two rules. Gonna 00:11:19.812-->00:11:24.817 scan that. It programs it, and next let's launch command. And now we just have a command 00:11:27.720-->00:11:32.292 propped open. We have extra barcodes. So we can just type in that user. So we can actually 00:11:32.292-->00:11:37.430 type in text in a line by line. So you can have a list of one-liners that you really love 00:11:37.430-->00:11:42.435 and just use them over and over again. And a quick iteration of stuff like this, you can go and 00:11:44.637-->00:11:49.642 say, you know, net user adds, and just go click like that, click run, now we can type user 00:11:55.949-->00:12:00.887 add. Next up, do the serial box to know. So right here we've got an unalt-an unaltered box of 00:12:05.124-->00:12:09.696 s'mores. It's a little smashed from travel here from Dallas, but it's got a barcode on the 00:12:09.696-->00:12:16.636 bottom. Simply BC barcode. We're gonna execute an attack with that barcode. So first let's 00:12:16.636-->00:12:21.641 demonstrate that we scan this, it types in a barcode. Next let's scan the programming 00:12:23.710-->00:12:28.715 barcode. There we go. Let's prep ourselves. We've already got Metasploit running right here, 00:12:36.489-->00:12:41.494 just waiting for our reversal. So let's scan this barcode and see what happens. [laughter] >> 00:12:52.038-->00:12:57.043 Oh come on, you can do it. We had to change our webpost at like 2am and it's super slow 00:12:59.345-->00:13:05.084 right now. But it's working, it should. Just give it time. There we go! And we're gonna switch 00:13:05.084-->00:13:10.089 over to this window. [applause] >> So that's all great. That's all serious. But, you know, what 00:13:19.298-->00:13:23.670 if we just really wanna play some video games? What if we're really feeling down for 00:13:23.670-->00:13:28.675 something more fun? So let's play some Tetris. So right here we'll scan this barcode. It can 00:13:31.277-->00:13:35.281 be a little tricky with the glare on the screen, stage. So there we go, we've got Tetris. 00:13:35.281-->00:13:40.286 We'll put that over here. And we've got photos. [laughter] >>So. [more laughter] >> 00:13:55.268-->00:14:00.206 Basically we've invented the world's shadiest way to play Tetris. [laughter and applause] 00:14:09.716-->00:14:15.388 >>[speaker laughs] [applause] >>And finally let's just show off what we can do with a little 00:14:15.388-->00:14:20.393 bit of mayhem. So we'll go back to our brick payload. So there's the program bar-barcode at the 00:14:28.501-->00:14:35.408 top. So right now, if I scan any of that barcode, it's gonna scan the cereal box demo, but if we 00:14:35.408-->00:14:40.947 scan this one simple programming barcode, we're basically telling the scanner whenever you get a 00:14:40.947-->00:14:47.186 barcode, just leave for 20 seconds and then don't print anything. Any barcode. So let's 00:14:47.186-->00:14:53.826 try and scan the cereal box again. If you can't tell, this thing is not lighting up, it's 00:14:53.826-->00:14:57.897 just sitting there for 20 seconds doing nothing. It looks like it's powered off, the 00:14:57.897-->00:15:02.802 light's off, the button doesn't do anything. It'll just sit for 20 seconds and wait. And the 00:15:02.802-->00:15:08.207 only way to reset it is to go to the factory defaults, which almost no one knows how to do. 00:15:08.207-->00:15:13.179 So once we give it 20 seconds to go through, um, it looks like it's dead. You scan this one 00:15:13.179-->00:15:18.184 barcode, it's basically a zombie for that 20 seconds, we've tried up to like 1 and a half minutes 00:15:21.254-->00:15:26.259 before we got bored, so now if our scanner goes to defaults, we can go back and scan all the 00:15:28.494-->00:15:33.499 barcodes we want. But almost no one knows how to do that. And that whole thing about we find a 00:15:38.404-->00:15:43.409 lot of barcodes hiding everywhere? Well, alright. First let's talk about this.So, first, 00:15:46.412-->00:15:52.451 can you turn it off? And the answer is yes! You can scan that barcode to disable barOwning 00:15:52.451-->00:15:57.456 barcodes. Can anyone guess how you turn them back on? [laughter] >>So some 00:16:07.433-->00:16:13.372 considerations for red team attack. Um, this is really, this is an advanced attack. You can't 00:16:13.372-->00:16:18.744 just walk into a Wal-Mart and just pull something from your phone and hit enter and hope 00:16:18.744-->00:16:24.884 something exploits it. This is something that takes a lot of testing, a lot of recon, but it 00:16:24.884-->00:16:29.856 allows some windows into systems that normally you wouldn't be able to access. They don't have 00:16:29.856-->00:16:34.293 keyboards, they are controlled, you only have access to the barcode or maybe you're not even 00:16:34.293-->00:16:40.833 there. Maybe you send a package with a malicious barcode. One thing to think about, find the 00:16:40.833-->00:16:45.371 beeper hole and cover it up because the programming barcode, at least on symbol scanners, 00:16:45.371-->00:16:48.975 they actually play at full volume. Some of you guys can even hear it in the audience. I 00:16:48.975-->00:16:54.380 have it taped over, but it's really loud. So just cover that up. Another good example is, you 00:16:54.380-->00:16:58.818 can actually bring your own scanner. These things all, most all of these scanners have the 00:16:58.818-->00:17:03.756 same 10B10C connector, ethernet with 2 extra pins. And you can just slide in a screwdriver, 00:17:06.225-->00:17:12.431 unclick it, and bring our own scanner. Or steal a scanner and replace it, and then test with 00:17:12.431-->00:17:16.669 that one. So you can actually program your malicious barcode scanner, bring it into the 00:17:16.669-->00:17:23.409 store, swap it out real quick and you don't even have to scan a barcode. One great thing, 00:17:23.409-->00:17:27.046 there's a great example in the next slide. Even when the scanners are turned off, a lot 00:17:27.046-->00:17:31.183 of them are still powered. Most of these aren't actually doing anything but they're almost all 00:17:31.183-->00:17:36.455 still powered. So you can still program them even if the terminal's off. Another thing, 00:17:36.455-->00:17:42.862 laser scanners like this one from probably before I was born, no not that really, this one's a 00:17:42.862-->00:17:47.300 laser scanner, the ones they have in like Wal-Mart and the end counter checkouts. This 00:17:47.300-->00:17:52.305 one's actually end counter. Right here, spinning laser beam of death. Those ones won't work 00:17:54.340-->00:17:59.178 with phones. You gotta have a Kindle, paper, something like that. And we have some great 00:17:59.178-->00:18:05.284 ideas with, you can trick others to deliver these barcodes. For example, maybe you're at 00:18:05.284-->00:18:11.857 airport. And you just airdrop someone and say hi, I'm United Airlines. Have this barcode for 00:18:11.857-->00:18:16.862 your free upgrade. [laughter] That's actually the cat PR code.Or you know p-Pet Smart. 00:18:20.499-->00:18:25.504 Just send a fake email to someone and hopefully they do it. Literally a minute after I 00:18:28.941-->00:18:34.680 walked off the plane at Vegas, in the airport, came across that scene on the left, unattended 00:18:34.680-->00:18:38.351 little coffee shop, the machine's powered off, everything's locked up, probably 00:18:38.351-->00:18:44.090 the cash is gone, but we've got a powered scanner right there. No one's watching this so we can 00:18:44.090-->00:18:48.995 just go scan barcodes all we want because you can program them. And then the one on the 00:18:48.995-->00:18:55.034 right is uh percentage without comment from Piso's, if anyone's been there. They even posed with 00:18:55.034-->00:18:57.903 their bar scanner for me. They probably would have let me scan some barcodes if I had asked. 00:19:00.773-->00:19:05.778 For the blue team. I don't have good news for you. [laughter] >>As far as I know, there is no 00:19:07.913-->00:19:12.718 way to secure these scanners from programming. The only benefit you have is that some 00:19:12.718-->00:19:18.491 models may not support it. Some really really old ones may not support it. All the new ones do. 00:19:18.491-->00:19:23.362 So you just have to assume that anything that has a barcode control. I shouldn't be able to 00:19:23.362-->00:19:26.432 type Windows key R and get an admin prompt but a lot times you can, especially on these 00:19:26.432-->00:19:28.968 unattended kiosks. And there's some good ideas about filtering malicious keys at the OS level. 00:19:28.968-->00:19:33.973 So you can just say if this device has a scanner type, then don't allow any like Windows 00:19:49.722-->00:19:55.761 keys or super keys. Or we can just enforce non-HID modes. These will transport or serial 00:19:55.761-->00:19:59.565 port. You can use a barcode to change them into a keyboard though, so you gotta enforce 00:19:59.565-->00:20:05.738 that at an eDev level. Anyway, we're gonna wrap it up with some special thanks to Terry Burton 00:20:05.738-->00:20:09.809 at BWIPP who made some last-minute changes and helped us a lot. Mark Warren made the 00:20:09.809-->00:20:14.713 BWIP in JS version. Hermit, thanks for the shirts. Dallas Hackers, thanks for all your 00:20:14.713-->00:20:18.250 help and support. This talk was actually kind of boring there. And thanks CyberArk for the 00:20:18.250-->00:20:22.955 travel and support. If anyone's looking for some interested talks, related talks, these are 00:20:22.955-->00:20:28.694 some good examples. Um, there, none of them really go into this depth of building a tool, but 00:20:28.694-->00:20:34.600 they give some great details about barcodes and how they work. And there is our site. 00:20:34.600-->00:20:39.605 There is the GitHub link. And QR codes trust me, they're safe. [laughter] [applause]