Metasploit
Auxiliary Modules
Port Scan
use auxiliary/scanner/portscan/tcp
set RHOSTS 10.10.10.0/24
runDNS Enumeration
use auxiliary/gather/dns_enum
set DOMAIN target.tgt
runHost FTP Server
use auxiliary/server/ftp
set FTPROOT /tmp/ftproot
runProxy Server
Any proxied traffic matching the subnet of a route will be routed through the specified session. Use proxychains configured for socks4 to route application traffic through a Meterpreter session.
msfvenom
List Payloads
Format Options
exe
Windows executable
elf
Linux executable
aspx
ASP.NET web payload
jsp
Java Server Pages
war
Java web archive
php
PHP script
py
Python script
pl
Perl script
rb
Ruby script
raw
Raw shellcode
c
C code
ps1
PowerShell script
dll
Windows DLL
msi
Windows installer
Common Payload Generation
Encoding Payloads
Backdoored Executables
Inject payload into a legitimate executable template. The -k flag runs the original program in a separate thread so it appears to function normally.
Multi/Handler
Set up a listener to catch reverse connections from msfvenom payloads:
Run as a background job:
Meterpreter
Meterpreter uses DLL injection to reside entirely in memory. It leaves no traces on disk, uses AES-encrypted communication (MSF6+), and can migrate between processes.
How It Works
Target executes the initial stager (bind, reverse, etc.)
Stager loads a Reflective DLL
Meterpreter core initializes, establishes an AES-encrypted link
Extensions
stdapiandpriv(if admin) are loaded over AES
Core Commands
background / bg
Background the current session
exit / quit
Terminate the Meterpreter session
guid
Get the session GUID
help
Display the help menu
info
Display information about a Post module
irb
Open an interactive Ruby shell on the session
load
Load one or more Meterpreter extensions
migrate
Migrate the server to another process
run
Execute a Meterpreter script or Post module
sessions
Quickly switch to another session
sleep
Force Meterpreter to go quiet, then re-establish
transport
Change the current transport mechanism
uuid
Get the UUID for the current session
File System Commands
cd
Change directory
ls / dir
List files in current directory
pwd / getwd
Print working directory
cat
Read the contents of a file
edit
Edit a file (vim)
rm
Delete the specified file
mv
Move source to destination
cp
Copy source to destination
mkdir
Make directory
rmdir
Remove directory
upload
Upload a file or directory
download
Download a file or directory
search
Search for files
checksum
Retrieve the checksum of a file
show_mount
List all mount points/logical drives
lcd
Change local working directory
lpwd / getlwd
Print local working directory
lls
List local files
Networking Commands
arp
Display the host ARP cache
ifconfig / ipconfig
Display network interfaces
netstat
Display the network connections
portfwd
Forward a local port to a remote service
route
View and modify the routing table
resolve
Resolve hostnames on the target
getproxy
Display the current proxy configuration
System Commands
clearev
Clear the event log
execute
Execute a command
getpid
Get the current process identifier
getuid
Get the user the server is running as
getsid
Get the SID of the running user
getprivs
Attempt to enable all privileges for the current process
getenv
Get environment variable values
kill
Terminate a process
pkill
Terminate processes by name
pgrep
Filter processes by name
ps
List running processes
shell
Drop into a system command shell
sysinfo
Get information about the remote system
reboot
Reboot the remote computer
shutdown
Shut down the remote computer
reg
Modify and interact with the remote registry
steal_token
Steal an impersonation token from a process
drop_token
Relinquish any active impersonation token
rev2self
Calls RevertToSelf() on the remote machine
localtime
Display the target system's local date and time
suspend
Suspend or resume a list of processes
User Interface Commands
enumdesktops
List all accessible desktops and window stations
screenshot
Grab a screenshot of the interactive desktop
screenshare
Watch the remote user's desktop in real-time
keyscan_start
Start capturing keystrokes
keyscan_dump
Dump the keystroke buffer
keyscan_stop
Stop capturing keystrokes
keyboard_send
Send keystrokes
idletime
Returns seconds the remote user has been idle
record_mic
Record audio from the default microphone for X seconds
webcam_list
List webcams
webcam_snap
Take a snapshot from the specified webcam
webcam_stream
Play a video stream from the specified webcam
Privilege Commands
getsystem
Attempt to elevate privilege to local system
hashdump
Dump the contents of the SAM database
timestomp
Manipulate file MACE attributes
New Meterpreter Session Steps
After gaining access, insert AV path exception, write implant to disk and execute to catch callback:
Now running as a thread in the address space of the svchost.exe process.
Process Migration and Token Stealing
Use steal_token when you need to impersonate another user's security context without fully migrating into their process.
Credential Harvesting
Hashdump
Output format: Username:SID:LM hash:NTLM hash:::
LM hash aad3b435b51404eeaad3b435b51404ee = empty password. NTLM hash 31d6cfe0d16ae931b73c59d7e0c089c0 = empty password.
If hashdump prints hashes and then errors with a Ruby stack trace around priv/passwd.rb / report_creds, the collection may have succeeded but failed while storing creds in the Metasploit database. Copy the printed hashes and rerun with a post module or dump SAM/SYSTEM/SECURITY manually if needed.
Credential Collector
Kiwi (Mimikatz)
creds_all
Retrieve all credentials (parsed)
creds_kerberos
Retrieve Kerberos creds (parsed)
creds_msv
Retrieve LM/NTLM creds (parsed)
creds_ssp
Retrieve SSP creds
creds_tspkg
Retrieve TsPkg creds (parsed)
creds_wdigest
Retrieve WDigest creds (parsed)
dcsync
Retrieve user account information via DCSync
dcsync_ntlm
Retrieve user NTLM hash, SID and RID via DCSync
golden_ticket_create
Create a golden kerberos ticket
kerberos_ticket_list
List all kerberos tickets
kerberos_ticket_purge
Purge any in-use kerberos tickets
kerberos_ticket_use
Use a kerberos ticket
kiwi_cmd
Execute an arbitrary mimikatz command
lsa_dump_sam
Dump LSA SAM
lsa_dump_secrets
Dump LSA secrets
password_change
Change the password/hash of a user
wifi_list
List wifi profiles/creds for the current user
wifi_list_shared
List shared wifi profiles/creds (requires SYSTEM)
Local Exploit Suggester
Background your current session, then:
Use the suggested exploit:
Execute a Program
-H
Create the process hidden from view
-a
Arguments to pass to the command
-i
Interact with the process after creating it
-m
Execute from memory
-t
Execute with currently impersonated thread token
-s
Execute process in a given session as the session user
Powershell from Meterpreter
Powershell Extension
One-shot Commands
Incognito (Token Impersonation)
Upgrade Shell to Meterpreter
Post-Exploitation Modules
Windows Survey Modules
Winenum
Built-in enumeration using net, netsh, and wmic commands:
Output stored per-command in the path shown in the output.
Routing and Pivoting
Set Route
Autoroute Module
Port Forwarding
UAC Escalation
Change UAC to Not Notify
Requires admin:
Disable LUA (UAC)
Persistence Modules
Registry Run Key
Set RUN_NAME at minimum.
WMI Event Subscription
Requires failed login auditing enabled:
Event ID for failed logon: 4625. Set USERNAME_TRIGGER and SESSION at minimum. Cannot be run as SYSTEM or USER — needs ADMINISTRATOR.
Clearing the Event Log
Firewall and IDS/IPS Evasion
Endpoint vs Perimeter Protection
Endpoint
Software on the host (AV, anti-malware, host firewall, anti-DDoS)
Perimeter
Physical/virtual devices at the network edge (IDS/IPS, network firewalls, WAF)
Detection Methods
Signature-based
Compares packets/files against known attack pattern signatures
Heuristic / Statistical Anomaly
Behavioral comparison against established baselines
Stateful Protocol Analysis
Recognizes divergence from accepted protocol definitions
Live SOC Monitoring
Analysts using live-feed software to monitor and alert
Evasion Techniques
MSF6 AES Encryption: All Meterpreter communications are AES-encrypted, handling network-based IDS/IPS.
Backdoored Executables: Inject payload into legitimate executables using the -x template flag and -k to keep original execution:
Password-Protected Archives: Archive the payload with a password and strip the file extension. This bypasses many signature-based AV scans (flagged as unable to scan, not as malicious).
Packers: Executable compression that packs payload + decompression code into one file. The payload decompresses transparently at runtime.
UPX
Open source, widely used
The Enigma Protector
Commercial
MPRESS
Lightweight
Themida
Advanced anti-debugging
MEW
Minimal
ExeStealth
Stealth-oriented
MSF6 Changes (Evasion Improvements)
End-to-end AES encryption for all five Meterpreter implementations (Windows, Python, Java, Mettle, PHP)
SMBv3 client support with encryption
Polymorphic payload generation for Windows shellcode (instructions shuffled each generation)
DLLs resolve functions by ordinal instead of name
ReflectiveLoaderexport no longer present as text data in payload binariesMeterpreter commands encoded as integers instead of strings
Kiwi replaced old Mimikatz extension
Last updated