I need some serious help guys. I got locked out from my sever: some hacker changed my password. However, he wasn't able to hack the root account. I still have access but it's not enabled in SSH, so I need access to my account in Linux. I only have access to HTTP on my server. I want to know whether it is possible to change my password by PHP.
I have the problem error message "sudo requires terminal". Can you please help me to recover 开发者_如何学编程my password.
<?
$command_exec = 'su root -u root mypwd';
$root_pwd = 'msiamd';
$description = array(
0 => array("pipe","r"),
1 => array("pipe","w"),
2 => array("file","error-output", "a"
));
$process = proc_open($command_exec,$description,$pipes);
if(is_resource($process))
{
fwrite($pipes[0],$root_pwd."\r\n");
fclose($pipes[0]);
echo stream_get_contents($pipes[1]);
print_R($pipes);
fclose($pipes[1]);
proc_close($process);
}
?>
Have you tried
string shell_exec ('sudo su [[password]]');
string shell_exec ('passwd [[account]]');
string shell_exec ('[[new-password]]');
string shell_exec ('[[new-password]]');
WARNING This is untested and may not work/have unintended consequences! Use at your own risk!
I have only used shell_exec for a few simple things, never tried to do it with something like this.
精彩评论