Metasploit’s public tree lags behind fresh exploits by weeks or months. When a new CVE drops and someone publishes a .rb module on GitHub, you can drop it straight into your local framework and run it alongside the shipped modules.

Module Paths

MSF scans these directories at startup (and on reload_all):

# System-wide (requires sudo)
/usr/share/metasploit-framework/modules/

# Per-user (no sudo needed — preferred)
~/.msf4/modules/

The per-user path mirrors the system tree:

~/.msf4/modules/
├── exploits/
│   └── <platform>/<service>/<name>.rb
├── auxiliary/
├── payloads/
├── post/
├── encoders/
└── evasion/

Organize into subdirectories

Don’t dump every custom .rb straight into exploits/. Mirror the shipped layout (exploits/windows/smb/, exploits/linux/http/) or make a dedicated namespace (exploits/custom/). It keeps search output clean and use paths predictable.

Dropping a Ruby Module

Standard flow when you grab an exploit off GitHub or ExploitDB:

# 1. Grab the .rb file
wget https://example.com/cve-2024-xxxx.rb
 
# 2. Drop it into the matching module tree
mkdir -p ~/.msf4/modules/exploits/custom/
mv cve-2024-xxxx.rb ~/.msf4/modules/exploits/custom/
 
# 3. Make sure it's readable
chmod 644 ~/.msf4/modules/exploits/custom/cve-2024-xxxx.rb

Then from msfconsole:

msf6 > reload_all
[*] Reloading modules from all module paths...
 
msf6 > use exploit/custom/cve-2024-xxxx
msf6 exploit(cve-2024-xxxx) > info
msf6 exploit(cve-2024-xxxx) > show options

reload_all rescans every module path — new files appear, edited files refresh. You don’t need to restart msfconsole.

System-Wide Install

Same steps, system path, needs root:

sudo mkdir -p /usr/share/metasploit-framework/modules/exploits/custom/
sudo cp cve-2024-xxxx.rb /usr/share/metasploit-framework/modules/exploits/custom/
sudo chmod 644 /usr/share/metasploit-framework/modules/exploits/custom/cve-2024-xxxx.rb

Prefer ~/.msf4/modules/ when you can — no sudo, survives Metasploit upgrades (which can overwrite /usr/share/), and per-user isolation means one messy module can’t break another user’s framework.

Verifying the Module Loaded

msf6 > reload_all
msf6 > search cve-2024-xxxx
msf6 > search path:custom

If it doesn’t show up:

  • Wrong directory — must be under a valid module type (exploits/, auxiliary/, post/, etc.)
  • Wrong extension — must end in .rb
  • Syntax error in the Ruby — reload_all will print the error. Look for lines starting with [-] or [!].
  • Permissions — the file must be world-readable (chmod 644)

Read the Ruby before you run it

You just downloaded someone else’s code and told it to run in the context of your pentest workstation, with the credentials and network access that entails. Audit the module’s exploit and check methods before firing. Bogus “PoC” modules occasionally contain outbound beacons or credential-stealing payloads targeted at operators.

Loading Plugins (Not Modules)

Plugins extend msfconsole itself — they’re different from modules. They live in:

/usr/share/metasploit-framework/plugins/

Load them at runtime:

msf6 > load nessus
msf6 > load wmap
msf6 > nessus_help

Install a community plugin by dropping its .rb into the plugins directory, then load <name> — no reload_all required for plugins.

Resource Scripts — Replaying Workflows

Not strictly “importing a module,” but the sibling workflow: automate common command sequences with resource scripts (.rc files).

# Record
msf6 > makerc /tmp/eternalblue.rc
 
# Replay
msf6 > resource /tmp/eternalblue.rc
 
# Or auto-run on startup
msfconsole -r /tmp/eternalblue.rc

A resource script is just a text file with one msfconsole command per line. Combine with setg to fully automate a known exploitation flow across engagements.