I am trying to learn about XSS so in order to that I have made a web app vulnerable to reflected XSS. I am trying to steal the user's cookies, so if I write the following the cookie value is displayed:


I want to send the cookie value to the following PHP script (getcookies.php) in my localhost:

$file = 'cookies_list.txt';
$stringPrint = 'Time ' . date("Y/m/d - h:i:sa") . ' Origin IP: ' . $_SERVER['REMOTE_ADDR'] . '  Cookie: ' . $_GET["c"] .  PHP_EOL;
file_put_contents($file, $stringPrint, FILE_APPEND | LOCK_EX);

When I write in the browser's URL this, the PHP script gets the 'test' value of c param.


Instead when I write this, the PHP script does not get any value.


Could somebody tell me why it doesn't work?


  • I can also execute this payloads:

    message=<script>document.body.innerHTML = '';</script>
  • The cookies are not HttpOnly.

  • No, the GET request is not sent to the server.

  • This really isn't enough information for us to answer this question. Are other XSS payloads executed? (if not, see here) Are the cookies httpOnly? (if so, it will not work) What does your browser console say? Is there a request to localhost/getcookies.php?
    – tim
    Jan 23, 2017 at 19:18
  • @Tim. First of all thank you for your response. I have found what has happened. The URL was not encoded correctly. I have had to change the + character by %2B in the payload to make it work. What should I do now? answer my own answer or post the solution in the question?
    – v8rs
    Jan 23, 2017 at 20:13
  • I wouldn't add the solution in the question, as it's an answer, not a question (it also adds to the number of unanswered questions). Feel free to add it as an answer (ideally with additional infos; eg how you found it out (did you use an error message in the browser console?)), or just delete the question (I'm not sure if an answer would really help out others having the same problem)
    – tim
    Jan 23, 2017 at 20:23

1 Answer 1


I have seen in Firebug that the GET request's sent payload was the following:


So the + character was not being URL encoding. I have encoded it: %2B resulting the payload the following:


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .