婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 網站建設 > 建站知識 > DedeCMS 如何修補XSS跨站腳本攻擊

DedeCMS 如何修補XSS跨站腳本攻擊

POST TIME:2021-05-23 01:53

 XSS又叫CSS (Cross Site Script) ,跨站腳本攻擊。它指的是惡意攻擊者往Web頁面里插入惡意html代碼,當用戶瀏覽該頁之時,嵌入其中Web里面的html代碼會被執行,從而達到惡意攻擊用戶的特殊目的。XSS屬于被動式的攻擊,因為其被動且不好利用,所以許多人常忽略其危害性。而本文主要講的是利用XSS得到目標服務器的shell。技術雖然是老技術,但是其思路希望對大家有幫助。
 
  首先打開文件:/include/common.func.php
 
  在文件中加入函數:
 
Copy to ClipboardLiehuo.Net Codes引用的內容:[www.dede58.com]
function RemoveXSS($val) { 
$val = preg_replace('/([\x00-\x08,\x0b-\x0c,\x0e-\x19])/', '', $val); 
 
$search = 'abcdefghijklmnopqrstuvwxyz'; 
$search .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; 
$search .= '1234567890!@#$%^&*()'; 
$search .= '~`";:?+/={}[]-_|\&;\\'; 
for ($i = 0; $i < strlen($search); $i++) { 
$val = preg_replace('/(&#[xX]0{0,8}'.dechex(ord($search[$i])).';?)/i', $search[$i], $val); 
$val = preg_replace('/(&#0{0,8}'.ord($search[$i]).';?)/', $search[$i], $val); 
 
$ra1 = array('javascript', 'vbscript', 'expression', 'applet', 'meta', 'xml', 'blink', 'link', 'style', 'script', 'embed', 'object', 'iframe', 'frame', 'frameset', 'ilayer', 'layer', 'bgsound', 'title', 'base'); 
$ra2 = 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'); 
$ra = array_merge($ra1, $ra2); 
 
$found = true; 
while ($found == true) { 
$val_before = $val; 
for ($i = 0; $i < sizeof($ra); $i++) { 
$pattern = '/'; 
for ($j = 0; $j < strlen($ra[$i]); $j++) { 
if ($j > 0) { 
$pattern .= '('; 
$pattern .= '(&#[xX]0{0,8}([9ab]);)'; 
$pattern .= '|'; 
$pattern .= '|(&#0{0,8}([9|10|13]);)'; 
$pattern .= ')*'; 
$pattern .= $ra[$i][$j]; 
$pattern .= '/i'; 
$replacement = substr($ra[$i], 0, 2).'<x>'.substr($ra[$i], 2); 
$val = preg_replace($pattern, $replacement, $val); 
if ($val_before == $val) { 
$found = false; 
return $val; 
}
然后在過濾顯示的標簽中修改,例如:/templets/default/search.htm,將:
 
Copy to ClipboardLiehuo.Net Codes引用的內容:[www.dede58.com]
<p> 
搜索 <strong class="fc_03c">{dede:global name='keyword'/}</strong> 的結果 
</p>
修改為:
 
Copy to ClipboardLiehuo.Net Codes引用的內容:[www.dede58.com]
<p> 
搜索 <strong class="fc_03c">{dede:global name='keyword' function='RemoveXSS(@me)'/}</strong> 的結果 
</p>
這樣就可以了,當然其他地方顯示的地方也可以通過這個函數過濾掉。


收縮
  • 微信客服
  • 微信二維碼
  • 電話咨詢

  • 400-1100-266
主站蜘蛛池模板: 武乡县| 嫩江县| 塔城市| 卢氏县| 礼泉县| 织金县| 曲阜市| 拉孜县| 济阳县| 红安县| 漳浦县| 平果县| 淅川县| 民丰县| 章丘市| 弥勒县| 榆中县| 庆元县| 湘西| 赤壁市| 大城县| 湖北省| 临漳县| 宁化县| 茌平县| 高州市| 察雅县| 札达县| 普兰县| 宾阳县| 旌德县| 汉寿县| 宁蒗| 大化| 珲春市| 竹北市| 平罗县| 五华县| 凤台县| 喀喇沁旗| 徐水县|