Welcome to Project Obsidian. This is Thornhuffton Kill Chain 1. The title of this is Go Fish! Visualizing Basic Malice. And this will be by myself, SamanowskiX. A little bit about myself, who I am. I'm SamanowskiX. I'm a tinkerer. I'm also a SOC team member for an organization. I am a blue team enthusiast, have been for many, many years. I am also an instructor, but most of all, I am also a student. So let's take a look at what we're going to be learning today. First of all, we're going to learn what fishing is and what is a fishing payload in context of fishing. We're going to be learning what visual basic malice. For applications is. We're also going to learn what macros are and what does this have to do with fishing and threat hunting. And we'll also learn how to walk through the process from a hypothesis to tangible results during a threat hunt. Also, we're going to recognize what tools that we have in our arsenal and what can we do with it for our threat hunt. So let's take a look at fishing. So fishing is still one of the most common attack methods in use today. Generally, what fishing means is that it's a way for an adversary to get credentials or information from an individual via nefarious or malicious means. A fishing payload is the method of getting that data. So a fishing payload could be a document, a zip file, a link in an email. We also are going to learn there are differences between these different types of payloads. We'll see that a little bit later. Here are a couple of examples of some fishing payloads that I've seen in my actual day to day experience. Here's one example. So this is an IT security update from the IT help desk. And if you look at this, it is, has so many warnings that a user would be I'd be surprised if a user would actually click on the the email link that's in it. However, let's take a look at it. Microsoft gives you an email header that says this person's from outside of your organization. They also have another one inside saying that the email is from an external source. The warnings are there. In the actual body of the email, we see it says your email account will be deactivated shortly to stop deactivation. Click here. Companies are not going to do that. If somebody were to click on the click here button, it would take them to a site that would have them enter their credentials. Part of what makes phishing a little bit more concerning is that the adversaries will try to use a sense of urgency, or you need to do this immediately, or you need to do this before the end of the day, or you'll lose something, or we'll charge you, or something like that. Okay. Let's take another look at another one. Say the user clicks on a link that says, hey, here's something that, here's some money that you owe. We need you to review it. So they would click on the link, and they would get something like this. This is obviously inside of a web page, and there is a box that says that your authentication is needed to log into this document. This is not legit. We have another one as well. This comes from, goes back to the urgency that we discussed earlier. This is an invoice that's urgent. If you take a look at the spelling in the email, there's often misspellings. That's not always an absolute tell, but it's one of those signs that could mean that it is potentially malicious. And then we have the invoice.dlcx, which is a Microsoft Word document. That most likely has a malicious payload inside of it via a macro, which we'll learn about later. So Visual Basic for Applications. We call it BBA for short. But it's Microsoft's generous gift for extensibility in Office. So what this does, this allows for adding functionality in Microsoft Word, PowerPoint, Excel, Access, Microsoft Project, I believe, or Publisher. But what that does is it allows a file to interact with the underlying operating system or other Office applications to transfer data or do different things between different applications automatically. That could be a good thing, but it more than likely is a bad thing. We refer to these functions as macros. And as I discussed, it's not limited in scope to just the Office applications, which is what makes this kind of a bigger issue, except if it were not just limited to the Office applications. As I said, this can be a rather large concern. With the amount of privilege. And the actions that can be done with this functionality. This can actually be weaponized by adversaries. And we'll see an example of that here shortly. The macros can perform the actions automatically and without, sometimes without obvious signs, just by opening a document. Or a file that contains active macros. What are the implications? If a user downloads an email, a file from an email, and they open the document, and they click a button, that could activate additional downloads of malicious files from an adversary's systems. What does a macro look like? Here's an example of a macro that is not a macro. It's not legitimate. But this is what the macro interface looks like in Microsoft Office applications. Let's think a little bit about what our scenario is right now. Let's say I'm a new team member of the Magnum Tempest MT security team. I've been asked to build a threat hunt based on what I think might have been missed in the environment. But I've never done a threat hunt before. Where do I start? So first things first, what you need to do is we need to start with a hypothesis. All threat hunts need to start with a hypothesis in mind because you need to know what you're looking for. For me, I'm focusing on macro usage in the environment. So visual basic frames. For applications, macros. I'm going to start with a broad hypothesis. And I'm going to presume that Magnum Tempest employees receive malicious documents or malicious emails. This is a good starting point, but it's far too broad because malicious emails, yes, we will get that. But we need to kind of refine that hypothesis a little more direct. So let's refine. And what we come up with is Magnum Tempest employees are targeted with malicious Microsoft documents containing BBA macros via phishing email. And we're going to presume that some employees will download and open and detonate these malicious documents. Let's see if we've got this right here. Let's go all the way to where I think we are. Well, what's important to note about This is That a lot of what we're going to be going over And doing here is specifically structured towards the Splunk query language, But these concepts Can be applied To any platform. to another. We won't be discussing that here, but that is available. So let's start with the ThreadHunt. So we need to start with a query in Splunk, but we need to know what sources we have available. So yeah, we could start by just going across the entire platform and just go index equals asterisk. Let's take a look and see what we get when we do that. So we're going to type index equals star. We have no hits right now, but that's because we need to go to the timeline here. And for lack of a better time period, let's go with all time and then click on search. So we're going to go to the timeline here, and we're going to type index equals star. Interesting. We have nothing. So let's take a look. Let's kind of refine it a little bit more. Oh, we do. As you see, the search is increasing. Oh, this is more. These are more entries than we could ever want. Let's go through and parse. And this number is just going to go higher and higher. Let's stop this right now. Let's go back to our drawing board. Let's see what else we can do. And for reference, this is bad practice to do the asterisk, with a query. Because it's a great way to get server admins mad at you for slowing down the system. But you might also not get exactly what you're expecting. You might get more, and you won't be able to kind of refine your query as much. So let's take a look at a query that we could use. So this one will summarize all of the log sources that we have in Splunk. Now, I'm going to cheat, because I already have this as a search in my history. So I'm going to add that to my search. I'm going to do all time, and I'm going to search. OK. So we see we have a number of different indexes. We have 12 results. And the ones that kind of stand out to me right now is Zeek, because Zeek will allow me to get information about data that is being transmitted over the wire, so over the network. Let's go back and look and see what we can do with that information. So this is what we saw. Again, we're just start with zeek let's see what what files are transmitted over the network so instead of putting the asterisk we're going to go index zeek and as i said previously we need to set a date range for the what we're going through and for the example we're going to use uh february 11th through february 13th of 2022. index equals zeek i'm going to do date range between february 11th and february 13th i'm going to apply that and then we're going to search as you still see we still have a rather large amount of events still we need to refine that a little bit better go back to our drawing board we already know that we're dealing with microsoft office documents uh and with the macro behavior so let's see what we can do so our typical microsoft document files that we typically see being transmitted over uh email and attacks are dot dlc dot dlc x dot xls and dot xlsx so we have microsoft word documents and excel documents let's see if we can add that to the query like this index equals zeek dot doc or dot docx or dot xls or dot xlsx so let's add that to our query and i have that here so let's query that okay we're getting better we have 863 events so let's scroll through and see what we can see that's still a lot of documents so we want to see can we refine that a little bit better see what what we can do as you see we saw 863 events and then we're going to add that to our query so let's check that out what do we what do we find there were a lot of events we can probably narrow down this more so we've got the initial uh entry uh index.z frequently not these document formats but this is also probably a great point to bring up something that's integral for blood hunting What worked? What didn't work? And for the purposes of this, we're keeping track as we go along. How can we refine this search? Since we're focusing on supposed phishing emails, we can look at common terms that are used in phishing documents. SANS has a cool extensive list. It's not comprehensive, but it's very useful at this link here. And we can use some terms to fine tune the search. So let's add some of the ones that I found. Invoice. We see a lot of that or remit or payment or order. So let's go back to Splunk. Let's see how that looks. So while these are common phishing email document names or it could be part of emails, we're not getting very many hits. We're actually getting no hits. So let's go back to the drawing board. Let's try using another index. This is Sysmon. So what Sysmon will do. Sysmon will... Is essentially giving you telemetry from the endpoint. Much how Z gives you telemetry from the network. So let's add Sysmon to that if we have any hits. Again, no hits. Okay. So perhaps we should try a different approach. Let's go back. As you see, we had no event. Okay. What can we do to get better results? Again, we want to probably go back to our notes. Kind of see what we've done so far. What hasn't worked. And let's see what else we can do to kind of fine tune. Maybe do some external searching. See what we can kind of do to get better results. But we need to go back and remember what we were looking for when we started, right? We're looking for Visual Basic for applications macro evidence tied to Office documents obtained via email. Is there a way for us to determine via logs that a macro has been executed? Yes. Obviously. Because SANS actually has a really nice explanation of registry entries that will indicate that a macro has been activated. According to SANS, we can look for something called trust records. And this indicates macro execution on a system. And this is from the web page from SANS. It points out one of the few places where macro execution leaves traces is in the trust records entry in the registry. And we can see that right here in this box. And that's something that we can use in our search. So let's try to add that and see if we can find trust records in our query. So we're going to stick with our initial index in Deacon Sysmon. And we're going to add trust records to that. We're going to take this out. I'm going to do trust records. And let's see what happens. Let's see what we get. Okay. So we get 48 events. Let's see what we have. Okay. So we're going to look here. We see this. This file right here. Employee code of conduct. But this one appears on a file server. So let's take a look and see. Okay. Well, this is evidence of a macro. So let's go back and look at this. Okay. So we have a result. And the first event we see, it's an internal file share, as we noticed. What's the significance of it being a file share? It appears to be a company file share. We're looking for documents downloaded by a user via email. We're not going to likely see this on a file share, at least not initially. We would expect to see it on a user's desktop or endpoint. So let's take a look and see how many of these events are located on the file share. So by doing that, in doing that, we're going to have the trust records. But then we're going to add in and end files.magnumtempestfinancial.com. Let's go back to our blog. Okay. All right. Okay. And I have that here. Files.magnumtempest.com. So we get 26 events. Okay. Employee code of conduct. Employee code of conduct. Marketing template. Marketing template. Okay. So at this point, I am fairly confident that that's not necessarily malicious. Could be. But going based off my hypothesis of being from an email, I'm going to disregard these files for now. So going back to our... We saw 26 events. Associated with the file share. So let's do the inverse. Removing the file share event from our query. So all we're going to change is not in the query. Well, this gives us 22 events. Which is better because this is a little bit more for us to work with. Okay. So let's look at this. So the first one is... Trust records. User profile. Downloads. Downloads. That's what we're looking for. Magnum Tempest. Policy violation. Mattress... Tristique. At magnumtempestfinancial.com. Okay. So this one stands out because I would not expect to see a user's email address in a document. That... Is being sent from a legitimate internal group. What we do know is that having templates and sending out to mass users, you might see the name like this. But having the entire email just kind of signifies that this might be... Could be malicious. But we need to kind of dig a little bit deeper. Let's see what else we have here. Okay. We have another similar one. From a different user. Amanda Nuensis. Okay. So let's go back to our drawing board. So we ran the query. So we do have 22 events. Are we done? No. But we do have 22 events. And like I said, we do have that file name stands out to me as potentially an issue. And it stands out because the naming convention is odd. Why would they have an email address in the file name, right? The location indicates that it's downloaded on the user's endpoint in both scenarios. Downloads and desktop. What you would expect if you were downloading an email from... On an actual endpoint. It also indicates that the trust record section was triggered for the file. Which, as we know, indicates macroactivity. Can we find similar files? Let's refine our query knowing that we know the file name. And what we may suspect to be a malicious file. So we're going to stick with indexing Zeek and Sysmon. But we're going to go with MagnumTempest-policy-violation-. And let's see what this results. . . . . . . . . . . . . . . . . . . . . just uh downloaded this file and it looks like it was caught as a forced authentication however we also noticed that this was not parsed as well so that's another thing for us to add to our notes and we scroll down see more it's obviously Matt Tristique again and Matt Tristique so right now where she's Matt and Amanda so let's go back and see can we refine this more well we know we have 40 events available us we looked at what we saw the first events prayers not been parsed let's note this so we can notice in our findings but like we said it we saw that there was one that had a drive-by compromise the program used was Thunderbird and it fits the file target file name that we were discussing previously now I don't know a whole lot about the organization yet but it appears that the organization uses Thunderbird as a mail client so can we refine that a little bit deeper knowing that that little bit of information so let's go back and we're going to add thunderbird.exe to our query here we're down to 12 events again if we look at these they're not done they're not parked correctly so that's something to note that we're going through Amanda downloaded it Amanda Karen Newtons also appears to have downloaded this okay so let's see what do we have so let's go back at this point uh with our previous query we see that we have 12 entries scrolling we see two additional users downloaded Amanda Nunez and Karen Mutens what does this mean at this point we validated our initial hypothesis that a Microsoft Office document was downloaded from email by the end users and that it contained visual basic for applications macros are we done we can be we we've satisfied our hypothesis and our investigation or our threat hunt um however if you're like me you like might be interested in digging a bit deeper to see if you can find more information about these spirals so what does this mean we need to go deeper so what's next so we have other tools available to us that um might be useful um we have access to the packet capture uh for network traffic that's done that's a Zeek but we can actually be able to kind of uh look at uh traffic flows and actually rebuild those traffic flows and that's what we call a packet capture um or we call it pcap for short a common tool that we use to browse and hunt in a pcap file it's called wireshark let's load up wireshark with the appropriate pcap and let's see what we can find once we load the pcap we can start searching for some information that we located in our hunt let's look back and remember that we found a file name that was opened by multiple users and the file name was magnum tempest policy violation dash user email dot doc okay so we know that knowing that the company's name is magnum tempest we we probably should avoid using that because it's possible we could end up with other uh events that we were not really interested in what stands out to me in this would be the policy-dash-file-ation-dash it could be very unique to the file name so let's proceed uh with searching for this because if you're not familiar with this you're probably familiar with the policy-dash-file-ation-dash you remember we only had 12 hits for that file name let's load up wireshark so i already have wireshark already up and ready to go what we want to do if we want to do control f we'll change this it starts off the packet list where the packet details this starts off as display filter we're going to switch this string i already have policy violation in here but if you didn't have anything in there it would be red so you would type policy dash violation dash and you hit enter and it's going to take a little bit of time to search for it but we did we found one right here so if you see here it says action required internal i.t policy violation from legal-internal magnum tempest dot financial at this point we can right click we can follow pcp stream so what this will do this will bring up the stream of data that is associated with this particular packet so let's do that now this will take a little bit of time to do so to load go back to our uh document real quick so here's an explanation of how to switch the display filter the string so as we saw we saw action required internal ikey policy violation from legal dash internal at magnum tempestfinancial.com as we saw again this is where we will right click and follow tcp stream but again tcp stream will give you the actual data flow for that particular packet where it exists the colors indicate whether data was sent or received let's go back to our operation so there's a lot of data here but so if we go back a little bit we will see the original the email that we're referring to so subject action required internal ikey policy violation from legal dash internal at magnum tempest.financial so this one was sent to so so this so let's say acuna for this file this is the email itself the actual email text that was sent what stands out here is this is uh network traffic so network traffic by in a in a good network should be encrypted especially with emails you should never be able to see email text over a um over a network that's a security issue that's also something to note uh uh when you're uh keeping track what we see here too this is the file name that we were expecting uh magnum tempest dash ikey policy violation and then we have the uh username here dot doc this is what we expected and then what we have here is a base64 encoded blob of text what will it do is Чтобы diese um document that contains the macro uh files of it so let's go back to our So, like we said, we had needed to scroll a little bit to get to the what we needed again. So, let's take a look at what we said in one and two. We're seeing the subject and the from that we saw before. And number three, we're seeing what appears to be the email contents in plain text. This is concerning, as I said previously, that unencrypted email over the wire is not a good thing. It could be a misconfiguration by the server admins when they set up email. In number four and five, we notice that this is a base 64 encoded attachment. And the file name matches what we would expect to see based on what we did in plain text. Splunk. Again, it's important to recognize that because it's a base 64, we have the ability to turn that into an actual document or file. At this point, what's next? At this point, we could dive further, investigate, we could try to download the attachment and see what the macros are inside of it. However, just one. This might be a good point for us to stop and pass off to the next team to begin with their investigation or their threat hunt. But it's also a chance for us to take a look and check our notes. What we want to do is look for our Threat Hunter playbook. Our playbook title is going to be Detecting Enterprise Macro Activity from Emails. The minor tactic is T1566, which is phishing, but we're also going to use the sub-technique 001, spear phishing attachment, because based on what we know so far, this could be a spear phishing attachment. So we're going to take our initial hypothesis, which is that employees are targeted with malicious documents with VBA macro code, and some employees will open the documents and detonate the payload. Based on what we've seen, that is the case. The proposed detection query is index in, Zeek and Syslog, .doc or .xls or .docx or .xlsx, trust records, and not files.magnumtempestfinancial.com. We have no simulation details. And for the Hunter limit. During several portions of the hunt, we discovered that there were log sources that were not properly parsed, which made finding details difficult. Hunt findings. Three users downloaded the malicious document. Two users appear to have been affected by the payload. And that brings us to the end of the talk. Thank you so much to join the conversation. Join the conversation. Join us at discord.blue-team-village.org. Thank you.