hi this is project obsidian threat hunting kill chain three the logs are gone who am i i'm extreme paperclip digital forensics nerd linux geek infosec engineer lifelong student of everything amateur history buff spice fanatic loads of fun here are the things we're going to go over we're going to go over how to develop a threat hunting hypothesis sources we could use for developing a threat hunting hypothesis research the methods attackers use to clear the windows event logs we're going to find data sources we need for our threat hunting hypothesis and we'll find evidence of an attacker clearing the logs and we'll answer the how of our hypothesis and finally we'll we'll go over how to document your threat hunting using a simple template okay a quick note about note taking pro tip during and throughout the threat hunting process one should take good notes these notes will be very useful throughout the engagement several times throughout this exercise i'll be sure to mention that some fact or discovery we find should be added to the notes this is generally a good habit to embrace in the world of information security okay so what is threat hunting many people have their own interpretations and definitions of this but we could say threat hunting is a threat hunting hypothesis or a threat hunting hypothesis one way to introduce threat hunting is by adding data sources and looking for the data and giving that data to the user on your site and being able to see if you have the data so that's not a threat hunting hypothesis but actually that's a threat hunting hypothesis and based on the data that you're looking for the data that you're seeking is that you are looking for the path you're looking for the risk that you're looking for but you are seeking for different things and some of them are was previously unaware of. So, question. What guides the development of a hypothesis for the purpose of threat hunting? Here are some things to consider and take note of when building a threat hunting hypothesis. The IT environment. What are the operating systems in the environment? Windows, Linux, Mac. Does the org have active directory? What data gets logged? Windows event, Sysmon, Zeek. Also, vulnerabilities. Does the organization perform vulnerability scans? If so, are the vulnerabilities analyzed and remediated? Are there outstanding vulnerabilities that still need to be remediated? What are the vulnerabilities that still need to be remediated? The MITRE ATT&CK framework offers a wealth of great information that can help build a threat hunting hypothesis. So, take some time to look at the enterprise matrix, and within each of the tactics or techniques that attackers use, these techniques can be used to help inspire your threat hunting adventures. So, what can your users, employees, coworkers, tell you about things they have seen in the environment? And for the notes, as the threat hunter, we would add all of these sources to our notes and continue. Okay, in this scenario, we will consider the question, what happens when an attacker clears the logs in an application? effort to hide their tracks. So we should start with a very broad hypothesis. Let's focus on that middle section of that question. Attacker clears the logs. Focusing on that, we could make a broad hypothesis like attackers will try to cover their tracks. This hypothesis is broad. It only addresses the who and the what, but not the how. So for the notes, as the threat hunter, you would add your broad hypothesis here to your notes and continue. So how can we develop this further into a specific hypothesis for our hunt? Well, we need to develop a specific hypothesis for our hunt. Looking at our notes, we see that the MITRE attack framework was listed as one of the things we could use to help build a threat hunting hypothesis. And how would we do that? Well, a quick Google search for MITRE attacker covering tracks brings us to the following MITRE attack page. Indicator removal on host. Technique ID T1070. Let's follow that link and read what MITRE attack says about this. And remember, in our scenario, we're looking for information about Windows event logs being cleared. We can clearly see something more relevant to our scenario in the sub-technique listed above. It's the T1070 70.001, Clear Windows Event Logs. So let's take a look at the details of this sub-technique. Here we can see the details of the MITRE ATT&CK sub-technique, Clear Windows Event Logs. Now note the methods listed here. Windows commands using wevtutilcl. Let's see there's also the event viewer GUI and PowerShell. So for our notes as the threat hunter, we would add the above MITRE ATT&CK technique, the sub-technique, the ATT&CK methods listed and any source URLs. We would add this to our notes and continue. Using the info from the MITRE ATT&CK sub-technique that we just saw about the specific methods attackers will use to cover their tracks, we can update our threat hunting hypothesis to be more specific. So let's take a quick review of how we got here. We started with a broad hypothesis and then we did some research and found some details. And then we did some research and found some details. from the MITRE ATT&CK framework to enhance our broad hypothesis into a specific hypothesis. So now we can make a specific hypothesis like attackers will try to cover their tracks using one of the following methods. The event viewer GUI, Windows commands such as wevtutilcl or PowerShell. So for the notes, we would, as the threat hunter, we would add these specific items. This, we would add this specific hypothesis to our notes and continue. All right, so let's talk about data sources. It's important to know your data sources when conducting a threat hunt. So which data sources could you possibly use? And where would we find the data needed for our hypothesis? And where would we find the data needed for our hypothesis? Let's take a look at the data sources available to us in Splunk. Let's take a look at the data sources available to us in Splunk. What this simple Splunk query we are about to run basically does is to search the Splunk events, event count, and then it's gonna split the events by index. And that's the summarize equals F. F is for false. Then it's gonna search for any index. That's index equals wildcard. Then we're gonna dedupe the results by the field index using dedupe index. And finally, we're gonna specify the fields we want. We're gonna say fields index to just show the field index. And looking at the results, which of these indexes would be, would be useful to us? So with the list of sources here, these indexes, we will most likely find what we need within the sysmon and win event indexes, because these data sources are gonna show us what was happening inside a host. So for the notes, as a threat hunter, we would add the Splunk indexes sysmon and win event logs as data sources to our notes, and we would continue. So to begin our hunt, we should look for evidence that the Windows event logs were cleared. A simple Google search for Windows event logs cleared gives us a clue, a Microsoft article about Windows security event ID 1102. So let's take a look at this article. Windows security event ID 1102, the audit log was cleared. In this article, pay close attention to what Microsoft says for security monitoring recommendations. It says, typically you should not see this event. There is no need to manually clear the security event log in most cases. We recommend monitoring this event and investigating why, this action was performed. That's interesting. So for the notes, as a threat hunter, we would add this information about Windows security event ID 1102, including any source URLs. We would add this to our notes and continue. But question, which data sources should we use? I'm going to pause here. Are you there? Yeah. What's up? Sorry. I might want to redo this little section right here, because I just noticed that Discord popped up and probably got into my screen. All right. Um. um if you want to back up a slide insert yeah yeah I'm gonna do that I can splice it together sounds good man sorry about that that's okay okay I'm about to start just uh just uh give a three second pause and then okay so I'm gonna say right now three second pause starting now okay Windows security event ID 1102 the audit log was cleared in this article pay close attention to what the Microsoft article says for security monitoring recommendations it says typically you should not see this event there is no need to manually clear the security event log in most cases we recommend monitoring this event and investigating why this action was performed interesting so for the notes as the threat Hunter we should add this information about Windows security event ID 1102 including any source URLs to our notes and continue question which data source should we use looking at our notes we see that we have win event logs listed which contains the typical Windows event logs found on a Windows operating system and this is listed as a data source in Splunk so let's go search for this event within our Splunk data because for this search we're going to search the win event logs index in Splunk for event.code1102 and we'll see if we get any results we do so we get 26 events here discovered showing proof that the Windows event logs were cleared so for the notes as the threat Hunter we would add this broad Splunk query including the date time specified for the query as well as some details about the results to our notes and continue so let's alter this Splunk query to make it look more presentable so what we're going to do is we'll search the win event logs index for event code event.code1102 and we'll use rename to rename the long field win log dot user underscore data subject username as simply user because that's much nicer right and we'll arrange the results in the query using table and we'll specify the fields we want displayed time host name event code win log task user and then we're going to sort the results by time from oldest at the top to newest at the bottom that's just my preference honestly okay wow interesting results here we can see evidence of the Windows event log logs being cleared on several hosts. Also, it's interesting to note that the search results here did not specify they didn't show if the event logs were cleared via the event event viewer GUI, the Windows command such as WVT util CL or PowerShell. But in any case, we see that the Windows Windows event logs were cleared. So for the notes as a threat Hunter, we would add this specific Splunk query, including the date time specified for the query, as well as some details about the results to our notes. And we would continue. Okay, so are we done? Did we accomplish what we set out to do? Some would say yes, they're not entirely wrong. We did find a way to detect when the Windows event logs were cleared. But what if we wanted to find the source of this activity? What if we wanted to find which command or commands the attacker might have used to clear the logs? What if we wanted to find the answer to how the attackers cleared the Windows event logs? Let's explore further to answer those questions. Okay, looking at our notes, we can see in our specific hypothesis that one of the methods attackers use to cover their tracks is by using the WVT util CL command. We should search for this command in our Splunk data. How do we do that? How would we find a specific Windows command that was executed on a host? Well, let's just Google log Windows command line and see what it gives us. And one of the first results is a Microsoft article command line process auditing, so let's take a look. Reading the Microsoft article, it mentions audit event ID 4688. So what is this audit event ID 4688? Let's find out. Quick Google search for audit event ID 4688 leads us to an article titled 4688. A new process has been created. So let's take a look. OK, one of the fields we see in this Windows security event ID 4688. Is the process command line field. Great. So it appears we can search Splunk for the Windows security event ID 4688, and we can specify the value we are looking for in the process command line field. Right. For the notes here as a threat hunter, we would add this information we have found about Windows security event ID 4688, including any source URLs to our notes. And continue. OK, let's take a look at Windows security event ID 4688 in Splunk and see what the process command line field is going to show us. So this is just a simple search. We'll just search the win event logs index index for event dot code for six eight eight. Bummer. So looking at the results, we don't find any data for the process command line field in Windows security event ID for six eight eight. So for the notes as a threat hunter, we would add this specific Splunk query, including the date time specified for the query. As well as some details about the results to our notes and continue. So we didn't find any command line data in the Windows security event ID for six eight eight. Why? Well, according to the Microsoft article previously mentioned about a new process has been created, if you scroll down a bit and read, it says you must enable administrative templates system audit process creation include command line in process creation events. So. You need to enable this in group policy to include command line in the process creation events. So now what? Are we dead in the water? Is there anything else we can do to find what commands the attacker used to clear the logs? OK, checking our notes, we take a look and recall that we made note of the two data sources, Sysmon and win event logs. So let's go take a look at the Sysmon data. OK, question which Sysmon ID could possibly show us the command line details. A quick Google search for Sysmon event showing command line leads us to an article about Sysmon event ID one process creation. OK, we see in this article that it lists the fields in Sysmon event ID one and two interesting fields pop up here, command line. And parent command line. So for the notes as a threat hunter, we would add this information we've discovered about Sysmon event ID one, including any source URLs, we would add this to our notes and continue. Yay. OK, all is not lost. We have Sysmon event ID one process creation, which shows us the command line as well as the parent command line. OK, let's take a look at Sysmon event ID one in Splunk. We'll search the Sysmon index for event code one. OK, important note here. This simple query, this simple Splunk query is only a query to see what the command line data looks like from Sysmon event ID one. The actual values that we see in the command line in this specific search here, these results, they don't matter. Understand, we just want to verify that we can see command line data. And here's where we get. We can clearly see data for the command line and parent command line fields in Sysmon event ID one. Great. Now that we've verified that we can see command line values in Sysmon event ID one, let's search for the specific command W, E, V, T, U, TIL, C, L listed in our specific hypothesis. OK, we're going to run a Splunk search in the Sysmon index looking for event dot code one, and we're going to specify process dot command line. Contains the command W, E, V, T, U, TIL. CL. Nothing. Bummer. OK, so for the notes as the threat hunter, we would add this Splunk query, including the date time specified for the query, as well as any details about the results to our notes and continue. So again, are we dead in the water? Is there nothing else we can do to find what commands the attacker used to clear the logs? Checking our notes, we take a look and recall that we made note in our specific hypothesis that attackers have also been known to use PowerShell. So let's move on to PowerShell. So question, how could we find a way to clear the Windows event logs using PowerShell? A simple Google search for PowerShell clear event logs results in a link to a Microsoft article about a clear event log commandlet. Let's take a look. This PowerShell commandlet clears all entries from specified event logs on the local or remote computers. So for the notes here, as the threat hunter, we would add this information we've discovered about PowerShell commandlet clear event log, including any source URLs. We would add this to our notes and continue. This is interesting. So could an attacker use this PowerShell commandlet clear event log? As a method to clear the logs? Sure. Let's dive into Splunk and hunt for any evidence of this commandlet. OK, let's search this PowerShell command in Splunk. We're going to search the Sysmon index for event dot code one, and we're going to search for process dot command line containing clear event log. Twenty one events. Now we have proof that the attacker used the PowerShell commandlet clear event log as a method to wipe the Windows event logs. This is the how. To our hypothesis, so for the notes as the threat hunter, we would add this specific Splunk query. We're going to search the Sysmon index for event code one, as well as any details about the results to our notes and continue. Let's make this Splunk query more presentable. We're going to do is we're going to search the Sysmon index for event code one again, specify the process dot command line containing clear event log, and we're going to use rename to rename the long process dot command line. And we're going to use rename to rename the long process dot command line. And we're going to use rename to rename the long process dot command line. Then we're going to organize the results in a nice table using table, and we'll specify the fields we want. And finally, we're going to sort by time with the oldest on top to newest on the bottom. Looks great. So for our notes again, as a threat hunter, we would add this specific Splunk query, including the date time specified for the query, as well as any details about the results to our notes and continue. So how can we document the final results of the hunt? Perhaps you'll see now how important it is to take copious notes throughout the threat hunting process. We can take our notes. We can document the final results of the hunt, and we can use our notes to fill in the details of the threat hunting template. And this process can be repeated using new hypothesis in the future. For this threat hunting exercise that we just did, it would make sense to break these results into three separate threat hunting templates. Windows will name it like this. Windows event logs cleared via event viewer GUI, which will address the Windows security event ID 1 1 0 2. Windows event logs cleared via Windows command, which will address the Windows command WVT util CL and also Windows event logs cleared via PowerShell. And then we can use this simple threat hunting template to document these threat hunting exercises. We can use this simple threat hunting template. It contains a title, date created, our hypothesis, MITRE attack, MITRE sub technique, simulation. And then we can use this simple threat hunting template to document these threat hunting exercises. The information details, if any. Proposed search query are the limitations and observation notes that we can kind of summarize and expand on. And finally, our hunt findings with any recommendations. And then we'll have a proposed detection title, if any. And it proposed detection query and what it's going to look like would be something like this. So here, using our notes to guide us, we can create the title Windows event logs cleared via event GUI. We put in the date, our hypothesis, MITRE tactic. MITRE sub technique. Simulation details, if any, in this case, there's none. Proposed search query. And hunter limitations observation notes. Here's where we can summarize from our notes. So for this, I put the proposed search query did find evidence of Windows event logs getting cleared. But the results were broad. The search query was improved to display the relevant data in a readable format. And also put here, it's important to note that the search results did not specifically show if the Windows event logs were cleared via event viewer GUI. So it would be prudent to test this in a simulation to verify that Windows security event ID 1102 would still be triggered no matter what method an attacker used. GUI, command, PowerShell. So for the hunt findings for this, I wrote Windows event 1102 is wonderful for detecting when Windows event logs are cleared. And the query developed below should be made into detection. So here's the proposed detection title alert Windows event 1102. The audit log was cleared. And finally, here we have the specific proposed detection query. The second one, again, using our notes, we create a title Windows event logs cleared via Windows command W E V T U T L C L. The date, hypothesis, MITRE tactic, MITRE sub technique and note for these sub techniques for these three threat hunting templates. I'm adding some extra info at the end in parentheses. So for this one, I put via Windows command W E V T U T L C L. There was no simulation details. I put in my proposed search query. And for Hunter limitation observation notes have the proposed search query did not produce any valuable results, however, it would be prudent to run a simulation simulation test using this command and build the detection and the hunt findings. Although the query did not produce results, I believed that I believe the developed query should be made into a detection because attackers could possibly use the command to clear the Windows log events. Windows event logs, so proposed detection title for this one is alert Windows command W E V T U T L C L used to clear Windows event logs. And then finally, here we have the proposed detection query with my specific Splunk query. OK, third one here, again, using our notes to guide us, create a title Windows event logs cleared via PowerShell clear event log of the date or hypothesis. Miter tactic, miter sub technique. Again, notice here at the end, I put in parentheses. I added via PowerShell clear event log, no simulation details. The proposed search query. And for the Hunter limitations observation notes, I wrote the proposed search query produced evidence that the PowerShell command let clear event log was used, but the results were broad. The search query was improved to display the relevant data in a readable format. See proposed detection query. OK, so for hunt findings. Use the PowerShell use of the PowerShell command, let clear event log should be monitored for any suspicious behavior, and so the proposed detection query should be made into a detection. Proposed detection title alert PowerShell clear event log executed. And then, of course, my specific Splunk search. So. One final thing I'd like to mention here, there are many different ways one could conduct their threat hunting. There's no one way to do it, but this has just been a simple, methodical way to approach it in the end, we have our threat hunting results documented in a simple template and shared with our team. And that's it, so thank you. Thank you, thank you, and feel free to join in on the conversation with the blue team, the blue team village on Discord, there's the Discord server right there. Thank you very much.