Objective
Simulate the configuration of port mirroring on a managed switch, analyze the risks of unauthorized access, and implement security measures to prevent misuse.
Scenario
As a network security engineer, you are tasked with securing the network against unauthorized use of port mirroring. Port mirroring is a valuable feature for monitoring network traffic but can be misused by malicious actors to eavesdrop on sensitive data. In this exercise, you’ll configure port mirroring, capture traffic using Wireshark, and implement mitigation strategies.
⚠️ Important: Perform this exercise in a legal and controlled lab environment. Unauthorized traffic interception is illegal and unethical.
Lab Instructions
Step 1: Configure Port Mirroring on a Managed Switch
- Environment:
- Switch: Managed switch with port mirroring capability.
- Source Port (Port 1): Connected to a client device (e.g., PC1).
- Destination Port (Port 2): Connected to a monitoring machine (e.g., PC2 running Wireshark).
a. Access the Switch
- Connect to the switch via SSH, Telnet, or console.
b. Configure Port Mirroring (Cisco Example)
configure terminal
monitor session 1 source interface FastEthernet0/1
monitor session 1 destination interface FastEthernet0/2
end
write memory
- Port 1 (FastEthernet0/1): Source port (traffic to be mirrored).
- Port 2 (FastEthernet0/2): Destination port (where traffic is mirrored).
Step 2: Capture Mirrored Traffic Using Wireshark
On the Monitoring Machine (PC2), install Wireshark:
sudo apt update
sudo apt install wireshark -y
Launch Wireshark and select the mirrored network interface.
Start capturing packets and observe the traffic from PC1.
Step 3: Analyze Captured Data
- Review the captured packets:
- Analyze protocols in use (HTTP, DNS, etc.).
- Look for sensitive information (e.g., credentials in plaintext protocols).
Step 4: Discuss Risks of Unauthorized Port Mirroring
- Eavesdropping: Attackers can capture sensitive data, such as passwords or confidential documents.
- Data Exfiltration: Mirrored traffic could be redirected to unauthorized external devices.
- Network Mapping: Attackers can map the network by analyzing mirrored traffic.
Step 5: Mitigate Port Mirroring Misuse
a. Disable Unused Ports
Shut down unused ports on the switch to prevent unauthorized access:
configure terminal
interface range FastEthernet0/3 - 24
shutdown
end
write memory
b. Enable Port Security
Restrict devices that can connect to each port:
configure terminal
interface FastEthernet0/2
switchport mode access
switchport port-security
switchport port-security maximum 1
switchport port-security violation restrict
switchport port-security mac-address sticky
end
write memory
Limits the port to a single, known MAC address and blocks unauthorized devices.
c. Monitor Switch Configuration Changes
Enable logging for configuration changes:
configure terminal
logging buffered 10000
logging console
end
d. Implement VLAN Segmentation
Isolate sensitive systems using VLANs to minimize the impact of unauthorized mirroring.
Step 6: Verify Security Configurations
Attempt to connect an unauthorized device to a secured port.
Confirm that the port is disabled or restricted after unauthorized access.
Check switch logs for security violation alerts:
show port-security interface FastEthernet0/2
show logging
Solution & Explanation
What is Port Mirroring?
- Port mirroring duplicates network traffic from one port to another for monitoring purposes.
- Commonly used for network diagnostics and intrusion detection.
Risks of Unauthorized Port Mirroring
- Data Leakage: Sensitive data can be captured and misused.
- Reconnaissance: Attackers gain insight into network structure and traffic.
- Privilege Escalation: Captured credentials could lead to further exploitation.
Mitigation Strategies
- Disable Unused Ports: Reduces the attack surface.
- Enable Port Security: Limits access to known devices.
- Log Configuration Changes: Detects unauthorized modifications.
- VLAN Segmentation: Contains sensitive systems within isolated networks.
Testing & Verification
- Confirm that port mirroring captures intended traffic.
- Verify that unauthorized devices cannot access mirrored ports.
- Check logs for unauthorized connection attempts.
Check Port Security Status:
show port-security interface FastEthernet0/2
Review Switch Logs:
show logging | include SECURITY
Additional Script (Optional)
Automate port security configuration:
#!/bin/bash
# Secure switch ports to prevent unauthorized mirroring
SWITCH_IP="192.168.1.1"
USERNAME="admin"
PASSWORD="password"
ssh $USERNAME@$SWITCH_IP << EOF
configure terminal
interface range FastEthernet0/3 - 24
shutdown
interface FastEthernet0/2
switchport mode access
switchport port-security
switchport port-security maximum 1
switchport port-security violation restrict
switchport port-security mac-address sticky
end
write memory
EOF
Run the script:
chmod +x secure_ports.sh
./secure_ports.sh
Conclusion
In this exercise, you configured port mirroring on a managed switch and used Wireshark to capture and analyze mirrored traffic. You explored the risks of unauthorized port mirroring and implemented security measures like disabling unused ports and enabling port security to protect the network. Proper security controls are essential to prevent misuse of monitoring features and safeguard sensitive data.
0 Comments