2010-02-22 113 views
0

我需要一些嚴重的幫助球員。我離開了我的服務器:一些黑客更改了我的密碼。但是,他無法破解根帳戶。我仍然可以訪問,但它並未在SSH中啓用,所以我需要在Linux中訪問我的帳戶。我只能訪問我的服務器上的HTTP。我想知道是否可以通過PHP更改我的密碼。PHP了shell_exec如何更改密碼LINUX

我有問題的錯誤消息「命令要求終端」。你能幫我恢復我的密碼嗎?

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

我有什麼其他選擇用PHP奪回訪問我的服務器感謝.. – Saxtor 2010-02-22 06:10:08

+0

是您的主機不願意物理訪問服務器,並啓用根SSH登錄或重新passwd文件的登錄帳戶?據我所知,除非事先有不同的配置,否則su或sudo不會交互式地要求密碼,明確地勸阻這樣的事情(這可能很容易變成窮人程序員手中的安全漏洞)。 – 2010-02-22 06:17:20

+0

遠程手牌不可用嗎?它更容易直接啓動進入bash並進行調整。 – 2010-02-22 06:51:40

回答

0

你試過

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

警告未經測試可能無法正常工作/產生意想不到的後果!使用需要您自擔風險!

我只用了shell_exec幾個簡單的事情,從來沒有試過這樣的事情去做。