Ejemplo n.º 1
0
<?php

require_once "open_basedir.inc";
test_open_basedir_before("parse_ini_file");
$directory = dirname(__FILE__);
var_dump(parse_ini_file("../bad"));
var_dump(parse_ini_file("../bad/bad.txt"));
var_dump(parse_ini_file(".."));
var_dump(parse_ini_file("../"));
var_dump(parse_ini_file("../bad/."));
var_dump(parse_ini_file("../bad/./bad.txt"));
var_dump(parse_ini_file("./../."));
test_open_basedir_after("parse_ini_file");
require_once "open_basedir.inc";
delete_directories();
Ejemplo n.º 2
0
<?php

require_once "open_basedir.inc";
$initdir = getcwd();
test_open_basedir_before("symlink");
$target = $initdir . "/test/ok/ok.txt";
var_dump(symlink($target, "../bad/symlink.txt"));
var_dump(symlink($target, "../symlink.txt"));
var_dump(symlink($target, "../bad/./symlink.txt"));
var_dump(symlink($target, "./.././symlink.txt"));
$symlink = $initdir . "/test/ok/symlink.txt";
var_dump(symlink("../bad/bad.txt", $symlink));
var_dump(symlink("../bad", $symlink));
var_dump(symlink("../bad/./bad.txt", $symlink));
var_dump(symlink("../bad/bad.txt", $symlink));
var_dump(symlink("./.././bad", $symlink));
$target = $initdir . "/test/ok/ok.txt";
var_dump(symlink($target, $symlink));
var_dump(unlink($symlink));
var_dump(mkdir("ok2"));
$symlink = $initdir . "/test/ok/ok2/ok.txt";
var_dump(symlink("../ok.txt", $symlink));
// $target == (dirname($symlink)."/".$target) == ($initdir."/test/ok/ok.txt");
var_dump(unlink($symlink));
test_open_basedir_after("symlink");
require_once "open_basedir.inc";
delete_directories();
<?php

require_once "open_basedir.inc";
$initdir = getcwd();
test_open_basedir_before("file");
test_open_basedir_error("file");
var_dump(file("ok.txt"));
var_dump(file("../ok/ok.txt"));
var_dump(file($initdir . "/test/ok/ok.txt"));
var_dump(file($initdir . "/test/ok/../ok/ok.txt"));
test_open_basedir_after("file");
Ejemplo n.º 4
0
<?php

require_once "open_basedir.inc";
$initdir = getcwd();
test_open_basedir_before("tempnam");
var_dump(tempnam("../bad", "test"));
var_dump(tempnam("..", "test"));
var_dump(tempnam("../", "test"));
var_dump(tempnam("/", "test"));
var_dump(tempnam("../bad/.", "test"));
var_dump(tempnam("./../.", "test"));
var_dump(tempnam("", "test"));
//absolute test
$file = tempnam($initdir . "/test/ok", "test");
var_dump($file);
var_dump(unlink($file));
//relative test
$file = tempnam(".", "test");
var_dump($file);
var_dump(unlink($file));
$file = tempnam("../ok", "test");
var_dump($file);
var_dump(unlink($file));
test_open_basedir_after("tempnam");
error_reporting(0);
require_once "open_basedir.inc";
delete_directories();
Ejemplo n.º 5
0
<?php

require_once "open_basedir.inc";
$initdir = getcwd();
test_open_basedir_before("error_log");
var_dump(ini_set("error_log", $initdir . "/test/bad/bad.txt"));
var_dump(ini_set("error_log", $initdir . "/test/bad.txt"));
var_dump(ini_set("error_log", $initdir . "/bad.txt"));
var_dump(ini_set("error_log", $initdir . "/test/ok/ok.txt"));
var_dump(ini_set("error_log", $initdir . "/test/ok/ok.txt"));
test_open_basedir_after("error_log");
error_reporting(0);
require_once "open_basedir.inc";
delete_directories();
<?php

chdir(__DIR__);
ini_set("open_basedir", ".");
require_once "open_basedir.inc";
$initdir = getcwd();
test_open_basedir_before("readlink", FALSE);
chdir($initdir);
$target = $initdir . "/test/bad/bad.txt";
$symlink = $initdir . "/test/ok/symlink.txt";
var_dump(symlink($target, $symlink));
chdir($initdir . "/test/ok");
var_dump(readlink("symlink.txt"));
var_dump(readlink("../ok/symlink.txt"));
var_dump(readlink("../ok/./symlink.txt"));
var_dump(readlink("./symlink.txt"));
var_dump(readlink($initdir . "/test/ok/symlink.txt"));
$target = $initdir . "/test/ok/ok.txt";
$symlink = $initdir . "/test/ok/symlink.txt";
var_dump(symlink($target, $symlink));
var_dump(readlink($symlink));
test_open_basedir_after("readlink");
Ejemplo n.º 7
0
<?php

