Back to Browse

Remote System reboot & Shutdown using php + URL Call from remote system in Same newtwork

94 views
Feb 17, 2023
15:51

//Allow shutdown and reboot command without password but sudo //Add this like in to /etc/sudoers file %www-data ALL=NOPASSWD: /sbin/reboot, /sbin/shutdown in php file /var/www/html/syscommand.php And dont forgot to change owner of this file to www-data $ sudo chown www-data:www-data /var/www/html/syscomnd.php ----------------------------------------- OPEN PHP TAG if(isset($_GET['command'])){ $command= $_GET['command']; if( $command=='reboot'){ echo 'Reboot'; $command = 'sudo /sbin/reboot'; } else if($command=='shutdown'){ echo 'Shutdown'; $command = 'sudo /sbin/shutdown -P now'; } $resp = shell_exec( $command); var_dump($resp); } else{ echo ' invalid request'; } CLOSE PHP TAG if Reboot ----------------- URL: http://remote_ip/syscommand.php?command=reboot if Shutdown --------------------- URL: http://remote_ip/syscommand.php?command=shutdown if any other command ------------------------------------ URL: http://remote_ip/syscommand.php?command=anyComamnds

Download

0 formats

No download links available.

Remote System reboot & Shutdown using php + URL Call from remote system in Same newtwork | NatokHD