linux bash 漏洞修复方法

1.yum -y update bash
执行此命令用以更新bash

注意:若系统为CentOS6及以上,则可通过手动或在线下载rpm包进行升级
wget http://mirror.centos.org/centos/6/updates/x86_64/Packages/bash-4.1.2-15.el6_5.1.x86_64.rpm
rpm -Uvh bash-4.1.2-15.el6_5.1.x86_64.rpm
之后就不用再执行上述update命令了


1.1若执行过程中出现类似以下错误:
[root@localhost ~]# yum -y update bash
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
Setting up Update Process
No Packages marked for Update
说明yum源不对,需要更换成centos的yum源(此方法适用于redhat 5以上版本的服务器)
更换yum源为centos方法:
(1)cd /etc/yum.repos.d/ 进到该目录下,将文件rhel-debuginfo.repo备份
(2)在该目录下执行命令wget http://docs.linuxtone.org/soft/lemp/CentOS-Base.repo 下载centos的yum源
(3)然后将下载下来的文件重命名为rhel-debuginfo.repo
1.2若更换过yum源后仍然不能执行update命令,并提示:
正在解析主机 docs.linuxtone.org... 失败:域名解析暂时失败。
说明没有联网,建议手动下载rpm包安装:
http://mirrors.aliyun.com/centos/5/updates/x86_64/RPMS/
下载文件
http://mirrors.aliyun.com/centos/5/updates/x86_64/RPMS/bash-3.2-33.el5.1.x86_64.rpm
然后执行命令:

rpm -Uvh bash-3.2-33.el5.1.x86_64.rpm #[升级一个rpm]

注意:rpm -Uvh 中的U要大写

若操作系统为Red Hat Enterprise Linux Server release 5.6,则需要下载
bash-3.2-33.el5_11.4.x86_64.rpm包

1.3 若update命令执行时出现Another app is currently holding the yum lock提示,
则通过执行rm -rf /var/run/yum.pid 来强行解除锁定

1.4 若update命令执行时出现类似于http://mirrors.163.com/centos/5.5/addons/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404: Not Found
Trying other mirror.
http://ftp.stu.edu.tw/Linux/CentOS/5.5/addons/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404: Not Found
Trying other mirror.错误时,说明源找不到,需要更改update的地址
(1)cd /etc/yum.repos.d/
(2)vi CentOS-Base.repo
(3)将其中update的BaseUrl换成有效的链接:
如:
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/


baseurl值变为:
http://mirror.centos.org/centos/6/updates/$basearch/
保存退出,再执行update命令,即可成功。
1.5 若执行update操作出现
-bash: yum: command not found
说明没有安装yum,安装方法参考:http://lihuifen2014.iteye.com/blog/2145950


2.升级过bash后,进行验证,具体验证方法如下:

2.1 CVE-2014-6217漏洞验证
执行命令:env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
如果终端中没有输出“vulnerable”则证明该漏洞修复成功

2.2 CVE-2014-7169漏洞验证
执行命令:env X='() { (shellshocker.net)=>\' bash -c "echo id"; cat echo ; rm -f echo
如果终端中没有输出用户信息则证明该漏洞修复成功,如果返回用户信息则证明漏洞没有修复成功

2.3 CVE-2014-6277漏洞验证
执行命令:env -i X=' () { }; echo id' bash -c 'date'
如果终端中没有输出用户信息则证明该漏洞修复成功

2.4 CVE-2014-7186漏洞验证
执行命令:bash -c 'true <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF' || echo "CVE-2014-7186 vulnerable, redir_stack"
如果终端中没有输出“CVE-2014-7186 vulnerable”则证明该漏洞修复成功

2.5 CVE-2014-7187漏洞验证
执行命令:(for x in {1..200} ; do echo "for x$x in ; do :"; done; for x in {1..200} ; do echo done ; done) | bash || echo "CVE-2014-7187 vulnerable, word_lineno"
如果终端中没有输出“CVE-2014-7187 vulnerable”则证明该漏洞修复成功


猜你喜欢

转载自lihuifen2014.iteye.com/blog/2135476