require_once "open_basedir.inc";
test_open_basedir_before("chdir");
var_dump(chdir("../bad"));
var_dump(chdir(".."));
var_dump(chdir("../"));
var_dump(chdir("/"));
var_dump(chdir("../bad/."));
var_dump(chdir("./../."));
test_open_basedir_after("chdir");
require_once "open_basedir.inc";
delete_directories();
Ejemplo n.º 8
0
<?php

require_once "open_basedir.inc";
$initdir = getcwd();
test_open_basedir_before("unlink");
var_dump(unlink("../bad/bad.txt"));
var_dump(unlink(".././bad/bad.txt"));
var_dump(unlink("../bad/../bad/bad.txt"));
var_dump(unlink("./.././bad/bad.txt"));
var_dump(unlink($initdir . "/test/bad/bad.txt"));
test_open_basedir_after("unlink");
error_reporting(0);
require_once "open_basedir.inc";
delete_directories();
<?php

require_once "open_basedir.inc";
$initdir = getcwd();
test_open_basedir_before("is_executable");
test_open_basedir_error("is_executable");
var_dump(is_executable("ok.txt"));
var_dump(is_executable("../ok/ok.txt"));
var_dump(is_executable($initdir . "/test/ok/ok.txt"));
var_dump(is_executable($initdir . "/test/ok/../ok/ok.txt"));
test_open_basedir_after("is_executable");
Ejemplo n.º 10
0
<?php

require_once "open_basedir.inc";
$initdir = getcwd();
test_open_basedir_before("fopen");
var_dump(fopen("../bad", "r"));
var_dump(fopen("../bad/bad.txt", "r"));
var_dump(fopen("..", "r"));
var_dump(fopen("../", "r"));
var_dump(fopen("/", "r"));
var_dump(fopen("../bad/.", "r"));
var_dump(fopen("../bad/./bad.txt", "r"));
var_dump(fopen("./../.", "r"));
var_dump(fopen($initdir . "/test/ok/ok.txt", "r"));
var_dump(fopen("./ok.txt", "r"));
var_dump(fopen("ok.txt", "r"));
var_dump(fopen("../ok/ok.txt", "r"));
var_dump(fopen("../ok/./ok.txt", "r"));
test_open_basedir_after("fopen");
error_reporting(0);
require_once "open_basedir.inc";
delete_directories();
Ejemplo n.º 11
0
<?php

require_once "open_basedir.inc";
test_open_basedir_before("copy");
var_dump(copy("ok.txt", "../bad"));
var_dump(copy("ok.txt", "../bad/bad.txt"));
var_dump(copy("ok.txt", ".."));
var_dump(copy("ok.txt", "../"));
var_dump(copy("ok.txt", "/"));
var_dump(copy("ok.txt", "../bad/."));
var_dump(copy("ok.txt", "../bad/./bad.txt"));
var_dump(copy("ok.txt", "./../."));
var_dump(copy("ok.txt", "copy.txt"));
var_dump(unlink("copy.txt"));
test_open_basedir_after("copy");
error_reporting(0);
require_once "open_basedir.inc";
delete_directories();
Ejemplo n.º 12
0
<?php

chdir(__DIR__);
ini_set("open_basedir", ".");
require_once "open_basedir.inc";
$initdir = getcwd();
test_open_basedir_before("linkinfo", FALSE);
chdir($initdir);
$target = $initdir . "/test/bad/bad.txt";
$symlink = $initdir . "/test/ok/symlink.txt";
var_dump(symlink($target, $symlink));
chdir($initdir . "/test/ok");
var_dump(linkinfo("symlink.txt"));
var_dump(linkinfo("../ok/symlink.txt"));
var_dump(linkinfo("../ok/./symlink.txt"));
var_dump(linkinfo("./symlink.txt"));
var_dump(linkinfo($initdir . "/test/ok/symlink.txt"));
$target = $initdir . "/test/ok/ok.txt";
$symlink = $initdir . "/test/ok/symlink.txt";
var_dump(symlink($target, $symlink));
var_dump(linkinfo($symlink));
var_dump(unlink($symlink));
test_open_basedir_after("linkinfo");
error_reporting(0);
chdir(__DIR__);
require_once "open_basedir.inc";
delete_directories();
<?php

require_once "open_basedir.inc";
$initdir = getcwd();
test_open_basedir_before("mkdir");
var_dump(mkdir("../bad/blah"));
var_dump(mkdir("../blah"));
var_dump(mkdir("../bad/./blah"));
var_dump(mkdir("./.././blah"));
var_dump(mkdir($initdir . "/test/ok/blah"));
var_dump(rmdir($initdir . "/test/ok/blah"));
test_open_basedir_after("mkdir");
Ejemplo n.º 14
0
<?php

