MS17-010 SMB RCE Detection - Metasploit


This page contains detailed information about how to use the auxiliary/scanner/smb/smb_ms17_010 metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.

Module Overview


Name: MS17-010 SMB RCE Detection
Module: auxiliary/scanner/smb/smb_ms17_010
Source code: modules/auxiliary/scanner/smb/smb_ms17_010.rb
Disclosure date: -
Last modification time: 2021-06-29 16:18:28 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: microsoft-ds, netbios-ssn
Target network port(s): 139, 445
List of CVEs: CVE-2017-0143, CVE-2017-0144, CVE-2017-0145, CVE-2017-0146, CVE-2017-0147, CVE-2017-0148

This module is also known as DOUBLEPULSAR or ETERNALBLUE.

Uses information disclosure to determine if MS17-010 has been patched or not. Specifically, it connects to the IPC$ tree and attempts a transaction on FID 0. If the status returned is "STATUS_INSUFF_SERVER_RESOURCES", the machine does not have the MS17-010 patch. If the machine is missing the MS17-010 patch, the module will check for an existing DoublePulsar (ring 0 shellcode/malware) infection. This module does not require valid SMB credentials in default server configurations. It can log on as the user "\" and connect to IPC$.

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/smb/smb_ms17_010
msf auxiliary(smb_ms17_010) > show options
    ... show and set options ...
msf auxiliary(smb_ms17_010) > set RHOSTS ip-range
msf auxiliary(smb_ms17_010) > exploit

Other examples of setting the RHOSTS option:

Example 1:

msf auxiliary(smb_ms17_010) > set RHOSTS 192.168.1.3-192.168.1.200 

Example 2:

msf auxiliary(smb_ms17_010) > set RHOSTS 192.168.1.1/24

Example 3:

msf auxiliary(smb_ms17_010) > set RHOSTS file:/tmp/ip_list.txt

Required Options


  • RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'

Knowledge Base


MS17-010 fixes RCE in SMBv1, but seems to also have inadvertently added a remote, uncredentialed patch check information disclosure.

This module can determine if MS17-010 has been patched or not. Specifically, it connects to the IPC$ tree and attempts a PeekNamedPipe transaction on FID 0.

If the status returned is "STATUS_INSUFF_SERVER_RESOURCES", the machine does not have the MS17-010 patch. After the patch, Win10 returns "STATUS_ACCESS_DENIED" and other Windows versions "STATUS_INVALID_HANDLE". In case none of these are detected, the module says it was not able to detect the patch level.

This module does not require valid SMB credentials in default server configurations. It can log on as the user "" and connect to IPC$.

Vulnerable Application


To use smb_ms17_010, make sure you are able to connect to a SMB service that supports SMBv1.

Verification Steps


The following demonstrates a basic scenario of an unpatched system.

msf > use auxiliary/scanner/smb/smb_ms17_010
msf auxiliary(smb_ms17_010) > set RHOSTS 192.168.1.104
RHOSTS => 192.168.1.104
msf auxiliary(smb_ms17_010) > run

[*] 192.168.1.104:445    - Connected to \\192.168.1.104\IPC$ with TID = 2048
[*] 192.168.1.104:445    - Received STATUS_INSUFF_SERVER_RESOURCES with FID = 0
[!] 192.168.1.104:445    - Host is likely VULNERABLE to MS17-010!
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed

If you run the same scan on the system after patching, you should see the following:

msf auxiliary(smb_ms17_010) > run

[*] 192.168.1.104:445    - Connected to \\192.168.1.104\IPC$ with TID = 2052
[*] 192.168.1.104:445    - Received STATUS_ACCESS_DENIED with FID = 0
[+] 192.168.1.104:445    - Host does NOT appear vulnerable.
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed

Options


By default, the smb_ms17_010 module only requires the RHOSTS option to run. In a default configuration, you will not need valid credentials to connect to the IPC$ share. But, if you have them, it can't hurt.

The SMBUser option

If you are testing a specific user, use this option.

set SMBUser [user name]

