Metasploit provides functionality through programming libraries.
These support the user interface, as well as the exploit and
payload capabilities needed for testing.
Let's look at how these are used. Metasploit is written
in a programming language called Ruby.
Most everything in the framework uses that language.
It can also support modules written in Go and Python.
The Ruby programming language has its own set of core libraries.
There are also add‑on libraries called gems.
They provide very specific types of functionality.
For example, there are gems that Metasploit uses to interact with the database.
The Rex library is part of the Metasploit Framework. It provides
functionality needed for the exploit and payload modules.
It includes library functions for establishing network
connections and talking to services.
These are needed when you're building exploits that either communicate over
the network or interact directly with services like DHCP,
SMB, or HTTP.
There are functions for building payloads and executables for Windows PE files,
macOS Mach files, or Linux ELF files.
There are post‑exploitation functions and most of the
Meterpreter functionality as well.
The primary functionality of the Metasploit Framework is
contained in two libraries, MSF::CORE and MSF::BASE.
These are classes and methods in the Ruby programming language.
MSF::CORE, written as MSF colon colon CORE in Ruby notation,
provides the foundational part of the framework.
It is the source of the primary underlying functionality of the framework.
MSF::BASE provides simple wrappers to more
complicated functions in the core library.
The documentation describes these as easier to manage functions,
which hints at the power available, yet with a simpler method to
allow developers to quickly create modules.
Metasploit modules inherit core functionality from higher‑level Ruby objects.