I'm only a beginner so if any more info is needed just request and i'll update the question.
For one of my modules we are covering cross-site scripting and I have been given a series of PHP files that I need to get a script through to print document.cookie to an an alert box. I've spent a while on this one and i'm having some trouble, if someone could help me out.
<html><head>...</head> <?php require_once 'header.php'; ?> <?php if (isset($_POST["name"])) { echo "HELLO ".htmlentities($_POST["name"]); } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> Your name:<input type="text" name="name" /> <input type="submit" name="submit"/> </html
I have tried to POST URL encoded payloads and I have read through the PHP manual for htmlentities but they only show examples of injecting JavaScript where the PHP is inserting the POST data into an element already. This code is just writing it to the document and removing the characters < > " ". All other characters are written to the document.
I have also tried manually entering this data into the request headers directly and the same sensitization is done.
All that is in header.php is the cookie being set and the disabling of the browsers X-XSS-Protection.
Any help is much appreciated.