【发布时间】:2014-04-15 20:56:23
【问题描述】:
我担心我遇到的重复错误可能是企图通过在 URL 行注入来入侵网站。
这里有一些直接来自服务器的 error_log 文件的示例。这些似乎总是成对出现:
[11-Apr-2014 23:21:26 America/Chicago] PHP 警告:include(content/?p=389.php) [function.include]:未能打开流:/ 中没有这样的文件或目录home/the_site/public_html/includes/htmlContent.php 在第 27 行
[2014 年 4 月 11 日 23:21:26 America/Chicago] PHP 警告:include() [function.include]:无法打开 'content/?p=389.php' 以包含 (include_path='.: /usr/lib/php') 在 /home/the_site/public_html/includes/htmlContent.php 第 27 行
[2014 年 4 月 14 日 15:44:57 America/Chicago] PHP 警告:include(content/?124.php) [function.include]:无法打开流:/home/ 中没有这样的文件或目录the_site/public_html/includes/htmlContent.php 在第 27 行
[2014 年 4 月 14 日 15:44:57 America/Chicago] PHP 警告:include() [function.include]:无法打开“content/?124.php”以包含(include_path='.:/usr /lib/php') 在 /home/the_site/public_html/includes/htmlContent.php 第 27 行
当然,我知道这意味着有人试图将变量“p”添加到 URL 以通过 GET 代理进行检索。问题是这个站点很少使用 GET 代理,而且从不使用变量“p”。
这些事件不会在一天中的固定时间或固定间隔发生。
这是我的最佳猜测。这是我从一位 Wordpress 管理员手中救出的网站,我会慷慨地称他为半胜任者。我假设这些是 Wordpress 服务的产物,并且可能是尝试从推荐人那里链接到该网站。我不确定这些引荐来源的价值,也不确定是否可以使用 php 的 $_SERVER['REQUEST_URI'] 来嗅探有关来源的任何信息。
无论如何,如果这些 URL 变量本质上可能是有害的,我想问问任何对此有经验的人。我在 Web 上找不到与此相关的信息(甚至在 stackoverflow.com 上也找不到!)感谢您帮助我让偏执的程序员放心。
如果您需要任何其他信息,请告诉我。
提前谢谢你。
更新:这是 Juhana 要求的代码,如下:
<?php
// include:
// htmlContent.php
// Concatenate file name for the content include(s).
$replacements = array( // Content file name swaps:
"" => "whypowerwash",
"index" => "whypowerwash",
"~hrmpower" => "whypowerwash",
"?author=1" => "about",
);
$thisFile = basename($_SERVER['REQUEST_URI'], '?' . $_SERVER['QUERY_STRING']);
$contentName = explode(".",$thisFile);
if(array_key_exists($contentName[0],$replacements)) {
$contentFile = $replacements[$contentName[0]];
}
else {
$contentFile = $contentName[0];
}
echo '<div id="content">';
include('content/'.$contentFile.'.php');
echo' </div> <!-- closes content div -->';
?>
简单地说,它可以帮助我将主页与保存在“内容”文件夹中的 html 内容链接起来。我这样做是一种临时措施:稍后它将从 MySQL 数据库中提供数据。
“$_SERVER['REQUEST_URI']”将文件链接到内容文件夹中的同名文件,等待对所需替换的评估(请参阅数组 $replacements)。
有问题的行是:
include('content/'.$contentFile.'.php');
希望这会有所帮助。如果我需要解释其他任何内容,请告诉我。
【问题讨论】:
-
文件
/home/the_site/public_html/includes/htmlContent.php的第27行是什么? -
Juhana,我更新了原始帖子并进行了编辑。感谢您。 - 降落伞
标签: wordpress url line code-injection error-log