All right. Good morning, audience. Welcome to the second day of DEF CON. Proud to be here. Hopefully everyone's had a great experience so far. I want to kick things off by introducing our next speaker. He is coming all the way from Norway. So he's had a very long flight. So we definitely want to give this guy a lot of attention. His name is Melvin Langvik, and I'll read just a quick breakdown of his bio. Melvin is an accomplished professional with a diverse background in tech. He started his career as a developer and integration consultant, gaining practical experience in distributing critical back-end infrastructure for an international customer base. Melvin's passion for cybersecurity led him to transition into offensive security, the bad team. He previously worked for TrustedSec, which is an internationally recognized security company. As part of TrustedSec's targeted operations team, Melvin was tasked with performing targeted cyber attacks against some of the most mature and often largest companies in the world. Today, Melvin is with the offensive security team lead at a company called Colbert AS. So please give Melvin a very warm welcome and listen to what he has to say. Thank you, Melvin. Thank you so much. Thank you so much, guys. Okay, so this talk is only 25 minutes, so the first portion is going to be super quick, and then towards the end, we'll slow down and I'll give you guys a nice demo, okay? So evading modern fences versus phishing with pixels. We're going to be talking about QR code phishing specifically. Quick introduction about myself, even though my biography got read up here. My name is Melvin Langvik. I go by the alias Flangvik. I'm the team lead for a small Norwegian pentest company called Colbert. Previously, I was at TrustedSec. I've done quite a few offensive security tools for the community. Maybe somebody recognizes sharp collection or team filtration. I also create trash, semi-good-ish infosec content on YouTube and Twitch. I don't want to go on a stream every Sunday, but close to every Sunday, I do a stream. Like you guys, I'm a part-time alcoholic when I'm at conferences. And I'm also the guy who did the meme-y C2 and EDR tier lists. Obviously, AnyDesk is the best C2 out there, right? So this is all a meme. Okay, so the game plan for this talk. We're going to talk about QR codes one-on-one. We're going to talk about phishing with QR codes. Some basic detection engineering. Obviously, not my field, but just some basic stuff. Imageless QR codes, question mark, potential profit, taking things a step further. And then we're going to talk about the tool and toolkit I'm going to be demoing and sort of releasing today called Crucible. Okay, so let's talk about some QR codes. What is a QR code? QR code is a quick response code. It's essentially a barcode that contains a given amount of data. A QR code works while you scan it using a device. Typically, it's a mobile, right? The scan secure code takes you to a link or some other data. The QR code itself has a couple of key factors. Finder patterns, marked down here in purple, is for the device you're scanning the QR code to identify where the QR code is. Is this a QR code or not? You got the alignment marker in green, sort of telling the device the position of the QR code, so it knows which way to read it. And then you get the actual data modules, which is the black and white data between the alignment and finder markers. And then you have also error correction. I didn't know this before doing the talk, but QR codes can actually have error correction up to 30%. So if up to 30% of the QR code is missing, it's still readable depending on how it's generated. Different versions of QR codes refer to different size, how many modules are within. Take like the smallest one, I believe it's like a 21 by 21. Then you can go all up to like 172, I think, 171. And that will actually give you a bit over 4,000 alphanumerical characters. So a QR code can be huge and can contain a lot of data. Typical use cases for us, it's much smaller and does contain like a series of numbers or URL or something like that. QR codes has a lot of legitimate use cases. If you ever charge your electric vehicle, if you ever booked like an e-bike or like a scooter, if you ever ordered at a restaurant during COVID, they use QR codes. You scan them, you get to a web page, and then you give them all your data and you get some food, right? So they have a ton of legitimate use cases and they're great. We use them all the time. The thing is that attackers also like to use QR codes. I'm actually super proud of this meme. And why do attackers use QR codes? They're simple to create and easy to share. There's a bunch of online tools. There's libraries to use in scripting languages. There's pre-built offline tools, right? Easy to create, easy to share, and therefore easy to abuse. Again, everybody knows what a QR code is. Even non-technical people working in large organizations have some sort of reference to QR codes, right? So it definitely looks like a legitimate delivery method. Sometimes we'll talk more about this, but typically it's easy to evade initial email filters and some sandbox solutions by delivering URLs or data in QR codes. And actually, I think they convey a sense of legitimacy. I asked a bunch of my friends who's not technical, you know, can anybody create a QR code? And a lot of them thought no. A lot of them thought that you had to be some sort of legitimate entity, that you had to be an organization or get a license or whatever to create your QR code, which is obviously wrong, right? So I think that is underlying of why a lot of people feel QR codes are very legitimate. And also, the best thing about phishing, specifically with QR codes, is that you move the initial access of whatever you are giving to the victim off the main device. A lot of large corporate networks or large companies will have heavily protected machines, but the mobile devices are either private, owned by the employee themselves, or maybe not as heavily enrolled or doesn't have the same defensive capabilities as the machine itself. Meaning that, you know, a potential defense, a SOC, wouldn't gain the same telemetry from that phone as they would from the device. I think this is true for many, many organizations out there. Okay, so obviously, phishing with QR codes, I think everybody's seen a couple of these examples. I think the Microsoft multi-factor authentication one is by far the most abused, right? Because it's based on the legitimate use case where you set up a Microsoft account, you have to scan the QR code to set up your multi-factor app. And therefore, you know, you have to re-authenticate or whatever the context is a couple of times a year, and that really makes a good phishing campaign. DocuSign is also heavily abused. Anything related to Microsoft, really, people love throwing Microsoft logos around, right? So a bit of detection engineering. How do we detect QR codes? I googled this, which means I did great research on the subject, right? Found this blog post by Liam Jones, who created a basic detection rule for basically pulling out image attachments from emails. He then had some automation for parsing the images and looking for QR codes, essentially attempting to parse every image as a QR code and then look at the data, right? That's the manual way to do it. There's a couple of flaws in this rule. You can probably spot it. You know, there's a bunch of more image extensions than PNG, JPEG, and SVG. But yeah, that's just an example, right? And then you have black box solutions, which we don't know how to work like Microsoft Sentinel. If you give Microsoft some of your hard-earned money and get like an E5 or E3 or whatever their licensing model is at the time, you'll get this, which is Microsoft Sentinel. It will overwatch all your emails, inbound, outbound from the organization. And it will actually tell you if you got a URL from a QR code. You see, it will tag it as the source of this data is from a QR code and will give it a URL. And it will automatically browse through it. It will take a look at it and try to determine if it's nasty or not, right? So the detection solutions, defensive solutions out there are definitely aware of QR code phishing and it's an established thing. We'll get back to this later. Okay, how about image-less delivery methods, right? I think when I say that, most of you are immediately going to think about the ASCII art method because it's a known method where you basically use different weird ASCII characters to represent the QR code. And the reason I say that this is a known method because our well-known influencer John Hammond made a video about this four months ago and at least 2 million people know about this now. So it's definitely known. Obviously not to throw him under the bus, it's great. Just want to say it's an established thing. And so when we want to phish, if I wanted to phish without the use of images to avoid this detection that I just talked about, what could I possibly use for this? Well, I found this example in CSS. So there's a great guy called Jason Adelia or whatever I butcher his name. He's a web developer or a web designer and he has this CodePen link out on Google somewhere where he showcases his QR code to his website created with CSS. So he's actually using a blank white canvas and then using box shadows to fill in the black and white for the entire grid array and it turns into this beautiful QR code. Now, this looks interesting. This doesn't look like shit, right? So we could potentially use this. So me and ChatTPT sat down one night and we looked at some Python code and I came up with this dirty piece of crap. Basically, creates a QR code, goes through every cell in the QR code, determines if the QR code is... or that pixel or cell is black and then fills in the box shadow, the CSS using his technique with that. And then this looks really great. Actually, a bunch of email clients will happily render this. Both Thunderbird and Apple Mail, the built-in Apple Mail, will render this as CSS and it scans, it looks great and it's not an image. So this will fly by basic detection for email filters because there's no image there. So there's obviously no QR code there, right? And of course, you can see that the CSS is not offset because, you know, centering things to CSS is an absolute fucking nightmare. So I didn't bother spending the needed two hours to center this thing. I just screenshots it. That's your issue now. But it is what it is. The sad thing about this though is that Outlook doesn't support this in the desktop client. The web version of Outlook will happily render CSS for you, but the, again, not centered, but the desktop client will not render CSS. This is because the Outlook desktop client is extremely sassy and in general just is very picky about what HTML tags you can use, what CSS you can use. And if you ever made an email in the Outlook desktop client, you know what I'm talking about. It's a nightmare, right? So it doesn't work. And it's kind of important because it turns out, at least based on one source, that the Outlook desktop client owns about 58.1% of desktop machines. So it's kind of important. And, you know, when working against large organizations, by far the experience I have is that most people use the Outlook desktop client. I think we can all agree on that, right? That's a given. Okay, so we got to take a step back then. CSS, sure, we can use that. We already scripted that way, but we got to find some other way. What other structure could we possibly use to create like a drawing almost of pixels? Like what could we use, right? So the answer to that, at least one, is tables. So tables is something that Outlook desktop client supports. When I say tables, I don't mean like Excel tables. I mean like actual HTML tables and rows and columns. And they support styling. So you could take a table and you can style each column in that either white color or black color. And you can create a QR code. So again, me and ChattyPT sat down one night and we created this. So you set the cell spacing and the cell padding to zero or a given size for how big QR code you want to make. And then you basically start filling in, okay, this pixel of this QR code is white. Let's pad this or let's make the background color of this cell white or black, right? And then you go through the whole thing and voila, you got a beautiful looking table in HTML. And you got a beautiful looking QR code in Outlook Desktop Client, right? And this looks good. I actually think this deserves a round of applause, to be perfectly honest with you. And this is really dumb. This is KISS all the way, right? It's super simple, super dumb. And is it effective? That's the big question. Is this effective? So I actually, you know, I reached into my paycheck and I bought Microsoft Sentinel, XDR, EDR, whatever they call it now. They change them every week. And I give them my money and I wanted to test it. So first I set up two accounts. I set up Microsoft Sentinel. I started monitoring incoming email traffic. And then I set out this QR code in a Base64, as a Base64 image embedded in the email. And obviously Microsoft Sentinel picked this right up. It says, you know, this is a QR code. This is the URL. That's Rick Roll, if anybody recognized that. Hacks, Elite Hacks are to you if you recognize that. And then I tried sending a table and long and behold, nothing happened. So Microsoft Sentinel did not detect the table as an image or as a QR code at all and didn't parse it. And therefore, as a defender, you don't have telemetry for this. So if I send a bunch of phishing emails with QR codes generated as tables, the URL will not pop up. Nobody will spam it. No bot will hit it and it will reach a target and it's still scannable by mobile devices. So this works great. Now this, I've already done this. I talked about this at a conference a couple of months back. This is built into the tool Crucible, which I'll talk about later. And you can find that on GitHub. It works great. And yeah, it's cool. But let's think about it and take it a step further. We can generate QR codes in CSS, sick. We can generate QR codes in tables, even sicker. But what about obfuscating email content using tables? Because think about it, the table is essentially our drawing board. We can draw whatever we want. Each column in the table is a pixel for us, right? So we could draw the entire email. We could render HTML and draw the entire thing as a table. So this is what we dive into. And this was a bit of a nightmare, to be perfectly honest. This is the process. So we need to... So the point, what I want to do, I guess I should go back on this. Why would you want to do this in the first place, right? So more and more defensive solutions out there are using AI to get the context of the email you're sending. They're using risk scores. They're using a context-aware AI to understand, you know, is this potentially a legitimate message being delivered to my user? And then based on the risk score, whatever, it will be delivered, sandboxed, looked at, whatever, right? So the thought behind this is that if we can obfuscate keywords in the email, like MFA, like QR, like re-authenticate, like Microsoft, right? It's going to be much harder for the AI model to determine the context of the email and if it's legitimate or not. So the whole point behind this is I want to take a keyword, say re-authenticate, and I want to render that as an image. And then I want to turn it into a table. And then I want to replace the keyword in the email with that table. So there's no text there. It's a table representing the text. So there's no text. You can't select it, but it looks like a text. The end user will think it's text, but it's not. I went through this process. So basically, you give the Python script the email, the HTML email that you want to send, and then you tell it, hey, I want to replace the keyword, re-authenticate. The Python script will then render the, the Python script will then inject a marker in that as to handle that word. So it will inject like a box around the word in HTML, and then it will render the entire email. And then it will use image recognition to cut out that box. And then it will remove the borders and turn it into a table. And this is dumb and complicated, and you would never think this would work, but it actually works. So I'm going to demo that right now so you can see that. Hopefully, you can see my terminal now. Can you see a terminal? Great. I'll try to clear this and make it a bit bigger for you guys. Like, ooh, okay. So this is Crucible. This is the help menu. You give it a URL that you want the QR code data, the data you want inside the QR code doesn't have to be URL, but typically it's URL. You want to set a QR code size. You give it an input. So you give it like a typically like a phishing email template in HTML. And then wherever the word QR underscore placeholder is will be replaced with a QR code table or CSS. And then you give it an output path if you don't want a random generated name. You can choose if you want the CSS method or the tables method, and you can also generate output in straight EML, which is an email format. So you can just open it in Outlook afterwards, which is super nice. And then you have the obfuscate method. So that's what I'll be demonstrating now. So in this command here, I'll be linking to Defcon.org. I'm using my MFA or QR code template, and then I'm obfuscating the keywords MFA, QR, and Microsoft. So those words will be pulled out of the email template and replaced with images illustrated as tables in the new output. So it worked, hopefully. I have a backup if it doesn't. Open Sesame. Placeholder, I think. No. Oh, okay. Hopefully this works. Yeah. So this is a table QR code, and this is the... Fuck, it broke. Okay, it broke. Give me a second here. I'll go back to the demo. So it looks like this, if the demo worked correctly. And then this is the output. So this is the generated email. Can you spot the text that is tables? There is text. There are keywords in this email that is not text. Give you guys a second. Some of it is obvious. Some of it is not. And all of this is not text. This is tiny tables inserted into the email template, resulting in it looking like text, but it not being text. Round of applause. Cue that. And again, this works when you're not demoing it live at DefCon. And that's basically all I got. Thank you so much, Adversary Village, for having me. I got stickers for the project. Scan this QR code, if you trust me, to get to the project. And yeah, go out there and fish somebody and improve our defenses by some degree. Thank you so much for being here, guys.