PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Tue Nov 13, 2018 4:20 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Mon Nov 08, 2010 11:15 am 
Offline
Forum Newbie

Joined: Mon Nov 08, 2010 11:00 am
Posts: 2
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. : )


Top
 Profile  
 
PostPosted: Mon Nov 08, 2010 11:30 am 
Offline
Moderator
User avatar

Joined: Mon Nov 03, 2003 7:13 pm
Posts: 5978
Location: Odessa, Ukraine
Syntax: [ Download ] [ Hide ]
man sudo
man sudoers
 


Top
 Profile  
 
PostPosted: Tue Nov 09, 2010 4:04 am 
Offline
Forum Newbie

Joined: Mon Nov 08, 2010 11:00 am
Posts: 2
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 ?


Top
 Profile  
 
PostPosted: Tue Nov 09, 2010 6:52 am 
Offline
Moderator
User avatar

Joined: Mon Nov 03, 2003 7:13 pm
Posts: 5978
Location: Odessa, Ukraine
M.Nour wrote:
I mean to make reboot.php for example the only file that can sudo ?[/b]

None that I know of.


Top
 Profile  
 
PostPosted: Thu Apr 28, 2011 1:44 am 
Offline
Forum Newbie

Joined: Tue Apr 26, 2011 8:38 am
Posts: 15
Location: Ahmedabad
Not possible to give permission to specific file than user.


Top
 Profile  
 
PostPosted: Thu Apr 28, 2011 4:49 am 
Offline
Forum Commoner
User avatar

Joined: Sun Sep 06, 2009 12:28 pm
Posts: 71
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.


Top
 Profile  
 
PostPosted: Thu Apr 28, 2011 9:59 am 
Offline
Briney Mod
User avatar

Joined: Mon Jan 19, 2004 7:11 pm
Posts: 6445
Location: 53.01N x 112.48W
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.

_________________
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.


Top
 Profile  
 
PostPosted: Thu Apr 28, 2011 2:31 pm 
Offline
Forum Commoner
User avatar

Joined: Sun Sep 06, 2009 12:28 pm
Posts: 71
Quote:
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)

Quote:
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


Top
 Profile  
 
PostPosted: Mon Feb 20, 2012 7:31 am 
Offline
Forum Newbie

Joined: Sat Feb 18, 2012 2:12 am
Posts: 10
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");
?>

.....

?>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group