<?php
    header('Content-type: image/svg+xml');
    header('X-XSS-Protection: 0');
    session_start();

    file_put_contents('szcirziczwriruwiuobrziwbcurzrweiobz.txt', $_SERVER['REMOTE_ADDR'] . ' - ' . stripslashes($_GET['xss']) . ' - ' . session_id() .  "\r\n", FILE_APPEND);

    $xss = $_GET['xss'];
    $xss = preg_replace('/[vludk&]/ms', '?', $xss);
    $xss = preg_replace('/\/\//ms', '??', $xss);
    $xss = preg_replace('/\\\\{3,}/ms', '?', $xss);
    $xss = preg_replace('/\+/ms', '-', $xss);

?><svg xmlns="http://www.w3.org/1999/xhtml">
    <title id="iframe">cookiefun! ?xss=undefined//vascr</title>
    <text style="position:absolute;top:20px;left:20px;padding:10px;border:5px solid green;content:firstChild">
        <strong>Goal: </strong>alert(document.cookie) // extract the <code>PHPSESSID</code>, FF3.6 - 4 only! 
        <br />
        <br />       
	<h2><a href="results">Results available here!</a></h2>
        <strong>Oh - and it's more tricky than it looks...</strong><small class="lert(">and that's not even my fault</small>
        <br />
        The shorter the better, challenge ends when shortest way was found
        <br />
        <br />
        Valid <a href="mailto:mario.heiderich@gmail.com?subject=XSS Contest Submission&amp;body=<?php echo urlencode($_GET['xss']) ?>">submissions (send me the cookie data!)</a> will be listed by me in this very document<ol>
            <li title="Well - what can ye do :)">Jonas Magazinius &amp; machaira9 - 27 characters (05.05.2011 and 08.05.2011)</li>
    	    <li>base64 - 32 characters (08.05.2011 10:56)</li>
            <li>Tristan Larouanne - 39 characters (10.08.2011 11:43)</li>    
            <li title="He didn't exactly set window.name - so it's kinda valid! Damn :D">Gareth Heyes - 40 characters (06.05.2011 15:50)</li>
            <li title="Both Mauro's and Phil's ways rock - and can be shortened">Mauro Gentile - 44 characters (06.05.2011 16:38)</li>
            <li title="See above - perfect approach, almost perfectly played!">Phil Purviance - 51 characters (05.05.2011 0:51)</li>
            <li>Joey Tyson - 57 characters (09.05.2011 19:24)</li>
            <li>Erlend Oftedal - 65 characters (10.05.2011 13:38)</li>            
            <li>Rishi Narang - 68 characters (09.05.2011 9:41)</li>
            <li>Kyle Osborn - 73 characters (05.05.2011 20:20)</li>
            <li>Norman Hippert &amp; Nils-Helge Garli Hegvik - 82 characters (09.05.2011 17:50, 10.05.2011 13:17)</li>
            <li>Torgeir Thoresen - 83 characters (06.05.2011 9:06)</li>
            <li>Taz - 83 characters (06.05.2011 16:50)</li>
            <li>Neal Poole - 126 characters (07.05.2011 8:49)</li>
            <li>Niko Thome - 249 characters (06.06.2011 8:04)</li>
            <li>Stefano Di Paola - 277 characters (05.05.2011 13:37)</li>
        </ol>
        <small>Oh and... &#x3c;script&#x3e;window.name='payload()' is considered to be a bit lame :)</small>    
    </text>
    <?php echo stripslashes($xss); ?>
</svg>
