PHP Scribt to reboot the server
Moderator: General Moderators
PHP Scribt to reboot the server
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. : )
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
Code: Select all
man sudo
man sudoers
Re: PHP Scribt to reboot the server
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 ?
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
None that I know of.M.Nour wrote:I mean to make reboot.php for example the only file that can sudo ?[/b]
Re: PHP Scribt to reboot the server
Not possible to give permission to specific file than user.
- getmizanur
- Forum Commoner
- Posts: 71
- Joined: Sun Sep 06, 2009 12:28 pm
Re: PHP Scribt to reboot the server
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.
use ssh, it is not hard to set up.
Re: PHP Scribt to reboot the server
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.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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
- getmizanur
- Forum Commoner
- Posts: 71
- Joined: Sun Sep 06, 2009 12:28 pm
Re: PHP Scribt to reboot the server
I see the confusion, I should have wrote (correction text in double quotes)Loading a webpage in a browser does not upload a virus from the browser to the server.
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 redirectionif 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
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
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");
?>
.....
?>
<?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");
?>
.....
?>