Welcome back, my novice hackers!
We've done a number of tutorials using one of my favorite hacking tools, Metasploit. In each of them, we've used the msfconsole, which can be reached through either the menu system or through simply typing "msfconsole" from the terminal.
This msfconsole puts us into an interactive mode command prompt with the Metasploit Framework. This is my favorite way to use Metasploit, but certainly not the only way that is available to us.
Metasploit has multiple ways of accessing its power and tools including a command line (msfcli), a GUI (armitage), and a web-based (msfweb). In this tutorial, we're going on a tour of Metasploit to introduce you to the inner structure and some new capabilities of Metasploit.
In each of my previous tutorials, we've started from the interactive mode of Metasploit (the msfconsole). This time, however, let's go to the Metasploit directory directly so that we can explore its structure. We can get there by typing:
bt > cd /pentest/exploits/framework
Now that we're in the Metasploit Framework directory, let's take a look around. First, let's do a listing on this directory.
If you look to the top of this long listing, you will see a directory called armitage. This is a GUI for driving Metasploit that we'll return to in another tutorial.
Also note the following files—msfcli, the command line version of Metasploit, and msfencode, the command we used previously to re-encode a payload to get past antivirus software.
Let's now explore the Metasploit modules. These are the blood and guts of Metasploit. We have, for instance, used "exploit" modules and "payload" modules. This is where they reside. Type in:
As you can see from the screenshot above, Metasploit contains multiple modules. These include:
- nops (no operations)
- post (post exploitation)
These are the key modules in Metasploit, and as you've already guessed, we haven't even begun to explore the auxiliary, nops, and post exploitation modules, although we have used the exploits, payloads, and encoders.
The module we're probably most familiar with are the exploits. This is the module that contains the exploits that take advantage of a vulnerability in an application or an operating system, which enables us to place our payload on the victim. Let's look inside. Type:
The exploits module is broken into sub-directories that are specific to the operating system we're attempting to exploit. For instance, you can see at the top the directory, aix, (IBM's proprietary UNIX operating system) exploits. As we scan down, we can see exploit directories for:
If you have done any of my Metasploit tutorials and hacks, you've likely used exploits in the windows exploits directory. Let's look around there. Type:
Now, we can see that the windows exploits are broken down into types of windows exploits. It's important to note that exploits are very specific. Not only are they operating system specific, but also application or service specific, port specific, and sometimes even language specific. Recently, we looked at exploiting the Internet Explorer in Windows 7. Let's see if we can find it in the browser directory. Type:
As you can see in the above screenshot, our ms10_046_shortcut_icon_dllloader exploit is highlighted.
If we wanted to, for instance, find an exploit in this directory to hack Adobe products from the browser, we could use our Linux skills and "grep" for it. Type:
ls -l | grep adobe
When we hit enter, the terminal filters (grep) the output and shows us only the windows browser exploits that take advantage of Adobe products.
Next, let's navigate to the payloads directory. Type:
Then we can do a long listing on that directory by typing:
We can see that payloads are broken down by types.
Let's open up singles to look around. Type:
Once again, we can see that the Metasploit Framework categorizes the payloads by operating system. Let's move to the generic directory and see whether we can find the generic shell_reverse_tcp payload that we used to get a command prompt when hacking Windows XP. Type:
As you can see in this screenshot, I have highlighted the generic reverse tcp shell that we used earlier.
In the tutorial on encoding your payload to get past AV software, we created a payload that we re-encoded using shikata_ga_nai. Once we have that payload re-encoded to be undetectable to AV software and we want to use it other exploits, we could save it here in this payloads directory to make it available again and again to get past antivirus software
I'm hoping that this brief exploration of the structure of Metasploit was enlightening. I'll try to come back in the future and further elaborate on its structure including the post exploitation, auxiliary and nops modules, but don't wait for that. Start doing your own exploration to better understand this wonderful and powerful tool to make you a better and more effective hacker.
Want to start making money as a white hat hacker? Jump-start your hacking career with our 2020 Premium Ethical Hacking Certification Training Bundle from the new Null Byte Shop and get over 60 hours of training from cybersecurity professionals.
Other worthwhile deals to check out: