• <fieldset id="8imwq"><menu id="8imwq"></menu></fieldset>
  • <bdo id="8imwq"><input id="8imwq"></input></bdo>
    最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
    問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
    當前位置: 首頁 - 科技 - 知識百科 - 正文

    javascript過濾危險腳本方法_javascript技巧

    來源:懂視網 責編:小采 時間:2020-11-27 20:39:40
    文檔

    javascript過濾危險腳本方法_javascript技巧

    javascript過濾危險腳本方法_javascript技巧:腳本藏身之處不過有四: 1、<script>標簽、<link>標簽、<style>標簽、iframe標簽 2、on開頭的標簽屬性 3、javascript(vbscript)偽協議 4、css的epression下面是他們的字符串規則: 1、<(script|link|style
    推薦度:
    導讀javascript過濾危險腳本方法_javascript技巧:腳本藏身之處不過有四: 1、<script>標簽、<link>標簽、<style>標簽、iframe標簽 2、on開頭的標簽屬性 3、javascript(vbscript)偽協議 4、css的epression下面是他們的字符串規則: 1、<(script|link|style

    腳本藏身之處不過有四: 1、<script>標簽、<link>標簽、<style>標簽、iframe標簽 2、on開頭的標簽屬性 3、javascript(vbscript)偽協議 4、css的epression

    下面是他們的字符串規則:
    1、<(script|link|style|iframe)(.|\n)*<\/\1>\s*
    2、\s*on[a-z]+\s*=\s*("[^"]+"|'[^']+'|[^\s]+)\s*(?=>)
    3、\s*(href|src)\s*=\s*("\s*(javascript|vbscript):[^"]+"|'\s*(javascript|vbscript):[^']+'|(javascript|vbscript):[^\s]+)\s*(?=>)
    4、epression\((.|\n)*\);?
    了解他們的規則后,抓蟲行動就水到渠成。

    <textarea id="bug" cols="80" rows="16"> 
    <button id="kick">抓蟲1</button> 
    <script> 
    function kickBug(str) { 
    return str.replace(/<(script|link|style|iframe)(.|\n)*\/\1>\s*/ig,""); 
    } 
    </script> 
    <iframe></iframe> 
    <link href='test.css'></link> 
    <style> 
    a { 
    height:expression(alert('hei')); 
    } 
    </style> 
    </textarea> 
    <button id="kick">抓蟲1</button> 
    <script> 
    function kickBug(str) { 
    return str.replace(/<(script|link|style|iframe)(.|\n)*\/\1>\s*/ig,""); 
    } 
    if(!/msie/i.test(navigator.userAgent)){ 
    HTMLElement.prototype.__defineGetter__("innerText",function(){ 
    return this.textContent; 
    }); 
    HTMLElement.prototype.__defineSetter__("innerText",function(text){ 
    this.textContent = text; 
    }); 
    } 
    document.getElementById("kick").onclick = function() { 
    var bug = document.getElementById("bug"); 
    bug.innerText = kickBug(bug.innerText); 
    } 
    </script>
    <textarea id="bug" cols="80" rows="5"> 
    <a onclick="test(); 
    test1()" onblur= 
    "test3()">test</a> 
    </textarea> 
    <button id="kick">抓蟲2</button> 
    <script> 
    function kickBug(str) { 
    return str.replace(/<[a-z][^>]*\s*on[a-z]+\s*=[^>]+/ig,function($0,$1){ 
    return $0.replace(/\s*on[a-z]+\s*=\s*("[^"]+"|'[^']+'|[^\s]+)\s*/ig,""); 
    }); 
    } 
    if(!/msie/i.test(navigator.userAgent)){ 
    HTMLElement.prototype.__defineGetter__("innerText",function(){ 
    return this.textContent; 
    }); 
    HTMLElement.prototype.__defineSetter__("innerText",function(text){ 
    this.textContent = text; 
    }); 
    } 
    document.getElementById("kick").onclick = function() { 
    var bug = document.getElementById("bug"); 
    bug.innerText = kickBug(bug.innerText); 
    } 
    </script>
    <textarea id="bug" cols="80" rows="5"> 
    <a onclick="test();" href=" 
    jAvascript:alert('a')" href="jAvascript:" 
    href="vbscript:alert()" 
    >test</a> 
    </textarea> 
    <button id="kick">抓蟲3</button> 
    <script> 
    function kickBug(str) { 
    return str.replace(/<[a-z][^>]*\s*(href|src)\s*=[^>]+/ig,function($0,$1){ 
    $0 = $0.replace(/&#(6[5-9]|[78][0-9]|9[0789]|1[01][0-9]|12[012]);?/g,function($0,$1){return String.fromCharCode($1);}); 
    return $0.replace(/\s*(href|src)\s*=\s*("\s*(javascript|vbscript):[^"]+"|'\s*(javascript|vbscript):[^']+'|(javascript|vbscript):[^\s]+)/ig,""); 
    }); 
    } 
    if(!/msie/i.test(navigator.userAgent)){ 
    HTMLElement.prototype.__defineGetter__("innerText",function(){ 
    return this.textContent; 
    }); 
    HTMLElement.prototype.__defineSetter__("innerText",function(text){ 
    this.textContent = text; 
    }); 
    } 
    document.getElementById("kick").onclick = function() { 
    var bug = document.getElementById("bug"); 
    bug.innerText = kickBug(bug.innerText); 
    } 
    </script>
    <textarea id="bug" cols="80" rows="5"> 
    expression() 
    <a style="color:expression( 
    'red' 
    )">test</a> 
    </textarea> 
    <button id="kick">抓蟲4</button> 
    <script> 
    function kickBug(str) { 
    return str.replace(/<[a-z][^>]*\s*style\s*=[^>]+/ig,function($0,$1){ 
    $0 = $0.replace(/&#(6[5-9]|[78][0-9]|9[0789]|1[01][0-9]|12[012]);?/g,function($0,$1){return String.fromCharCode($1);}); 
    return $0.replace(/\s*style\s*=\s*("[^"]+(expression)[^"]+"|'[^']+\2[^']+'|[^\s]+\2[^\s]+)\s*/ig,""); 
    }); 
    } 
    if(!/msie/i.test(navigator.userAgent)){ 
    HTMLElement.prototype.__defineGetter__("innerText",function(){ 
    return this.textContent; 
    }); 
    HTMLElement.prototype.__defineSetter__("innerText",function(text){ 
    this.textContent = text; 
    }); 
    } 
    document.getElementById("kick").onclick = function() { 
    var bug = document.getElementById("bug"); 
    bug.innerText = kickBug(bug.innerText); 
    } 
    </script>

    這樣調用就可以
    k1(k2(k3(k4(str))))

    這樣就是單純地過濾腳本而已,所謂過濾“危險腳本”應該是能夠判斷哪些屬于“危險"腳本,不危險的就不過濾才對……那可就難辦了,相當于防火墻了。

    聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

    文檔

    javascript過濾危險腳本方法_javascript技巧

    javascript過濾危險腳本方法_javascript技巧:腳本藏身之處不過有四: 1、<script>標簽、<link>標簽、<style>標簽、iframe標簽 2、on開頭的標簽屬性 3、javascript(vbscript)偽協議 4、css的epression下面是他們的字符串規則: 1、<(script|link|style
    推薦度:
    標簽: 過濾 方法 js
    • 熱門焦點

    最新推薦

    猜你喜歡

    熱門推薦

    專題
    Top
    主站蜘蛛池模板: 9re热国产这里只有精品| 国产午夜精品一区二区| 国产成人高清精品免费观看| 最新精品露脸国产在线| 国产精品福利一区二区| 亚洲精品国产高清不卡在线| 国产高清在线精品一区小说| 国产国拍亚洲精品mv在线观看| 亚洲高清国产拍精品青青草原 | 国产在线观看高清精品| 国产精品毛片无遮挡| 亚洲欧洲国产精品香蕉网| 国产一区二区精品久久凹凸 | 欧美精品区一级片免费播放| 亚洲精品在线观看视频| 97国产精品视频| 久久99国产精品尤物| 最新精品国偷自产在线| 久久se这里只有精品| 99精品视频在线观看婷| 久久se精品一区二区| 国产成人精品无码播放| 欧洲精品99毛片免费高清观看| 青青热久久国产久精品| 久久精品国产一区二区 | 久久精品国产一区二区三区日韩| 国产精品免费大片| 精品人人妻人人澡人人爽人人| 午夜不卡久久精品无码免费| 亚洲欧美日韩精品久久亚洲区| 亚洲精品456播放| 亚洲国产精品嫩草影院在线观看 | 国产精品欧美日韩| 国产精品亚洲A∨天堂不卡| 久久成人国产精品| 久久久精品国产sm调教网站| 精品无人码麻豆乱码1区2区| 国产精品久久久久jk制服| 国产a∨精品一区二区三区不卡| 国产精品免费高清在线观看| 国产国产精品人在线视|