Metasploit Framework is one of the tools most widely used by security auditors and penetration testers. It includes a large collection of exploits and a development environment for creating custom exploits. It integrates easily with tools such as Nmap and vulnerability scanners and can be customized for specific needs.
BASIC DEFINITIONS
Exploit
Code written to take advantage of programming errors and obtain privileges on vulnerable systems or software. An exploit is used to gain control of a target machine.
Payload
The malicious part delivered by an exploit. It is the code executed on the victim machine after exploitation.
0-Day Exploit
Malicious code that allows an attacker to gain control of a vulnerable system before the vulnerability is known to users or vendors and before a patch is available.
Metasploit
A collection of tools that enables penetration testers to develop and execute exploits against target machines to evaluate security.
Modules
Features that make Metasploit easier to use. Common module types include:
- Auxiliary – External tools such as scanners and sniffers.
- Exploits – Contains exploit code.
- Payloads – Stores payloads to be used with exploits.
MSFVenom
A combination of msfpayload and msfencode, making it easier to generate and obfuscate payloads from a single console.
MSFCONSOLE COMMANDS
| Command | Description |
|---|---|
back | Exit the current module/exploit context |
check | Check whether the target is vulnerable |
connect | Connect to a remote host |
exploit | Run the loaded exploit |
run | Execute the loaded module |
irb | Start the Ruby interpreter |
jobs | List background jobs |
load | Load a plugin |
unload | Unload a plugin |
loadpath | Load modules from a custom directory |
resource | Execute commands from a script file |
route | Manage routing tables |
info | Display module information |
set | Set module options |
unset | Remove an option value |
sessions | List/manage active sessions |
search | Search for modules |
show | Show exploits, payloads, options, etc. |
setg | Set global variables |
save | Save configuration |
use | Select a module |
Examples:
show auxiliary
show exploits
show payloads
show options
show targets
show advanced
show encoders
show nops
show evasion
METERPRETER COMMANDS
| Command | Description |
|---|---|
sysinfo | Display system information |
ps | List running processes |
kill <PID> | Terminate a process |
getuid | Show current user ID |
upload | Upload a file |
download | Download a file |
pwd / lpwd | Show working directory |
cd / lcd | Change directory |
cat | Display file contents |
bglist | List background scripts |
bgrun | Run a script in background |
bgkill | Kill a background script |
background | Send session to background |
edit | Edit a file |
shell | Spawn a system shell |
migrate | Move to another process |
idletime | Show user idle time |
screenshot | Take a screenshot |
clearev | Clear event logs |
? | Show help |
exit / quit | Exit Meterpreter |
shutdown / reboot | Restart or shut down the system |
use | Load an extension |
Additional:
channel Show active channels
NETWORK COMMANDS
| Command | Description |
|---|---|
ipconfig | Show network interface configuration |
portfwd | Port forwarding |
route | View/edit routing table |
USER INTERFACE / OUTPUT COMMANDS
| Command | Description |
|---|---|
enumdesktops | List available desktops |
getdesktop | Show current desktop |
keyscan_start | Start keylogger |
keyscan_stop | Stop keylogger |
keyscan_dump | Dump captured keystrokes |
set_desktop | Change desktop |
PROCESS MANAGEMENT COMMANDS
| Command | Description |
|---|---|
getpid | Show process ID |
getuid | Show user ID |
ps | List processes |
kill | Terminate process |
getprivs | List privileges |
reg | Access system registry |
shell | Open a shell |
execute | Execute a command |
migrate | Move into another process |
MSFVENOM COMMAND OPTIONS
| Option | Description |
|---|---|
-p | Payload options |
-l | List modules (payloads, encoders) |
-f | Output format |
-e | Encoder to use |
-a | Target architecture |
-s | Maximum payload size |
-b | Bad characters to avoid |
-i | Number of encoding iterations |
-x | Use a custom template file |
-o | Save payload |
-h | Help |