bWAPP A7:Missing Functional Level Access Control 应用层访问控制缺失。

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/github_37216944/article/details/86207255

Directory Traversal - Directories在这里插入图片描述

function show_file($file)
{

    // Checks whether a file or directory exists
    // if(file_exists($file))
    if(is_file($file))
    {

        $fp = fopen($file, "r") or die("Couldn't open $file.");

        while(!feof($fp))
        {

            $line = fgets($fp,1024);
            echo($line);
            echo "<br />";

        }

    }

    else
    {

        echo "This file doesn't exist!";

    }

}

low

            case "0" :

                show_file($file);

                // Debugging
                // echo "<br />" . $_GET['page'];

                break;

未对输入的目录进行限制,可以访问任意目录。

http://localhost/bwapp/directory_traversal_2.php?directory=documents/../../../../

medium

       strpos($data, "../") !== false ||
       strpos($data, "..\\") !== false ||
       strpos($data, "/..") !== false ||
       strpos($data, "\..") !== false)

同目录遍历medium,只限制了目录遍历,仍可使用文件名访问当前目录任意文件。

http://localhost/bwapp/directory_traversal_2.php?directory=eval

high

    $real_base_path = realpath($base_path);

    // echo "base path: " . $base_path . " real base path: " . $real_base_path . "<br />";

    $real_user_path = realpath($user_path);

使用real user path进行比较。
这里需要比较我们要访问的目录是不是在我们的目录下。从逻辑上解决了目录遍历的问题。

Directory Traversal - Files

http://localhost/bwapp/directory_traversal_1.php?page=666

还可以结合目录遍历访问上层目录文件

http://localhost/bwapp/directory_traversal_1.php?page=../../manual.chm

Host Header Attack (Cache Poisoning)low
还可以结合目录遍历访问上层目录文件

http://localhost/bwapp/directory_traversal_1.php?page=../../manual.chm

在这里插入图片描述medium

同目录遍历medium,只限制了目录遍历,仍可使用文件名访问当前目录任意文件。
high

同目录遍历high,使用real user path进行比较。

猜你喜欢

转载自blog.csdn.net/github_37216944/article/details/86207255