• php xss 函数


    function xss($string) {
        if (is_array($string)||is_object($string)||is_resource($string)) {
            return '';
        }else {
            $string = preg_replace('/[x00-x08x0Bx0Cx0E-x1Fx7F]+/S', '', $string);
        
            $parm1 = Array('javascript', 'vbscript', 'expression', 'applet', 'meta', 'xml', 'blink', 'link', 'script', 'embed', 'object', 'iframe', 'frame', 'frameset', 'ilayer', 'layer', 'bgsound', 'title', 'base');
        
            $parm2 = Array('onabort', 'onactivate', 'onafterprint', 'onafterupdate', 'onbeforeactivate', 'onbeforecopy', 'onbeforecut', 'onbeforedeactivate', 'onbeforeeditfocus', 'onbeforepaste', 'onbeforeprint', 'onbeforeunload', 'onbeforeupdate', 'onblur', 'onbounce', 'oncellchange', 'onchange', 'onclick', 'oncontextmenu', 'oncontrolselect', 'oncopy', 'oncut', 'ondataavailable', 'ondatasetchanged', 'ondatasetcomplete', 'ondblclick', 'ondeactivate', 'ondrag', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'onerror', 'onerrorupdate', 'onfilterchange', 'onfinish', 'onfocus', 'onfocusin', 'onfocusout', 'onhelp', 'onkeydown', 'onkeypress', 'onkeyup', 'onlayoutcomplete', 'onload', 'onlosecapture', 'onmousedown', 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onmousewheel', 'onmove', 'onmoveend', 'onmovestart', 'onpaste', 'onpropertychange', 'onreadystatechange', 'onreset', 'onresize', 'onresizeend', 'onresizestart', 'onrowenter', 'onrowexit', 'onrowsdelete', 'onrowsinserted', 'onscroll', 'onselect', 'onselectionchange', 'onselectstart', 'onstart', 'onstop', 'onsubmit', 'onunload');
        
            $parm = array_merge($parm1, $parm2); 
        
            for ($i = 0; $i < sizeof($parm); $i++) { 
                $pattern = '/';
                //var_dump($parm[$i]); 
                for ($j = 0; $j < strlen($parm[$i]); $j++) { 
                    if ($j > 0) { 
                        $pattern .= '('; 
                        $pattern .= '(&#[x|X]0([9][a][b]);?)?'; 
                        $pattern .= '|(&#0([9][10][13]);?)?'; 
                        $pattern .= ')?'; 
                    }
                    $pattern .= $parm[$i][$j];
                    var_dump($pattern); 
                }
                $pattern .= '/i';
                //var_dump($pattern);
                $string = preg_replace($pattern, '', $string); 
            }
            return $string;
        }       
    }
  • 相关阅读:
    this关键字
    方法重载和方法重写
    构造方法
    Java数据类型以及变量的定义
    Java 语言概述
    Java Socket通信
    类图
    JAVA语言编程注意事项
    Scanner--控制台输入
    java运算符
  • 原文地址:https://www.cnblogs.com/pengcz/p/6529324.html
Copyright © 2020-2023  润新知