start	end	text
0	4420	All right. Good morning, audience. Welcome to the second day of DEF CON.
4420	7340	Proud to be here. Hopefully everyone's had a great experience so far.
8780	11700	I want to kick things off by introducing our next speaker.
11760	15300	He is coming all the way from Norway. So he's had a very long flight.
15300	17480	So we definitely want to give this guy a lot of attention.
17500	22740	His name is Melvin Langvik, and I'll read just a quick breakdown of his bio.
22900	26600	Melvin is an accomplished professional with a diverse background in tech.
26600	30060	He started his career as a developer and integration consultant,
30060	33360	gaining practical experience in distributing critical back-end infrastructure
33360	36500	for an international customer base.
36520	42800	Melvin's passion for cybersecurity led him to transition into offensive security, the bad team.
42800	47900	He previously worked for TrustedSec, which is an internationally recognized security company.
47900	51900	As part of TrustedSec's targeted operations team, Melvin was tasked with performing
51900	57980	targeted cyber attacks against some of the most mature and often largest companies in the world.
58100	63760	Today, Melvin is with the offensive security team lead at a company called Colbert AS.
63800	68760	So please give Melvin a very warm welcome and listen to what he has to say.
69260	70860	Thank you, Melvin. Thank you so much.
71240	72600	Thank you so much, guys.
72740	76380	Okay, so this talk is only 25 minutes, so the first portion is going to be super quick,
76380	79480	and then towards the end, we'll slow down and I'll give you guys a nice demo, okay?
79480	82560	So evading modern fences versus phishing with pixels.
82560	85680	We're going to be talking about QR code phishing specifically.
85680	89520	Quick introduction about myself, even though my biography got read up here.
89520	92300	My name is Melvin Langvik. I go by the alias Flangvik.
92300	95020	I'm the team lead for a small Norwegian pentest company called Colbert.
95020	96680	Previously, I was at TrustedSec.
96680	99660	I've done quite a few offensive security tools for the community.
99660	102280	Maybe somebody recognizes sharp collection or team filtration.
102600	106900	I also create trash, semi-good-ish infosec content on YouTube and Twitch.
107380	111120	I don't want to go on a stream every Sunday, but close to every Sunday, I do a stream.
112580	115540	Like you guys, I'm a part-time alcoholic when I'm at conferences.
115940	120260	And I'm also the guy who did the meme-y C2 and EDR tier lists.
120640	123240	Obviously, AnyDesk is the best C2 out there, right?
123240	124340	So this is all a meme.
124940	126740	Okay, so the game plan for this talk.
126740	128360	We're going to talk about QR codes one-on-one.
128360	130120	We're going to talk about phishing with QR codes.
130120	131900	Some basic detection engineering.
131900	134080	Obviously, not my field, but just some basic stuff.
134080	139240	Imageless QR codes, question mark, potential profit, taking things a step further.
139240	142000	And then we're going to talk about the tool and toolkit I'm going to be demoing
142000	143980	and sort of releasing today called Crucible.
144420	146660	Okay, so let's talk about some QR codes.
146660	147580	What is a QR code?
147580	149360	QR code is a quick response code.
149360	152720	It's essentially a barcode that contains a given amount of data.
153120	155920	A QR code works while you scan it using a device.
155920	157040	Typically, it's a mobile, right?
157040	160000	The scan secure code takes you to a link or some other data.
161780	164660	The QR code itself has a couple of key factors.
164660	167240	Finder patterns, marked down here in purple,
167240	170960	is for the device you're scanning the QR code to identify where the QR code is.
171060	172800	Is this a QR code or not?
172800	174600	You got the alignment marker in green,
174600	177860	sort of telling the device the position of the QR code,
177860	179600	so it knows which way to read it.
179600	181360	And then you get the actual data modules,
181360	186580	which is the black and white data between the alignment and finder markers.
187000	189060	And then you have also error correction.
189060	190700	I didn't know this before doing the talk,
190700	194980	but QR codes can actually have error correction up to 30%.
194980	197540	So if up to 30% of the QR code is missing,
197540	200080	it's still readable depending on how it's generated.
200960	204380	Different versions of QR codes refer to different size,
204380	206640	how many modules are within.
206640	210440	Take like the smallest one, I believe it's like a 21 by 21.
210440	214340	Then you can go all up to like 172, I think, 171.
214340	218840	And that will actually give you a bit over 4,000 alphanumerical characters.
218840	221620	So a QR code can be huge and can contain a lot of data.
221760	223780	Typical use cases for us, it's much smaller
223780	229100	and does contain like a series of numbers or URL or something like that.
229880	232620	QR codes has a lot of legitimate use cases.
232760	234840	If you ever charge your electric vehicle,
234840	237300	if you ever booked like an e-bike or like a scooter,
237300	239760	if you ever ordered at a restaurant during COVID,
239760	240780	they use QR codes.
240780	242220	You scan them, you get to a web page,
242220	244900	and then you give them all your data and you get some food, right?
244900	247960	So they have a ton of legitimate use cases and they're great.
247960	249040	We use them all the time.
250020	253140	The thing is that attackers also like to use QR codes.
253700	255520	I'm actually super proud of this meme.
256940	259300	And why do attackers use QR codes?
259300	261240	They're simple to create and easy to share.
261240	262600	There's a bunch of online tools.
262600	264440	There's libraries to use in scripting languages.
264440	266680	There's pre-built offline tools, right?
266680	269240	Easy to create, easy to share, and therefore easy to abuse.
269780	271920	Again, everybody knows what a QR code is.
271920	274460	Even non-technical people working in large organizations
274460	276800	have some sort of reference to QR codes, right?
276800	280300	So it definitely looks like a legitimate delivery method.
281080	282720	Sometimes we'll talk more about this,
282720	285280	but typically it's easy to evade initial email filters
285280	289060	and some sandbox solutions by delivering URLs or data in QR codes.
289780	292800	And actually, I think they convey a sense of legitimacy.
292800	295040	I asked a bunch of my friends who's not technical,
295040	297640	you know, can anybody create a QR code?
297640	299220	And a lot of them thought no.
299220	302340	A lot of them thought that you had to be some sort of legitimate entity,
302340	304600	that you had to be an organization or get a license or whatever
304600	307980	to create your QR code, which is obviously wrong, right?
307980	312700	So I think that is underlying of why a lot of people feel QR codes are very legitimate.
313860	316680	And also, the best thing about phishing, specifically with QR codes,
316680	320480	is that you move the initial access of whatever you are giving to the victim
320480	321900	off the main device.
321900	324200	A lot of large corporate networks or large companies
324200	326540	will have heavily protected machines,
326540	330640	but the mobile devices are either private, owned by the employee themselves,
330640	332540	or maybe not as heavily enrolled
332540	337740	or doesn't have the same defensive capabilities as the machine itself.
337740	339800	Meaning that, you know, a potential defense, a SOC,
339800	343080	wouldn't gain the same telemetry from that phone as they would from the device.
343080	345960	I think this is true for many, many organizations out there.
347000	349480	Okay, so obviously, phishing with QR codes,
349480	351580	I think everybody's seen a couple of these examples.
351800	353760	I think the Microsoft multi-factor authentication one
353760	355240	is by far the most abused, right?
355240	357100	Because it's based on the legitimate use case
357100	358700	where you set up a Microsoft account,
358700	361420	you have to scan the QR code to set up your multi-factor app.
361420	363320	And therefore, you know, you have to re-authenticate
363320	366320	or whatever the context is a couple of times a year,
366320	368040	and that really makes a good phishing campaign.
368040	369640	DocuSign is also heavily abused.
369640	371200	Anything related to Microsoft, really,
371200	373600	people love throwing Microsoft logos around, right?
374280	376440	So a bit of detection engineering.
376440	378300	How do we detect QR codes?
378300	382180	I googled this, which means I did great research on the subject, right?
382200	384620	Found this blog post by Liam Jones,
384620	386140	who created a basic detection rule
386140	389640	for basically pulling out image attachments from emails.
389640	392140	He then had some automation for parsing the images
392140	394060	and looking for QR codes,
394060	396880	essentially attempting to parse every image as a QR code
396880	398460	and then look at the data, right?
398460	400160	That's the manual way to do it.
400160	401640	There's a couple of flaws in this rule.
401640	402660	You can probably spot it.
402660	404380	You know, there's a bunch of more image extensions
404380	406420	than PNG, JPEG, and SVG.
406620	408480	But yeah, that's just an example, right?
408480	409880	And then you have black box solutions,
409880	412000	which we don't know how to work like Microsoft Sentinel.
412020	414160	If you give Microsoft some of your hard-earned money
414160	416420	and get like an E5 or E3 or whatever
416420	418600	their licensing model is at the time,
418600	421120	you'll get this, which is Microsoft Sentinel.
421120	423680	It will overwatch all your emails,
423680	425420	inbound, outbound from the organization.
425460	428580	And it will actually tell you if you got a URL from a QR code.
428580	431360	You see, it will tag it as the source of this data
431360	433620	is from a QR code and will give it a URL.
433840	435600	And it will automatically browse through it.
435600	436420	It will take a look at it
436420	438660	and try to determine if it's nasty or not, right?
438660	440420	So the detection solutions,
440420	441480	defensive solutions out there
441480	443020	are definitely aware of QR code phishing
443020	444460	and it's an established thing.
444460	446080	We'll get back to this later.
446560	449180	Okay, how about image-less delivery methods, right?
449180	450820	I think when I say that,
450820	452260	most of you are immediately going to think
452260	453400	about the ASCII art method
453400	454420	because it's a known method
454420	457020	where you basically use different weird ASCII characters
457020	458800	to represent the QR code.
458940	460620	And the reason I say that this is a known method
460620	463460	because our well-known influencer John Hammond
463460	464900	made a video about this four months ago
464900	467420	and at least 2 million people know about this now.
467420	468800	So it's definitely known.
468800	471180	Obviously not to throw him under the bus, it's great.
471180	473040	Just want to say it's an established thing.
473340	475060	And so when we want to phish,
475060	477040	if I wanted to phish without the use of images
477040	479440	to avoid this detection that I just talked about,
479440	482100	what could I possibly use for this?
482100	484660	Well, I found this example in CSS.
484660	486860	So there's a great guy called Jason Adelia
486860	488340	or whatever I butcher his name.
488560	490560	He's a web developer or a web designer
490560	493860	and he has this CodePen link out on Google somewhere
493860	496800	where he showcases his QR code to his website
496800	498280	created with CSS.
498280	500780	So he's actually using a blank white canvas
500780	502160	and then using box shadows
502160	503940	to fill in the black and white
503940	505360	for the entire grid array
505360	507860	and it turns into this beautiful QR code.
507860	509320	Now, this looks interesting.
509320	510600	This doesn't look like shit, right?
510600	512260	So we could potentially use this.
512300	514160	So me and ChatTPT sat down one night
514160	515480	and we looked at some Python code
516020	518560	and I came up with this dirty piece of crap.
518560	520260	Basically, creates a QR code,
520260	522460	goes through every cell in the QR code,
522460	524320	determines if the QR code is...
524320	525880	or that pixel or cell is black
525880	528160	and then fills in the box shadow, the CSS
528160	530360	using his technique with that.
530380	531900	And then this looks really great.
531900	533080	Actually, a bunch of email clients
533080	534200	will happily render this.
534200	535960	Both Thunderbird and Apple Mail,
535960	537040	the built-in Apple Mail,
537040	538160	will render this as CSS
538160	539600	and it scans, it looks great
539600	540720	and it's not an image.
540720	542660	So this will fly by basic detection
542660	543740	for email filters
543740	544880	because there's no image there.
544880	546820	So there's obviously no QR code there, right?
546880	548300	And of course, you can see
548300	549540	that the CSS is not offset
549540	551160	because, you know, centering things to CSS
551160	552740	is an absolute fucking nightmare.
552740	554120	So I didn't bother spending
554120	555980	the needed two hours to center this thing.
555980	557340	I just screenshots it.
557340	558820	That's your issue now.
558820	560060	But it is what it is.
560060	561320	The sad thing about this though
561320	564240	is that Outlook doesn't support this
564240	565560	in the desktop client.
565560	566700	The web version of Outlook
566700	568760	will happily render CSS for you,
568760	570360	but the, again, not centered,
570360	573520	but the desktop client will not render CSS.
573520	575240	This is because the Outlook desktop client
575240	576420	is extremely sassy
576420	581160	and in general just is very picky
581160	583000	about what HTML tags you can use,
583000	584440	what CSS you can use.
584440	586360	And if you ever made an email
586360	587780	in the Outlook desktop client,
587780	588760	you know what I'm talking about.
588760	590260	It's a nightmare, right?
590260	591460	So it doesn't work.
591460	592240	And it's kind of important
592240	593440	because it turns out,
593440	595060	at least based on one source,
595060	596520	that the Outlook desktop client
596520	600420	owns about 58.1% of desktop machines.
600420	601780	So it's kind of important.
601780	602560	And, you know, when working
602560	604260	against large organizations,
604260	606220	by far the experience I have
606220	607340	is that most people use
607340	608840	the Outlook desktop client.
608840	610480	I think we can all agree on that, right?
610480	611660	That's a given.
612560	614240	Okay, so we got to take a step back then.
614240	615600	CSS, sure, we can use that.
615600	616860	We already scripted that way,
616860	619020	but we got to find some other way.
619020	620340	What other structure
620340	621840	could we possibly use
621840	625180	to create like a drawing
625180	626580	almost of pixels?
626580	628220	Like what could we use, right?
628260	629820	So the answer to that,
629820	632020	at least one, is tables.
632020	633320	So tables is something
633320	635460	that Outlook desktop client supports.
635460	636440	When I say tables,
636440	638480	I don't mean like Excel tables.
638480	640540	I mean like actual HTML tables
640540	642020	and rows and columns.
642020	643500	And they support styling.
643500	645100	So you could take a table
645100	646940	and you can style each column
646940	649020	in that either white color
649020	649980	or black color.
649980	651480	And you can create a QR code.
651660	653640	So again, me and ChattyPT sat down
653640	655760	one night and we created this.
655760	657180	So you set the cell spacing
657180	659260	and the cell padding to zero
659260	660180	or a given size
660180	662100	for how big QR code you want to make.
662100	663540	And then you basically start filling in,
663540	666340	okay, this pixel of this QR code is white.
666340	667280	Let's pad this
667280	668840	or let's make the background color
668840	670740	of this cell white or black, right?
670740	671840	And then you go through the whole thing
671840	674280	and voila, you got a beautiful
674280	676660	looking table in HTML.
676940	678460	And you got a beautiful looking QR code
678460	680000	in Outlook Desktop Client, right?
680000	680960	And this looks good.
680960	682240	I actually think this deserves
682400	683060	a round of applause,
683060	684900	to be perfectly honest with you.
685420	686740	And this is really dumb.
686740	688540	This is KISS all the way, right?
688540	690000	It's super simple, super dumb.
690000	690980	And is it effective?
690980	691900	That's the big question.
691900	692980	Is this effective?
693100	694640	So I actually, you know,
694640	696180	I reached into my paycheck
696180	698000	and I bought Microsoft Sentinel,
698000	699640	XDR, EDR, whatever they call it now.
699640	700940	They change them every week.
701300	703040	And I give them my money
703040	704020	and I wanted to test it.
704020	706380	So first I set up two accounts.
706380	707680	I set up Microsoft Sentinel.
707680	708340	I started monitoring
708340	709780	incoming email traffic.
709920	711720	And then I set out this QR code
711720	714080	in a Base64, as a Base64 image
714080	715480	embedded in the email.
715480	716560	And obviously Microsoft Sentinel
716560	717600	picked this right up.
717600	718080	It says, you know,
718080	719060	this is a QR code.
719060	720120	This is the URL.
720340	722020	That's Rick Roll,
722020	723280	if anybody recognized that.
723280	724180	Hacks, Elite Hacks are to you
724180	725380	if you recognize that.
725640	727260	And then I tried sending a table
727260	729500	and long and behold, nothing happened.
729500	730160	So Microsoft Sentinel
730160	731940	did not detect the table as an image
731940	733360	or as a QR code at all
733360	734800	and didn't parse it.
734800	736260	And therefore, as a defender,
736260	738140	you don't have telemetry for this.
738180	739640	So if I send a bunch of phishing emails
739640	741420	with QR codes generated as tables,
741420	742760	the URL will not pop up.
742760	743700	Nobody will spam it.
743700	744580	No bot will hit it
744580	745820	and it will reach a target
745820	748400	and it's still scannable by mobile devices.
748400	750200	So this works great.
750660	752220	Now this, I've already done this.
752220	753280	I talked about this at a conference
753480	754640	a couple of months back.
754640	757340	This is built into the tool Crucible,
757340	758680	which I'll talk about later.
758680	760140	And you can find that on GitHub.
760140	761220	It works great.
761220	763100	And yeah, it's cool.
763100	764660	But let's think about it
764660	765680	and take it a step further.
765680	768380	We can generate QR codes in CSS, sick.
768400	771120	We can generate QR codes in tables, even sicker.
771280	774220	But what about obfuscating email content
774220	775940	using tables?
776260	777280	Because think about it,
777280	779520	the table is essentially our drawing board.
779520	781080	We can draw whatever we want.
781080	783940	Each column in the table is a pixel for us, right?
784020	786340	So we could draw the entire email.
786540	787860	We could render HTML
787860	790480	and draw the entire thing as a table.
791020	793160	So this is what we dive into.
793160	794500	And this was a bit of a nightmare,
794500	795500	to be perfectly honest.
795500	796660	This is the process.
797100	798620	So we need to...
798620	799800	So the point, what I want to do,
799800	801080	I guess I should go back on this.
801080	802380	Why would you want to do this
802380	803420	in the first place, right?
803420	806240	So more and more defensive solutions out there
806240	808320	are using AI to get the context
808320	809440	of the email you're sending.
809440	810680	They're using risk scores.
810680	812300	They're using a context-aware AI
812300	813220	to understand, you know,
813220	815760	is this potentially a legitimate message
815760	817000	being delivered to my user?
817000	818520	And then based on the risk score, whatever,
818520	820060	it will be delivered, sandboxed,
820060	821420	looked at, whatever, right?
821580	823220	So the thought behind this is that
823220	825160	if we can obfuscate keywords
825160	828420	in the email, like MFA, like QR,
828420	830800	like re-authenticate, like Microsoft, right?
830800	832060	It's going to be much harder
832060	833420	for the AI model to determine
833420	834640	the context of the email
834640	836540	and if it's legitimate or not.
836540	838060	So the whole point behind this is
838060	839820	I want to take a keyword,
839820	841140	say re-authenticate,
841140	844160	and I want to render that as an image.
844160	846300	And then I want to turn it into a table.
846300	848520	And then I want to replace the keyword
848520	850680	in the email with that table.
850860	852540	So there's no text there.
852540	854900	It's a table representing the text.
855420	856480	So there's no text.
856480	857360	You can't select it,
857360	858500	but it looks like a text.
858500	859760	The end user will think it's text,
859760	860520	but it's not.
860980	862700	I went through this process.
862860	865220	So basically, you give the Python script
865220	866700	the email, the HTML email
866700	867640	that you want to send,
867640	868680	and then you tell it,
868680	870340	hey, I want to replace the keyword,
870340	871260	re-authenticate.
871380	873340	The Python script will then render the,
873340	874400	the Python script will then
874400	876880	inject a marker in that
876880	878700	as to handle that word.
878700	879780	So it will inject like a box
879780	881920	around the word in HTML,
881920	884120	and then it will render the entire email.
884120	885840	And then it will use image recognition
885840	888380	to cut out that box.
888580	889960	And then it will remove the borders
889960	891780	and turn it into a table.
892460	894300	And this is dumb and complicated,
894300	895220	and you would never think
895220	895880	this would work,
895880	897040	but it actually works.
897040	898360	So I'm going to demo that right now
898360	899780	so you can see that.
899960	904040	Hopefully, you can see my terminal now.
904040	905360	Can you see a terminal?
905440	906240	Great.
906260	908740	I'll try to clear this
908740	910920	and make it a bit bigger for you guys.
911840	914180	Like, ooh, okay.
914280	915540	So this is Crucible.
915540	916800	This is the help menu.
917180	917980	You give it a URL
917980	919600	that you want the QR code data,
919600	921360	the data you want inside the QR code
921360	922360	doesn't have to be URL,
922360	923560	but typically it's URL.
923560	925380	You want to set a QR code size.
925380	926800	You give it an input.
926800	927960	So you give it like a typically
927960	930420	like a phishing email template in HTML.
930420	932340	And then wherever the word
932340	934600	QR underscore placeholder is
934600	937580	will be replaced with a QR code table or CSS.
937620	939020	And then you give it an output path
939020	940700	if you don't want a random generated name.
940700	942440	You can choose if you want the CSS method
942440	943480	or the tables method,
943480	945920	and you can also generate output in straight EML,
945920	947000	which is an email format.
947000	948820	So you can just open it in Outlook afterwards,
948820	949940	which is super nice.
949980	952020	And then you have the obfuscate method.
952020	953740	So that's what I'll be demonstrating now.
954220	955560	So in this command here,
955560	957840	I'll be linking to Defcon.org.
957840	960440	I'm using my MFA or QR code template,
960440	962680	and then I'm obfuscating the keywords MFA,
962680	964060	QR, and Microsoft.
964060	966860	So those words will be pulled out
966860	967680	of the email template
967680	969300	and replaced with images
969300	972520	illustrated as tables in the new output.
974720	976680	So it worked, hopefully.
977200	980040	I have a backup if it doesn't.
981040	982440	Open Sesame.
983580	984640	Placeholder, I think.
984640	985240	No.
986320	987460	Oh, okay.
987520	988860	Hopefully this works.
989940	991060	Yeah.
991840	994120	So this is a table QR code,
994120	995340	and this is the...
995340	996540	Fuck, it broke.
996540	998460	Okay, it broke.
998460	999420	Give me a second here.
999420	1000920	I'll go back to the demo.
1002760	1004440	So it looks like this,
1004440	1006340	if the demo worked correctly.
1006520	1007840	And then this is the output.
1007840	1010180	So this is the generated email.
1010180	1013320	Can you spot the text that is tables?
1013480	1014660	There is text.
1014660	1015980	There are keywords in this email
1015980	1017500	that is not text.
1017920	1018980	Give you guys a second.
1018980	1020240	Some of it is obvious.
1020700	1022220	Some of it is not.
1022740	1025480	And all of this is not text.
1025980	1027400	This is tiny tables
1027400	1030260	inserted into the email template,
1030260	1032600	resulting in it looking like text,
1032600	1034180	but it not being text.
1036160	1037180	Round of applause.
1037180	1037980	Cue that.
1043460	1045020	And again, this works
1045020	1047120	when you're not demoing it live at DefCon.
1047920	1049860	And that's basically all I got.
1050160	1051740	Thank you so much, Adversary Village,
1051740	1052580	for having me.
1052580	1054200	I got stickers for the project.
1054200	1055560	Scan this QR code, if you trust me,
1055560	1056760	to get to the project.
1056900	1058320	And yeah, go out there and fish somebody
1058320	1060180	and improve our defenses
1060180	1062320	by some degree.
1062340	1063580	Thank you so much for being here, guys.
