A Metasploit resource script is a file of console commands that can run at startup with msfconsole -r or inside an existing console with resource. For a repeatable lab, use a .rc file to select a prepared workspace, record configuration, and list background jobs before beginning a separate testing exercise.
Key takeaways
- Keep the setup file limited to workspace selection, observations, and a transcript.
- A workspace organizes database records; verify the lab’s network boundary separately.
- Review existing jobs and global settings before reusing an open console.
- Preserve a reset record so a successful rerun means more than the absence of an error message.
What should a setup-only resource script do?
It should establish or confirm the conditions you need before the exercise, with every command understandable on inspection. Rapid7’s resource-script documentation describes sequential console commands and supports startup and interactive execution. Keep the file’s purpose narrow enough to explain its effects line by line.
Define a disposable, authorized lab and document its actual network connections before opening the console. For this setup exercise, use only a local lab database and synthetic records. You do not need to contact a target system to demonstrate workspace selection or job inventory.
Write the expected end state beside the file: the intended workspace is selected, the framework version and global settings have been recorded, the existing job list is visible, and console spooling has ended. These are observable conditions you can check. A completed file is not evidence that those conditions were satisfied.
The Metasploit career skills discussion supplies broader context for candidates. A smaller setup exercise gives you a specific work sample: a reviewed command file, its assumptions, the resulting observations, and a record of what changed when you repeated it.
Which workspace and version assumptions should you record?
Record your installed framework version, database connection, workspace name, script location, and transcript destination. Check those details before running the file. The examples below follow documentation and the Framework’s master-branch command implementation checked on October 25, 2026; your installed version and local help remain the comparison points for your own run.
The Framework database documentation says Metasploit can operate without a database, while database-backed features support organizing recorded results in workspaces. This particular exercise assumes a working lab database. Check db_status interactively and resolve a missing connection before attempting its workspace steps.
Create the named lab workspace if it does not exist, using workspace -a study_setup in your prepared lab console. Then run workspace and confirm the intended workspace is selected. Keep creation separate from the reusable file so its routine job is selecting an already prepared workspace and reporting state.
Make the distinction explicit in your notes: the workspace separates recorded data logically. It does not restrict where later commands can send traffic. Verify network isolation through the lab’s network configuration and permitted scope, rather than inferring it from the workspace name or an empty host list.
Choose an existing, writable working directory for the example and use a fresh transcript filename for each recorded run. The sample’s relative path depends on the console’s working directory. Record the resolved location so you can find the output and distinguish it from an older transcript with a similar name.
What commands belong in the reviewed .rc file?
Save the following plain-text commands as setup-review.rc after preparing the database, workspace, and output directory. The sample selects the workspace, displays relevant state, and writes console output to a file. Its command meanings were checked against documentation and source; verify the behavior on your installed version before relying on the transcript.
spool ./setup-review.log
version
db_status
workspace study_setup
workspace
setg
jobs -l
spool off
Here, setg has no option or value arguments. In the current Framework command implementation, that invocation displays the global datastore. Adding arguments changes its purpose, so retain the exact reviewed command when your intent is observation.
| Command | Intended effect | Check after execution |
|---|---|---|
spool ./setup-review.log |
Begin a console-output transcript | Output path is writable and belongs to this run |
version and db_status |
Report version and database state | Installed version and intended lab connection are recorded |
workspace study_setup and workspace |
Select and list workspaces | The named workspace is selected successfully |
setg and jobs -l |
Display global settings and background jobs | Unexpected state has been identified for review |
spool off |
End console spooling | Later console activity is outside this transcript |
Review the entire file before saving it, including commands copied from examples or exported from a previous session. A setup script should have a clear reason for every effect. If a proposed addition starts a module or performs another activity, review it as a separate exercise with its own scope and expected outcome.
How do you run a Metasploit resource script with msfconsole -r?
Use msfconsole -r ./setup-review.rc from your shell to load the file as the console starts. Inside an already running console, use resource ./setup-review.rc. The startup option belongs to the shell command; the interactive command belongs at the Metasploit console prompt.
msfconsole -r ./setup-review.rc
For the interactive route, enter this at the console prompt:
resource ./setup-review.rc
Use the route that matches the state you intend to study. Startup gives you a new console process, while interactive execution takes place in the console you already have open. In either case, inspect the version, database status, selected workspace, settings, and jobs rather than assuming the launch method established a clean baseline.
After execution, read the transcript in command order. Confirm the workspace-selection result itself, not merely the later workspace listing or final prompt. If the workspace was unavailable, correct the prerequisite and rerun with a distinct transcript; later output is not proof that the earlier selection succeeded.
If spooling did not start, investigate the path and directory permissions before treating the run as recorded. If execution was interrupted, verify the spool state manually. The example ends with spool off, but a final line in a file does not establish that execution reached it.
Why inspect existing jobs before rerunning setup?
The Framework jobs reference documents jobs -l for listing background jobs and jobs -i JOB_ID for inspecting a named job. Existing jobs are part of the environment you are observing. The setup file inventories them without deciding which should be stopped.
Use the identifier reported by your own job listing when you inspect a job; JOB_ID is a placeholder in the documented syntax. Record the job’s purpose and whether it belongs to the current exercise. Unexpected output should trigger an explanation of the state before you reuse the console for another task.
Capitalization matters. The reference distinguishes jobs -k JOB_IDS, which stops specified jobs, from jobs -K, which stops all currently running jobs. Neither termination action belongs in this inventory script. Any cleanup should follow a review of the actual lab state and ownership of the affected work.
A workspace change is also insufficient evidence that earlier activity ended. Keep job inventory, current workspace, active console context, and any session review as separate entries in your run record. That separation helps explain why selecting the intended data container did not answer every question about a reused console.
What should a reset record contain?
Keep the starting conditions, script revision, transcript path, unexpected state, deliberate cleanup, and final observations beside the file. The record should let you explain what you reset and what you preserved. Repeatable setup depends on comparable conditions as well as consistent commands.
Preserve the earlier transcript before changing the example’s output filename for a rerun. Note the database and workspace, global values requiring review, and any jobs associated with a previous exercise. Record the reason for a cleanup action separately from the routine setup file so its effects remain visible.
Compare a rerun with the baseline. If the version, connection, workspace, settings, or job list changed, investigate and document the difference before calling the runs equivalent. A useful result may be that you found an unrecorded dependency; that is something to fix in the setup notes rather than hide in a successful-looking transcript.
The Kali Linux skills discussion can help you place the exercise within a broader lab practice. Keep the environment details specific to your own installation. A distribution name alone does not identify the framework version, database configuration, or network connections that produced a result.
For an interview, explain an actual discrepancy you found and how you resolved it. If you later compare transcripts with a small local utility, the Python security-skills discussion offers related career context. Describe that utility’s actual role and keep the original observations available to support your explanation.
Frequently Asked Questions
Is a resource script the same as a shell script?
The file in this exercise contains Metasploit console commands loaded by the console. The shell starts msfconsole -r; an existing console accepts resource. Review any file you reuse because resource scripts can contain more than a simple list of observation commands, including embedded Ruby.
Does changing the workspace isolate network traffic?
A workspace organizes database-backed results. Verify the network boundary independently through the lab configuration and permitted scope. A workspace name does not establish that a later command can reach only authorized lab systems.
Should a setup script stop all existing jobs?
The proposed file lists jobs so you can inspect and explain them. Identify what each job belongs to before deciding on cleanup. The documented stop flags have different scopes, and a broad termination action would change the state you were trying to inventory.
What is the next useful verification step?
Save the reviewed file, confirm its prerequisites, and run it in your prepared lab with a fresh transcript path. Compare the reported workspace, global settings, version, database connection, and jobs with your written expectations, then record every difference in the reset notes.
