b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

织梦CMS 登录页面的XSS 注入漏洞及处理

电脑杂谈  发布时间:2019-09-03 17:04:08  来源:网络整理

织梦cms模板免费_织梦cms百度分享插件_织梦cms留言板注入的

时间:2019-07-12

本文章向你们介绍织梦CMS 登录页面的XSS 注入漏洞及处理,主要包含织梦CMS 登录页面的XSS 注入漏洞及处理使用示例、应用方法、基本知识点总结和必须留意事项织梦cms留言板注入的,具有必定的参考价值织梦cms留言板注入的,需要的朋友可以参考一下。

一、客户检测报告:

事件URL:

织梦cms留言板注入的_织梦cms百度分享插件_织梦cms模板免费

%22%3E%3Cinput%20type=%22text%22%20onInput=alert(1)%3E%3Cx=%22

事件类型:

漏洞-KingCms门户系统存储型XSS

事件URL:

织梦cms模板免费_织梦cms百度分享插件_织梦cms留言板注入的

%22%3E%3Cinput%20type=%22text%22%20onInput=alert(1)%3E%3Cx=%22

二、XSS注入分析

检测方使用的登录方法(转码前):

"><input type="text" onInput=alert(1)><x="

织梦cms模板免费_织梦cms百度分享插件_织梦cms留言板注入的

原理是运用目标表单页面里面的一个input隐藏域:<input value="${gotopage}">实现注入。

三、处理方式 :

方法1:过滤js关键字

function xss_clea1($var)
{
    $ra=array('/([\x00-\x08,\x0b-\x0c,\x0e-\x19])/','/script/i','/javascript/i','/vbscript/i','/onload/i','/onunload/i','/onchange/i','/onsubmit/i','/onreset/i','/onselect/i','/onblur/i','/onfocus/i','/onabort/i','/onkeydown/i','/onkeypress/i','/onkeyup/i','/onclick/i','/ondblclick/i','/onmousedown/i','/onmousemove/i','/onmouseout/i','/onmouseover/i','/onmouseup/i','/onunload/i');
    $var = preg_replace($ra,'',$var);
   
    return htmlspecialchars($var,ENT_QUOTES);
}

织梦cms留言板注入的_织梦cms模板免费_织梦cms百度分享插件

方法2:转义特殊符号及html关键字

function xss_clean2($data){
 // Fix &entity\n;

 $data=str_replace(array('&','<','>'),array('&amp;','&lt;','&gt;'),$data);
 $data=preg_replace('/(&#*\w+)[\x00-\x20]+;/u','$1;',$data);
 $data=preg_replace('/(&#x*[0-9A-F]+);*/iu','$1;',$data);
 $data=html_entity_decode($data,ENT_COMPAT,'UTF-8');
 // Remove any attribute starting with "on" or xmlns

 $data=preg_replace('#(<[^>]+?[\x00-\x20"\'])(?:on|xmlns)[^>]*+>#iu','$1>',$data);
 // Remove javascript: and vbscript: protocols

 $data=preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([`\'"]*)[\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iu','$1=$2nojavascript...',$data);
 $data=preg_replace('#([a-z]*)[\x00-\x20]*=([\'"]*)[\x00-\x20]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iu','$1=$2novbscript...',$data);
 $data=preg_replace('#([a-z]*)[\x00-\x20]*=([\'"]*)[\x00-\x20]*-moz-binding[\x00-\x20]*:#u','$1=$2nomozbinding...',$data);
 // Only works in IE: <span style="width: expression(alert('Ping!'));"></span>

 $data=preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?expression[\x00-\x20]*\([^>]*+>#i','$1>',$data);
 $data=preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?behaviour[\x00-\x20]*\([^>]*+>#i','$1>',$data);
 $data=preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*+>#iu','$1>',$data);
 // Remove namespaced elements (we do not need them)

 $data=preg_replace('#</*\w+:\w[^>]*+>#i','',$data);
 do{// Remove really unwanted tags

 $old_data=$data;
 $data=preg_replace('#</*(?:applet|b(?:ase|gsound|link)|embed|frame(?:set)?|i(?:frame|layer)|l(?:ayer|ink)|meta|object|s(?:cript|tyle)|title|xml)[^>]*+>#i','',$data);
 }while($old_data!==$data);
 // we are done...
  return $data;
}

四、如何使用:

在接收页面,用这两个函数分别过滤所有的参数:

如:

$gotopage = xss_clean1($gotopage);

$gotopage= xss_clean2($gotopage);


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/ruanjian/article-121578-1.html

    相关阅读
      发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

      热点图片
      拼命载入中...