require_once "open_basedir.inc";
$initdir = getcwd();
test_open_basedir_before("chmod");
var_dump(chmod("../bad", 0600));
var_dump(chmod("../bad/bad.txt", 0600));
var_dump(chmod("..", 0600));
var_dump(chmod("../", 0600));
var_dump(chmod("/", 0600));
var_dump(chmod("../bad/.", 0600));
var_dump(chmod("../bad/./bad.txt", 0600));
var_dump(chmod("./../.", 0600));
var_dump(chmod($initdir . "/test/ok/ok.txt", 0600));
var_dump(chmod("./ok.txt", 0600));
var_dump(chmod("ok.txt", 0600));
var_dump(chmod("../ok/ok.txt", 0600));
var_dump(chmod("../ok/./ok.txt", 0600));
chmod($initdir . "/test/ok/ok.txt", 0777);
test_open_basedir_after("chmod");
error_reporting(0);
require_once "open_basedir.inc";
delete_directories();
<?php

require_once "open_basedir.inc";
$initdir = getcwd();
test_open_basedir_before("scandir");
test_open_basedir_error("scandir");
var_dump(scandir($initdir . "/test/ok/"));
var_dump(scandir($initdir . "/test/ok"));
var_dump(scandir($initdir . "/test/ok/../ok"));
test_open_basedir_after("scandir");
<?php

require_once "open_basedir.inc";
$initdir = getcwd();
test_open_basedir_before("disk_free_space");
test_open_basedir_error("disk_free_space");
var_dump(disk_free_space($initdir . "/test/ok"));
test_open_basedir_after("disk_free_space");
Ejemplo n.º 17
0
<?php

require_once "open_basedir.inc";
$initdir = getcwd();
test_open_basedir_before("opendir");
test_open_basedir_error("opendir");
var_dump(opendir($initdir . "/test/ok/"));
var_dump(opendir($initdir . "/test/ok"));
var_dump(opendir($initdir . "/test/ok/../ok"));
test_open_basedir_after("opendir");
require_once "open_basedir.inc";
delete_directories();
<?php

require_once "open_basedir.inc";
$initdir = getcwd();
test_open_basedir_before("file_put_contents");
var_dump(file_put_contents("../bad/bad.txt", "Hello World!"));
var_dump(file_put_contents(".././bad/bad.txt", "Hello World!"));
var_dump(file_put_contents("../bad/../bad/bad.txt", "Hello World!"));
var_dump(file_put_contents("./.././bad/bad.txt", "Hello World!"));
var_dump(file_put_contents($initdir . "/test/bad/bad.txt", "Hello World!"));
test_open_basedir_after("file_put_contents");
Ejemplo n.º 19
0
<?php

require_once "open_basedir.inc";
$initdir = getcwd();
test_open_basedir_before("touch");
var_dump(touch("../bad"));
var_dump(touch("../bad/bad.txt"));
var_dump(touch(".."));
var_dump(touch("../"));
var_dump(touch("/"));
var_dump(touch("../bad/."));
var_dump(touch("../bad/./bad.txt"));
var_dump(touch("./../."));
var_dump(touch($initdir . "/test/ok/ok.txt"));
var_dump(touch("./ok.txt"));
var_dump(touch("ok.txt"));
var_dump(touch("../ok/ok.txt"));
var_dump(touch("../ok/./ok.txt"));
test_open_basedir_after("touch");
error_reporting(0);
require_once "open_basedir.inc";
delete_directories();
Ejemplo n.º 20
0
<?php

require_once "open_basedir.inc";
$initdir = getcwd();
test_open_basedir_before("rename");
var_dump(rename("../bad/bad.txt", "rename.txt"));
var_dump(rename(".././bad/bad.txt", "rename.txt"));
var_dump(rename("../bad/../bad/bad.txt", "rename.txt"));
var_dump(rename("./.././bad/bad.txt", "rename.txt"));
var_dump(rename($initdir . "/test/bad/bad.txt", "rename.txt"));
test_open_basedir_after("rename");
error_reporting(0);
require_once "open_basedir.inc";
delete_directories();
Ejemplo n.º 21
0
<?php

require_once "open_basedir.inc";
$initdir = getcwd();
test_open_basedir_before("rmdir");
var_dump(rmdir("../bad"));
var_dump(rmdir(".././bad"));
var_dump(rmdir("../bad/../bad"));
var_dump(rmdir("./.././bad"));
var_dump(rmdir($initdir . "/test/bad"));
test_open_basedir_after("rmdir");
error_reporting(0);
require_once "open_basedir.inc";
delete_directories();