Part 1- Portswigger - Xss Attacks | Shahul Hameed
Lab 1: Reflected XSS into HTML context with nothing encoded
Lab 2: Stored XSS into HTML context with nothing encoded
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. Enter a random alphanumeric string into the search box.
- 2. Right-click and inspect the element, and observe that your random string has been placed inside an
img src
attribute. - 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.
"><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
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. 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
innerHTML
assignment, which changes the HTML contents of a div
element, using data from location.search
.Step 1: UI view
<img src=1
onerror=alert(1)>
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)
Comments
Post a Comment