0

我需要一些认真的帮助。我的服务器被锁定了:一些黑客更改了我的密码。但是,他无法破解 root 帐户。我仍然可以访问,但它没有在 SSH 中启用,所以我需要访问我在 Linux 中的帐户。我只能在我的服务器上访问 HTTP。我想知道是否可以通过 PHP 更改我的密码。

我有问题错误消息“sudo 需要终端”。你能帮我找回密码吗?

<?
$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);
}
?>
4

1 回答 1

0

你有没有尝试过

string shell_exec ('sudo su [[password]]');
string shell_exec ('passwd [[account]]');
string shell_exec ('[[new-password]]');
string shell_exec ('[[new-password]]');

警告 这是未经测试的,可能无法工作/产生意想不到的后果! 使用风险自负!

我只将 shell_exec 用于一些简单的事情,从未尝试过这样的事情。

于 2015-01-21T22:36:58.247 回答