<?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 John Krupakar  on Medium]]></title>
        <description><![CDATA[Stories by John Krupakar  on Medium]]></description>
        <link>https://medium.com/@john245461?source=rss-9d76ef40fe29------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by John Krupakar  on Medium</title>
            <link>https://medium.com/@john245461?source=rss-9d76ef40fe29------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 20:44:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@john245461/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[ParrotPost: Phishing Analysis]]></title>
            <link>https://medium.com/@john245461/parrotpost-phishing-analysis-e5409455d0a3?source=rss-9d76ef40fe29------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5409455d0a3</guid>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[phishing]]></category>
            <category><![CDATA[phishing-awareness]]></category>
            <dc:creator><![CDATA[John Krupakar ]]></dc:creator>
            <pubDate>Wed, 02 Aug 2023 09:10:50 GMT</pubDate>
            <atom:updated>2023-08-02T09:10:50.354Z</atom:updated>
            <content:encoded><![CDATA[<p>Reveal how attackers can craft client-side credential-stealing webpages that evade detection by security tools.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-T3pwpHITsZ6Wekk-9mAeg.png" /></figure><h3><strong>Learning Objectives</strong></h3><ul><li>Understand what email headers are and familiarize yourself with common headers.</li><li>Utilize tools for inspecting and analyzing suspicious emails and attachments.</li><li>Learn to recognize different obfuscation techniques employed in malicious HTML, CSS, and JavaScript code.</li></ul><h3><strong>Task 2 - Phishing Email Analysis</strong></h3><p>While working as a <strong>SOC </strong>Analyst for <em>Flying-Sec</em>, you receive an incoming report from senior executive Paul Feathers. Paul recently received an email from <em>ParrotPost</em>, a legitimate company email tool, asking him to log into his account to resolve an issue with his account information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YmXTIXamLiKoLERF.png" /></figure><p>Your task is to investigate the email and determine whether it is a legitimate request or a phishing attempt. The EML file can be accessed on the AttackBox under /root/Rooms/ParrotPost. However, it is also attached to this task and available for download.</p><h3><strong>Task 3 - Email Headers</strong></h3><p>Let’s talk about analyzing email files. Emails are comprised of several components, including the header, body, and, if applicable, any attachments. The standard that emails generally follow is defined by the <strong><em>Internet Engineering Task Force</em></strong><em> (IETF)</em>, specifically in <a href="https://datatracker.ietf.org/doc/html/rfc5322">RFC 5322</a>, which specifies the syntax and semantics of email messages, and the <a href="https://datatracker.ietf.org/doc/html/rfc2045">RFC 2045–2049</a> series, which defines the <em>Multipurpose Internet Mail Extensions (MIME)</em> standard for email messages on the Internet.</p><blockquote><strong><em>Email Headers</em></strong></blockquote><p>The email headers are a great place to start when manually investigating a suspicious email. Email headers contain important metadata and information such as the sender and recipient’s email addresses, the date and time the email was sent, and the path the message took to reach its intended destination. Investigating email headers can provide valuable insights into an email’s origin and potential security concerns.</p><blockquote><strong><em>Viewing Email Headers</em></strong></blockquote><p>The process for viewing an email’s headers can vary depending on the email client or service you are using. Sometimes in the specific email’s context or view menu, there will be an option to view the headers directly or to download the original message as a file. In our case, we already have a copy of the email Paul received in .eml format. The .eml file format is in plaintext, meaning it can be read and edited using a basic text editor like Notepad, TextEdit, or Sublime Text.</p><p>To investigate this email further, open up URGENTParrotPostAccountUpdateRequired.eml in Sublime Text. You can optionally copy the file&#39;s contents and paste it into an email headers analyzer tool, such as <a href="https://mxtoolbox.com/EmailHeaders.aspx"><strong>MXToolbox</strong></a> or <a href="https://mha.azurewebsites.net/"><strong>Message Header Analyzer</strong></a>. These client-side web tools provide a more graphical view of the email headers.</p><blockquote><strong><em>Common Email Headers</em></strong></blockquote><p>You are probably used to seeing several standard email headers, as most email clients (like Gmail, Outlook, Yahoo, and others) will display these headers by default:</p><ol><li><strong>Subject</strong> — This provides a topic or summary of the email’s content</li><li><strong>From</strong> — This identifies the sender of the email message (this can easily be spoofed!)</li><li><strong>To</strong> — This identifies the primary recipient(s) of the email</li><li><strong>Date</strong> — Indicates the date and time when the email message was sent</li></ol><p>Below, visually locate where these headers are mapped to in Paul’s email client, as seen from the Outlook on the Web (OWA) app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NTxPvPp4humE827k.png" /></figure><p>Most email headers will not be visible directly from an email client, so we need a text editor to view the complete email header information.</p><p>It’s also important to understand that any line in an email can be forged or spoofed. However, there are some headers that you can trust more than others when conducting analysis. For example, the “Received” headers are added by each email server that processes the email, and they can offer a record of the email’s path from source to destination.</p><blockquote><strong><em>Identifying the Source</em></strong></blockquote><p>Because email headers are so easily spoofed, it can be challenging to determine the originating sender or source of an email. As mentioned earlier, the “Received” headers are added by email servers to show the path the email took. The sender’s IP address is typically listed in the first “Received” header (look at the date/times!).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/0*eZu-0uY3SgfBFfHn.png" /></figure><p>Once you have identified the source IP address, you can use an IP lookup tool to find out more information about the sender, such as their ISP (Internet Service Provider) or the geographic location of their IP address. Several free tools are available online, such as<strong> </strong><a href="https://iplocation.io/"><strong>iplocation.io</strong></a> and <a href="https://www.iplocation.net/ip-lookup"><strong>iplocation.net</strong></a>.</p><blockquote><strong>Custom Email Headers</strong></blockquote><p>Email headers starting with “X-” are custom headers the sender can add. The “X-” prefix is typically used to denote that the header is not an official or standardized header defined by the IETF. These custom headers often provide additional information or metadata about the email, such as tagging the email for spam filtering or sorting purposes or adding information specific to a particular organization or system.</p><p><strong>Answer the questions below</strong></p><blockquote><strong>According to the IP address, what country is the sending email server associated with?</strong></blockquote><blockquote>Latvia</blockquote><blockquote><strong>If Paul replies to this email, which email address will his reply be sent to?</strong></blockquote><blockquote>no-reply@postparr0t.thm</blockquote><blockquote><strong>What is the value of the custom header in the email?</strong></blockquote><blockquote>Go to <a href="https://www.iplocation.net/ip-lookup">iplocation.net</a>: Search the ip and get the flag THM{y0u_f0und_7h3_h34d3r}</blockquote><h3><strong>Task 4 — Email Attachment Analysis</strong></h3><p>As we discovered by looking at the .eml file in a text editor, the email Paul received contains an embedded attachment named <em>&quot;ParrotPostACTIONREQUIRED.htm.&quot;</em> Based on this file type and the listed <strong>Content-Type</strong>, this is an <strong>HTML</strong> (Hypertext Markup Language) file used to create a web page or document that can be viewed in a web browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KWRGBL4MfmIEeRhW.png" /></figure><p>Some email filters or security systems may be configured to block or quarantine certain file types, such as HTML files. By using alternatives like HTM or SHTM file extensions instead of HTML, attackers may be able to bypass these filters and increase the chances of their email reaching the intended recipient. A .htm file is the most common alternative to HTML and is similarly used to represent web pages written in HTML code.</p><p>You may think receiving an HTML document attached to an email is inherently suspicious. While uncommon, there are valid reasons why a legitimate service may do so, such as including interactive forms or dynamic content. For example, secure mail platforms (like <em>Cisco Secure Email Encryption Service</em>) may also attach HTML documents to enhance the user experience with advanced features like encryption and authentication.</p><blockquote><strong>Content Transfer Encoding</strong></blockquote><p>In the attachment metadata section of the .eml file, “Content-Transfer-Encoding” is a header that indicates how the attachment’s content is encoded. Base64 encodes binary data (such as images, audio files, or other content) into ASCII characters that can be sent via email or other text-based channels.</p><p>You will notice a large section of base64 encoded text at the end of the .eml file. This is the encoded contents of the embedded HTM file, which we can extract and manually decode, but typically attachments can be extracted through any modern email client.</p><p>The attachment has been extracted and separated from the email to simplify this task. You can find this .htm file on the AttackBox under /root/Rooms/ParrotPost or download the ParrotPostACTIONREQUIRED.htm file by clicking on <strong>Download Task Files</strong> at the top of this task.</p><blockquote>Analyzing the File</blockquote><p>Since <em>ParrotPostACTIONREQUIRED.htm</em> is a plaintext file, we can also open this up in Sublime Text. By doing so, we uncover the markup of this webpage, which seemingly is another wall of encoded text!</p><p><em>Tip: Turn on </em><strong><em>Word Wrap</em></strong><em> in Sublime Text under View &gt; Word Wrap</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xcItK_MlBu9jUIJn.png" /></figure><p>The creator of this file uses encoding to obfuscate the true nature of the webpage. Between this and the suspicious file extension, the original sender may have nefarious intentions and is actively trying to evade detection.</p><p>This HTML document declares a variable called b64 which is set to another long string of seemingly encoded data. Aside from the telling variable name, base64-encoded data typically includes the characters A-Z, a-z, 0-9, +, /, and padding characters (=). If you see these characters in a string of text, there is a good chance it may be base64-encoded.</p><p>atob()</p><p>After declaring the encoded string, the browser will execute the following line of JavaScript:</p><p>document.write(unescape(atob(b64)));</p><p><strong>To break down this nested function:</strong></p><ol><li>The atob() is a built-in JavaScript function to decode a base64-encoded string. This function passes in the b64 variable that was previously declared as its input.</li><li>The unescape() the function converts any escaped characters in the decoded string into their original form. This is necessary because base64-encoded strings may contain special characters that must be appropriately formatted before being displayed on a webpage.</li><li>The document.write() function displays the decoded and unescaped string on the webpage where the code is executed.</li></ol><p>The encoded variable likely contains the actual website content rendered at runtime. Because of this, we will need to go another layer deeper and decode the variable to find out what this webpage consists of.</p><blockquote>Base64 Decoding</blockquote><p>There are many ways to decode base64 data, and a very common method is to use CyberChef, which is a powerful web-based application that provides tools for encoding, decoding, analyzing, and manipulating data in various formats. It can be found pre-installed on the AttackBox (navigate to http://localhost:7777), or it can be accessed on the Internet here: <a href="https://gchq.github.io/CyberChef/"><strong>https://gchq.github.io/CyberChef/</strong></a></p><p>To uncover the contents of the b64 variable, copy the entire base64 string (everything between the opening and closing quotation marks) and paste it into the <strong>Input</strong> field of CyberChef. From there, we can select the <strong>From Base64</strong> operation on the left-hand side of the page and drag it into the <strong>Recipe</strong> pane.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VTYPkhvsgAiBtQ9_.png" /></figure><p>If successful, you should see the decoded data under the <strong>Output</strong> pane. Copy that entire output and save it as a new HTML file named “decoded_webpage.html.”</p><blockquote><strong>Answer the questions below</strong></blockquote><blockquote><strong>What encoding scheme is used to obfuscate the web page contents?</strong></blockquote><blockquote>base64</blockquote><blockquote><strong>What is the built-in JavaScript function used to decode the web page before writing it to the page?</strong></blockquote><blockquote>atob()</blockquote><blockquote><strong>After the initial base64 decoding, what is the value of the leftover base64 encoded comment?</strong></blockquote><blockquote>check the source and find the comment decode the comment in base62 THM{d0ubl3_3nc0d3d}</blockquote><h3><strong>Task 5 - HTML Obfuscation</strong></h3><blockquote>HTML Entity Decoding</blockquote><p>Analyzing our “decoded_webpage.html” file is a little daunting as this file isn’t made to be human-readable. This is because it’s been compressed into a minified form, which means that all unnecessary characters, such as spaces, line breaks, and some comments, have been removed to reduce the file size. Minified code is often used in web development to reduce the loading time of web pages since smaller files can be loaded faster. However, it can make the code harder to read and understand for humans.</p><p>We will work on making the code more human-readable shortly, but first, there appears to still be some encoding in the HTML. If you locate the &lt;h1&gt; tag, you will notice a long string of seemingly random characters followed by semicolons. Ex: &lt;h1&gt;&amp;#80;&amp;#97;&amp;#114;&amp;#114;&amp;#111;&amp;#116;</p><p>This is known as <strong>HTML Entity Encoding</strong> and is another trick that the author of this file is using to throw us off. HTML entities are special sequences of characters used to represent reserved characters and other special characters in HTML. Fortunately, CyberChef can handle the decoding process of HTML Entity characters.</p><p>Copy everything from the opening &lt;h1&gt; tag to the closing &lt;/form&gt; tag and paste it into the <strong>Input</strong> field of CyberChef. From there, search for &quot;HTML Entity&quot; in the <strong>Operations</strong> search bar and drag the <strong>From HTML Entity</strong> into the <strong>Recipe</strong> pane.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gsxvJICWxq7nvkHm.png" /></figure><p><em>Tip: Make sure you click </em><strong><em>Clear Recipe </em></strong><em>(trashcan icon) before this step so you do not attempt to base64 decode again as well!</em></p><p>Great! Now we can copy the <strong>Output</strong> contents and paste them into the “decoded_webpage.html” file in place of all the HTML Entity characters we originally copied. This is also an excellent time to add line breaks to clarify what we’ve decoded. Your file should look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-Aa47w6Xmhyzxpwz.png" /></figure><p>It is still unclear, but we can make out the HTML elements now. Looking into it more, it is a login page. Some input elements prompt the user for an email and password, with a login submit button.</p><blockquote><strong>Answer the questions below</strong></blockquote><blockquote><strong>After decoding the HTML Entity characters, what is the text inside of the &lt;h1&gt; tag?</strong></blockquote><blockquote>ParrotPost Secure Webmail Login</blockquote><h3><strong>Task 6 - CSS Obfuscation</strong></h3><p>CSS (Cascading Style Sheets) is a web language used for declaring the visual design of a web page written in HTML. CSS allows web developers to separate the presentation of a document from its content, making it easier to create and maintain visually appealing web pages. CSS can also be embedded directly into an existing HTML document using the &lt;style&gt; element.</p><p>In our file, the CSS stylesheet makes up a good portion at the beginning of the document and is contained within the opening &lt;style&gt; and closing &lt;/style&gt; tags. The CSS has also gone through a <strong>Minifier</strong> to remove unnecessary whitespace, comments, and other characters that are not needed for the browser to interpret and display the styles correctly. If we wanted to understand the stylesheet more, we could copy and paste it into a <strong>CSS Beautify</strong> tool to make it more readable.<strong> </strong><a href="https://gchq.github.io/CyberChef/"><strong>CyberChef</strong></a> can perform CSS Beautify and CSS Minify operations. However, another good example is <a href="https://www.cleancss.com/css-beautify/"><strong>https://www.cleancss.com/css-beautify/</strong></a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*587dCFTtk3OhueCu.png" /></figure><p>The stylesheet has been run through a <strong>CSS Obfuscator</strong> tool. Like a minimizer, a CSS obfuscator transforms the CSS code to make it difficult to read and understand without affecting its functionality. It is typically used to protect the intellectual property of the code, making it difficult for others to copy, modify or reverse-engineer it.</p><p>Often, in the case of phishing and credential capture webpages, attackers will directly copy the CSS stylesheets from known trusted websites (think of the Google or Microsoft sign-in page). By obfuscating the copied stylesheets, it makes it harder for antivirus engines and sandboxing agents to detect the stolen stylesheet.</p><p>This section was covered for the sake of thoroughness. However, we can effectively ignore everything before the closing &lt;/style&gt; tag and add some line breaks to separate things visually.</p><blockquote><strong>Answer the questions below</strong></blockquote><blockquote><strong>What is the reverse of CSS Minify?</strong></blockquote><blockquote>CSS Beautify</blockquote><h3>Task 7 - JavaScript Obfuscation</h3><p>So far, we have uncovered that the attached .htm file renders an HTML login form, and an inline stylesheet is used to define the webpage’s design. However, where is the login form sending its captured data? And what happens after we submit credentials? To find these answers, we must look at the final piece of this file inside the &lt;script&gt; tag.</p><p>JavaScript is often used in login forms to perform client-side form validation asynchronously and to send the user’s credentials to the server for authentication. As a running theme with this file, there are some hoops we need to jump through first to make it readable.</p><blockquote>JavaScript Beautify</blockquote><p>This JavaScript code has been minified, removing any unnecessary characters and whitespace. Fortunately, we can “beautify” this code by copying everything between the opening &lt;script&gt; and closing &lt;/script&gt; tags, pasting it into the input of <a href="https://beautifier.io/">Beautifier.io</a>, and clicking <strong>Beautify Code</strong>. Alternatively, we can leverage <a href="https://gchq.github.io/CyberChef/">CyberChef&#39;s</a> &quot;JavaScript Beautify&quot; operation to accomplish the same result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7i4M2ZlqAAfCDdq9.png" /></figure><p>We can then copy and replace the output in our file with the original JavaScript code we copied. Now that we have readable code, the author accidentally left over some verbose comments that help us understand what each statement is doing. Use this and some external JavaScript research to answer the questions below.</p><blockquote><strong>Answer the questions below</strong></blockquote><blockquote><strong>What is the URL that receives the login request when the login form is submitted?</strong></blockquote><blockquote><a href="http://evilparrot.thm:8080/cred-capture.php">Correct Answer</a></blockquote><blockquote><strong>What is the JavaScript property that can redirect the browser to a new URL?</strong></blockquote><blockquote><a href="http://window.location.href/">Correct Answer</a></blockquote><h3><strong>Task 8 - Putting It All Together</strong></h3><p>Through our investigation, we manually decoded and inferred the true nature of this webpage. To summarize, this is a login page that impersonates the legitimate ParrotPost website to capture user credentials for malicious purposes. The JavaScript code listens for the login form submission event and sends an HTTP GET request to another URL location, which is clearly not the <em>actual</em> ParrotPost login endpoint.</p><blockquote>Detonating the Form</blockquote><p>Interacting with this malicious webpage isn’t something you usually want to do (unless you are in a controlled sandbox environment), but let’s demonstrate what happens when a victim falls for this phishing website! This will help us study the behavior of the document and its potential impact on a real system (and victim) without actually infecting or harming any systems.</p><p>First, click <strong>Start Machine</strong> at the top of this task. This will open up the VM in a split-screen browser window. If the VM is not visible, click the blue <strong>Show Split View</strong> button at the top-right of the page. Once you are brought to the desktop, open the original ParrotPostACTIONREQUIRED.htm document in the VM&#39;s web browser (right-click, and select <strong>Open With Firefox Web Browser</strong>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/0*lDV-SkjTqQ84J7Mv.png" /></figure><p><strong>Note:</strong> For this task, please ensure you are using the VM attached to this task, rather than the AttackBox.</p><p>You should be directed to the following HTML page in your browser:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*II2lmo_i3TGyKu0r.png" /></figure><p>As suspected, this is a credential capture login page, and it appears Paul’s email address has already been filled in under the <strong>Email</strong> field. This is a common familiarity tactic to have a victim think a site has remembered or cached their username, helping to create trust. It also reveals that this is likely a targeted phishing campaign, and since Paul is a senior executive, this may specifically be a <a href="https://www.ncsc.gov.uk/guidance/whaling-how-it-works-and-what-your-organisation-can-do-about-it"><strong>Whaling attack</strong></a>.</p><p>Let’s change the value of the <strong>Email</strong> and <strong>Password</strong> fields to represent fake credentials, as this will probably be logged on the attacker’s server. Then, click <strong>Login</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/0*otmksaNjuzzXtb0W.png" /></figure><p>Upon submitting our phony credentials, the website returns an error message claiming an error processing our login request. However, that might not be the case; this may be a “fake” error message that attackers use to ease suspicion, whereas, in reality, our request containing credentials did go through in the background (through the beauty of asynchronous JavaScript).</p><p><strong>Check the Network Requests</strong></p><p>By checking the <strong>Network</strong> tab in the browser’s <strong>Developer Tools</strong>, we can quickly determine whether submitting the form sent a successful HTTP GET request. To open the Developer Tools menu, right-click on the page and select <strong>Inspect</strong>. Once the tab is open, click on the <strong>Network</strong> tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RLCVqK4MfUHzcXR7.png" /></figure><p>From here, we only need to click the <strong>Login</strong> button to submit the form again. You should suddenly see a GET request appear!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dQJyPhmRQRZrlzBs.png" /></figure><p>Our browser successfully established the connection to the evilparrot.thm web server and included our credentials as query parameters in the GET request to /cred-capture.php.</p><p>Clicking on the listed request will give us more details in the right-hand panel. We can navigate between different tabs to view information, such as the request and response headers. The <strong>Response</strong> tab will show any response content, such as the HTML, JSON, or XML response body. Sometimes this can give us more information about how the web server handles the request, depending on how verbose the server-side code is designed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HcXQhCeOWVz4MOuF.png" /></figure><p>Play around by testing a request and analyzing the response. You may find some interesting information to help answer the questions below.</p><blockquote><strong>Answer the questions below</strong></blockquote><blockquote><strong>What is the flag you receive after sending fake credentials to the /cred-capture.php endpoint?</strong></blockquote><blockquote>THM{c4p7ur3d_y0ur_cr3d5}</blockquote><blockquote><strong>What is the path on the web server hosting the log of captured credentials?</strong></blockquote><blockquote>/creds.txt</blockquote><blockquote><strong>Based on the log, what is Chris Smith’s password?</strong></blockquote><blockquote>FlyL1ke!A~Bird</blockquote><h3>Task 9 - Conclusion</h3><p>You should now better understand how to identify and analyze phishing attacks that attempt to steal user credentials. You have learned to use various tools to inspect and analyze suspicious emails and attachments and recognize and decode different obfuscation techniques used in malicious HTML, CSS, and JavaScript code.</p><p>Remember, the analysis doesn’t end here; it’s always a good idea to report malicious domains and IP addresses to help protect yourself and others from future attacks. Domain registrars typically have a Registrar Abuse Contact, which can be found by performing a<strong> </strong><a href="https://www.whois.com/whois/"><strong>WhoIs</strong></a> lookup of the malicious domain. Malicious IPs can be reported through the appropriate Internet Service Provider (ISP) or hosting provider.</p><p>#tryhackmewriteups #tryhackme #phishing #ctf</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5409455d0a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Active Directory Hardening]]></title>
            <link>https://medium.com/@john245461/active-directory-hardening-c804f3c3e63e?source=rss-9d76ef40fe29------2</link>
            <guid isPermaLink="false">https://medium.com/p/c804f3c3e63e</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[continuous-learning]]></category>
            <category><![CDATA[active-directory]]></category>
            <category><![CDATA[tryhackme-writeup]]></category>
            <dc:creator><![CDATA[John Krupakar ]]></dc:creator>
            <pubDate>Wed, 26 Jul 2023 10:04:56 GMT</pubDate>
            <atom:updated>2023-07-26T10:04:56.022Z</atom:updated>
            <content:encoded><![CDATA[<p>To learn basic concepts regarding Active Directory attacks and mitigation measures.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*kk22SDXEt6p-mQCSlOYpcg.png" /></figure><h3><strong>1- Introduction</strong></h3><p><strong>Active Directory (AD)</strong> is widely used by almost every big organisation to manage, control and govern a network of computers, servers and other devices. The room aims to teach basic concepts for hardening AD in line with best cyber security practices.</p><h3><strong>Learning Objectives</strong></h3><p><strong>The topics that we will cover in this room include:</strong></p><ul><li>Secure authentication methods</li><li>Securing hosts through group policies</li><li>Implementing the Least Privilege model</li><li>Protection against known AD attacks</li><li>Recovery Plan (Post-compromise scenario)</li></ul><h3>2 - Understanding General Active Directory Concepts</h3><p><strong>Domain:</strong></p><p>The domain acts as a core unit regarding the logical structure of the Active Directory. It initially stores all the critical information about the objects that belong to the domain only.</p><p><strong>Domain Controller:</strong></p><p>A <strong>Domain Controller</strong> is an Active Directory server that acts as the brain for a Windows server domain; it supervises the entire network. Within the domain, it acts as a gatekeeper for users’ authentication and IT resources authorization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*pdQTH1pPTEsfqVw9WqX5Og.png" /></figure><p><strong>Trees and Forests:</strong></p><p>Trees and Forests are the two most critical concepts of the Active Directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*-DPbbiZcmzk8PalGYzFjwg.png" /></figure><p><strong>Trees:</strong></p><p><strong>Trees </strong>are responsible for sharing resources between the domains. The communication between the domains inside a tree is possible by either one-way or two-way trust. When a domain is added to the Tree, it becomes the Offspring domain of that particular domain to which it is added — now a Parent domain.</p><p><strong>Forests:</strong></p><p>When the sharing of the standard global catalogue, directory schema, logical structure, and directory configuration between the collections of trees is made successfully, it is called a Forest. Communication between two forests becomes possible once a forest-level trust is created.</p><p><strong>Trust in Active Directory:</strong></p><p>AD trust is the established communication bridge between the domains in Active Directory. When we say one domain trusts another in the AD network, it means its resources can be shared with another domain. However, one domain’s resources are not directly available to every other domain, as it is not safe. Thus, the resource sharing availability is governed by Trusts in AD. The AD trusts are of two categories, which are classified based on their characteristics or the current direction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*-DPbbiZcmzk8PalGYzFjwg.png" /></figure><p>AD trusts categorised based on characteristics are known as <strong>Transitive</strong> and <strong>non-Transitive trusts</strong>. Transitive trust reflects a two-way relationship between domains. If there are three domains, domain A trusts domain B and domain B has a transitive trust with domain C. Consequently, domain A will automatically trust domain C for sharing resources.</p><p>Again, AD trusts are of two types when classified based on their direction: <strong>One-way</strong> and <strong>Two-way trusts</strong>. You can access the AD trust through the following:<br>Server Manager &gt; Tools &gt; Active Directory Domains and Trust</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*3MhkVUsFIzGLZWXDiVo9EQ.png" /></figure><p><strong>Container and Leaves:</strong></p><p>For those familiar, each network part is treated as an object in AD. Anything from resources, users, services, or part of the network can be an object. The hierarchical structure of AD defines that an object may or may not contain other objects based on the scenario. When an object holds another object, it is termed a container; otherwise, it is called the leaf object.</p><h3><strong>Answer the questions below:</strong></h3><blockquote>What is the root domain in the attached AD machine?</blockquote><blockquote>tryhackme.loc</blockquote><h3>3 — Securing Authentication Methods</h3><p>In this task, we will briefly learn various security authentication methods that can be used for secure communication and ensuring data integrity from one machine to another in an AD environment. We will use the built-in Microsoft tool <strong>Group Policy Management Editor</strong> available in the attached AD machine for configuring various security policies. The instructions to access the tool are as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N_D7DT6sQ1PqBerAP0blHw.gif" /></figure><p><strong>LAN Manager Hash:</strong></p><p>The user account password for Windows isn’t stored in clear text; instead, it stores passwords with two types of hash representation. When the password for any user account is changed or set with fewer than 15 characters, both <strong>LM hash</strong> (LAN Manager hash) and <strong>NT hash</strong> (<strong>Windows NT hash</strong>) are generated by Windows and can be stored in AD. The LM hash is relatively weaker than the NT and is prone to a fast brute-force attack. The best recommendation is to prevent Windows from storing the password’s LM hash. You can access it through the following:</p><p>Group Policy Management Editor &gt; Computer Configuration &gt; Policies &gt; Windows Settings &gt; Security Settings &gt; Local Policies &gt; Security Options &gt; double click Network security - Do not store LM hash value on next password change policy &gt; select &quot;Define policy setting&quot;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4QeG2z19UokXm0UTb_v9kA.png" /></figure><p><strong>SMB Signing:</strong></p><p>SMB stands for <strong>Server Message Block</strong>. Generally, Microsoft-based networks utilise this protocol for file and print communication. Moreover, it allows secure transmission over the network. Configuring SMB signing through group policy is crucial to detect <strong>Man in the Middle (</strong><a href="http://A man in the middle (MITM) attack is a general term for when a perpetrator positions himself in a conversation between a user and an application—either to eavesdrop or to impersonate one of the parties, making it appear as if a normal exchange of information is underway"><strong>MiTM</strong></a><strong>)</strong> attacks that may result in modification of SMB traffic in transit. SMB signing ensures the integrity of data for both client and server. All supported Windows versions have an SMB packet signing option.</p><p>Group Policy Management Editor &gt; Computer Configuration &gt; Policies &gt; Windows Settings &gt; Security Settings &gt; Local Policies &gt; Security Options &gt; double click Microsoft network server: Digitally sign communication (always) &gt; select Enable Digitally Sign Communications</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tyQXj2-_Mzn-j0Yy.png" /></figure><p><strong>LDAP Signing:</strong></p><p><strong>Light Weight Directory Access Protocol</strong> (<strong>LDAP</strong>) enables locating and authenticating resources on the network. Hackers may introduce replay or MiTM attacks to launch custom LDAP requests. Therefore, LDAP signing is a Simple Authentication and <strong>Security Layer (SASL)</strong> property that only accepts signed LDAP requests and ignores other requests (plain-text or non-SSL). We can enable LDAP signing through the following:</p><p>Group Policy Management Editor &gt; Computer Configuration &gt; Policies &gt; Windows Settings &gt; Security Settings &gt; Local Policies &gt; Security Options &gt; Domain controller: LDAP server signing requirements &gt; select Require signing from the dropdown</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KVeJlNBUYkZtw_yt.png" /></figure><p><strong>Password Rotation:</strong></p><p>Active Directory password security is critical to address because of security breaches and password reuse. It becomes challenging for any organisation to reset account passwords or update them everywhere, so they prefer not to do it. This scenario could have a few alternate approaches, and each method has pros and cons.</p><ul><li><strong>First Technique: </strong>Creating a script to update passwords automatically in the Scheduled Task with the help of PowerShell. This method does not require any additional overhead and removes all the manual efforts for password rotation, but it requires you to write and maintain your script — which could be challenging.</li><li><strong>Second Technique:</strong> Add a Multi-Factor Authentication (MFA) solution to AD and choose not to change the password often. It adds a security layer, and you will not need to change your password often. You can read more about implementing MFA <a href="https://docs.microsoft.com/en-us/azure/active-directory/authentication/howto-mfa-getstarted">here</a>.</li><li><strong>Third Technique:</strong> Microsoft provides a solution for services account password rotation through Group Managed Services Accounts (<strong>gMSAs</strong>), which changes passwords after every 30 days. You can learn more about it <a href="https://docs.microsoft.com/en-us/azure/active-directory/fundamentals/service-accounts-group-managed">here</a>.</li></ul><p><strong>Password Policies:</strong></p><p>Attackers use various corporate password-compromise techniques, including brute force, dictionary, password spraying, credential attacks etc. All organisations must have a strict password policy to defend against all such attacks. Password policies mean different rules for creating passwords, including length, complexity, and changing frequency. For viewing and configuring the password policy, you can use the following:</p><p>Group Policy Management Editor &gt; Computer Configuration &gt; Policies &gt; Windows Settings &gt; Security Settings &gt; Account Policies &gt; Password Policy</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/0*TyHS3sz6wTnJaARM.png" /></figure><p>Understanding Password Policy Settings</p><ul><li><strong>Enforce password history:</strong> Prevent at least 10 to 15 old passwords from being set as new ones.</li><li><strong>Minimum password length:</strong> The minimum password length should be set between 10 to 14.</li><li><strong>Complexity requirements: </strong>Must not contain the name of the user account and ensure the password has uppercase letters, lowercase letters, digits, or special characters.</li></ul><h3><strong>Answer the questions below:</strong></h3><blockquote>What is the default minimum password length (number of characters) in the attached VM?</blockquote><blockquote>7</blockquote><h3>4 — Implementing Least Privilege Model</h3><p>Implementing the least privilege model requires limiting the user or application access to minimise security risks and attack surfaces. When the application or the users are allowed to operate with administrative privileges, they are granted complete access to modify, alter, create other resources on the system and perform any action with administrative rights. Contrary to this, the least privilege model grants limited and authorised access per current conditions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/0*m8HUtfxXSW63TLdS.png" /></figure><p><strong>Creating the Right Type of Accounts:</strong></p><p>Implementing the least privilege model requires setting up the different account types for diverse purposes. It includes the following account types:</p><ul><li><strong>User accounts</strong>: You must promote using regular user accounts for most people in the network, who are necessary to perform their regular duties.</li><li><strong>Privilege account</strong>s: These are the accounts with elevated privileges and are further classified as first and second privilege accounts.</li><li><strong>Shared accounts</strong>: These accounts are shared amongst a group of people, as the visitors with bare minimum privileges, to give limited access for a specific time. These accounts are not recommended and must be utilised in limited scenarios.</li></ul><p><strong>Role-Based Access Control on Hosts:</strong></p><p>As a System Administrator, it is of utmost importance to grant rights to resources while keeping the principle of Least privilege in mind, which <a href="https://en.wikipedia.org/wiki/Principle_of_least_privilege">states </a>that:</p><p>Per Wikipedia, <strong>“<em>The principle of minimal privilege or the principle of least authority, requires that in a particular abstraction layer of a computing environment, every module (such as a process, a user, or a program, depending on the subject) must be able to access only the information and resources that are necessary for its legitimate purpose</em>”.</strong></p><p><strong>Role-based access control</strong> allows you to indicate access privileges at different levels. It includes DNS zone, server, or resource record levels and specifies who has access control over creating, editing, and deleting operations of various resources of Active Directory.</p><p><strong>Tiered Access Model:</strong></p><p>The <strong>Active Directory Tiered Access Model (TAM)</strong> comprises plenty of technical controls that reduce the privilege escalation risks. It consists of a logical structure that separates Active Directory’s assets by creating boundaries for security purposes. The primary goal is the protection of Active Directory’s top-valued identities (Tier 0). At the same time, domain members and other users can perform routine tasks, such as email checking, surfing the internet, and using apps and other services (Tier 1, 2). It comprises three tiers, Tier 0, 1, and 2, which are as follows:</p><ul><li><strong>Tier 0</strong>: Top level and includes all the admin accounts, Domain Controller, and groups.</li><li><strong>Tier 1</strong>: Domain member applications and servers.</li><li><strong>Tier 2</strong>: End-user devices like HR and sales staff (non-IT personnel).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/0*8o-b6mspapCUCc3A.png" /></figure><p>I<strong>mplementation of Tiered Access Model:</strong></p><p>The critical implementation of this model is based on the principle of <strong><em>“Prevention of privileged credentials from crossing boundaries, either accidentally or intentionally”</em></strong>. Implementing technical controls via Group Policy Objects is crucial to avoid such scenarios. These Group Policy Objects put together the security rights that can deny access or grant permission. You can read more about the Tiered and Enterprise Access Model (EAM) <a href="https://docs.microsoft.com/en-us/security/compass/privileged-access-access-model">here</a>.</p><p><strong>Auditing Accounts:</strong></p><p>Accounts audit is a crucial task mainly carried out by setting up the correct account, assigning privileges, and applying restrictions. Three audit types related to accounts must be done periodically: usage, privilege, and change audits.</p><ul><li>Usage audits allow monitoring each account’s specific tasks and validating their access rights.</li><li>A privilege audit allows you to check if every account in the system has the least privilege.</li><li>Change audits allow you to look for any improper changes to account permissions, passwords, or settings. Any unacceptable change to these may lead to a data breach.</li></ul><h3><strong>Answer the questions below</strong></h3><blockquote>Computers and Printers must be added to Tier 0 — yea/nay?</blockquote><blockquote>nay</blockquote><blockquote>Suppose a vendor arrives at your facility for a 2-week duration task. Being a System Administrator, you should create a high privilege account for him — yea/nay?</blockquote><blockquote>nay</blockquote><h3><strong>5 - Microsoft Security Compliance Toolkit</strong></h3><p><strong>Microsoft Security Compliance Toolkit (MSCT)</strong> is an official toolkit provided by Microsoft to implement and manage local and domain-level policies. You don’t have to worry about complex policy syntaxes and scripts, as Microsoft will provide pre-developed security baselines per the end user environment. You can download MSCT from the official Microsoft website<a href="https://www.microsoft.com/en-us/download/details.aspx?id=55319"> link.</a> You can find all the baselines and policy analyser software on Desktop &gt; Scripts of the attached VM.</p><p><strong>Installing Security Baselines:</strong></p><p>Microsoft offers its customers security baselines readily available in consumable formats, like, Group Policy Objects Backups. You can easily download it as zip files and extract the content. Here is how you can download and install the security baselines for Windows Server in a simple way:</p><p>Open Microsoft Security Compliance Website &gt; click Download &gt; click Windows Servers Security Baseline.zip &gt; Download</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ENt9Ma0lE0cKbQ9p.png" /></figure><p>Open extracted folder &gt; Scripts &gt; &amp; select desired baseline &amp; execute with PowerShell</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/0*SC-yGBKc7nSSiby1.png" /></figure><p><strong>Policy Analyser:</strong></p><p>One of the Security Compliance ToolKit’s features is a policy analyser which allows comparison of group policies to quickly check inconsistencies, redundant settings, and the alterations that need to be made between them. Consider a scenario where plenty of GPOs are applied at diverse levels. There will be conflicting, redundant settings and many more avenues that can be quickly resolved with a policy analyser. Same as security baselines, it is downloaded as a zip file from the <a href="https://www.microsoft.com/en-us/download/details.aspx?id=55319">same link</a>, and one can easily extract the content and then follow the procedure, as shown in the following steps:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rcVD86g8mnfSr5AT.png" /></figure><p>Once downloaded, you can run the PolicyAnalyzer.exe to add and manage local or domain-level policies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/0*LRM6rXgqA53iuRvk.png" /></figure><p>Be careful while downloading security baselines, as they should only be downloaded from the official Microsoft website.</p><h3><strong>Answer the questions below</strong></h3><blockquote>Find and open <strong>BaselineLocalInstall</strong> script in PowerShell editor — Can you find the flag?</blockquote><blockquote>THM{00001}</blockquote><blockquote>Find and open <strong>MergePolicyRule</strong> script (Policy Analyser) in PowerShell editor — Can you find the flag?</blockquote><blockquote>{THM00191}</blockquote><h3><strong>6 — Protecting Against Known Attacks</strong></h3><p>If an intruder successfully gains domain admin account access, you may consider that the game is over. No one is ever ready to disclose the company’s confidential data or for financial loss. Before we discuss some known attacks, it is crucial to think like an attacker and develop a mindset wearing their shoes. Here are some already developed interesting rooms on THM to get you going through the possibilities and swathe of attack vectors for an adversary.</p><ul><li><a href="https://tryhackme.com/room/zer0logon"><strong>Zero Logon</strong> </a>(Get admin access to an AD without credentials).</li><li><a href="https://tryhackme.com/room/breachingad"><strong>Breaching AD</strong> </a>(Getting the first set of credentials in an AD environment).</li><li><a href="https://tryhackme.com/room/exploitingad"><strong>Exploiting AD</strong></a> (Learn common AD exploitation techniques).</li><li><a href="https://tryhackme.com/room/postexploit"><strong>Post-Exploitation</strong></a> basics (What an attacker does after gaining an initial foothold of AD).</li></ul><p>Let’s review a few methods for Active Directory protection against known attacks.</p><p><strong>Kerberoasting:</strong></p><p><a href="https://tryhackme.com/room/attackingkerberos"><strong>Kerberoasting </strong></a>is a common and successful post-exploitation technique for attackers to get privileged access to AD. The attacker exploits Kerberos Ticket Granting Service (TGS) to request an encrypted password, and then the attacker cracks it offline through various brute force techniques. These attacks are difficult to detect as the request is made through an approved user, and no unusual traffic pattern is generated during this process. You can prevent the attack by ensuring an additional layer of authentication through MFA or by frequent and periodic Kerberos Key Distribution Centre (KDC) service account password reset. You can learn more about the attack <a href="https://microsoft.com/security/blog/2020/08/27/stopping-active-directory-attacks-and-other-post-exploitation-behavior-with-amsi-and-machine-learning/">here</a>.</p><p><strong>Weak and Easy-to-Guess Passwords:</strong></p><p>The easiest target for intruders to breach security is the weak and easy-to-guess old passwords. The best recommendation is to use strong passwords and avoid already known ones. A strong password consists of a combination of uppercase and lowercase letters, numbers, and special characters. You can learn more about password strength <a href="https://docs.microsoft.com/en-us/azure/active-directory/authentication/concept-password-ban-bad-combined-policy">here</a>. There are many tools available that can help you perform Password Auditing in AD. You can see a report generated through a free tool on Desktop &gt; Password-Report.png.</p><p><strong>Brute Forcing Remote Desktop Protocol:</strong></p><p>The intruders or attackers use scanning tools to brute force the weak credentials. Once the brute force is successful, they quickly access the compromised systems and try to do privilege escalation along with a persistent foothold in the target’s computer. The best recommendation is to never expose RDP without additional security controls to the public internet. Continuous audits for scanning attacks or brute-force attempts are also an important step.</p><p><strong>Publically Accessible Share:</strong></p><p>During AD configuration, some share folders are publicly accessible or left unauthenticated, providing an initial foothold for attackers for lateral movement. You can use the Get-SmbOpenFile cmdlet in PowerShell to look for any undesired share on the network and configure access accordingly.</p><h3><strong>Answer the questions below</strong></h3><blockquote>Does Kerberoasting utilise an offline-attack scheme for cracking encrypted passwords — yea/nay?</blockquote><blockquote>yea</blockquote><blockquote>As per the generated report, how many users have the same password as aaron.booth?</blockquote><blockquote>186</blockquote><h3><strong>7 — Windows Active Directory Hardening Cheat Sheet</strong></h3><p><strong>Are you sure your AD is secure from all types of attacks?</strong></p><p>Hardening of an AD is a continuous process and demands collective efforts by System Administrators and end-users. There have been various system hardening standards, and we discussed a few in this room. Below is a quick summary of the hardening techniques that will enable System Administrators to harden AD quickly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/0*JAVlWrR1tMcKUfFZ.png" /></figure><p>This is simple — isn’t it? This room was a basic introduction. We are planning to develop a few detailed AD hardening rooms to discuss in-depth how to protect an AD through group policies and implement the least privilege model. Stay tuned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c804f3c3e63e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>