Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php open_basedir限制未按预期工作_Php_Windows_Penetration Testing_Open Basedir - Fatal编程技术网

Php open_basedir限制未按预期工作

Php open_basedir限制未按预期工作,php,windows,penetration-testing,open-basedir,Php,Windows,Penetration Testing,Open Basedir,我将在web服务器上执行笔测试作为考试中的任务之一,在利用不受限制的文件上载漏洞()后,我试图访问web服务器上的某个文件夹,我遇到以下错误: Warning: scandir(): open_basedir restriction in effect. File(C:\inetpub\sitesdata\mysite.com\SESSIONS\USERS) is not within the allowed path(s): (C:\inetpub\vhosts\mysite.com\subd

我将在web服务器上执行笔测试作为考试中的任务之一,在利用不受限制的文件上载漏洞()后,我试图访问web服务器上的某个文件夹,我遇到以下错误:

Warning: scandir(): open_basedir restriction in effect. File(C:\inetpub\sitesdata\mysite.com\SESSIONS\USERS) is not within the allowed path(s): (C:\inetpub\vhosts\mysite.com\subdomains\me\httpdocs;C:\inetpub\sitesdata\mysite.com\SESSIONS\USERS) in C:\inetpub\vhosts\mysite.com\subdomains\me\httpdocs\ticketAttachments\4b3519fbe17e82993e76927e5f253e33\hack.php
请注意,该路径实际上是在允许的路径中(我想这就是考试中这个任务的重点,窃取所有用户会话)

我无法访问服务器,因此无法更改服务器上的任何设置,我只需获取可能存储在
C:\inetpub\sitesdata\mysite.com\SESSIONS\USERS
文件夹中的所有sess文件

以下是我的hack.php文件的内容:

<pre style="text-align:left">
    <?php
        $files = scandir($_GET['path']);
        foreach ($files as $file) {
            echo $file;
            echo "\n";
        }
    ?>
</pre>

我已经尝试在允许的路径中访问另一个路径,结果是一样的。 但奇怪的是,我可以读取
C:\inetpub\vhosts\mysite.com\subdomains\me\httpdocs\ticketAttachments
,但不能读取
C:\inetpub\vhosts\mysite.com\subdomains\me\httpdocs
的内容,这实际上是在允许的路径中


我做错什么了吗?

这是个简单的打字错误

You want to access:         C:\inetpub\sitesdata\mysite.com\SESSIONS\USERS
The allowed path contains:  C:\inetpub\sitesdata\mysites.com\SESSIONS\USERS

注意丢失的“s”?

哦,对不起,我在这里输入问题时打错了,我会在问题中更正。@Nenapavicevic真的吗?它看起来像是复制粘贴的错误消息。如果你把它全部打印出来,我会感到惊讶。不,我只是更改了网站名称。很抱歉造成误解。@Nenapavicevic您能确认您已重新运行代码并复制并粘贴了错误消息,而不是手动更正它吗?不,我手动更正了它。这有关系吗?我第一次复制并粘贴了这条消息,我只是把网站名改成了mysite.com,以隐藏真实姓名。这是个问题吗?FWIW,类似于
函数($\u GET[“foo”])是高度不安全的,通常会完全否定任何可能的安全性。将该值取为变量,对其进行清理并传递清理后的值,然后再次开始讨论安全性。@Smar我完全同意,如果这是代码的一部分的话。但该文件是一个漏洞,并不意味着安全。我在那里植入它是为了恶意尝试访问该网站,它意味着不安全和可利用。我添加了Windows标记,因为这是针对Windows上的PHP的,并且在谈论PHP时Linux和Windows之间经常存在差异,如果basedir是其中之一,我不会感到惊讶。如果你觉得标签不应该在那里,请随意删除它。还有Windows的文件权限,这些权限也会影响到这一点吗?是说“作为一个Apache模块,父目录的open_basedir路径现在自动继承”。我猜您在Windows上安装了Apache,所以可能这就是为什么会将奇怪的路径添加到safedir中?也许其他地方也有覆盖配置?当然,谢谢更新。至于文件权限,是的,可能也是这样。但由于我没有访问服务器的权限,我无法知道。