<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script>alert('123')</script>
</body>
</html>
這個頁面,只能打印出
<script>alert('123')</script>
但是如果改成這樣
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script>alert('123')</script>
</body>
</html>
可以彈框
說明轉義字符在html頁面解析的時候不能立即執行,它只是把字符轉義了,用於顯示
類似的php代碼
<?php
$abc='<script>alert('123')</script>';
$abcd="<script>alert('123123')</script>";
echo $abc;
?>
只能顯示出<script>alert('123')</script>
如果改成
<?php
$abc='<script>alert('123')</script>';
$abcd="<script>alert('123123')</script>";
echo $abcd;
?>
則會彈窗
這就告訴我們用xss腳本注入,通過轉義字符的方式是沒戲的