Last active
December 4, 2018 07:47
-
-
Save nerdfiles/2f2182fd081f8de3cfbb16e05b311025 to your computer and use it in GitHub Desktop.
Replay a CSRF Token with request and cheerio (like if they're using session tokens on a webpage, sometimes they use JWT as CSRF tokens)
This file contains hidden or 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
/* @fileOverview ./csrfCapture.js | |
* @description | |
* 1. Open Terminal | |
* 2. $ npm i request cheerio | |
*/ | |
var request = require('request'); | |
var cheerio = require('cheerio'); | |
var someUrl = "https://microsoft.com/webpage"; | |
request.get({ | |
url: someUrl, | |
jar: true, | |
followAllRedirects: true | |
}, function(err, resp, body){ | |
var $ = cheerio.load(body); | |
var token = $('[name="csrfToken"]').val(); | |
request.post({ | |
url: "https://microsoft.com/createItemEndpoint", | |
form: { '_token': token }, | |
jar: "true", | |
followAllRedirects: true | |
}, function (error, response, body) { | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment