What is Metasploit?
Metasploit is an open-source framework that provides information about security vulnerabilities and aids in penetration testing and IDS signature development. It was created in 2003 by H.D Moore and is currently owned and maintained by Rapid 7[1][2]. Metasploit is used mainly by penetration testers to identify vulnerabilities, execute exploit code, and run payloads to compromise target systems.
Metasploit has two versions, the free “Metasploit Framework” and the paid “Metasploit Pro.” The framework edition is already included in Kali and is completely free and open source. Metasploit provides access to an extensive and continually growing database of exploits. The framework also includes a variety of payloads and a ranking system to gauge the effectiveness of exploits[1].
Metasploit can be used to test the vulnerability of computer systems or to break into remote systems. Like many information security tools, Metasploit can be used for both legitimate and unauthorized activities. Since the acquisition of the Metasploit Framework, Rapid7 has added two open core proprietary editions called Metasploit Express and Metasploit Pro[3].
Metasploit’s emerging position as the de facto exploit development framework led to the release of software vulnerability advisories often accompanied by a third party Metasploit exploit module that highlights the exploitability, risk, and remediation of that particular bug. Metasploit 3.0 began to include fuzzing tools, used to discover software vulnerabilities, rather than just exploits for known bugs[3].
Metasploit has many benefits. It provides access to an extensive and continually growing database of exploits. The framework also includes a variety of payloads and a ranking system to gauge the effectiveness of exploits. And It's completely free and open source[1].
Metasploit has many commands that can be used to navigate the console, select the exploit or payload to use in an attack, launch an attack, and execute post-exploitation modules.
Metasploit is a powerful tool that can be used for both offensive and defensive security purposes. It contains over 1500 exploits and has a practical user interface.
### Basic Commands
The basic commands in Metasploit are used to navigate the console and select the exploit or payload to use in an attack. The following are the most commonly used basic commands in Metasploit:
- `msfconsole`: This command is used to launch the Metasploit console, which is the primary interface for interacting with the framework.
- `help` or `?`: These commands are used to display a list of available commands in the Metasploit console.
- `search`: This command is used to search for specific exploits or payloads within the Metasploit framework.
- `use`: This command is used to select a specific exploit or payload to use in an attack.
- `show`: This command is used to display information about various components of the Metasploit framework.
- `set`: This command is used to set various options for a selected exploit or payload.
- `exploit` or `run`: These commands are used to launch an attack using the selected exploit or payload.
- `back`: This command is used to go back to the previous menu.
- `exit` or `quit`: These commands are used to exit the Metasploit console.
For example, to use the `exploit/windows/smb/ms08_067_netapi` exploit, you can type `use exploit/windows/smb/ms08_067_netapi`. To set the target IP address for an exploit, you can type `set RHOST 192.168.1.100`. To launch an attack using the selected exploit or payload, you can type `exploit`.
### Exploit Commands
The exploit commands in Metasploit are used to set variables and show the exploit options, targets, payloads, encoders, nops, and the advanced and evasion options. The following are the most commonly used exploit commands in Metasploit:
- `set`: This command is used to set various options for a selected exploit or payload.
- `show`: This command is used to display information about various components of the Metasploit framework.
- `run` or `exploit`: These commands are used to run the selected exploit or payload.
- `back`: This command is used to go back to the previous menu.
For example, to set the target IP address for an exploit, you can type `set RHOST 192.168.1.100`. To show the available payloads for an exploit, you can type `show payloads`. To run the selected exploit or payload, you can type `run`.
### Meterpreter Commands
Meterpreter is a powerful post-exploitation tool that provides a command shell on a compromised host. The following are the most commonly used Meterpreter commands in Metasploit:
- `sysinfo`: This command is used to display system information about the compromised host.
- `getuid`: This command is used to display the current user ID on the compromised host.
- `ps`: This command is used to display the running processes on the compromised host.
- `shell`: This command is used to open a shell on the compromised host.
- `download`: This command is used to download a file from the compromised host.
- `upload`: This command is used to upload a file to the compromised host.
For example, to display system information about the compromised host, you can type `sysinfo`. To open a shell on the compromised host, you can type `shell`.
### Auxiliary Commands
Auxiliary modules in Metasploit are used for information gathering and other tasks that do not involve exploiting a vulnerability. The following are the most commonly used auxiliary commands in Metasploit:
- `search`: This command is used to search for specific auxiliary modules within the Metasploit framework.
- `use`: This command is used to select a specific auxiliary module to use.
- `set`: This command is used to set various options for a selected auxiliary module.
- `run`: This command is used to run the selected auxiliary module.
For example, to search for all auxiliary modules related to the SMB protocol, you can type `search smb`. To use the `auxiliary/scanner/smb/smb_version` module, you can type `use auxiliary/scanner/smb/smb_version`. To set the target IP address for the module, you can type `set RHOSTS 192.168.1.0/24`. To run the selected auxiliary module, you can type `run`.
### Conclusion
In conclusion, Metasploit is a powerful tool that can be used for both offensive and defensive security purposes. It contains over 1500 exploits and has a practical user interface. In this block, we have explained the commands used in the Metasploit free version by giving examples. These commands can be used to navigate the console, select the exploit or payload to use in an attack, launch an attack, and execute post-exploitation modules. It is important to note that Metasploit should only be used for legitimate and authorized security testing purposes.
Citations:
[1] https://www.stationx.net/metasploit-tutorial/
[2] https://en.wikipedia.org/wiki/Metasploit
[3] https://pentest.tonyng.net/list-of-metasploit-commands-cheatsheet/
[4] https://www.hackingloops.com/metasploit-commands/
[5] https://github.com/rapid7/metasploit-framework
[6] https://www.tutorialspoint.com/metasploit/metasploit_basic_commands.htm