2011-08-12 285 views
1

我試圖追查一下Wordpress網站如何不斷遭到黑客攻擊,而我試圖追蹤的事件之一是哪些文件被「touch」命令擊中以僞造last_modified日期(在這種情況下許多黑客會隱藏自己併發生)。我創建了一個名爲newtouch的腳本,它只是使用時間戳記記錄發送給它的所有參數,然後將別名改爲newtouch。這工作正常,當我ssh進入,但是當我試圖從PHP調用它不識別別名。我做了一些研究,並意識到這是因爲PHP運行在不同的shell下:Shell無法識別別名命令

$ php -r'echo shell_exec(「echo $ 0」);' sh

在主目錄中沒有.profile,所以我創建了一個,但無論我把它放在哪裏,我都無法讓shell識別出於某種原因。爲了測試我試過一個簡單的別名命名touch2是簡單重複的單詞測試,並且已經嘗試了所有的.profile以下里面的,沒有一個工作:

alias touch2='echo test' 

alias touch2 'echo test' 

touch2() { 
    echo test 
} 

無論我嘗試,我得到相同結果:

$ sh 
$ alias 
$ touch2 
sh: touch2: command not found 

$ php -r 'echo shell_exec("alias");' 
$ php -r 'echo shell_exec("touch2");' 
sh: touch2: command not found 

任何幫助表示讚賞,謝謝。

+1

您的個人別名並不意味着什麼,以系統爲新用戶(特別是如果他們已經得到了根)或碰巧執行觸控式/路徑/到/觸摸/ EXEC – zellio

+2

如果你設置了一個它不會阻止直接調用'/ usr/bin/touch'(繞過別名),也不會阻止php內部的'touch()'函數(它更有可能被使用)。 – mario

+0

你們回答得很快,這篇文章只是寫了一半,但是在我添加標籤時意外提交,對此抱歉。而且,這絕對是通過php完成的,而不是通過另一個shell。 –

回答

1
#!/path/to/bash 

mv /path/to/touch /some/where/else 
chmod -x /some/where/else/touch 
chown root:root /some/where/else/touch 
mv /path/to/new/touch /where/touch/was/before 
+0

我沒有root權限,它是DreamHost上的共享主機環境。 –