Conducting a penetration test with Metasploit
After setting up Kali Linux, we are now ready to perform our first penetration test with Metasploit. However, before we start the test, let's recall some of the essential functions and terminologies used in the Metasploit framework.
Recalling the basics of Metasploit
After we run Metasploit, we can list all the useful commands available in the framework by typing help or ? in the Metasploit console. Let's recall the basic terms used in Metasploit, which are as follows:
- Exploits: This is a piece of code that, when executed, will exploit the vulnerability of the target.
- Payload: This is a piece of code that runs at the target after successful exploitation. It defines the actions we want to perform on the target system.
- Auxiliary: These are modules that provide additional functionalities such as scanning, fuzzing, sniffing, and much more.
- Encoders: Encoders are used to obfuscate modules to avoid detection by a protection mechanism such as an antivirus or a firewall.
- Meterpreter: Meterpreter is a payload that uses in-memory DLL injection stagers. It provides a variety of functions to perform at the target, which makes it a popular choice.
Now, let's recall some of the basic commands of Metasploit that we will use in this chapter. Let's see what they are supposed to do:
Command | Usage | Example |
| To select a particular module to start working with |
|
| To see the list of available modules of a particular type |
|
| To set a value to a particular object |
|
| To set a value to a particular object globally, so the values do not change when a module is switched on |
|
| To launch an auxiliary module after all the required options are set |
|
| To launch an exploit |
|
| To unselect a module and move back |
|
| To list the information related to a particular exploit/module/auxiliary |
|
| To find a particular module |
|
| To check whether a particular target is vulnerable to the exploit or not |
|
| To list the available sessions |
|
Let's have a look at the basic Meterpreter commands as well:
Meterpreter commands | Usage | Example |
| To list system information of the compromised host |
|
| To list the network interfaces on the compromised host |
|
| List of IP and MAC addresses of hosts connected to the target |
|
| To send an active session to the background |
|
| To drop a cmd shell on the target |
|
| To get the current user's details |
|
| To escalate privileges and gain SYSTEM access |
|
| To gain the process ID of the meterpreter access |
|
| To list all the processes running on the target |
|
Since we have now recalled the basics of Metasploit commands, let's have a look at the benefits of using Metasploit over traditional tools and scripts in the next section.
Note
If you are using Metasploit for the very first time, refer to https://www.offensive-security.com/metasploit-unleashed/msfconsole-commands/ for more information on basic commands.