在通过火车头向DiscuzX论坛发布文章时,出现错误“您当前的访问请求当中含有非法字符,已经被系统拒绝”。
解决方法是禁用Discuz的全局安全检查,但会引发一些不安全的恶意攻击,因此在发布之后改回原样。
方案1
则可以修改DiscuzX的配置文件 config/config_global.php,禁用安全检查:
$_config['security']['urlxssdefend'] = '1';修改为:
$_config['security']['urlxssdefend'] = 0;方案2
打开:
\source\class\discuz的discuz_application.php查找
private function _xss_check() {static check = array('"', '>', '<', '\'', '(', ')', 'CONTENT-TRANSFER-ENCODING');
if(isset(_GET['formhash']) && _GET['formhash'] !== formhash()) {
system_error('request_tainting');
}if(_SERVER['REQUEST_METHOD'] == 'GET' ) {
temp =_SERVER['REQUEST_URI'];
} elseif(empty (_GET['formhash'])) {temp = _SERVER['REQUEST_URI'].file_get_contents('php://input');
} else {temp = '';
}if(!empty(temp)) {temp = strtoupper(urldecode(urldecode(temp)));
foreach (check as str) {
if(strpos(temp, $str) !== false) {
system_error('request_tainting');
}
}
}return true;
}修改为:
/**private function _xss_check() {
static check = array('"', '>', '<', '\'', '(', ')', 'CONTENT-TRANSFER-ENCODING');
if(isset(_GET['formhash']) && _GET['formhash'] !== formhash()) {
system_error('request_tainting');
}if(_SERVER['REQUEST_METHOD'] == 'GET' ) {
temp =_SERVER['REQUEST_URI'];
} elseif(empty (_GET['formhash'])) {temp = _SERVER['REQUEST_URI'].file_get_contents('php://input');
} else {temp = '';
}if(!empty(temp)) {temp = strtoupper(urldecode(urldecode(temp)));
foreach (check as str) {
if(strpos(temp, str) !== false) {
system_error('request_tainting');
}
}
}return true;
}
*/private function _xss_check() {temp = strtoupper(urldecode(urldecode(_SERVER['REQUEST_URI'])));
if(strpos(temp, '<') !== false || strpos(temp, '"') !== false || strpos(temp, 'CONTENT-TRANSFER-ENCODING') !== false) {
system_error('request_tainting');
}
return true;
}
同时进行以下操作:
1. 在DiscuzX管理后台禁用登录/发布的验证码功能
2. 在火车头的发布模块中将登录模式改为数据包模式,填写用户名和密码然后测试发布,应该没问题了。