Chapter 2: Reinventing Metasploit
We have covered the basics of Metasploit, so now we can move further into the underlying coding part of Metasploit Framework. We will start with the basics of Ruby programming to understand various syntaxes and their semantics. This chapter will make it easy for you to write Metasploit modules. In this chapter, we will see how we can design and fabricate various Metasploit modules with the functionality of our choice. We will also look at how we can create custom post-exploitation modules, which will help us gain better control of the exploited machine. Consider a scenario where the number of systems under the scope of the penetration tests is massive, and we crave a post-exploitation feature such as downloading a particular file from all the exploited systems. Manually, downloading a specific file from each system is not only time-consuming but inefficient. Therefore, in a scenario like this, we can create a custom post-exploitation script that will automatically download the file from all of the compromised systems.
This chapter kicks off with the basics of Ruby programming in the context of Metasploit and ends with developing various Metasploit modules. In this chapter, we will cover the following topics:
- The basics of Ruby programming in the context of Metasploit modules
- Understanding Metasploit modules
- Developing an auxiliary – the FTP scanner module
- Developing an auxiliary – the SSH brute force module
- Developing post-exploitation modules
- Performing post-exploitation with RailGun
Now, let's understand the basics of Ruby programming and gather the required essentials we need to code Metasploit modules.
Before we delve deeper into coding Metasploit modules, we must have knowledge of the core features of Ruby programming that are required to design these modules. Why do we need to learn Ruby to develop Metasploit modules? The following key points will help us understand the answer to this question:
- First and foremost, Metasploit is developed in Ruby.
- Constructing an automated class for reusable code is a feature of the Ruby language that matches the needs of Metasploit.
- Ruby is an object-oriented style of programming that again matches the needs of Metasploit.