每日签到奶昔超市积分商城奶昔访达
返回列表 发布新帖
查看: 1106|回复: 2

[教程] Discuz系统错误,含有非法字符登录503

发表于 2024-9-9 22:08:38 | 查看全部 |阅读模式

登录后免广告,享受更多奶昔会员权益!

您需要 登录 才可以下载或查看,没有账号?注册

×
刚刚群友 @Godtokoo 反馈了无法登录的问题,一开始以为是CDN缓存导致。
结果发现是触发了discuz的xss注入检测机制xss_check和系统错误机制system_error,附上我的解决方式
首先打开 \source\class\discuz的discuz_application.php 查找
  1. private function _xss_check() {

  2.                 static $check = array('"', '>', '<', '\'', '(', ')', 'CONTENT-TRANSFER-ENCODING');

  3.                 if(isset($_GET['formhash']) && $_GET['formhash'] !== formhash()) {
  4.                         system_error('request_tainting');
  5.                 }

  6.                 if($_SERVER['REQUEST_METHOD'] == 'GET' ) {
  7.                         $temp = $_SERVER['REQUEST_URI'];
  8.                 } elseif(empty ($_GET['formhash'])) {
  9.                         $temp = $_SERVER['REQUEST_URI'].file_get_contents('php://input');
  10.                 } else {
  11.                         $temp = '';
  12.                 }

  13.                 if(!empty($temp)) {
  14.                         $temp = strtoupper(urldecode(urldecode($temp)));
  15.                         foreach ($check as $str) {
  16.                                 if(strpos($temp, $str) !== false) {
  17.                                         system_error('request_tainting');
  18.                                 }
  19.                         }
  20.                 }

  21.                 return true;
  22.         }
复制代码
替换为
  1. private function _xss_check() {
  2.                 $temp = strtoupper(urldecode(urldecode($_SERVER['REQUEST_URI'])));
  3.                 if(strpos($temp, '<') !== false || strpos($temp, '"') !== false || strpos($temp, 'CONTENT-TRANSFER-ENCODING') !== false) {
  4.                         system_error('request_tainting');
  5.                 }
  6.                 return true;
  7.         }
复制代码
然后后台清除缓存就解决了。
爱生活,爱奶昔~
回复

使用道具 举报

发表于 2024-10-30 02:21:13 | 查看全部
新版的文件是这样的
  1.         private function _xss_check() {

  2.                 static $check = array('"', '>', '<', '\'', '(', ')', 'CONTENT-TRANSFER-ENCODING');

  3.                 if(isset($_GET['formhash']) && $_GET['formhash'] !== formhash()) {
  4.                         if(defined('CURMODULE') && constant('CURMODULE') == 'logging' && isset($_GET['action']) && $_GET['action'] == 'logout') {
  5.                                 header("HTTP/1.1 302 Found");
  6.                                 header("Location: index.php");
  7.                                 exit();
  8.                         } else {
  9.                                 system_error('request_tainting');
  10.                         }
  11.                 }

  12.                 if($_SERVER['REQUEST_METHOD'] == 'GET' ) {
  13.                         $temp = $_SERVER['REQUEST_URI'];
  14.                 } elseif(empty ($_GET['formhash'])) {
  15.                         $temp = $_SERVER['REQUEST_URI'].http_build_query($_POST);
  16.                 } else {
  17.                         $temp = '';
  18.                 }

  19.                 if(!empty($temp)) {
  20.                         $temp = strtoupper(urldecode(urldecode($temp)));
  21.                         foreach ($check as $str) {
  22.                                 if(strpos($temp, $str) !== false) {
  23.                                         system_error('request_tainting');
  24.                                 }
  25.                         }
  26.                 }

  27.                 return true;
  28.         }
复制代码


也可以直接替换上面的吗
爱生活,爱奶昔~
发表于 2024-10-30 02:59:33 | 查看全部
你好,想咨询一下现在奶昔用的是那套模板哈,很喜欢这种简洁风格! @Nyarime
爱生活,爱奶昔~
您需要登录后才可以回帖 登录 | 注册

本版积分规则

© 2026 Naixi Networks. 沪ICP备13020230号-1|沪公网安备 31010702007642号手机版小黑屋RSS
返回顶部 关灯 在本版发帖
快速回复 返回顶部 返回列表