Conducting Network Penetration Test
When to Use
- Assessing the security posture of internal or external network infrastructure before or after deployment
- Validating firewall rules, network segmentation, and access controls under realistic attack conditions
- Identifying exploitable vulnerabilities in network services, protocols, and configurations
- Meeting compliance requirements for PCI-DSS, HIPAA, SOC 2, or ISO 27001 that mandate periodic penetration testing
- Evaluating the effectiveness of IDS/IPS, SIEM, and SOC detection capabilities against real attack traffic
Do not use for testing networks without explicit written authorization from the asset owner, against production systems without a pre-approved change window and rollback plan, or for denial-of-service testing unless explicitly scoped and authorized.
Prerequisites
- Signed Rules of Engagement (RoE) document specifying target IP ranges, excluded hosts, testing hours, and emergency contacts
- Written authorization letter (get-out-of-jail letter) from the network owner
- Dedicated testing laptop with Kali Linux or equivalent distribution with up-to-date tools
- VPN or direct network access to the target scope as defined in the RoE
- Out-of-band communication channel with the client's incident response team
- Scope document listing in-scope IP ranges, domains, and any explicitly excluded systems (medical devices, SCADA, critical infrastructure)
Workflow
Step 1: Pre-Engagement and Scope Validation
Validate the scope by confirming IP ranges with the client. Verify that all IP addresses in scope are owned by the client using ARIN/RIPE WHOIS lookups. Confirm testing windows, escalation procedures, and any sensitivity constraints. Set up the testing environment with a dedicated VM, VPN connection, and logging enabled on all tools. Create a timestamped activity log that records every command executed, every scan launched, and every exploit attempted throughout the engagement.
Step 2: Host Discovery and Network Mapping
Identify live hosts within the authorized scope using layered discovery techniques:
- ICMP sweep:
nmap -sn -PE -PP -PM 10.10.0.0/16 -oA discovery_icmp to find hosts responding to ping
- ARP scan (internal networks):
nmap -sn -PR 10.10.0.0/24 -oA discovery_arp or arp-scan -l for local subnet enumeration
- TCP SYN discovery:
nmap -sn -PS21,22,25,80,443,445,3389,8080 10.10.0.0/16 -oA discovery_tcp to find hosts with ICMP blocked
- UDP discovery:
nmap -sn -PU53,161,500 10.10.0.0/16 -oA discovery_udp for hosts only responding on UDP
Consolidate live hosts into a target list. Map the network topology by identifying gateways, VLAN boundaries, and trust relationships using traceroute and SNMP community string guessing where authorized.
Step 3: Port Scanning and Service Enumeration
Perform detailed port scanning on discovered hosts:
- Full TCP scan:
nmap -sS -p- --min-rate 1000 -T4 -oA full_tcp <target> to identify all open TCP ports
- Top UDP ports:
nmap -sU --top-ports 200 -T4 -oA top_udp <target> for commonly exploitable UDP services
- Service version detection:
nmap -sV -sC -p <open_ports> -oA service_enum <target> to fingerprint service versions and run default NSE scripts
- OS fingerprinting:
nmap -O --osscan-guess -oA os_detection <target> to identify operating systems
Enumerate discovered services in depth using protocol-specific tools:
- SMB:
enum4linux -a <target>, crackmapexec smb <target> --shares
- SNMP:
snmpwalk -v2c -c public <target>
- DNS:
dig axfr @<dns_server> <domain> for zone transfer attempts
- LDAP:
ldapsearch -x -H ldap://<target> -b "dc=example,dc=com"
Step 4: Vulnerability Identification
Correlate discovered service versions against known vulnerability databases:
- Run
nmap --script vuln -p <ports> <target> for NSE vulnerability scripts
- Use
searchsploit <service> <version> to query the Exploit-DB offline database
- Cross-reference with NVD (National Vulnerability Database) and CVE records for confirmed vulnerabilities
- Check for default credentials on management interfaces (Tomcat Manager, Jenkins, phpMyAdmin, database consoles)
- Test for common misconfigurations: anonymous FTP, open SMTP relays, unrestricted SNMP communities, NFS exports without authentication
Prioritize vulnerabilities by CVSS score, exploitability, and business impact. Document each finding with CVE identifier, affected host, service, and version.
Step 5: Exploitation
Attempt controlled exploitation of validated vulnerabilities using the principle of minimum necessary access:
- Metasploit Framework:
msfconsole with appropriate exploit modules matched to confirmed vulnerabilities. Set RHOSTS, RPORT, and payload options. Prefer bind/reverse TCP Meterpreter for post-exploitation flexibility.
- Manual exploitation: Use public proof-of-concept exploits from Exploit-DB after code review. Compile and modify as needed for the target environment.
- Credential attacks: Use
hydra or crackmapexec for password spraying against discovered services (SSH, RDP, SMB, HTTP basic auth) using common credential lists. Respect lockout policies.
- Pass-the-hash / relay: If NTLM hashes are obtained, attempt pass-the-hash with
impacket-psexec or relay attacks with impacket-ntlmrelayx where SMB signing is disabled.
Document every exploitation attempt including failures. Capture screenshots of successful compromises showing hostname, IP, current user, and privilege level.
Step 6: Post-Exploitation and Pivoting
After gaining access to a host, demonstrate business impact:
- Privilege escalation: Check for local privilege escalation paths using
linpeas.sh (Linux) or winPEAS.exe (Windows). Look for misconfigured services, SUID binaries, unquoted service paths, or kernel exploits.
- Credential harvesting: Extract stored credentials from memory (
mimikatz), files (config files, browser stores), or cached hashes (hashdump).
- Lateral movement: Use obtained credentials to pivot to additional systems. Test network segmentation by attempting to reach out-of-scope networks from compromised hosts.
- Data access demonstration: Identify sensitive data accessible from compromised systems (PII databases, file shares, backup files) and document access without exfiltrating actual data.
Maintain detailed notes on every pivot point, credential obtained, and system accessed to build the attack chain narrative.
Step 7: Cleanup and Reporting
Remove all testing artifacts from compromised systems:
- Delete uploaded tools, shells, and temporary files
- Remove any accounts created during testing
- Revert configuration changes made during exploitation
- Verify cleanup by re-scanning affected hosts
Prepare the penetration test report with executive summary, methodology description, finding details with CVSS scores, proof-of-concept evidence, and prioritized remediation recommendations.
Key Concepts
| Term |
Definition |
| Rules of Engagement (RoE) |
Formal document defining the scope, boundaries, testing hours, authorized actions, and escalation procedures for a penetration test |
| Pivot |
Using a compromised host as a relay point to access additional network segments not directly reachable from the tester's position |
| Service Enumeration |
The process of identifying running services, their versions, and configurations on discovered hosts to map the attack surface |
| Credential Spraying |
Testing a small number of commonly used passwords against many accounts simultaneously to avoid account lockout thresholds |
| CVSS |
Common Vulnerability Scoring System; an industry-standard framework for rating the severity of vulnerabilities on a 0-10 scale |
| Lateral Movement |
Techniques used to move from one compromised system to another within a network, expanding the scope of access |
| Post-Exploitation |
Activities performed after initial compromise including privilege escalation, persistence, credential harvesting, and data access |
Tools & Systems
- Nmap: Network discovery, port scanning, service enumeration, and vulnerability detection via the Nmap Scripting Engine (NSE)
- Metasploit Framework: Exploitation framework providing exploit modules, payloads, encoders, and post-exploitation tools for validated vulnerability exploitation
- CrackMapExec: Swiss-army knife for Windows/Active Directory environments supporting SMB, WinRM, LDAP, and MSSQL enumeration and exploitation
- Impacket: Python library providing low-level programmatic access to network protocols (SMB, MSRPC, Kerberos) used for relay attacks and remote execution
- Burp Suite: Web application proxy used when network services expose HTTP-based management interfaces
Common Scenarios
Scenario: Internal Network Penetration Test for a Financial Institution
Context: The client is a mid-size bank requiring PCI-DSS compliance. Scope includes the internal corporate network (10.10.0.0/16), excluding payment processing systems in a separate VLAN. Testing window is Monday-Friday 20:00-06:00 to minimize impact on operations.
Approach:
- Perform ARP-based host discovery on accessible subnets and TCP SYN discovery for hosts with ICMP disabled
- Conduct full port scans on all discovered hosts, prioritizing Windows servers and domain controllers
- Enumerate SMB shares, SNMP communities, and web management interfaces for quick wins
- Identify and exploit an unpatched Apache Tomcat instance with default credentials to gain initial foothold
- Escalate privileges via a local Windows kernel vulnerability, then extract cached domain credentials with Mimikatz
- Demonstrate lateral movement to the database server containing customer records, proving inadequate network segmentation
- Document the complete attack path from initial access to sensitive data, with remediation steps for each vulnerability
Pitfalls:
- Scanning too aggressively during business hours and triggering IDS alerts or service disruptions
- Failing to verify that all target IPs are actually owned by the client before scanning
- Not documenting exploitation attempts that failed, missing the opportunity to report on effective controls
- Forgetting to clean up Meterpreter sessions and uploaded tools after testing
Output Format
## Finding: Unpatched Apache Tomcat with Default Credentials
**ID**: NET-001
**Severity**: Critical (CVSS 9.8)
**Affected Host**: 10.10.5.23 (tomcat-prod.internal.corp)
**Service**: Apache Tomcat 8.5.31 on port 8080
**CVE**: CVE-2019-0232
**Description**:
The Apache Tomcat instance on 10.10.5.23:8080 is running version 8.5.31, which is
vulnerable to CVE-2019-0232 (remote code execution via CGI Servlet). Additionally,
the Tomcat Manager interface is accessible with default credentials (tomcat:tomcat),
allowing deployment of arbitrary WAR files.
**Proof of Concept**:
1. Accessed http://10.10.5.23:8080/manager/html with credentials tomcat:tomcat
2. Deployed malicious WAR file containing a reverse shell payload
3. Obtained command execution as NT AUTHORITY\SYSTEM
**Impact**:
Full system compromise of the Tomcat server. From this host, the tester
pivoted to 3 additional systems on the same subnet using harvested credentials,
ultimately accessing the customer database containing 50,000+ records.
**Remediation**:
1. Immediately change default Tomcat Manager credentials
2. Upgrade Apache Tomcat to the latest stable release (currently 10.1.x)
3. Restrict access to the Tomcat Manager interface to authorized management IPs only
4. Implement network segmentation between web servers and database tier
1---
2name: conducting-network-penetration-test
3description: 'Conducts comprehensive network penetration tests against authorized
4 target environments by performing host discovery, port scanning, service enumeration,
5 vulnerability identification, and controlled exploitation to assess the security
6 posture of network infrastructure. The tester follows PTES methodology from reconnaissance
7 through post-exploitation and reporting. Activates for requests involving network
8 pentest, infrastructure security assessment, internal network testing, or external
9 perimeter testing.
10
11 '
12domain: cybersecurity
13subdomain: penetration-testing
14tags:
15- network-pentest
16- Nmap
17- Metasploit
18- vulnerability-exploitation
19- infrastructure-security
20version: 1.0.0
21author: mahipal
22license: Apache-2.0
23nist_csf:
24- ID.RA-01
25- ID.RA-06
26- GV.OV-02
27- DE.AE-07
28mitre_attack:
29- T1046
30- T1595.002
31- T1190
32- T1210
33- T1021
34- T1078
35source: https://github.com/mukul975/Anthropic-Cybersecurity-Skills
36source_commit: 04450304b12645cb2b974ab96d28c0664758a88d
37metadata:
38 source: https://skillmd.com/skills/yanacuti1121/conducting-network-penetration-test
39---
40
41# Conducting Network Penetration Test
42
43## When to Use
44
45- Assessing the security posture of internal or external network infrastructure before or after deployment
46- Validating firewall rules, network segmentation, and access controls under realistic attack conditions
47- Identifying exploitable vulnerabilities in network services, protocols, and configurations
48- Meeting compliance requirements for PCI-DSS, HIPAA, SOC 2, or ISO 27001 that mandate periodic penetration testing
49- Evaluating the effectiveness of IDS/IPS, SIEM, and SOC detection capabilities against real attack traffic
50
51**Do not use** for testing networks without explicit written authorization from the asset owner, against production systems without a pre-approved change window and rollback plan, or for denial-of-service testing unless explicitly scoped and authorized.
52
53## Prerequisites
54
55- Signed Rules of Engagement (RoE) document specifying target IP ranges, excluded hosts, testing hours, and emergency contacts
56- Written authorization letter (get-out-of-jail letter) from the network owner
57- Dedicated testing laptop with Kali Linux or equivalent distribution with up-to-date tools
58- VPN or direct network access to the target scope as defined in the RoE
59- Out-of-band communication channel with the client's incident response team
60- Scope document listing in-scope IP ranges, domains, and any explicitly excluded systems (medical devices, SCADA, critical infrastructure)
61
62## Workflow
63
64### Step 1: Pre-Engagement and Scope Validation
65
66Validate the scope by confirming IP ranges with the client. Verify that all IP addresses in scope are owned by the client using ARIN/RIPE WHOIS lookups. Confirm testing windows, escalation procedures, and any sensitivity constraints. Set up the testing environment with a dedicated VM, VPN connection, and logging enabled on all tools. Create a timestamped activity log that records every command executed, every scan launched, and every exploit attempted throughout the engagement.
67
68### Step 2: Host Discovery and Network Mapping
69
70Identify live hosts within the authorized scope using layered discovery techniques:
71
72- **ICMP sweep**: `nmap -sn -PE -PP -PM 10.10.0.0/16 -oA discovery_icmp` to find hosts responding to ping
73- **ARP scan** (internal networks): `nmap -sn -PR 10.10.0.0/24 -oA discovery_arp` or `arp-scan -l` for local subnet enumeration
74- **TCP SYN discovery**: `nmap -sn -PS21,22,25,80,443,445,3389,8080 10.10.0.0/16 -oA discovery_tcp` to find hosts with ICMP blocked
75- **UDP discovery**: `nmap -sn -PU53,161,500 10.10.0.0/16 -oA discovery_udp` for hosts only responding on UDP
76
77Consolidate live hosts into a target list. Map the network topology by identifying gateways, VLAN boundaries, and trust relationships using traceroute and SNMP community string guessing where authorized.
78
79### Step 3: Port Scanning and Service Enumeration
80
81Perform detailed port scanning on discovered hosts:
82
83- **Full TCP scan**: `nmap -sS -p- --min-rate 1000 -T4 -oA full_tcp <target>` to identify all open TCP ports
84- **Top UDP ports**: `nmap -sU --top-ports 200 -T4 -oA top_udp <target>` for commonly exploitable UDP services
85- **Service version detection**: `nmap -sV -sC -p <open_ports> -oA service_enum <target>` to fingerprint service versions and run default NSE scripts
86- **OS fingerprinting**: `nmap -O --osscan-guess -oA os_detection <target>` to identify operating systems
87
88Enumerate discovered services in depth using protocol-specific tools:
89- SMB: `enum4linux -a <target>`, `crackmapexec smb <target> --shares`
90- SNMP: `snmpwalk -v2c -c public <target>`
91- DNS: `dig axfr @<dns_server> <domain>` for zone transfer attempts
92- LDAP: `ldapsearch -x -H ldap://<target> -b "dc=example,dc=com"`
93
94### Step 4: Vulnerability Identification
95
96Correlate discovered service versions against known vulnerability databases:
97
98- Run `nmap --script vuln -p <ports> <target>` for NSE vulnerability scripts
99- Use `searchsploit <service> <version>` to query the Exploit-DB offline database
100- Cross-reference with NVD (National Vulnerability Database) and CVE records for confirmed vulnerabilities
101- Check for default credentials on management interfaces (Tomcat Manager, Jenkins, phpMyAdmin, database consoles)
102- Test for common misconfigurations: anonymous FTP, open SMTP relays, unrestricted SNMP communities, NFS exports without authentication
103
104Prioritize vulnerabilities by CVSS score, exploitability, and business impact. Document each finding with CVE identifier, affected host, service, and version.
105
106### Step 5: Exploitation
107
108Attempt controlled exploitation of validated vulnerabilities using the principle of minimum necessary access:
109
110- **Metasploit Framework**: `msfconsole` with appropriate exploit modules matched to confirmed vulnerabilities. Set RHOSTS, RPORT, and payload options. Prefer bind/reverse TCP Meterpreter for post-exploitation flexibility.
111- **Manual exploitation**: Use public proof-of-concept exploits from Exploit-DB after code review. Compile and modify as needed for the target environment.
112- **Credential attacks**: Use `hydra` or `crackmapexec` for password spraying against discovered services (SSH, RDP, SMB, HTTP basic auth) using common credential lists. Respect lockout policies.
113- **Pass-the-hash / relay**: If NTLM hashes are obtained, attempt pass-the-hash with `impacket-psexec` or relay attacks with `impacket-ntlmrelayx` where SMB signing is disabled.
114
115Document every exploitation attempt including failures. Capture screenshots of successful compromises showing hostname, IP, current user, and privilege level.
116
117### Step 6: Post-Exploitation and Pivoting
118
119After gaining access to a host, demonstrate business impact:
120
121- **Privilege escalation**: Check for local privilege escalation paths using `linpeas.sh` (Linux) or `winPEAS.exe` (Windows). Look for misconfigured services, SUID binaries, unquoted service paths, or kernel exploits.
122- **Credential harvesting**: Extract stored credentials from memory (`mimikatz`), files (config files, browser stores), or cached hashes (`hashdump`).
123- **Lateral movement**: Use obtained credentials to pivot to additional systems. Test network segmentation by attempting to reach out-of-scope networks from compromised hosts.
124- **Data access demonstration**: Identify sensitive data accessible from compromised systems (PII databases, file shares, backup files) and document access without exfiltrating actual data.
125
126Maintain detailed notes on every pivot point, credential obtained, and system accessed to build the attack chain narrative.
127
128### Step 7: Cleanup and Reporting
129
130Remove all testing artifacts from compromised systems:
131
132- Delete uploaded tools, shells, and temporary files
133- Remove any accounts created during testing
134- Revert configuration changes made during exploitation
135- Verify cleanup by re-scanning affected hosts
136
137Prepare the penetration test report with executive summary, methodology description, finding details with CVSS scores, proof-of-concept evidence, and prioritized remediation recommendations.
138
139## Key Concepts
140
141| Term | Definition |
142|------|------------|
143| **Rules of Engagement (RoE)** | Formal document defining the scope, boundaries, testing hours, authorized actions, and escalation procedures for a penetration test |
144| **Pivot** | Using a compromised host as a relay point to access additional network segments not directly reachable from the tester's position |
145| **Service Enumeration** | The process of identifying running services, their versions, and configurations on discovered hosts to map the attack surface |
146| **Credential Spraying** | Testing a small number of commonly used passwords against many accounts simultaneously to avoid account lockout thresholds |
147| **CVSS** | Common Vulnerability Scoring System; an industry-standard framework for rating the severity of vulnerabilities on a 0-10 scale |
148| **Lateral Movement** | Techniques used to move from one compromised system to another within a network, expanding the scope of access |
149| **Post-Exploitation** | Activities performed after initial compromise including privilege escalation, persistence, credential harvesting, and data access |
150
151## Tools & Systems
152
153- **Nmap**: Network discovery, port scanning, service enumeration, and vulnerability detection via the Nmap Scripting Engine (NSE)
154- **Metasploit Framework**: Exploitation framework providing exploit modules, payloads, encoders, and post-exploitation tools for validated vulnerability exploitation
155- **CrackMapExec**: Swiss-army knife for Windows/Active Directory environments supporting SMB, WinRM, LDAP, and MSSQL enumeration and exploitation
156- **Impacket**: Python library providing low-level programmatic access to network protocols (SMB, MSRPC, Kerberos) used for relay attacks and remote execution
157- **Burp Suite**: Web application proxy used when network services expose HTTP-based management interfaces
158
159## Common Scenarios
160
161### Scenario: Internal Network Penetration Test for a Financial Institution
162
163**Context**: The client is a mid-size bank requiring PCI-DSS compliance. Scope includes the internal corporate network (10.10.0.0/16), excluding payment processing systems in a separate VLAN. Testing window is Monday-Friday 20:00-06:00 to minimize impact on operations.
164
165**Approach**:
1661. Perform ARP-based host discovery on accessible subnets and TCP SYN discovery for hosts with ICMP disabled
1672. Conduct full port scans on all discovered hosts, prioritizing Windows servers and domain controllers
1683. Enumerate SMB shares, SNMP communities, and web management interfaces for quick wins
1694. Identify and exploit an unpatched Apache Tomcat instance with default credentials to gain initial foothold
1705. Escalate privileges via a local Windows kernel vulnerability, then extract cached domain credentials with Mimikatz
1716. Demonstrate lateral movement to the database server containing customer records, proving inadequate network segmentation
1727. Document the complete attack path from initial access to sensitive data, with remediation steps for each vulnerability
173
174**Pitfalls**:
175- Scanning too aggressively during business hours and triggering IDS alerts or service disruptions
176- Failing to verify that all target IPs are actually owned by the client before scanning
177- Not documenting exploitation attempts that failed, missing the opportunity to report on effective controls
178- Forgetting to clean up Meterpreter sessions and uploaded tools after testing
179
180## Output Format
181
182```
183## Finding: Unpatched Apache Tomcat with Default Credentials
184
185**ID**: NET-001
186**Severity**: Critical (CVSS 9.8)
187**Affected Host**: 10.10.5.23 (tomcat-prod.internal.corp)
188**Service**: Apache Tomcat 8.5.31 on port 8080
189**CVE**: CVE-2019-0232
190
191**Description**:
192The Apache Tomcat instance on 10.10.5.23:8080 is running version 8.5.31, which is
193vulnerable to CVE-2019-0232 (remote code execution via CGI Servlet). Additionally,
194the Tomcat Manager interface is accessible with default credentials (tomcat:tomcat),
195allowing deployment of arbitrary WAR files.
196
197**Proof of Concept**:
1981. Accessed http://10.10.5.23:8080/manager/html with credentials tomcat:tomcat
1992. Deployed malicious WAR file containing a reverse shell payload
2003. Obtained command execution as NT AUTHORITY\SYSTEM
201
202**Impact**:
203Full system compromise of the Tomcat server. From this host, the tester
204pivoted to 3 additional systems on the same subnet using harvested credentials,
205ultimately accessing the customer database containing 50,000+ records.
206
207**Remediation**:
2081. Immediately change default Tomcat Manager credentials
2092. Upgrade Apache Tomcat to the latest stable release (currently 10.1.x)
2103. Restrict access to the Tomcat Manager interface to authorized management IPs only
2114. Implement network segmentation between web servers and database tier
212```