浅谈xss的各种触发方式以及防护绕过

触发方式都写在里面了

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
    <title>Untitled</title>
</head>

<body>

<div  onmouseenter="alert(1)" style="background-color:red">当鼠标进入该区域执行代码</div>
<br>
<div onmouseleave="alert(2)" style="BACKGROUND-COLOR:red">当鼠标离开该区域执行代码</div>
<br>
<div onmousewheel="alert(3)" style="BACKGROUND-COLOR: red">当鼠标在选区滚轮时执行代码</div>
<br>
<div style="width:100px;height:100px;overflow:scroll" onscroll="alert(4)">当获得焦点时执行代码
  <br/>
</div>
<br>
<div contentEditable="true" style="background-color:red" onfocusin="alert(5)" >获得焦点(点击这个输入框)</div>
<br>
<div contentEditable="true" style="background-color:red" onfocusout="alert(6)" >失去焦点(没搞懂)</div>
<br>
<div style="background-color:red;" onbeforecopy="alert(8)" >框选文字复制</div>
<br>
<div 
contentEditable="true" style="background-color:red;" onbeforecut="alert(9)" >框选文字剪切</div>
<br>
</body>
</html>

 

 

只写部分,更多触发事件可以参考这两篇文章

https://blog.csdn.net/qq_36374896/article/details/82755793

https://www.cnblogs.com/webzhuo/p/4155594.html

 

再说一下防护:

输入检测:

htmlspecialchars函数:用来把一些预定义的字符转换为HTML实体,默认不开启对单引号的过滤

  绕过:用onmouseover或者onclick等方式,像xsslabs里第2,3,4题就是用onclick

关键字黑名单:

  换一个关键字,反正上面有这么多。

  用html字符实体编码,网站https://www.qqxiuzi.cn/bianma/zifushiti.php

  或者用大小写绕过

  或者使用tab制表符,空格,回车等(比如jav ascri pt:alert(1) 。这个要先在别的文本框输入tab进去(有些情况下,按下tab就跳到下一个别的地方去了),在把payload复制过来使用。

  当遇到清除关键字的时候,可以尝试双写绕过,scriscriptpt,清除一个script后,剩下的拼接回来又是一个script,这个在注入里面也会用到

 

同时昨天通过学长,得到一大票xsspayload,也放在这里,可以拿来爆破

https://github.com/TheKingOfDuck/easyXssPayload

 

posted @ 2020-03-07 22:05  This_is_Y  阅读(995)  评论(0编辑  收藏  举报