Table of Contents


Summery

Metasploit is a penetration-testing framework used to find, develop, and execute exploits against vulnerable systems. It includes exploit modules, payloads, auxiliary modules for scanning/enumeration, and post-exploitation modules.

Its main interface is msfconsole.

Closely related to metasploit are other concepts like msfvenom and meterpreter.

Concepts

Here are some metasploit concepts which can be a bit confusing.

Workspace - Separate database context for organizing hosts, services, credentials, and scan results.
workspace - List available workspaces and show the current one.
workspace -a NAME - Create a new workspace named NAME.
workspace -d NAME - Delete the workspace named NAME.

Session - An active connection established with a target, such as a Meterpreter or shell session.
sessions - List active sessions.
sessions -i 1 - Interact with session 1.
sessions -K - Kill all active sessions.

Channel - A communication channel opened inside a Meterpreter session, often for command shells or other streams.
channels - List channels available in the current Meterpreter session.
channel -i 1 - Interact with channel 1.

Job - A module or task running in the background.
jobs - List currently running background jobs.
jobs -K - Kill all running jobs.
jobs -i 1 - Interact with job 1.

Adding custom exploits

Sometimes you need to add custom exploits to metasploit - often when you get them from internet or from searchsploit.
To do so you need to:

  1. Put your script in /usr/share/metasploit-framework/modules/exploits/ I like to create a custom folder inside of it and upload it there like so /usr/share/metasploit-framework/modules/exploits/custom.
  2. Your exploit filename has to use lowercase snake_case, no hyphens and no dots besides the extension one.
  3. In msfconsole you run reload_all.
  4. You should be able now to search for your custom script.

References

21. The Metasploit Framework, Introduction to Metasploit, Cheatsheet - 09 Using the Metasploit Framework
And all the other HtB modules about it.