漏洞修複之 bash漏洞遠程命令執行

來源:互聯網
上載者:User

系統版本

[root@www bash]# cat /etc/issueRed Hat Enterprise Linux AS release 4 (Nahant Update 8)Kernel \r on an \m

不能使用yum

測試方法:
可以使用如下命令來檢查系統存在此漏洞:

env -i X=’() { (a)=>\’ bash -c ‘echo date’; cat echo
修複前輸出:當前系統時間
使用修補方案修複後
date

嘗試過此篇介紹的 升級bash 安裝完成重啟後沒有成功

最終修複方案:
建立

vim bash_ld_preload.c檔案

#include <sys/types.h>#include <stdlib.h>#include <string.h>static void __attribute__ ((constructor)) strip_env(void);extern char **environ;static void strip_env(){char *p,*c;int i = 0;for (p = environ[i]; p!=NULL;i++ ) {c = strstr(p,"=() {");if (c != NULL) {*(c+2) = '\0';}p = environ[i];} }

編譯成so

gcc bash_ld_preload.c -fPIC -shared -Wl,-soname,bash_ld_preload.so.1 -o bash_ld_preload.so

把編譯出來的bash_ld_preload.so拷貝到/lib/

往/etc/ld.so.preload添加 註: 此處ld.so.preload檔案為建立的

/lib/bash_ld_preload.so

env x=’() { :; };echo vul’ bash -c “:”

再驗證就沒有漏洞了

原文地址:http://bobao.360.cn/news/detail/449.html

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.