Skip to content
This repository was archived by the owner on Nov 20, 2021. It is now read-only.

Commit c8359a5

Browse files
http header POC cve-2014-6271
1 parent 7b04d15 commit c8359a5

File tree

4 files changed

+211
-0
lines changed

4 files changed

+211
-0
lines changed

.gitignore

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Compiled source #
2+
###################
3+
*.com
4+
*.class
5+
*.dll
6+
*.exe
7+
*.o
8+
*.so
9+
10+
# Packages #
11+
############
12+
# it's better to unpack these files and commit the raw source
13+
# git has its own built in compression methods
14+
*.7z
15+
*.dmg
16+
*.gz
17+
*.iso
18+
*.jar
19+
*.rar
20+
*.tar
21+
*.zip
22+
23+
# Logs and databases #
24+
######################
25+
*.log
26+
*.sql
27+
*.sqlite
28+
29+
# OS generated files #
30+
######################
31+
.DS_Store
32+
.DS_Store?
33+
._*
34+
.Spotlight-V100
35+
.Trashes
36+
ehthumbs.db
37+
Thumbs.db
38+
39+
# Presentations #
40+
#################
41+
.key
42+
43+
44+
.state
45+
.state/
46+
.!*!*

LICENSE

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright (c) 2014, Critical Stack LLC
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
7+
* Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
10+
* Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
14+
* Neither the name of the {organization} nor the names of its
15+
contributors may be used to endorse or promote products derived from
16+
this software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

bash-cve-2014-6271/README.md

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
CVE-2014-6271
2+
===
3+
4+
[1. Overview](#overview)
5+
[2. HTTP Header](#httpheader)
6+
7+
<a name="overview"></a>
8+
##1. Overview
9+
===
10+
11+
**CVE-2014-6271** is a real nasty one; this vulnerability is in one of those pervasive pieces of software that comes with nearly every unixy type device- the [bash](http://tiswww.case.edu/php/chet/bash/bashtop.html), the Bourne-Again SHell. Let's test to see if your servers|workstations|internet-of-things is vulnerable:
12+
13+
Open a shell and paste:
14+
```
15+
env x='() { :;}; echo vulnerable' bash -c 'echo hello'
16+
```
17+
18+
If you are not vulnerable, then the following will be shown:
19+
```
20+
bash: warning: x: ignoring function definition attempt
21+
bash: error importing function definition for `x'
22+
hello
23+
```
24+
If you are vulnerable, then you will see:
25+
```
26+
vulnerable
27+
hello
28+
```
29+
30+
If you are vulnerable you should update your device immediately. I have a feeling that this is the kind of exploit that is going to start cropping up in a large variety of cases. I'll try to keep this updated to detect the various methods as the situation evolves.
31+
32+
<a name="httpheader"></a>
33+
##2. HTTP Header Attack
34+
===
35+
36+
37+
First POC is out- attempting to attack bash based cgi scripts; [internet wide scans](http://blog.erratasec.com/2014/09/bash-shellshock-scan-of-internet.html) have been kicked off and I expect to see this genuinely weaponized before the evening is out.
38+
39+
A vulnerable piece of code will look something like this:
40+
41+
```
42+
#!/bin/bash
43+
44+
echo Content-type: text/html
45+
echo ""
46+
47+
/bin/cat << EOM
48+
<HTML>
49+
<HEAD><TITLE>File Output: /home/user1/public_html/text-file.txt </TITLE>
50+
</HEAD>
51+
<BODY bgcolor="#cccccc" text="#000000">
52+
<P>
53+
<SMALL>
54+
<PRE>
55+
EOM
56+
57+
/bin/env
58+
59+
CAT << EOM
60+
</PRE>
61+
</SMALL>
62+
<P>
63+
</BODY>
64+
</HTML>
65+
EOM
66+
```
67+
[[source](http://www.yolinux.com/TUTORIALS/LinuxTutorialCgiShellScript.html)
68+
69+
This piece of code will output something like this:
70+
```
71+
<HTML>
72+
<HEAD><TITLE>File Output: /home/user1/public_html/text-file.txt </TITLE>
73+
</HEAD>
74+
<BODY bgcolor="#cccccc" text="#000000">
75+
<P>
76+
<SMALL>
77+
<PRE>
78+
SERVER_SIGNATURE=
79+
Apache/2.0.40 Server at localhost Port 80
80+
81+
82+
UNIQUE_ID=DErk6n8AAAEAAAblFQEAAAAD
83+
HTTP_USER_AGENT=Mozilla/4.8 [en] (X11; U; Linux 2.4.18-27.8.0 i586)
84+
SERVER_PORT=80
85+
HTTP_HOST=localhost
86+
DOCUMENT_ROOT=/var/www/html
87+
HTTP_ACCEPT_CHARSET=iso-8859-1,*,utf-8
88+
SCRIPT_FILENAME=/var/www/cgi-bin/env.sh
89+
REQUEST_URI=/cgi-bin/env.sh
90+
SCRIPT_NAME=/cgi-bin/env.sh
91+
HTTP_CONNECTION=Keep-Alive
92+
REMOTE_PORT=32984
93+
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin
94+
PWD=/var/www/cgi-bin
95+
SERVER_ADMIN=root@localhost
96+
HTTP_ACCEPT_LANGUAGE=en
97+
HTTP_ACCEPT=image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*
98+
REMOTE_ADDR=127.0.0.1
99+
SHLVL=1
100+
SERVER_NAME=localhost
101+
SERVER_SOFTWARE=Apache/2.0.40 (Red Hat Linux)
102+
QUERY_STRING=
103+
SERVER_ADDR=127.0.0.1
104+
GATEWAY_INTERFACE=CGI/1.1
105+
SERVER_PROTOCOL=HTTP/1.0
106+
HTTP_ACCEPT_ENCODING=gzip
107+
REQUEST_METHOD=GET
108+
_=/bin/env
109+
</PRE>
110+
</SMALL>
111+
<P>
112+
</BODY>
113+
</HTML>
114+
```
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module Bash;
2+
3+
export {
4+
redef enum Notice::Type += {
5+
## Indicates that a host may have attempted a bash cgi header attack
6+
HTTP_Header_Attack,
7+
};
8+
}
9+
10+
event http_header(c: connection, is_orig: bool, name: string, value: string) &priority=3
11+
{
12+
13+
if ( is_orig )
14+
{
15+
if ( /\x7b.*\x7d.*\x3b/ in value )
16+
{
17+
NOTICE([$note=Bash::HTTP_Header_Attack,
18+
$conn=c,
19+
$msg=fmt("%s may have attempted a bash CGI HTTP header attack against %s submitting \"%s\"=\"%s\"",c$id$orig_h, c$id$resp_h, name, value),
20+
$identifier=c$uid]);
21+
}
22+
}
23+
24+
}

0 commit comments

Comments
 (0)