The libraries layout

Metasploit modules are the buildup of various functions contained in different libraries, and general Ruby programming. Now, to use these functions, we first need to understand what they are. How can we trigger these functions? What number of parameters do we need to pass? Moreover, what will these functions return?

Let's have a look at how these libraries are organized; this is illustrated in the following screenshot:

As we can see in the preceding screenshot, we have the critical rex libraries along with all other essential ones in the /lib directory.

The /base and /core libraries are also a crucial set of libraries, and are located under the /msf directory:

Now, under the /msf/core libraries folder, we have libraries for all the modules we used earlier in the first chapter; this is illustrated in the following screenshot:

These library files provide the core for all modules. However, for different operations and functionalities, we can refer to any library we want. Some of the most widely used library files in most of the Metasploit modules are located in the core/exploits/ directory, as shown in the following screenshot:

As we can see, it's easy to find all the relevant libraries for various types of modules in the core/ directory. Currently, we have core libraries for exploits, payload, post-exploitation, encoders, and various other modules.

Visit the Metasploit Git repository at https://github.com/rapid7/metasploit-framework to access the complete source code.