23. Exploitation with Metasploit
23.1 What Metasploit Is
In short: Metasploit Framework is a free, open-source collection of exploits, payloads and tools that fit together.
Metasploit Framework is a free, open-source collection of exploits, payloads and tools that fit together. Instead of writing attack code from scratch, you pick a tested module, set a few options, and run it.
Key words you must know:
| Term | Meaning | Everyday picture |
|---|---|---|
| Exploit | Code that uses a specific vulnerability | The key that fits one lock |
| Payload | What runs on the target after the exploit works | What you do once inside |
| Module | Any single tool in Metasploit (exploit, scanner, etc.) | One tool in the box |
| Listener / handler | Waits for the target to connect back | You waiting by the phone |
| Session | Your live connection to a compromised host | The open line |
| Meterpreter | A powerful in-memory payload with many commands | A remote control inside |
Payload types: a bind payload opens a port on the target and you connect to it; a reverse payload makes the target connect back to you (better, because firewalls usually allow outbound). LHOST/LPORT = your Kali machine; RHOSTS/RPORT = the target.
Ravindra Bagale's Tip
Students confuse exploit and payload. A simple rule: exploit = the way in, payload = what to do once you are in. The same exploit can be used with different payloads. Interviewers almost always ask about this difference.
Ravindra Bagale's Tip – मराठी
Students exploit आणि payload मध्ये गोंधळतात. सोपा नियम: exploit = आत शिरण्याचा मार्ग, payload = आत गेल्यावर काय करायचं. एकाच exploit ला वेगवेगळे payloads लावता येतात. Interview मध्ये हा फरक नक्की विचारतात.
Ravindra Bagale's Tip – हिंदी
Students exploit और payload में उलझ जाते हैं. आसान नियम: exploit = अंदर घुसने का रास्ता, payload = अंदर जाने के बाद क्या करना है. एक ही exploit के साथ अलग-अलग payloads लगाए जा सकते हैं. Interview में यह फ़र्क ज़रूर पूछते हैं.
Practice task
In your notes, write one line each for exploit, payload, session and Meterpreter. Then explain in one sentence why a reverse payload usually works when a bind payload is blocked.