加固-01/02: CWD 无关 include 改造 + UEditor 全入口鉴权 (P0-01)
A. 相对路径 include/require 全量改写为 __DIR__ 基址
- 修复 nginx+fastcgi 下 php-cgi 继承启动目录 CWD (D:\phpstudy_pro\COM)
导致 require '../function/...' 相对路径 include 全部失效;
28 文件 101 处统一改为 __DIR__ 绝对基址,任意 Web 服务器行为一致。
- 补齐带括号/缺斜杠漏改的 13 处 (controller.php、epay lib、
payment.php、notify_url.php、return_url.php)。
- function/config.inc.php 增加 config.local.inc.php 本地覆盖机制
(该文件加入 .gitignore 不入库),仓库默认配置保持中立。
B. UEditor 后台入口安全加固 (P0-01)
- admin/php/controller.php 全部 action 前置管理员会话校验
(admin_username + admin_password),匿名无法上传/抓取/列目录/读配置。
- 禁用远程图片抓取 catchimage (SSRF 向量),删除 action_crawler.php。
- 上传/列表白名单剔除 .exe/.dll/.iso/.cab/.swf。
- Uploader: 移除 iconv('unicode') Windows 告警行;
getFileInfo/action_list 的 URL 拼接增加 REQUEST_SCHEME 回退。
验证: 匿名访问全部 action 返回未授权;登录态上传成功且 URL 正确;
catchimage 已禁用;JSON 合法;全量 php -l 0 错误;
nginx(8081) 与内置服务器(8082) 双通道回归通过。
This commit is contained in:
@@ -44,8 +44,8 @@ function makejson($code = 1,$msg = 'ok',$data = array()){
|
||||
*/
|
||||
|
||||
$G = array();
|
||||
include 'db.class.php';
|
||||
include 'config.inc.php';
|
||||
include __DIR__ . '/db.class.php';
|
||||
include __DIR__ . '/config.inc.php';
|
||||
$return = $db = new db($G['db']['server'], $G['db']['user'], $G['db']['pass'], $G['db']['dbname']);
|
||||
if (!$return) {
|
||||
die('数据库链接失败,请检查设置是否正确:' . $db->geterror());
|
||||
@@ -60,7 +60,7 @@ $back = $db->select_all_row('sq_config', array('*'), '', '');
|
||||
foreach ($back as $value) {
|
||||
$G['config'][$value['setname']] = $value['setvalue'];
|
||||
}
|
||||
include 'setname.inc.php';
|
||||
include __DIR__ . '/setname.inc.php';
|
||||
foreach ($SetName as $key=>$value){
|
||||
if (!isset($G['config'][$key])){
|
||||
$db->insert_back_id('sq_config',array('setname'=>$key,'setvalue'=>$value));
|
||||
@@ -114,8 +114,8 @@ if ($auth['code'] == '1'){
|
||||
*/
|
||||
|
||||
$ServerURL = 'https://new.api.shouquan.wenquan6.cn:99/api.php';
|
||||
include 'ver.inc.php';
|
||||
include_once 'MailTipsTemplate.php';
|
||||
include __DIR__ . '/ver.inc.php';
|
||||
include_once __DIR__ . '/MailTipsTemplate.php';
|
||||
/*
|
||||
* 注册申明常用函数
|
||||
*/
|
||||
@@ -351,9 +351,9 @@ function curl_request($url, $post = '', $cookie = '', $returnCookie = 0)
|
||||
function sendemail($title, $contant, $tomail, &$msg = '', $debug = false)
|
||||
{
|
||||
global $G,$ServerURL;
|
||||
require_once ('PHPMailer.php');
|
||||
require_once ('SMTP.php');
|
||||
require_once ('Exception.php');
|
||||
require_once (__DIR__ . '/PHPMailer.php');
|
||||
require_once (__DIR__ . '/SMTP.php');
|
||||
require_once (__DIR__ . '/Exception.php');
|
||||
$mail = new \PHPMailer\PHPMailer\PHPMailer();
|
||||
$mail->SMTPDebug = $debug;
|
||||
$mail->isSMTP();
|
||||
|
||||
Reference in New Issue
Block a user