黑帽联盟

 找回密码
 会员注册
查看: 2824|回复: 1

[建站文章] Discuz“您当前的访问请求当中含有非法字符“的解决方法

[复制链接]
yun 黑帽联盟官方人员 

920

主题

37

听众

1364

积分

超级版主

Rank: 8Rank: 8

  • TA的每日心情
    奋斗
    2019-10-18 11:20
  • 签到天数: 678 天

    [LV.9]以坛为家II

    故障描述:
    退出登录时出现”您当前的访问请求当中含有非法字符,已经被系统拒绝“错误。如下图:
    21.png


    解决方法:
    打开 \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() {
        $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;
    }

    52

    主题

    2

    听众

    310

    积分

    黑帽学员

    Rank: 3Rank: 3

  • TA的每日心情
    奋斗
    2019-9-27 16:27
  • 签到天数: 258 天

    [LV.8]以坛为家I

    这个应该不用把,系统自带的,安全些
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 会员注册

    发布主题 !fastreply! 收藏帖子 返回列表 搜索
    回顶部