Cross-site scripting
https://portswigger.net/web-security/cross-site-scripting
Lab: Reflected XSS into HTML context with nothing encoded
This lab contains a simple reflected cross-site scripting vulnerability in the search functionality.
Lab: Stored XSS into HTML context with nothing encoded
This lab contains a stored cross-site scripting vulnerability in the comment functionality.
csrf=dEw6a3DaskdxmTVrwvlONQj1sGecwy30&postId=6&comment=
%3Cscript%3Ealert%280%29%3C%2Fscript%3E
+This+is+a+comment.&name=test&email=test%40test.com&website=https%3A%2F%2Fwww.test.com
Lab: DOM XSS in document.write sink using source location.search
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.
Search -> 123456789
Search ->
Lab: DOM XSS in document.write sink using source location.search inside a select element
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.
Lab: DOM XSS in innerHTML sink using source location.search
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.
Lab: DOM XSS in jQuery anchor href attribute sink using location.search source
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.
Lab: DOM XSS in jQuery selector sink using a hashchange event
This lab contains a DOM-based cross-site scripting vulnerability on the home page. It uses jQuery's $() selector function to auto-scroll to a given post, whose title is passed via the location.hash property.
To solve the lab, deliver an exploit to the victim that calls the print() function in their browser.
Exploit Server ->
Lab: DOM XSS in AngularJS expression with angle brackets and double quotes HTML-encoded
This lab contains a DOM-based cross-site scripting vulnerability in a AngularJS expression within the search functionality.
AngularJS is a popular JavaScript library, which scans the contents of HTML nodes containing the ng-app attribute (also known as an AngularJS directive). When a directive is added to the HTML code, you can execute JavaScript expressions within double curly braces. This technique is useful when angle brackets are being encoded.
Search ->
Lab: Reflected DOM XSS
This lab demonstrates a reflected DOM vulnerability. Reflected DOM vulnerabilities occur when the server-side application processes data from a request and echoes the data in the response. A script on the page then processes the reflected data in an unsafe way, ultimately writing it to a dangerous sink.
Search -> 12345678
Search ->
Lab: Stored DOM XSS
This lab demonstrates a stored DOM vulnerability in the blog comment functionality.
Website encoded first <> angle brackets. If we add <> at the beginning we can bypass it. But we can not. We can see the cause in the response.
JS added \ before /. So we can not use this payload. Try another one.
In an attempt to prevent XSS, the website uses the JavaScript replace() function to encode angle brackets.
Lab: Reflected XSS into HTML context with most tags and attributes blocked
This lab contains a reflected XSS vulnerability in the search functionality but uses a web application firewall (WAF) to protect against common XSS vectors.
There is a WAF. It blocks most of tags and attributes.
XSS tags list -> https://portswigger.net/web-security/cross-site-scripting/cheat-sheet -> Copy tags to clipboard
Sniper attack with xss tags list ->
GET /?search=<§§> HTTP/1.1
Just body tag is allowed.
XSS events list -> Choose body tag -> https://portswigger.net/web-security/cross-site-scripting/cheat-sheet -> Copy events to clipboard
Sniper attack with xss events list ->
GET /?search=<body%20§§=1> HTTP/1.1
Just onresize attribute is allowed.
Exploit Server ->
Deliver exploit to victim -> Solved.
Lab: Reflected XSS into HTML context with all tags blocked except custom ones
This lab blocks all HTML tags except custom ones.
Exploit Server ->
Lab: Reflected XSS with event handlers and href attributes blocked
This lab contains a reflected XSS vulnerability with some whitelisted tags, but all events and anchor href attributes are blocked.
Sniper attack with xss tags list ->
GET /?search=<§§> HTTP/1.1
a, animate, image, svg, title
Lab: Reflected XSS with some SVG markup allowed
This lab has a simple reflected XSS vulnerability. The site is blocking common tags but misses some SVG tags and events.
Sniper attack with xss tags list ->
GET /?search=<§§> HTTP/1.1
animatetransform, image, svg, title
Lab: Reflected XSS into attribute with angle brackets HTML-encoded
This lab contains a reflected cross-site scripting vulnerability in the search blog functionality where angle brackets are HTML-encoded.
Lab: Stored XSS into anchor href attribute with double quotes HTML-encoded
This lab contains a stored cross-site scripting vulnerability in the comment functionality.
Lab: Reflected XSS in canonical link tag
This lab reflects user input in a canonical link tag and escapes angle brackets.
Lab: Reflected XSS into a JavaScript string with single quote and backslash escaped
This lab contains a reflected cross-site scripting vulnerability in the search query tracking functionality. The reflection occurs inside a JavaScript string with single quotes and backslashes escaped.
Search -> 12345678
Single quote gets backslash-escaped
Lab: Reflected XSS into a JavaScript string with angle brackets HTML encoded
This lab contains a reflected cross-site scripting vulnerability in the search query tracking functionality where angle brackets are encoded. The reflection occurs inside a JavaScript string.
Search -> 12345678
Angle brackets get encoded.
Lab: Reflected XSS into a JavaScript string with angle brackets and double quotes HTML-encoded and single quotes escaped
This lab contains a reflected cross-site scripting vulnerability in the search query tracking functionality where angle brackets and double are HTML encoded and single quotes are escaped.
Search -> 12345678
Single quote gets backslash-escaped. Can we bypass adding a backslash and double slash?
Lab: Reflected XSS in a JavaScript URL with some characters blocked
This lab reflects your input in a JavaScript URL, but all is not as it seems. This initially seems like a trivial challenge; however, the application is blocking some characters in an attempt to prevent XSS attacks.
Post a comment with these to name and comment : < > / ' " : ; =
/ : ; =
are allowed.
Lab: Stored XSS into onclick event with angle brackets and double quotes HTML-encoded and single quotes and backslash escaped
This lab contains a stored cross-site scripting vulnerability in the comment functionality.
Post a comment:
Lab: Reflected XSS into a template literal with angle brackets, single, double quotes, backslash and backticks Unicode-escaped
This lab contains a reflected cross-site scripting vulnerability in the search blog functionality. The reflection occurs inside a template string with angle brackets, single, and double quotes HTML encoded, and backticks escaped.
Search -> 12345678
There is a JavaScript template string.
Lab: Reflected XSS with AngularJS sandbox escape without strings
This lab uses AngularJS in an unusual way where the $eval function is not available and you will be unable to use any strings in AngularJS.
Search -> 12345678
/?search=1&toString().constructor.prototype.charAt%3d[].join;[1]|orderBy:toString().constructor.fromCharCode(120,61,97,108,101,114,116,40,49,41)=1
Lab: Reflected XSS with AngularJS sandbox escape and CSP
This lab uses CSP and AngularJS.
"Search term cannot exceed 70 characters"
Exploit Server ->
Deliver exploit to victim -> Solved.
We added #x to location parameter. Because victim has to focus on x to get exploit successfully.
Lab: Exploiting cross-site scripting to steal cookies
This lab contains a stored XSS vulnerability in the blog comments function. A simulated victim user views all comments after they are posted.
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
Burp Collaborator -> HTTP Request -> Request to Collaborator
Lab: Exploiting cross-site scripting to capture passwords
This lab contains a stored XSS vulnerability in the blog comments function. A simulated victim user views all comments after they are posted.
Burp Collaborator -> HTTP Request -> Request to Collaborator
We got an advantage of using autofill option. When the password field changed, we got victim's credential via fetch request.
Lab: Exploiting XSS to perform CSRF
This lab contains a stored XSS vulnerability in the blog comments function.
We can bypass csrf protection with extraction and using csrf value via JS.
Lab: Reflected XSS protected by CSP, with dangling markup attack
This lab uses CSP to mitigate against XSS attacks.
To solve the lab, perform a dangling markup attack that steals a CSRF token and uses it to change the email address of another user.
Payload ->
Exploit Server ->
csrf = ZWeTT0MOouA9WCDtr93ekFbnQvueoN42
Intercepted request of updating mail address -> Engagement Tools -> CSRF PoC Generator -> Options -> Include Auto-Submit Script(Checked) -> Regenerate -> Replace csrf value with it
Exploit Server ->
Lab: Reflected XSS protected by very strict CSP, with dangling markup attack
This lab using a strict CSP that blocks outgoing requests to external web sites.
To solve the lab, perform a cross-site scripting attack that bypasses the CSP and exfiltrates the CSRF token using Burp Collaborator. You need to label your vector with the word "Click" in order to induce the simulated victim user to click it. For example:
Exploit Server ->
csrf -> MMzLWRNQx3jtLpcfqf5ecVAx2DBrLuqh
Intercepted request of updating mail address -> Engagement Tools -> CSRF PoC Generator -> Options -> Include Auto-Submit Script(Checked) -> Regenerate -> Replace csrf value with it
Exploit Server ->
Lab: Reflected XSS protected by CSP, with CSP bypass
This lab uses CSP and contains a reflected XSS vulnerability.
To solve the lab, perform a cross-site scripting attack that bypasses the CSP and calls the alert function.
In response header:
Content-Security-Policy: default-src 'self'; object-src 'none';script-src 'self'; style-src 'self'; report-uri /csp-report?token=
/?search=alert(1)&token=;script-src-elem 'unsafe-inline'
In response header:
Content-Security-Policy: default-src 'self'; object-src 'none';script-src 'self'; style-src 'self'; report-uri /csp-report?token=;script-src-elem 'unsafe-inline'
Last updated