The SMBPass option

If you are testing a specific password, use this option.

set SMBPass [password]

Go back to menu.

Msfconsole Usage


Here is how the scanner/smb/smb_ms17_010 auxiliary module looks in the msfconsole:

msf6 > use auxiliary/scanner/smb/smb_ms17_010

msf6 auxiliary(scanner/smb/smb_ms17_010) > show info

       Name: MS17-010 SMB RCE Detection
     Module: auxiliary/scanner/smb/smb_ms17_010
    License: Metasploit Framework License (BSD)
       Rank: Normal

Provided by:
  Sean Dillon <[email protected]>
  Luke Jennings

Check supported:
  No

Basic options:
  Name         Current Setting                                                              Required  Description
  ----         ---------------                                                              --------  -----------
  CHECK_ARCH   true                                                                         no        Check for architecture on vulnerable hosts
  CHECK_DOPU   true                                                                         no        Check for DOUBLEPULSAR on vulnerable hosts
  CHECK_PIPE   false                                                                        no        Check for named pipe on vulnerable hosts
  NAMED_PIPES  /opt/metasploit-framework/embedded/framework/data/wordlists/named_pipes.txt  yes       List of named pipes to check
  RHOSTS                                                                                    yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
  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:
  Uses information disclosure to determine if MS17-010 has been 
  patched or not. Specifically, it connects to the IPC$ tree and 
  attempts a transaction on FID 0. If the status returned is 
  "STATUS_INSUFF_SERVER_RESOURCES", the machine does not have the 
  MS17-010 patch. If the machine is missing the MS17-010 patch, the 
  module will check for an existing DoublePulsar (ring 0 
  shellcode/malware) infection. This module does not require valid SMB 
  credentials in default server configurations. It can log on as the 
  user "\" and connect to IPC$.

References:
  https://nvd.nist.gov/vuln/detail/CVE-2017-0143
  https://nvd.nist.gov/vuln/detail/CVE-2017-0144
  https://nvd.nist.gov/vuln/detail/CVE-2017-0145
  https://nvd.nist.gov/vuln/detail/CVE-2017-0146
  https://nvd.nist.gov/vuln/detail/CVE-2017-0147
  https://nvd.nist.gov/vuln/detail/CVE-2017-0148
  https://docs.microsoft.com/en-us/security-updates/SecurityBulletins/2017/MS17-010
  https://zerosum0x0.blogspot.com/2017/04/doublepulsar-initial-smb-backdoor-ring.html
  https://github.com/countercept/doublepulsar-detection-script
  https://technet.microsoft.com/en-us/library/security/ms17-010.aspx

Also known as:
  DOUBLEPULSAR
  ETERNALBLUE

Module Options


This is a complete list of options available in the scanner/smb/smb_ms17_010 auxiliary module:

msf6 auxiliary(scanner/smb/smb_ms17_010) > show options

Module options (auxiliary/scanner/smb/smb_ms17_010):

   Name         Current Setting                                                              Required  Description
   ----         ---------------                                                              --------  -----------
   CHECK_ARCH   true                                                                         no        Check for architecture on vulnerable hosts
   CHECK_DOPU   true                                                                         no        Check for DOUBLEPULSAR on vulnerable hosts
   CHECK_PIPE   false                                                                        no        Check for named pipe on vulnerable hosts
   NAMED_PIPES  /opt/metasploit-framework/embedded/framework/data/wordlists/named_pipes.txt  yes       List of named pipes to check
   RHOSTS                                                                                    yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
   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/smb/smb_ms17_010 auxiliary module:

msf6 auxiliary(scanner/smb/smb_ms17_010) > show advanced

Module advanced options (auxiliary/scanner/smb/smb_ms17_010):

   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"
   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)
   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/smb/smb_ms17_010 module can do:

msf6 auxiliary(scanner/smb/smb_ms17_010) > show actions

Auxiliary actions:

   Name  Description
   ----  -----------

Evasion Options


Here is the full list of possible evasion options supported by the scanner/smb/smb_ms17_010 auxiliary module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

