xss 脚本攻击问题

如下php代码

<?phperror_reporting(0);
$name = $_GET["name"];?><input id="text" type="text" value="<?php echo $name;?>" />
<div id="print"></div><script type="text/javascript">var text = document.getElementById("text"); 
var print = document.getElementById("print");
print.innerHTML = text.value; // 获取 text的值,并且输出在print内。这里是导致xss的主要原因。</script>

为什么会有两种不同情况?chrome 55版本

http://localhost/test/?name=<script>alert(1)</script>//失败

http://localhost/test/?name=<img src=1 onerror=alert(1)>//成功


呼唤远方
浏览 600回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript