無料スクリプト配布のPHP.TO   PHPの実用的なtips PHPマニュアル MySQLマニュアル Apacheマニュアル PostgreSQLマニュアル マニュアル検索    

????

?

PHP ????????? ??????????? ?????????????? ???????????? ?????????? ???

PHP?????? ????PHP??/etc/password ?? ?????????? ???????????? ????????????

?????????? ??????Web??? ?????Apache ??????????

1 ???

<?php
// ???????
$username $_POST['user_submitted_name'];
$userfile $_POST['user_submitted_filename'];
$homedir  "/home/$username";

unlink("$homedir/$userfile");

echo 
"???!";
?>
username filename ????????? username filename ? ??????????? ???????????? "../etc/" "passwd " ??????? ?????

2 ... ????

<?php
// ?PHP????????PHP
// ?????
$username $_POST['user_submitted_name']; // "../etc"
$userfile $_POST['user_submitted_filename']; // "passwd"
$homedir  "/home/$username"// "/home/../etc"

unlink("$homedir/$userfile"); // "/home/../etc/passwd"

echo "???!";
?>
????????????2 ? ????????

3 ????

<?php
// PHP?????????
$username $_SERVER['REMOTE_USER']; // ???
$userfile basename($_POST['user_submitted_filename']);
$homedir  "/home/$username";

$filepath "$homedir/$userfile";

if (
file_exists($filepath) && unlink($filepath)) {
    
$logstring "$filepath ?\n";
} else {
    
$logstring "$filepath ???\n";
}
$fp fopen("/home/logging/filedelete.log""a");
fwrite($fp$logstring);
fclose($fp);

echo 
htmlentities($logstringENT_QUOTES);

?>
???????? ?????????? ??"../etc/"???? ?????????? ????

4 ????

<?php
$username     
$_SERVER['REMOTE_USER']; // ???
$userfile     $_POST['user_submitted_filename'];
$homedir      "/home/$username";

$filepath     "$homedir/$userfile";

if (!
ctype_alnum($username) || !preg_match('/^(?:[a-z0-9_-]|\.(?!\.))+$/iD'$userfile)) {
    die(
"Bad username/filename");
}

//etc...
?>

??????????? ?????(/dev/ ? COM1)? (/etc/ ?? .ini ?)??? (/home/ My Documents)????? ?????????



powered by SEO.CUG.NET