<?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 Safouat El Yassini on Medium]]></title>
        <description><![CDATA[Stories by Safouat El Yassini on Medium]]></description>
        <link>https://medium.com/@elyassinisafouat2?source=rss-a16ca16d744f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*v484XErLNI0rLOlmoI3gXg.jpeg</url>
            <title>Stories by Safouat El Yassini on Medium</title>
            <link>https://medium.com/@elyassinisafouat2?source=rss-a16ca16d744f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 10:33:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@elyassinisafouat2/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[XSStrike and Cypress: Finding XSS Vulnerabilities, Testing, and Safe Your Web Apps.]]></title>
            <link>https://medium.com/@elyassinisafouat2/xsstrike-and-cypress-finding-xss-vulnerabilities-testing-and-safe-your-web-apps-84e0cdc51afc?source=rss-a16ca16d744f------2</link>
            <guid isPermaLink="false">https://medium.com/p/84e0cdc51afc</guid>
            <dc:creator><![CDATA[Safouat El Yassini]]></dc:creator>
            <pubDate>Mon, 16 Oct 2023 23:44:28 GMT</pubDate>
            <atom:updated>2023-10-16T23:44:28.898Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*jZBW3pAfH5d-OdD1d8Va1w.jpeg" /></figure><p>Whether you’re a developer or a QA tester, ensuring your website’s safety is crucial. Even if you use security measures like a Content Security Policy, you must actively test and protect your site from XSS attacks. In this article, I’ll introduce you to some tools that can help you discover malicious payloads. You’ll also learn how to use these payloads with Cypress to figure out which one is harmful and where it can sneak into your website.</p><p><strong>What is XSS:</strong></p><p>XSS (Cross-Site Scripting) is when bad actors inject harmful javascript code into a website. The tricky part is, the website’s server can’t always tell if the code is from a trusted or untrusted source. With XSS, they can insert code that can swipe data from cookies and sessions, or even plant keyloggers to capture keystrokes. It’s like inviting a spy into your web world without realizing it.there is two type of XSS attack :</p><ul><li><strong>Stored XSS (Persistent XSS):</strong> In this type of XSS , the injected malicious script is permanently stored on the web server, such as in a database, and it is then retrieved and executed when a user visits a specific page that displays the stored content. This means that any user who accesses the page is at risk of running the malicious script.</li><li><strong>Reflected XSS (Non-Persistent XSS):</strong>In this type of XSS attack, the malicious script is embedded in a URL or a web form input, and it is reflected off a web server to the victim’s browser. The victim clicks on a link or submits a form with the injected script, and the server sends the script back as part of the response.</li></ul><p>Stored XSS is often more dangerous than reflected XSS because it can affect a broader range of users and persists even after the attacker has injected the script.</p><p>A simple example of Stored XSS a payload :</p><pre>&lt;script&gt;<br>  // Malicious code here to steal cookies or perform other harmful actions<br>   alert(&quot;hi&quot;); //this is a simple example<br>&lt;/script&gt;</pre><p><strong>how can i find Payloads:</strong></p><h4>You can discover XSS payloads using different methods:</h4><p>The traditional approach involves manually inspecting your browser and experimenting to see if you can inject a payload into the HTML or JavaScript code of a web page. However, this method can be time-consuming, may not cover all possible vulnerabilities, and often requires a solid understanding of JavaScript and web development to be effective.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*4zGLGeoiGD1oWQR0OndAAQ.jpeg" /></figure><p>A more efficient way is to use a specialized scanner tool designed to detect XSS vulnerabilities by automatically injecting various payloads and analyzing the application’s responses. These tools can help you identify potential weaknesses in your web application more quickly and comprehensively, reducing the manual effort required for testing.for example <strong>XSStrike</strong></p><p><strong>What is XSStrike:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/273/1*hBGUaEIAxuJ1GTdvP2MAHw.png" /></figure><p>is an open-source advanced XSS (Cross-Site Scripting) detection and exploitation framework. It is designed to help security professionals, ethical hackers, and penetration testers identify and exploit XSS vulnerabilities in web applications.</p><p>Key features of XSStrike include:</p><p><strong>Payload Generation:</strong> XS-Strike provides a range of payload templates and encoding techniques, making it easier to craft payloads to test for XSS vulnerabilities.</p><p><strong>Detection:</strong> The tool automates the process of detecting and identifying XSS vulnerabilities in web applications by injecting various payloads and analyzing the responses.</p><p><strong>Exploitation:</strong> XS-Strike can be used to confirm the presence of an XSS vulnerability and even exploit it, allowing testers to demonstrate the impact of the vulnerability.</p><p><strong>Advanced Techniques:</strong> XS-Strike includes support for a variety of advanced techniques, such as DOM-based and blind XSS detection, which can be particularly challenging to identify.</p><p><strong>Reporting:</strong> The tool generates detailed reports that can be used to document and communicate the results of XSS testing to development and security teams.</p><p><strong>Setup and installation:</strong></p><pre>git clone https://github.com/s0md3v/XSStrike.git<br>cd XSStrike<br>pip install -r requirements.txt<br>python3 xsstrike.py -u &quot;http://example.com&quot;<br></pre><h4>Let’s try using XS-Strike on a website, but not on an official website; I don’t like lentils.</h4><p>i will use this <a href="http://www.sudo.co.il/xss/level6.php?p=your_payload">website sudo.co.il</a> for finding the payloads :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*ZvloXSodo4smkaeopGfRJQ.png" /><figcaption>1-Payloads of our Target</figcaption></figure><p>As we can see,<strong> XSStrike </strong>provides us with possible payloads to test on the website. Now, we should proceed to test these payloads in <strong>Cypress</strong>, especially when dealing with numerous inputs, as it’s essential to assess all the payloads in various DOM elements.</p><p><strong>Be careful</strong>Be carefull</p><p>XSStrike may not only provide payloads but also identify potential vulnerabilities in your <strong>JavaScript code</strong> that should be avoided. In such cases, the tool might help you recognize weak points in your code or risky practices that could lead to XSS vulnerabilities, even if it doesn’t generate payloads for you. It’s essential to address these vulnerabilities and strengthen the security of your web application to prevent potential attacks.</p><p><strong>For example, on this official website, I discovered a vulnerable script that could potentially be exploited by a malicious attacker.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*dB-yDgEA-WMcRGLBefolLA.png" /></figure><p><em>Eval is evil.</em> — Some frustrated JavaScript engineer</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AXSb7tK5nEO5A9n3_C-RyQ.jpeg" /></figure><h3><strong>Cypress</strong></h3><p>Cypress is an open-source end-to-end testing framework for web applications. It is designed to simplify and improve the process of testing web applications by providing a powerful and developer-friendly testing environment.</p><p><strong>setup and instalation:</strong></p><pre><br>npm install cypress --save-dev<br>npx cypress open</pre><p>in your todo.file.js and by using the &#39;payloads for our target&#39; on the website, we don&#39;t have any input fields, which means that the only possible payload insertion point is in the URL.</p><pre><br>/// &lt;reference types=&quot;cypress&quot; /&gt;<br><br><br>describe(&#39;URL-based XSS Testing&#39;, () =&gt; {<br>  const targetUrl = &#39;http://www.sudo.co.il/xss/level6.php?p=your_payload&#39;; // Replace with your target URL<br><br>  it(&#39;Test for URL-based XSS Vulnerabilities&#39;, () =&gt; {<br>    cy.visit(targetUrl);<br><br>    // Define an array of payloads for XSSTrike.<br>    const payloads = [<br>      &quot;\\&#39;;confirm()//&quot;, &quot;\\&#39;;(confirm)()//&quot;    <br>      /* Add more payloads as needed, and if your payload starts with a <br>backslash (&#39;&#39;), add two backslashes (&#39;\&#39;) in your payloads list instead <br>of a single backslash, because the backslash character is not typically<br> encrypted itself.*/<br>    ];<br><br>    // Loop through the payloads and test the URL with the payloads.<br>    payloads.forEach((payload) =&gt; {<br>      // Construct the URL with the payload.<br>      const xssUrl = `${targetUrl}?param=${payload}`;<br><br>      // Visit the URL with the payload and check the response.<br>      cy.visit(xssUrl);<br><br>      // You can then use Cypress assertions to check the page for signs of successful XSS.<br>      // For example, you might check for the appearance of an alert box triggered by the payload.<br>      cy.on(&#39;window:confirm&#39;, (confirmText) =&gt; {<br>        if (confirmText) {<br>          // Check if confirmText is defined before making assertions.<br>          expect(confirmText).to.include(&#39;www.sudo.co.il&#39;);<br>        }<br>      });<br>    });<br>  });<br>});</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*HDaSgHCvqVazP5kD7ERLuw.png" /></figure><p>As we can see all of the payloads are being executed on the target page, and the results of these executions are being captured by the test script for further analysis.</p><ul><li>(confirm)http://www.sudo.co.il/xss/level6.php?p=your_payload?param=&#39;;confirm()//:</li><li>This line indicates that the payload was injected into the URL, and it triggered a JavaScript confirm() dialog.</li></ul><p><strong>in case of having multiple inputs:</strong></p><pre>/// &lt;reference types=&quot;cypress&quot; /&gt;<br><br>describe(&#39;Input-based XSS Testing&#39;, () =&gt; {<br>  const targetUrl = &#39;http://www.example.com&#39;; // Replace with your target URL<br><br>  it(&#39;Test for Input-based XSS Vulnerabilities&#39;, () =&gt; {<br>    // Visit the target URL.<br>    cy.visit(targetUrl);<br><br>    // Define an array of payloads for XSSTrike.<br>    const payloads = [<br>      &quot;\\&#39;;(confirm)()//&quot;, &quot;\\&#39;;(a=confirm,a())//&quot;, &quot;\\&#39;;[8].find(confirm)//&quot;, &quot;\\&#39;;confirm()//&quot;<br>      // Add more payloads as needed...<br>    ];<br><br>    // Loop through the payloads.<br>    payloads.forEach((payload) =&gt; {<br>      // Find and interact with each input field on the page.<br>      cy.get(&#39;input&#39;).each((input, index) =&gt; {<br>        // Type the payload into the current input field.<br>        cy.wrap(input).type(payload);<br><br>        // Submit the form or perform any required actions to trigger the payload.<br><br>        // You can add additional steps based on the specific behavior of the website.<br>        // For example, clicking a &quot;Submit&quot; button or triggering an event.<br><br>        // Then, check for signs of a successful XSS attack, such as an alert box.<br>        cy.on(&#39;window:alert&#39;, (alertText) =&gt; {<br>          expect(alertText).to.equal(&#39;XSS&#39;);<br>        });<br>      });<br>    });<br>  });<br>});</pre><p>you can find all of this codes in my <a href="https://github.com/safouat/XSStrike-Cypress-Testing">GitHub</a>.</p><p><strong>Conclusion:</strong></p><p>the combination of XSStrike and Cypress empowers web developers and security professionals to conduct thorough and systematic XSS testing, allowing for the timely discovery and mitigation of vulnerabilities before they can be exploited by malicious actors.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84e0cdc51afc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>