So you know it takes a lot to talk in front of all you guys and we got two noobs today. So let's give it up for Michael and Colin. Cheers if you got them. Whiskey. All right. Welcome, everybody. We're going to be talking today about barcodes and barcode scanner hacking. First quick introduction, even though you probably don't care who we are. I'm Michael. I'm obsessed with barcode scanners. As you can see, I have way too many of them. Colin? Hey, I'm Colin. I do stuff on the web professionally. He's what we call a web master. So, So, something we've kind of noticed and something we may take for granted is that barcodes are everywhere. You may not notice them in real life, but they really will, they really kind of permeate everything we buy, everything we use. And you may think, oh, there's some obvious ones. Well, there's a lot of non-obvious ones. Like, there's three barcodes on that USPS label. There's one on Intel CPUs. There's some on most printers that print color. Even hospital wristbands. And as a result, because those barcodes are everywhere, barcodes are everywhere. It means the scanners are everywhere. And so, these scanners are basically kind of hiding all over the place. If you go to almost any store, you'll find them. If you go to an airport, you'll find them. But they're really an attack vector. So, before we get into that, let's just talk a little bit about barcodes and kind of what they are. So, normally, they decode to text. These are just a couple of different types of barcodes called symbologies. You don't have to care about what they are. You just have to know that they decode to text. So, these are text. Some of them have restrictions, like the UPC on the right, where it can only decode to certain numbers. Some, like PDA4 and 7, can hold a lot of data. And others, like QR, are really good at being viewed at weird angles. But the thing is, these scanners are mostly the same. These manufacturers, this one, most of these are symbol scanners. And most of these are vulnerable to this attack. They sell, I mean, look at this. These are about, like, 10 years apart. They look exactly the same. The scanner, the equipment inside are pretty much, the controller inside is basically running the same software, the same features year to year. Most of them will act as an HID device. So, they just act as a keyboard. They type in the keys. And key by key, they type the buffer out. So, with all these barcode scanners everywhere, acting as keyboards, what could we do if we could change the text? Or send arbitrary keystrokes? Or do things like Windows key R? Or whatever. What could we do? With proper permission, and a legal sanction pen test? So, it's not a bug, what this is. A lot of manufacturers will add special features in. Code 128, that's what barcode right there, that was the one the first slide. It says bahr underneath that, but there's a hidden character. That one in the red right there, right after the start code, is FNC 3. That's why that barcode went there. That's why it's sad. It says the same code for the 3, which is our best friend in some of these examples. It tells the scanner, this isn't a normal barcode. This is a programming barcode. A lot of scanners support this. It is a little manufacturer specific. And if this is starting to sound familiar, it's because this is basically in-band signaling. If you guys haven't seen the blue box on the left, that's basically what this is, just modernized. We haven't learned our lessons from decades ago. So why does this programming exist that we can do this from? It mainly exists for legacy systems. So in this example, we have a legacy system we call Cyberdyne cat ERP. And we use it to track and herd our cats. A novel goal. It's a little too, it was made a long time ago. Nobody wants to replace it. Nobody wants to modify it. It's way too expensive. It's probably Fortran or something. But we've been told to make it faster. So we want to make it faster with barcodes. This is actually a real fake example. This is actually a C-Sharp program running in the background that we created just to show this off. Because I don't know how to program in Fortran. So here we have my cat Java. He's a domestic short here. He's born like 2005ish. And our system wants those three inputs. And so normally we would have to look at the label on the cat, grab their name, type it in manually, press tab, type in the breed, press tab, type in the year, and finally we hit F12 to save. So we're going to go ahead and do that. Well that takes a lot of work. There's a lot of room for error. And it's generally just kind of slow. So what if we solve that by barcoding our cats? Because how could that go wrong? So we create a barcode like the one on the upper right that says DSH, domestic short here, 2005, Java. Now we've got this barcode. We can't modify the ERP app to no barcodes. It's just like I expect a keyboard and that's it. And so these rules that we generate, they're going to go a little bit like this. So first we've got a cursor and we've got a buffer of the actual scanned barcode. And you can see we're starting it right before D or on D. So we just move the cursor forward a little bit. And now we move it forward seven characters. Seven characters are defined length for how big those two fields can be. And then the rest of the barcode is the cat's name. So you could have a name that's eight characters long, 12 characters long, doesn't matter. Now we're at this cursor point. We send that info. And then we're going to go ahead and we press tab. And you can see it types it for us and moves to the next field. Now we go back because the next field is DSH or breed, which is DSH. The cursor moves back to the front. We type in three characters and we hit tab. Again, it doesn't matter what those characters are. We're just typing three characters from the buffer. And then same thing, the cursor has already moved forward for us. So all we do is type four characters. And we hit F12. And it saves it for us. So all we do is take one quick scan on this legacy system that nobody knows how to modify and we can actually automate that. That's why these rules exist. That's why manufacturers added them 20 or so years ago. And so we're back at that. We've put our barcode on our cat, which is a very successful endeavor, I might add. And we're going to just do a scan. So this is what the scan looks like. Simple as that. It's extremely fast, a lot less error prone. But, of course, we're going to do it. We can make our own malicious rules. We can make our own malicious programming. So we can do all sorts of things. We can specify criteria for these rules. So we can say just do it on everything, do it on certain barcodes, ones that have a certain text in it or certain symbologies like EPC. Or and then once we're done with that, we can specify actions. So you can see here on the left, that is the or the right, that is the actual programming barcode for that cat ERP system. So if you scan that with this scanner, it will do that. And then we're going to do the same thing. A lot of these scanners can actually support multiple rules, as we'll see later. They do have a size limit, but it's fairly expensive. You can't write a novel in PowerShell, like you can't write hundreds of characters. But you can get a lot in. These are some of the actions we can do, some of the ideas. So we can modify and replace text on the fly. We can just ignore text. So you scan something, it doesn't actually give you any text. We can add extra characters in the end. We can do special keys, like Windows can do special keys. We can do control, alt. And we can just do nothing. We can soft brick scanners by scanning a rule that says do nothing, and the scanner is dead until you reset it to defaults. There's the classic attack, you guys probably heard of it, of like, you know, the Walmarts where you put a sticker over the barcode of a different barcode for something cheaper, but it's super obvious, like that. This is a digital equivalent of that. We can change those barcodes on the fly, make your $200 item ring up as 10 ducks. So this culminates in, you know, a little bit of a change in our tool called Barcodes. Barcodes is an attack IDE developed by Colin in JavaScript. We built payloads in JSON, and it makes it really easy to rapidly design them. These barcode scanners, they don't give you a lot of feedback. If you give it something invalid, they just go, they give you a bad beep instead of a good beep. And that's all. You don't have any feedback, there's no output, there's no logs. Trying to do these barcodes manually is possible but literally spent the past year working on that. So this makes it easy for you guys to just write some JSON. It's a little harder than DuckyScript. DuckyScript, you know, it's kind of basic. This allows you to do a lot more, but this takes away all the complexity of doing those barcodes. And you don't have to design for any manuals. Right now it supports more symbol, which I think is like 40% of the market. Most other scanners support this, like Honeywell, NCR, and it's open source under MIT license. Here on the right you can see just a simple, this is how we run Calculator. So, let's push over the demo. First demo, run Calc. This is the barcode website, barcode.com. It's live right now. Quick home page right there and it takes us into a quick IDE. First thing we do is run Calc. I know this text is a little small, but don't worry about it. So, you see on the bottom we have exclamation point Calc. What we have basically defined is a rule where if a barcode starts with exclamation point, we go press Windows key R, we press Enter and when we run, we type in that command and press Enter. So this basically allows us to easily build new payloads by just having a simple rule. So, as an example, let's scan it. This is simply some this scanner is fresh, it's reset to defaults. Here's what it looks like just by itself. Types in exclamation point calc. And here's what happens if we scan that programming barcode. You hear it had a programming noise? Full screen calc, my favorite. So let's go and try another demo. Next one is run command. And so this is what the quick iteration looks like. We can just go back, click things up up here. We can change all this text really easy on the fly. And so what we're going to do is just run this one. This one has two rules. We're going to scan that. It programs it. And then next, let's launch command. And now we just have a command prompt open. We have extra barcodes so we can just type in net user. So we can actually type in text, you know, line by line. So you can actually have a list of one liners that you really love and just use them over and over again. And the quick iteration is stuff like this. You can go and say, you know, net user add. So you can just go click like that. Click run. Now we can type net user add. And now we have a command prompt open. Next up, do the serial box demo. So right here we've got an unaltered box of s'mores. It's a little smashed from travel here from Dallas, but it's got a barcode on the bottom. Simple UPC barcode. We're going to execute an attack with that barcode. So first let's demonstrate that we scan this. It types in a barcode. Next let's scan the programming barcode. There we go. Let's prep ourselves. We've already got Metasploit running right here just waiting for a reverse shell. And so let's scan this barcode and see what happens. Oh, come on. You can do it. We had to change our website. We have to get it back. So all we post at like 2 a.m. and it's super slow right now, but it's working. It should. Just give it time. There we go. Now we can switch over to this other window. Session one opened. So that's all great. That's all serious. But, you know, what if we just really want to play some video games? What if we're really feeling down for something more fun? So let's play some Tetris. So right here we'll scan this barcode. It can be a little tricky with the glare on the screen stage, but there we go. Got that programmed. So we've got Tetris. Put that over here. And we've got photos. So basically we've invented the world's shittiest way to play Tetris. And finally let's just show off what we can do with a little bit of mayhem. So we'll go back to our brick payload. So there's the programming barcode on the top. So right now if I scan, you know, that barcode, it's going to scan the serial box demo. But if we scan this one simple programming barcode, we're basically telling the scanner whenever you get a barcode, just sleep for 20 seconds and then don't print anything. Any barcode. So let's try and scan the serial box again. If you can't tell, this thing's not lighting up. It's just sitting there for 20 seconds doing nothing. It looks like it's powered off. The light's off. The button doesn't do anything. It'll just sit for 20 seconds and wait. And the only way to reset it is to go to the factory defaults, which almost no one knows how to do. So once we give this a few seconds to go through, it looks like it's dead. You scan this one barcode, it's basically a zombie for that 20 seconds. We've tried up to, like, one and a half minutes before we got bored. So now if we scan restore defaults, we can go back to the factory defaults and see what we've done. So that's the way it works. We can go back and scan all the barcodes we want. But almost no one knows how to do that. And that whole thing about we find a lot of barcodes hiding everywhere? Well... First let's talk about this. So first, can you turn it off? And the answer is yes. You can scan that barcode to disable programming barcodes. Can anyone guess how you turn them back on? . So some considerations for a red team attack. This is really, this is an advanced attack. You can't just walk into a Walmart and just pull this up on your phone and hit enter and hope it kind of exploits it. This is something that takes a lot of testing, a lot of recon. But it allows some windows into systems that normally you wouldn't be able to access. They don't have keyboards. They are controlled. You only have access to the barcode. Or maybe you're not even there. Maybe you send a package to the malicious barcode. One thing to think about, find the beeper hole and cover it up. Because the programming barcodes, at least on symbol scanners, they actually play at full volume. Some of you guys can even hear it in the audience. I have it taped over. But it's really loud. So just cover that up. Another good example is you can actually bring your own scanner. These things, almost all of these scanners have the same 10B, 10C connector. Ethernet with two extra pins. And you can just slide in a screwdriver, unclick it, and bring your own scanner. Or steal a scanner and replace it and then test with that one. So you can actually program your malicious barcode scanner, bring it in the store, swap it out real quick, and you don't even have to scan a barcode. . One great thing, there's a great example in the next slide. Even when the scanners are turned off, a lot of them are still powered. Most of these aren't actually doing anything, but they're almost all still powered. So you can still program them even if the terminal's off. Another thing, laser scanners like this one from probably before I was born. Nope, not that early. This one's a laser scanner. The ones they have at Walmart in the Encounter checkouts. This one's actually Encounter. Right here. Spinning laser beam of death. Those ones won't work with phones. You gotta have a Kindle, paper, something like that. And then we have some great ideas with, you can trick others to deliver these barcodes. For example, maybe you're at airport and you just airdrop someone and say, Hi, I'm United Airlines. You know, have this, scan this QR code for your free upgrade. . That's actually the cat ERP code, but don't worry about it. Or, you know, PetSmart. Just send a fake email to someone and hopefully they do it. Literally a minute after I walked off the plane at Vegas in the airport, came across that scene on the left. Unattended little coffee shop place. The machine's powered off. Everything's locked up. All the cash is gone. But we've got a powered scanner right there. No one's watching this and we can just go scan our barcodes all we want. Because you can program them. And then the one on the right is presented without comment. From Piso's, if anyone's been there. They even posed with their barcode scanner for me. They probably would have let me scan some barcodes if I'd asked. For the blue team, I don't have good news for you. As far as I know, there's no way to secure these scanners from programming. The only benefit you have is that some models may not support it. Some really old ones may not support it. All the new ones do. So you just have to assume that anything that has a barcode scanner attached is going to get hostile input. So these are the standard kind of stuff we've been talking about in security for a long time. Remove local admin. Use endpoint protection. App control. I shouldn't be able to type Windows key R and get an admin command prompt, but a lot of times you can, especially on these unattended kiosks. And there are some good ideas about filtering malicious keys at the OS level. So you could just say, if you're going to use a Windows scanner type, then don't allow any Windows keys or super keys. Or you can just enforce non-HID modes. These will transfer a serial port. You can use a barcode to change into a keyboard, though. So you've got to enforce that at UW level. Anyways, we're going to wrap it up with some special thanks to Terry Burton at BWIP who made some last minute changes and helped us a lot. Mark Warren made the BWIP in JS version. Hermit, thanks for the shirts. DOS Hackers, thanks for all your help and support. This talk was actually kind of boring there. And thanks CyberArk for the travel and support. If anyone's looking for some interesting talks, related talks, these are some good examples. None of them really go into this depth of building a tool, but they give some great details about barcodes and how they work. And there is our site. There's the GitHub link and QR codes. Trust me, they're safe.