msf6 auxiliary(scanner/smb/smb_ms17_010) > 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:

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.

Host is likely INFECTED with DoublePulsar! - Arch: <ARCH>, XOR Key: 0x<XOR_KEY>


Here is a relevant code snippet related to the "Host is likely INFECTED with DoublePulsar! - Arch: <ARCH>, XOR Key: 0x<XOR_KEY>" error message:

118:	          code, signature1, signature2 = do_smb_doublepulsar_probe(tree_id)
119:	
120:	          if code == 0x51
121:	            xor_key = calculate_doublepulsar_xor_key(signature1).to_s(16).upcase
122:	            arch = calculate_doublepulsar_arch(signature2)
123:	            print_warning("Host is likely INFECTED with DoublePulsar! - Arch: #{arch}, XOR Key: 0x#{xor_key}")
124:	            report_vuln(
125:	              host: ip,
126:	              name: "MS17-010 DoublePulsar Infection",
127:	              refs: self.references,
128:	              info: "MultiPlexID += 0x10 on Trans2 request - Arch: #{arch}, XOR Key: 0x#{xor_key}"

Host does NOT appear vulnerable.


Here is a relevant code snippet related to the "Host does NOT appear vulnerable." error message:

145:	            )
146:	          end
147:	        end
148:	      elsif status == "STATUS_ACCESS_DENIED" or status == "STATUS_INVALID_HANDLE"
149:	        # STATUS_ACCESS_DENIED (Windows 10) and STATUS_INVALID_HANDLE (others)
150:	        print_error("Host does NOT appear vulnerable.")
151:	      else
152:	        print_error("Unable to properly detect if host is vulnerable.")
153:	      end
154:	
155:	      unless (fp_match = Recog::Nizer.match('smb.native_os', simple.client.peer_native_os)).nil?

Unable to properly detect if host is vulnerable.


Here is a relevant code snippet related to the "Unable to properly detect if host is vulnerable." error message:

147:	        end
148:	      elsif status == "STATUS_ACCESS_DENIED" or status == "STATUS_INVALID_HANDLE"
149:	        # STATUS_ACCESS_DENIED (Windows 10) and STATUS_INVALID_HANDLE (others)
150:	        print_error("Host does NOT appear vulnerable.")
151:	      else
152:	        print_error("Unable to properly detect if host is vulnerable.")
153:	      end
154:	
155:	      unless (fp_match = Recog::Nizer.match('smb.native_os', simple.client.peer_native_os)).nil?
156:	        report_host(
157:	          host: rhost,

An SMB Login Error occurred while connecting to the IPC$ tree.


Here is a relevant code snippet related to the "An SMB Login Error occurred while connecting to the IPC$ tree." error message:

164:	
165:	    rescue ::Interrupt
166:	      print_status("Exiting on interrupt.")
167:	      raise $!
168:	    rescue ::Rex::Proto::SMB::Exceptions::LoginError
169:	      print_error("An SMB Login Error occurred while connecting to the IPC$ tree.")
170:	    rescue ::Exception => e
171:	      print_error("#{e.class}: #{e.message}")
172:	    ensure
173:	      disconnect
174:	    end

ErrorClass


Here is a relevant code snippet related to the "ErrorClass" error message:

212:	    # convert packet to response struct
213:	    pkt = Rex::Proto::SMB::Constants::SMB_TRANS_RES_HDR_PKT.make_struct
214:	    pkt.from_s(bytes[4..-1])
215:	
216:	    # convert error code to string
217:	    code = pkt['SMB'].v['ErrorClass']
218:	    smberr = Rex::Proto::SMB::Exceptions::ErrorCode.new
219:	
220:	    return smberr.get_error(code)
221:	  end
222:	

Go back to menu.


References


See Also


Check also the following modules related to this module:

Related Nessus plugins:

Authors


Version


This page has been produced using Metasploit Framework version 6.1.28-dev. For more modules, visit the Metasploit Module Library.

Go back to menu.