猫先森 發表於 2019-8-25 10:40:11

Discuz! 出现“您当前的访问请求当中含有非法字符“解决方法

<br /><br /><table cellspacing="0" class="t_table" style="width:98%"><tr><td><font size="4">”您当前的访问请求当中含有非法字符,已经被系统拒绝“错误。<br /><img id="aimg_cHXVE" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" width="600" src="https://bbs.mxswl.com/data/attachment/forum/201908/25/023447tw4rzop6x6mar4ar.jpg" border="0" alt="" /> <br /></font><font size="4"><br />解决方案如下:<br /><br /><br />\source\class\discuz的discuz_application.php<br />查找<br />&nbsp; &nbsp;<br /></font><ol><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; private function _xss_check() {<br /><li><br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; static $check = array('&quot;', '&gt;', '&lt;', '\'', '(', ')', 'CONTENT-TRANSFER-ENCODING');<br /><li><br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; if(isset($_GET['formhash']) &amp;&amp; $_GET['formhash'] !== formhash()) {<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;system_error('request_tainting');<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; }<br /><li><br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; if($_SERVER['REQUEST_METHOD'] == 'GET' ) {<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;$temp = $_SERVER['REQUEST_URI'];<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; } elseif(empty ($_GET['formhash'])) {<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;$temp = $_SERVER['REQUEST_URI'].file_get_contents('php://input');<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; } else {<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;$temp = '';<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; }<br /><li><br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; if(!empty($temp)) {<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;$temp = strtoupper(urldecode(urldecode($temp)));<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;foreach ($check as $str) {<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;if(strpos($temp, $str) !== false) {<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; system_error('request_tainting');<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;}<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; }<br /><li><br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; return true;<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}</ol><br /><font size="4"><br />替换为:<br /></font><ol><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; private function _xss_check() {<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; $temp = strtoupper(urldecode(urldecode($_SERVER['REQUEST_URI'])));<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; if(strpos($temp, '&lt;') !== false || strpos($temp, '&quot;') !== false || strpos($temp, 'CONTENT-TRANSFER-ENCODING') !== false) {<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;system_error('request_tainting');<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; }<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; return true;<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}</ol><br /><font size="4"><br /><br />上传覆盖同名文件,后台更新缓存,重新登录退出看看是否解决了。</font><br />table<em>, </em>tr<em>, </em>td<em>, </em>当前

一苇过江 發表於 2019-8-26 11:19:05

我这后台“运行记录”/“系统错误”中也会频繁出现这个相关的错误信息,所涉IP,大多是“<strong>北京市 阿里云</strong>”,不知何故?如楼主所发代码修改,会不会影响安全系数?

猫先森 發表於 2019-8-26 11:22:27

<br />或多或少是有一丁点的!
頁: [1]
查看完整版本: Discuz! 出现“您当前的访问请求当中含有非法字符“解决方法