start	end	text
0	5360	So, now it is 1 o'clock, and with all that setup time, we're good?
5440	6920	Yeah, we're good.
7100	11060	Right, we're good. So, it's my pleasure.
12380	17620	Jay, you presented... oh, wow, actually in this area, it seemed like yesterday, 2016.
17960	22720	So, without much ado, it's my pleasure to introduce to you, J.D. Martino Fidelis.
28680	30400	Thank you, guys. Thank you.
31560	37580	So, we've all kind of been there, most of us who kind of work like either SOC work or malware analysis,
37580	42340	or, you know, where you end up writing rules, right?
43800	47860	I'm just going to kind of give you a methodology, or at least my methodology,
47860	51400	of how I write rules and how I go about things.
52060	55100	You don't have to adopt it. I don't care if you do.
57160	65120	But hopefully, it gets better out there, and we can all rise up and start crafting good detections and whatnot.
65360	72600	So, my name is J.D. Martino, Head of Detections and Countermeasures for the Fidelis Threat Research.
73180	78100	That's just some fancy title my boss gave me. Really, I'm just like the rule bitch, right?
78100	81920	So, that's pretty much how it goes.
82980	85920	There are some prerequisites to this talk.
86980	91400	I do a lot with regular expressions and with Yara.
91400	95040	So, all my examples are going to kind of center around those two.
95560	101640	If you are unfamiliar with Yara, the talk that Ming just mentioned that I did back in 2016
102920	108260	was to catch an APT, Yara, and I go through more of the syntax and whatnot.
108260	112260	So, if you want to learn that, I definitely suggest going back and watching that.
113640	118400	Regular expressions, I don't know. I have good days and bad days, either way.
118400	122700	If you're not doing them every day, yeah, either way.
123280	129480	So, when you're writing detections, the real problem is that you and your coworkers,
129480	136080	you know, you're kind of building this structure, and it's very complicated, right?
136080	140280	And sometimes, you know, like the guy in the picture,
140280	143340	he may be looking down at what his coworker is doing.
143340	145680	He's like, what are you doing? I'm up here.
145680	150040	Or, hey, let's build this, and it's all disjointed and whatnot.
150140	154020	And there's a lot of complications. It's never really easy, right?
154040	159420	Because malware will be at all different layers upon the stack.
159420	161980	And the attack surface is at all different layers.
161980	166600	There's not one easy different thing over one protocol or, you know,
166600	172620	whether it be the file or the network layer, or even metadata and whatnot.
173500	180700	So, what happens when you two have been working alongside of each other,
180700	185480	and all of a sudden, your colleague leaves the company, right?
185560	189400	And everybody, you know, it's like, it's a normal thing.
189400	192400	And it's like, hey, cheers, we're going to throw a party for you.
192400	197120	And he's like, yeah, man, sorry for everything. We're going to be friends.
197220	201940	And then, like, Monday comes around, and then you look at one of his detections,
201940	206000	and you're like, holy... right?
207040	210740	It's like, I kind of equate it to Monopoly, right?
210740	216220	And you get the chance. Everybody wants to go and collect $200, right?
216220	217700	Everybody wants that.
217700	221120	But it's like, in this case, no, you've got to pay the other players.
221300	223780	You're taking your lumps. Like I said, I'm the rule bitch, right?
223780	225320	So, I learned this the hard way.
227260	232360	So, that being said, how do we rise up to the occasion, right?
234900	238040	So, I'm going to throw another one. I probably should have said this earlier.
239020	243380	The other prerequisite for this is a little bit of, you know, set theory and whatnot
243380	245540	that most of us probably learned in computer science.
245540	248100	So, yes, I'm going to give you some Venn diagrams.
248160	253520	It was the only way, or the best way, I can kind of convey it to you and whatnot.
254220	258100	And so, you know, you have your universal set. That's the set of everything.
258100	261040	Everything that's going on, whether it be the network, the endpoint.
261400	263760	And then you have your detection, your target, right?
263760	265360	What are you trying to signature?
265740	267140	I call it a target.
268160	274220	And so, it's, you know, you're trying to pick that needle out of the haystack.
275280	279320	So, when you finally go for it and you write your detection,
279320	282860	you end up getting these other set of events.
282860	287420	I really don't have a better name for them. They're just another set of events.
287540	290880	We all know them as mostly false positives, though, right?
290940	293880	But they're not exactly all the others.
293880	298480	They're just some random others that some of which happen to overlap with our target.
298480	300900	And those are the ones that are the false positives.
302800	306260	And so, you know, you have your red set.
306260	308560	Your red set on the left-hand side is the target.
308740	310980	That's your detection. The blue set is your other.
315430	320130	It may not always be large, you know, your other, your false positives.
320130	321550	They could be a lot smaller.
322350	325930	And then the purple area is in the middle. That's what you're trying to eliminate, right?
325930	327890	You're trying to eliminate that purple area.
329250	332090	So how do you do that? How do you do that?
332330	334270	I call it shrinkage.
337010	340450	So we want to shrink that other event set.
341270	347670	If we could shrink that other event set, we can get the union of the two sets to be smaller, right?
348610	356170	The typical way that people mostly do this is kind of with some sort of and not.
356170	360810	You know, hey, I got this detection. Oh, and not my domain controller.
360810	368610	Oh, and not this file that passes, you know, from this person to this person every day via cron job or something like that.
368610	378350	And so you have like these kind of one off detections where like, you know, this one set is a subset of your other.
378430	382670	And then you have another and it's a subset of that other.
382670	387530	And you have a third other, which is all still a subset of that other.
389150	397310	And so you end up with these long kind of daisy chains of and not situations where you're just kind of filtering out.
397770	405470	And, you know, those are those are somewhat maintainable, but those aren't really maintainable either.
405470	408530	At least they can get out of hand and whatnot, if not done properly.
411590	413430	So how do you do that?
413430	417570	So how do you how do you shrink, you know, your false positives?
419790	422570	There's like I said, there's the and not method.
422570	427530	But once you do that enough, your other set gets really, really small.
428210	434510	And it just like I said, it gets hard to maintain, but then your target set still stays large.
434730	446670	So is there anything and there's not so much of an overlap, but it's enough that it creates in your workflow where it takes time out of your workflow to be going through some of these false positives.
446850	449730	And you just don't want to be dealing with them anymore.
449730	453370	So we've manipulated the other set, right?
453370	457730	So what about maybe taking a look at the targeting set?
457770	468290	You know, and then so back to shrinkage, we're going to try and shrink that targeted set, your detection.
468290	471290	How do we shrink that profile, right?
471290	474590	That that that attack profile of that detection and whatnot.
474590	477090	And yes, you can do it.
480520	489100	One of the situations that the target set grows over time is because of false negative situations.
489400	499340	You get you find new activity all the time and your target set just you end up taking on more of these sets, your target one.
499340	503140	And now you have another target to some mutual exclusive set that has nothing.
503140	506360	It's involved, but then it's kind of not involved with the other set.
506360	508800	And then you have to merge those two together.
509720	513060	And then, like I said, that's a growing it's literally a growing problem.
513060	518680	You have two sets converging together and it's getting bigger in your other set.
518680	524700	May or may not be getting smaller, but it just doesn't become maintainable.
525420	532160	And what I like to call that is kind of the one rule to rule them all mentality.
532820	540020	Analysts like to write these catch all rules where, you know, the Lord of the Rings effect, I guess.
540020	550780	And so, you know, we write these really large monolithic detections that just like I said, they become unmaintainable. Right.
551600	557640	And so you got to kind of know when to separate or chain your detections.
557640	569420	And then you also you kind of drop or ignore some of the true positives and maybe even pick them up with another tech detection with either with a lesser confidence detection or with a lesser severity detection.
570720	575660	And so you you can kind of shrink that that target set a little bit.
575800	578980	Just to kind of give you an example. Right.
578980	588580	So at one point in my career, I inherited this network network Yara rule for ghost rat.
588920	596620	And it was literally it was it was 100 different beacon strings that we were targeting in the one rule.
596900	605300	And you look at the condition at the bottom and then all the number of conditions, all the number of beacon strings that we were we were looking at.
605300	618440	Notice the first for loop goes from A to Z and then there's another the second for loop from A star and then a third for loop B star and a fourth for loop C star.
618440	622580	So we've enumerated the alphabet going on the fourth time.
622580	629260	That's how many times we've enumerated those those those detections and whatnot.
629260	633940	And so what if what if one of them starts going crazy?
633940	638200	How do you how do you adjust this? How do you adjust something that's so monolithic?
638200	645660	You literally have 100 indicators of compromise in your in your target in your target set.
647320	653100	And we all get we all get defensive about our rules as analysts.
653340	657620	You know, it's our babies. We curate these and whatnot.
657620	661960	And so there is a kind of a fact that it's like, oh, precious.
661960	666780	Oh, yeah. And so, like, we don't want nothing to happen to them.
666780	671260	But the life cycle shows that we have to we have to do something about it.
672560	676000	So so let me give you some some clues enough.
676000	679540	I mean, I'll talk a little bit, but I'll give you some more kind of examples.
680000	682780	So how do you do that? You separate multiple detections.
682780	690900	You take the one take target set the full set. You separate it from target one and then target two.
690900	694520	And then they have a couple of other sets in between there as well.
695240	698160	And now your sets just got smaller. Right.
698160	705320	So this one is a lot larger. And then we've separated it out.
705420	708460	And now we have two smaller sets to kind of deal with.
708460	713520	One set may not be giving you problems, but another set may be giving you problems.
713520	716880	But at least when you do it, you've done your work up front.
716880	723100	You've done all your analysis up front that you don't necessarily have to manage the T1 set.
723100	728420	Or if the T1 set is giving you problems, you don't have to manage the T2 set when you go in and make your changes.
729000	734040	And then to even further slice it, you can make it into even more further slicing.
734040	741320	And then the sets become even smaller. And then they have a lot less kind of management and whatnot with them.
741760	747080	So just as a kind of warning, I am including some rules.
747080	749740	So I'm going to throw a bunch of walls of text at you.
750440	758720	If you do want to come back and watch the... there's a lot of good tidbits in some of these next few slides.
758720	762000	I suggest coming back. You're not going to ingest all this stuff.
762000	766120	And especially the syntax that I've got going on with some of these. You're going to be like, whoa, what's...
766120	770520	So you're going to need to take a second to kind of parse through it and whatnot, though.
770680	777040	But the main things that I want you to kind of focus for the next couple slides are the constructs and the naming and whatnot.
777040	779400	And I'll kind of walk you through the rest and whatnot.
779400	787420	So one thing you can do with Yara, at least, is you can separate by condition.
788420	800320	That ghost rule that I said earlier, notice that... so there was... I at least noticed that there was different lengths of our detection set, our indicators of compromise.
800360	807100	And so I kind of separated them and kind of grouped them by conditions in that case.
807120	814900	So I can group with the condition and it makes it easier to promote maintenance on your rules.
814900	820980	In these three examples, I have... I just have three, actually, but I had like up to 10.
821140	827260	I had up to 10 for all 100 different indicators. So I had 10 different rules that I was in managing.
827620	837320	But it was a lot easier because if one was false positing, I had a different confidence value when I need to make a change and whatnot about it.
837320	845480	And so rather than... I can then just focus on this one rule and all the other nine rules, I didn't even have to worry about.
845820	850820	So the ghost beacons, I split them up length four, just got like one little indicator.
850920	855800	Length five had 85 different indicators and indicators of compromise.
855800	859840	And then length six had... excuse me, had three of them.
863900	869020	And so how would you... how would you kind of separate just for... because not everybody knows Yara.
869020	873980	So an example, how would you kind of separate that in regular expressions?
874200	878500	I'll let you chew on this regular expression for a second while I take a sip and whatnot.
883870	894730	So this guy's kind of looking for like landing pages to do like man-in-the-middle attacks for PayPal, you know, Yahoo, Hotmail.
895650	900290	They got PowerPoint online, Word online, so like Office 365 and whatnot.
901310	905870	These are all these kind of landing pages that they're trying to man-in-the-middle and get your credentials.
907370	913150	And with the regular expressions, you're just grouping the IOCs with the or clause pretty much.
913250	922910	And so that's how you would do the equivalent of this rule from Yara, similar in a regular expression.
923190	927890	It's a totally different detection, but it's the same idea, same concept and whatnot.
930940	939480	So another thing is that you can separate your indicators by, so I talked about the condition statement in Yara,
939480	947040	but you can also separate them towards the indicators of compromise as well, grouping the indicators of compromise.
947140	953520	So what I like to do, so these are four different rules for strings out of an APT3 binary.
953520	963280	Notice the hash is all the same for all four rules, but I have four different rules for strings.
963800	969080	What's the thing that I said earlier, the one rule to rule them all? That's what most analysts do.
969100	974700	They all want to just jumble them up into one Yara rule and say, hey, give me this and do, you know,
974700	981060	gives you some kind of complex expression at the end of the condition and say, hey, this grouping or this grouping
981060	988460	or this other grouping or this other grouping. Well, you can, if you break them out into different rules
988460	997940	and then you be very selective with your rule names, excuse me, you can bring a lot of value to your analysis.
997940	1004620	When you start separating your detections like this, you start augmenting your analysis and you can say,
1004620	1013680	hey, this, I got this one binary here. It hit on one of these four string rules for APT3.
1013980	1021620	Maybe that's not an APT3 binary, but I got this other binary that hit on three of the four.
1021740	1028160	And so when it hits on three of the four, you're like, OK, it's more than likely APT.
1028160	1034460	And then, oh, wait, so we didn't have the fifth, the fourth rule. So maybe there's a shift in your detections.
1034460	1041940	Maybe you're detecting, you're, you're detecting the shift in, in targeting and whatnot.
1041940	1046400	And so their binaries are kind of changing. You know, they may have a different campaign going on.
1046400	1053380	And so a different person on the team is compiling these or something and or they fix their incorrect spellings and whatnot.
1053540	1061200	And so, like, if you look at some of these groupings, just I have some regular strings, just unique, very unique strings.
1061200	1074020	Then I have network GUID strings. And so and then notice that with the with the first rule there of strings that I say any of them.
1074020	1077580	Right. So that's basically the or clause with any of them.
1077580	1083340	And any one of those strings would are unique enough that they could stand on their own.
1083340	1089320	You don't need any other supporting strings to kind of make your detection and whatnot.
1089320	1093980	Now, there's a couple where there's two rules. There's two rules with any of them. And there's two rules with all of them.
1093980	1100440	And so the rules with all of them, where it says all of them in the condition, those are your lesser quality indicators.
1100440	1109960	You can still group them, but you need the strength of all four indicators of compromise to say to give you that confidence layer layer on your head and whatnot.
1110140	1116340	And so if you look and then there's a there's output strings, bad grammar. So I'm even calling out bad grammar.
1116340	1124200	You know, when people make mistakes in spellings now, granted, there's a lot of code reuse and whatnot.
1124420	1133640	So when you have all these mistakes like this, especially grammar mistakes, you can generally kind of attributed to one one person or.
1133640	1140520	But if you start seeing more and more than and there's a lot of different compilations floating around, there's probably some code reuse going on as well.
1140520	1142760	And that's how you would detect that stuff.
1143720	1150060	And then you have more output strings. So the output of this tool was our APT remote command tool.
1150860	1155340	I can't remember if I wrote these rules. I probably did. I don't know. I didn't put my name.
1155340	1158100	I guess I should have put my name on it, whether I was the author or not, though.
1158220	1167860	But it's a good grouping. It's a good representation of what I'm trying to convey to you guys on splitting up your detections to make them more manageable and whatnot.
1170720	1177020	So let's see, one more. Yeah, one more wall of text and then we'll get back to some other stuff.
1178760	1190660	So we talked about groupings by conditions. We talked about groupings by indicators of compromise, your string sections, or in with regex, you know, you're using your or statement.
1193320	1201100	The next one, you still want to try and create multiple detections, but you want to use multiple detection methods.
1201160	1206380	So I have three rules up here that are all looking for the same technique.
1206380	1211720	They're looking for a very simple embedded executable. That's it.
1212580	1220980	Well, maybe the detections are a little fancy, but nothing fancy about the technique that I'm trying to detect.
1221060	1229820	And like I said, this is what I said earlier about how when you build enough of these rules, the more rules you have, the more you can augment your analysis.
1229820	1243600	And so you can save this time up front on by just by running Yara or your regular expressions and let those automated scans do your triage for you.
1243600	1261340	And so when you can have a large enough rule set to scanning and do triage, and then you can have, without even throwing the binary in a hex editor or IDAPRO or even a text editor or something like that, you can run it against your rule set.
1261820	1266540	And you can get somewhat of a disposition, whether it be benign.
1266940	1271800	You still may need to verify it. If it's benign, you can get some sort of suspect disposition.
1271800	1276040	It's doing all these techniques, but then there's nothing attributable that's going on.
1276040	1281540	Or you can get a malicious disposition right off the bat if you have an attributable signature.
1281720	1286460	And so you can say, hey, this is definitely malicious. I can attribute it to this group.
1287060	1291160	How much more do I need to spend on this so I can move on to the next binary?
1292580	1298040	So, like I said, these are three different rules targeting embedded executables.
1298040	1301220	One of them looks for more than one DOS stub.
1301220	1311100	So the DOS, the 16-bit DOS stub that's present in the 32-bit Windows PE header, or just before it, I'm sorry, the MZ header, the 16-bit.
1311800	1314180	So it looks for multiple DOS stubs.
1314180	1319420	The other one, it looks for a possible PE structure in which the DOS stub may have been stripped.
1319420	1323060	And then there's another one that looks for a DOS stub.
1323340	1328780	It just looks for an additional DOS stub past the initial DOS header.
1328860	1337160	And so, well, what happens if the outer binary doesn't have a DOS stub and then the embedded binary does?
1337160	1343400	And so these are three different techniques to kind of catch embedded executables using these rules.
1346240	1351620	So next I want to talk to you about some detection targeting approaches and whatnot.
1351760	1353480	But first, let me take a step.
1357980	1359840	So we're all on the hunt, right?
1360220	1361560	We're all on the hunt.
1363500	1366280	What was the Black Hat talk?
1367400	1368700	2015, big game hunting.
1368700	1372140	We're all on the hunt for big game, big game malware and whatnot.
1373200	1376240	The original big game was JAWS, right?
1378980	1384400	So as, you know, as I go through all my data, I realize some things.
1386920	1391640	And that I'm hunting, but as a malware analyst, right?
1391800	1394120	So I'm always on the hunt for that big game.
1394120	1401480	So I can make an argument of this is bad, you know, and it could be just some random file.
1401480	1405280	This is bad any day of the week, blah, blah, blah, because of the context you give it to me in.
1407600	1410400	And I can do that a couple different ways.
1410400	1415940	I can do that with kind of unique code DNA.
1416220	1423100	You can either do it with the strings, with the very unique strings, or you can do it with unique byte sequences, right?
1423100	1428520	So that unique DNA allows you to track the families and go hunt.
1430020	1443300	But I noticed when hunting that the data that I was looking, or the rules that I was producing, based on the data that I was looking at, I had a bias.
1443500	1447920	Like I said, I can make an argument for anything to be malicious, right?
1448020	1452580	And given a limited scope of the view.
1452580	1459120	And so my, I didn't realize, but my detections also were becoming biased.
1461180	1466460	And so, you know, we're hunting for that shark, we're hunting for jaws, right?
1466460	1468680	And we see the fin come out the water.
1468680	1477420	But then we look under the water, we look and we see the whole scope, and it's just some guy wearing a shark fin, right?
1479240	1483180	And you're confused. You're like, wait, I thought this guy was bad.
1483360	1485200	You know, why is he not bad?
1485200	1488900	But it's just some guy with a shark fin strapped to his back, right?
1488900	1491200	Now, once you've seen the whole picture.
1491560	1499200	And I got that way actually, or at least I noticed that because just enough customers are like, no, this is good.
1499200	1500460	I'm like, no, this is bad.
1500460	1501820	And they're like, no, this is good.
1501860	1505700	And so I would argue with people and whatnot.
1505700	1508780	And so I noticed the bias in the detections.
1508820	1512040	And so I noticed that a lot of my detections were as a malware analyst.
1512040	1517500	And so I got to thinking, well, what would a network admin's detection be like?
1517680	1523040	You know, how would they write a detection and whatnot?
1523040	1532040	With malware authors, we're looking in a sea of bad or a sea of... let's see, what's...
1532040	1536620	Yeah, we're looking from a sea of bad that ignore the good.
1536940	1540800	And then the network admins are writing their detections.
1540800	1547680	They're writing detections from a sea of good to detect or highlight the anomalous bad.
1547680	1555160	So they're almost seeing this kind of inverse view of what we're looking at as a malware author.
1559830	1564530	So how do you write a malware analyst detection in Regex?
1564530	1572710	I showed you the one prior with the kind of the DNA, the unique sequences.
1572710	1574830	But how do you write that in Regex?
1575350	1578290	So I had a customer that was like, hey, I want to see these.
1578290	1584310	They had these custom mail headers and they were getting mail from all over the world.
1584630	1587710	And they were like, look, I know I know this is bad.
1587710	1590410	It's coming from this country or it's coming from that country.
1590410	1592310	And how do I detect this stuff?
1592310	1597350	So I started writing these regular expressions and then it quickly got out of hand for him.
1597350	1601050	He's like, look now, you know, he's like, you showed me how to do this.
1601050	1608370	But now, look, we've got 1, 2, 3, 4, 5, 6, 7 different countries and I'm getting new ones popping up every other day or so.
1608510	1613550	And so we can't really take that approach in our detections.
1613550	1617290	Right. Or at least the network admins can't take that approach in our detections.
1617290	1620570	So I had to kind of think of it. I had to flip and I had to go inverse.
1620570	1627550	How would I do this? And he's like, you know, really, we only do business with these three companies.
1627550	1635990	I mean, three countries. And he's like, if you can write me a signature that, you know, if it's not these three countries.
1635990	1640250	And I know like the DoD, they got Five Eyes and stuff like that.
1640250	1651030	Like there's smaller companies that, you know, they're only doing they know they don't have an office in Madagascar or something like that or Nigeria.
1651050	1657110	And I mean, they may have a Nigerian maybe related to a Nigerian prince, but they don't have an office office in Nigeria.
1657110	1664530	Right. And so and then they had these other kind of headers that were coming in through through one of their things upstream.
1665190	1669390	And they were marking all this mail stuff for us. I'm like, man, this is a gold mine here. Right.
1669390	1678970	And he's like, look, I want to find all these different these different detections based on these or the non presence of these strings and whatnot.
1678970	1685150	So I I kind of took the I went to the red the regular expression route.
1686550	1696970	And and when I inversed it, I I came up with negative look aheads. Right.
1697130	1705310	And so they're a little complex. Like I said, if you want to read into them, go back to the talk afterwards and kind of see it.
1705310	1711130	It's all about creating a set and then you have a match to non match on and then another matching set.
1711130	1718130	It gets a little hairy, but I definitely suggest going on like regex 101 to help you build your regular expressions and whatnot, though.
1718370	1724270	And I came up with three these three detections for these three different X headers for the situations that he wanted me to do.
1724330	1728350	And it worked out great. He's like, man, this is awesome. I don't have to do it.
1728350	1736370	I don't have to do any maintenance anymore for these these detections. And and it did everything that he wanted to accomplish.
1738630	1743650	So, you know, and that was kind of looking at that that inverse view. Right.
1745010	1750150	So we talked about kind of the malware analyst detections.
1750150	1760110	We talked about the bias that it kind of creates and how a network admin has a different view to it and whatnot.
1760910	1763910	But how do you get longevity out of your stuff?
1764830	1773030	And I have a technique that I call, I don't know how else to describe them, just circular detections.
1773030	1780310	I'll write a couple of rules based on a few things. And and those two those two target rule sets are mutually exclusive.
1780310	1786930	Right. They have nothing. They share the sample, but they don't share any same indicators of compromise.
1786990	1792810	Right. And so so I'll create these these circular detections.
1792810	1797670	I'll have rule one and it's and it detects a piece of malware.
1797990	1802830	But then I have another rule that I built off of my original source.
1803450	1811210	But rule one detected this malware. But rule two didn't trigger. Analyze it.
1811210	1817750	We know it's malware. But when I analyze it, I get an update to rule two.
1819750	1829370	So I got that rule. I got a new indicator of compromise for rule two that I didn't already have from my first original sample.
1829370	1835430	Right. And most people who do a lot of virus total or reversing labs hunting do a lot of retro hunts.
1835490	1841470	You guys are used to this stuff kind of panning out and finding the broader campaign.
1842490	1853070	This is a kind of common thing, but I want everybody else who's not a malware analyst or not a malware hunter to kind of, you know, learn this stuff.
1853070	1858550	So that's why I'm telling you about it. And so how do you do these circular detections? Right.
1861570	1867350	So my first round, this is actually a throwback to my old talk.
1867350	1874530	The payload names. I found these weird little payload names and these small DLLs that were getting loaded up.
1875150	1884430	And they kind of had some of these unique names. Now, it's set up that MSI may not be unique, but it's kind of unique in the context of it's a DLL and it's only 11k, right?
1885510	1889770	And then I came up with a string deobfuscation routine.
1889770	1911290	And that routine, so I had the payload name that was embedded into the loader and I had a string deobfuscation routine that was also embedded in the loader, but it deobfuscated the payload, not the strings for the file.
1911290	1920810	And so I run it, I do a retro hunt, find a bunch of other files, and then I go on to round two.
1920810	1930170	And I found some new payload names, so my set of indicators of compromise just got larger, right?
1930170	1935390	And they all stand apart from each other, so they can all be a detection on their own.
1936330	1941270	But I went from having two payload names to I now have eight payload names.
1942690	1951970	And then, instead of having just one byte sequence for the payload deobfuscation, I now have three.
1951970	1956290	I only got two rules up there, plus the previous one.
1956290	1957910	And so I ended up getting three.
1957910	1966830	And I keep doing these iterations and I keep finding more rules, I mean, more Intel and I keep finding more malware.
1966830	1977330	And in the end, I end up with like 27 payload names, some of which may not have even been PlugX for the payload.
1977330	1984710	So they were using a similar delivery method, or at least I suspect they were using a similar delivery method for a couple different pieces of malware.
1984710	1994990	And then, for as far as the strings, and then the byte sequences, I came up with 11 different byte sequence rules.
1996490	2011790	And so I would have a subset at any one time, if a file was scanned, I'd have a subset of maybe 5 out of 10 of these byte sequence rules would trigger on one of those things.
2011790	2016670	But if it got like 2 out of 10, then maybe I'd take a look at it.
2016770	2025410	But if I got a high number of matches, detections, then I would just kind of roll with it, right?
2025790	2027950	And kind of update it as I go along.
2029610	2033630	So, I'm all about stories.
2035130	2039830	My next one is a story, because we're all in the trenches, right?
2040470	2044830	And so I had a buddy of mine, Fish is his name.
2045050	2050150	And he calls me up one day and he's like, dude, we got hacked by the Russians.
2050210	2051210	I'm like, what?
2052430	2053150	Yeah.
2054030	2057010	And so I'm like, he's like, we got hacked by the Russians.
2057010	2058050	I'm like, no we didn't, dude.
2058050	2060650	I'm like, alright, we'll take a look at it, right?
2060990	2063190	And it's this, this, and this.
2063190	2064850	And he's all excited.
2064970	2066950	And it was the day before Thanksgiving, right?
2066950	2068250	And I'm on vacation.
2069830	2071510	It's Sunday at four o'clock, right?
2071510	2074270	It always happens on the weekend, right?
2074270	2077070	Or it always happens when you're on vacation, right?
2077990	2083270	And so we called it Operation Turkey Eve, because it was the day before Thanksgiving.
2083490	2085270	And he's calling me up.
2085270	2087530	And we're getting on the phone, we're talking back and forth.
2087530	2095150	And I'm like, walk me down the path that you arrived to, however it is, right?
2095350	2098310	And so he walks me down this path.
2098310	2101450	But I'm a guy that, I gotta look at the data, right?
2101450	2105150	I can't just take somebody else's word off the phone.
2106290	2117550	And so one of the big things that he pointed me out to was the file in question had a hit in VirusTotal.
2117550	2121490	And it was tagged by Thor APT scanner.
2121490	2129010	And it was tagged FancyBear, which is supposedly Russia, right?
2129350	2132010	Whether it is, whether it isn't, I don't know, but either way.
2132050	2138730	So that's what he, and we'll just say that it is just for the matter of fact, because he's like, yeah, we got it, we're Russian, blah, blah, blah.
2138790	2140470	So it says it's tagged by FancyBear.
2140470	2142970	And it says it's MAL, MAL FancyBear.
2143090	2149410	And it says CompuTrace agent, or computer, yeah, CompuTrace agent.
2149410	2155110	And so I'm looking at these files, and they look like malware.
2155110	2157170	They really look like malware.
2157170	2160250	The loaders are doing this crazy stuff.
2160250	2163590	They're using an undocumented API.
2163590	2166970	It's an arbitrary binary loader.
2167590	2172870	And it really looked like malware.
2172870	2175750	Just something that you wouldn't normally do, right?
2175870	2178450	And so I'm tearing through it, I'm tearing through it.
2179310	2183750	And for a good like three hours, I'm like, maybe we did get hacked, right?
2183750	2184890	Maybe we did.
2185010	2188890	But I was like, I got to see this through the end, right?
2189190	2193610	And by this time, I think it was like 12 o'clock at night, day before Thanksgiving.
2193750	2195850	Got to get the family up the next morning, right?
2195850	2197150	I'm not giving up.
2197550	2207310	And good thing that the person who wrote the rule, or at least I traced it back to where the source came for the rule.
2207310	2214070	Good thing, he actually uses a lot of things that I kind of preach, which is a good naming convention.
2214770	2219770	And also having good complete descriptions and whatnot.
2219770	2223250	And then also sourcing where your information came from.
2223330	2227890	So I noticed that this author, I'm not going to say his name, because I actually do respect him a lot.
2227890	2230350	But we're all human, we all make mistakes.
2231030	2235370	And it came from a report from Arbor Networks.
2235370	2240270	And so I was like, let me go back to this report that Arbor has.
2240270	2241950	And let me read their report.
2242450	2247390	And I probably read that report like four times.
2247410	2248830	Really, like four times.
2248830	2251690	I'm like, what is going on here? What is going on here?
2251890	2257210	And at the end of the report, they give a YARA rule.
2257210	2272650	And I'm looking, and I'm looking, and I'm like, this YARA rule looks similar to the YARA rule that Thor APT scanner used to kind of make this attribution.
2272710	2279610	And the name of the rule, and hats off to Arbor as well, they're doing good naming conventions.
2279990	2281850	They're doing descriptions.
2281850	2284470	Now, they didn't source anything, but that's fine, though.
2286810	2291770	And the name of the rule just says CompuTrace agent.
2291770	2293330	And I'm like, well, wait a second.
2293330	2295890	So I had to kind of dig more and dig more.
2295890	2309550	And turns out that what was going on was Fancy Bear was taking this CompuTrace agent, and they were patching the beacon, the domain beacon.
2309550	2311170	That's all they were doing.
2311170	2319850	And a normal CompuTrace agent, DLL, different from a Fancy Bear was only 28 bytes.
2319970	2322590	And then it was XORed, so it was obfuscated.
2322590	2328710	And so since it was obfuscated, you can't pre-predict what those domains are going to be.
2328710	2333470	So how do you signature the unsignatureable, right?
2333470	2338130	There is no real code in there that's attributable to Fancy Bear.
2338130	2341410	So this was a CompuTrace binary.
2343790	2350650	And so it took me a while to kind of tear it down and to kind of come to this discovery, did a byte-by-byte comparison.
2350650	2353950	And finally, I was like, no, we didn't get hacked by the Russians.
2354190	2359570	It's just whoever we have, like one box in the network that has this CompuTrace software running.
2359630	2362510	Let's go get the IT department, let's clean it up and whatnot.
2362510	2369410	And so, and to Thor APT Scanner's kind of credit, he...
2369410	2373330	So this was the day before Thanksgiving, so that's November 2018.
2373690	2379990	And then on March 2019, he actually renamed the rule.
2380330	2383190	He changed it instead of MAL for the first three.
2383190	2387950	He changed it to PUP, which is Potentially Unwanted Program.
2388090	2390910	Thanks to a colleague of mine, I was like, what is PUP, right?
2390910	2393990	And even I was like, I'm a seasoned guy.
2393990	2395190	I was like, what is PUP?
2395190	2399570	And I was like, what does that make any difference?
2399570	2403950	Well, it... but he still got the fancy bear attribution in there.
2404030	2411670	And that rule, once you look at it, it's hitting on all these CompuTrace binaries in VirusTotal.
2411670	2413810	Maybe it's running in reversing labs as well.
2413810	2418150	So anybody who goes and looks up a CompuTrace binary in VirusTotal,
2418150	2422750	they're going to get false attribution of fancy bear for this binary.
2422750	2426990	And then they themselves will be think they got hacked by fancy bear.
2426990	2432030	And so you see that domino effect of, you know, the just prop...
2432530	2436990	doing things kind of proper, taking your time, you know, making multiple detections
2437710	2442270	and, you know, doing proper naming conventions and whatnot,
2442270	2449910	and just kind of slowing it up a bit and not having that one rule to kind of rule them all mentality.
2450070	2452730	And so that's kind of my story.
2453110	2457990	Does anybody kind of have any questions or anything or what?
2482670	2489410	I would say, yeah, maybe you can do some automation into it and look at ratios and whatnot.
2490210	2495090	I kind of, when I do my circular detections, I do a lot of bytecode optimizations.
2495450	2498950	And I'll look back at the assembly table.
2499030	2502530	Take a look back at my previous talk and I talked a little bit about it.
2502530	2503850	But where do you stop?
2503850	2509130	Yeah, it's most of the time it's kind of by the analyst because most of us, I mean, we're all pretty bad.
2509170	2512010	We're doing things, we're hand jamming things.
2512270	2516830	Most of us probably should be, you know, because we all, a lot of the SOC people,
2516830	2519050	they're just getting things on a whim.
2519390	2524310	And, you know, if they write a script, take an hour out of their time and write a script,
2524310	2527790	they may never use that script again and do any kind of automation with it.
2527790	2531830	But with the rules that you're doing, you can do some triage up front.
2531830	2534950	But yeah, where do you kind of stop? It is kind of up to the analyst.
2534950	2538590	You just got to find that line within your workflow, I'd say.
2538650	2543610	If you do have it in a malware shop and you got a big, a much bigger automated workflow,
2543610	2549310	then I'd say, then you got to need to see, you know, give it some thresholds or something like that and say,
2549310	2557470	Hey, you know, I got some malware that in my eyes is pretty rare and whatever the source that may came from.
2557530	2564630	And let's say if I get a hundred hits on it, I'll, I'll just stop right there, right?
2564630	2572410	If I get a hundred hits, because probably more than it's a high confidence, very targeted sample.
2573250	2578770	Why are there going to be a hundred hits out there, you know, or you get a thousand, you can bump that up to a thousand maybe.
2578770	2585250	And so once you kind of get to that, that level, you can kind of say, okay, yeah, this is a lot of noise.
2585250	2594810	But then once your rule set gets more mature, you can leverage more of your rule set to kind of give you that other feeling.
2594810	2597530	So you don't, you're not really always relying on the numbers.
2597530	2602390	Does that kind of make sense? So at least in my, that's my point of view.
2602450	2613040	So, yeah. Any other questions? I know it was a lot, guys.
2613040	2616140	And I thank you and thank you for, for all the people that have stayed.
2616340	2622280	A lot of technical stuff. Go back and watch it. A lot of text on there.
2622480	2626340	Chew on some of those YARA rules and whatnot. If you haven't played with it, play with it.
2626340	2629680	It's a great thing. Regular expressions too and whatnot.
2629680	2632320	So, yeah. Thank you, guys.
