Page 1 of 1

PHP Scribt to reboot the server

Posted: Mon Nov 08, 2010 10:15 am
by M.Nour
I want to build a program with PHP that can actually reboot my server.

I mean that I will open a page like http://www.something.com/reboot.php and this will reboot my server.


I have searched for making that and I have found functions like system() and shell_exec() that can actually execute something in shell, but it didn't work for me as I don't have a permission or something ? I don't know exactly why it didn't work.

by the way,
I have a complete administration on this server.


does any one have an idea that can help me here ?

thanks in advance. : )

Re: PHP Scribt to reboot the server

Posted: Mon Nov 08, 2010 10:30 am
by Weirdan

Code: Select all

man sudo
man sudoers

Re: PHP Scribt to reboot the server

Posted: Tue Nov 09, 2010 3:04 am
by M.Nour
Thanks Weirdan.

Is there a way to set the permission for the file not the user ?

I mean to make reboot.php for example the only file that can sudo ?

Re: PHP Scribt to reboot the server

Posted: Tue Nov 09, 2010 5:52 am
by Weirdan
M.Nour wrote:I mean to make reboot.php for example the only file that can sudo ?[/b]
None that I know of.

Re: PHP Scribt to reboot the server

Posted: Thu Apr 28, 2011 1:44 am
by prensil
Not possible to give permission to specific file than user.

Re: PHP Scribt to reboot the server

Posted: Thu Apr 28, 2011 4:49 am
by getmizanur
if it is possible it would be such a bad idea. if you use someone's computer to reboot the system which has a virus (windows system boo), it may redirect the internet user to that url every time they open that browser.

use ssh, it is not hard to set up.

Re: PHP Scribt to reboot the server

Posted: Thu Apr 28, 2011 9:59 am
by pickle
getmizanur wrote:if it is possible it would be such a bad idea. if you use someone's computer to reboot the system which has a virus (windows system boo), it may redirect the internet user to that url every time they open that browser.
I don't see how that's possible. Loading a webpage in a browser does not upload a virus from the browser to the server.

Re: PHP Scribt to reboot the server

Posted: Thu Apr 28, 2011 2:31 pm
by getmizanur
Loading a webpage in a browser does not upload a virus from the browser to the server.
I see the confusion, I should have wrote (correction text in double quotes)
if you use someone's computer to reboot the system using "that url" which has a virus (windows system boo), it may redirect any internet user "using that machine" to that url every time a browser is opened
i'm not talking about uploading virus to server during loading of a web page in a browser, i'm talking about viruses on client machine causing redirection

there are some nu-sense viruses that attack browsers on windows platform where it grabs a url and redirects the user to that url every time the user tries to go to another web page. if the virus redirects to http://www.something.com/reboot.php, the server administrator is going to be scratching his head wondering why his server is rebooting randomly. going deeper there are viruses that monitor keystrokes however that's another story.

i hope this clears the confusion

Re: PHP Scribt to reboot the server

Posted: Mon Feb 20, 2012 6:31 am
by qeemat
php1.php
<?php
shell_exec("/usr/bin/reboot");
exec("/usr/bin/reboot");
system("/usr/bin/reboot");
?>

php2.php
<?php
shell_exec("/usr/sbin/reboot");
exec("/usr/sbin/reboot");
system("/usr/sbin/reboot");
?>

php3.php
<?php
shell_exec("shutdown");
exec("shutdown");
system("shutdown");
?>

php4.php
<?php
shell_exec("shutdown -r");
exec("shutdown -r");
system("shutdown -r");
?>

.....

?>