Part 1- Portswigger - Xss Attacks | Shahul Hameed

 

Lab 1: Reflected XSS into HTML context with nothing encoded    

    Description: This lab contains a simple reflected cross-site scripting vulnerability in the search function it reflected on the client-side.

Step 1: UI view


Step 2: Query pass in URL


Step 3: Inject payload to get attack

  Payload :  <script>alert(1)</script>

Step 4: Result

Lab 2: Stored XSS into HTML context with nothing encoded

    Description: This lab contains a stored cross-site scripting vulnerability in the comment functionality it is reflected on the server-side.

Step 1: UI view


Step 2: Inject payload in the Comment section and to get attack 


Step 3: Go back to comment section 


Lab 3: DOM XSS in document.write sink using source location.search

    Description: This lab contains a DOM-based cross-site scripting vulnerability in the search query tracking functionality. It uses the JavaScript document.write function, which writes data out to the page. The document.write function is called with data from location.search, which you can control using the website URL.

Solutions:

    1. 1. Enter a random alphanumeric string into the search box.
    2. 2. Right-click and inspect the element, and observe that your random string has been placed inside an img src attribute.
    1. 3. Break out of the img attribute by searching for: "><svg onload=alert(1)>

Step 1: UI view


Step 2: Inspect that "Google" word and find the image which has the same keyword in src image tag.


Step 3: Inject payload using svg format

    "><svg onload=alert(1)>



    Note: Note: To escape from the attribute and from the tag (then you will be in the raw HTML) and create new HTML tag to abuse: "><img [...]



Step 4 : Payload attacked



Lab 4: DOM XSS in document.write sink using source location.search inside a select element

    Description: This lab contains a DOM-based cross-site scripting vulnerability in the stock checker functionality. It uses the JavaScript document.write function, which writes data out to the page. The document.write function is called with data from location.search which you can control using the website URL. The data is enclosed within a select element.

Step 1: UI view


Step 2: Inspect that stock availability units




Step 3: Inject payload

    product?productId=1&storeId="></select><img%20src=1%20onerror=alert(1)>

  Decode as:

    "></select><img src=1 onerror=alert(1)>"></select><img src=1 onerror=alert(1)>

Step 4: Result


Lab 5: DOM XSS in innerHTML sink using source location.search

    Description: This lab contains a DOM-based cross-site scripting vulnerability in the search blog functionality. It uses an innerHTML assignment, which changes the HTML contents of a div element, using data from location.search.

Step 1: UI view



Step 2: Inject payload : 
    
    <img src=1 onerror=alert(1)>



Step 3: Result 



Lab 6: DOM XSS in jQuery anchor href attribute sink using location.search source

    Description: This lab contains a DOM-based cross-site scripting vulnerability in the submit feedback page. It uses the jQuery library's $ selector function to find an anchor element, and changes its href attribute using data from location.search.

To solve this lab, make the "back" link alert document.cookie.


Step 1: UI view






Step 2: Write some random word after URL => / and Inspect that back button in UI



Step 3: Inject payload

    javascript:alert(document.cookie)


Step 4: Result payload injected successfully









Comments

Popular posts from this blog

Using Burp Suite - Brute Force payloads using XSS Validator(Extension) | Shahul Hameed

Janus Vulnerability Exploitation

SQL Basics | Shahul Hameed