note 51827 added to function.escapeshellcmd
| From: | docey at osu1 dot php dot net | Date: | Tue, 12 Apr 2005 12:56:09 +0000 |
| Subject: | note 51827 added to function.escapeshellcmd | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-87891@lists.php.net to get a copy of this message | ||
the main reason for quoting a command is that it not multiple command can be joined. i don't
know for sure if this is the right syntax but remeber that this can do some nice security breaks.
here's one way of how to know exactly what your trying to break into for.
normal any user on linux can view almost any directory so:
ls / -als will print a complete list of any file in the linux filesystem including its size,
security and hidden files as well.
now the output would only become known to php and never will the user be able to view this data
unless the php script would actual start to print it out. like passtru does!! but a good php coder
knows never to use passtru unless not otherwise possible.
but what would happen if you can direct the output from ls also from that same commandline to a file
in the webroot most webserver still default their base-webroot to /var/www/ so storing it there in
text file to download it later and you can simply take coffee while checking wich files can be read
by php security mode and then simply use the cp command to copy those to the webroot and download
them to your own hard-disk. without a list of the files you can only guess where to copy from! and
thats harder then guessing the root password.
so if the first command was quoted it is not possible to attach another command because of a syntax
error. think of all the thinks you can do once you got a complete list of every file on the
filesystem. including mounted once via NFS and others. security starts at keeping the door hidden.
also another nice command for hanging the webserver can be "php <?php while(true){
exec('ls / -als'); }; ?>" this keeps creating a file list on the entire filesystem
wich not only keeps the hard-disk(s) bussy but also memory and cpu wich must store the returned
list. so keeping in mind not all command accepted from users can be used blind.
actualy never accept any command from external sources only proven built-in predefined commands
should be executed.
----
Manual Page -- http://www.php.net/manual/en/function.escapeshellcmd.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51827
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51827&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51827&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51827&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51827&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51827&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51827&report=yes
Search -- http://master.php.net/manage/user-notes.php