Cybersecurity guides, explanations and reader checklists on whilenetworking.com

Hands-On Lab: Using Wireshark to Capture and Decrypt Cleartext Traffic on a Man-in-the-Middle Simulated Network

In modern defensive security, understanding how traffic flows through a network is as critical as knowing how to stop it. This lab guides IT students and…

In modern defensive security, understanding how traffic flows through a network is as critical as knowing how to stop it. This lab guides IT students and junior engineers through the process of setting up a controlled Man-in-the-Middle (MitM) environment to capture and analyze cleartext traffic using Wireshark. By simulating an MitM attack, you will gain practical experience in packet capture, protocol analysis, and the importance of encryption. This exercise is strictly for authorized testing environments; performing these actions on a production network without explicit written authorization from all stakeholders violates compliance standards and ethical guidelines.

Environment Setup and Prerequisites

Before initiating any packet capture, you must prepare a safe, isolated environment. Attempting this on an active corporate network can lead to data breaches or violate the Acceptable Use Policy (AUP).

Required Software:
* Wireshark: The industry-standard protocol analyzer. Ensure you have the latest stable version installed.
* Nmap: Useful for scanning and identifying live hosts within your lab topology.
* Virtual Machines (VMs): You will need at least two VMs: one acting as the “Attacker” (or Monitor) and one as the “Victim.” Linux-based distributions (like Ubuntu or Kali Linux) are ideal for this lab due to their robust networking tools.

Network Topology:
1. Host A (Victim): Configured with a static IP address (e.g., 192.168.50.10). This machine will run a simple HTTP server serving cleartext content.
2. Host B (Attacker/Monitor): This machine will sit between the victim and the gateway, or act as a bridge to capture traffic. For this specific lab, we will use ARP Spoofing techniques on Host B to intercept traffic intended for Host A.
3. Gateway: A simple router or virtual network interface connecting the two hosts.

Security Note: Always assume that any device you connect to an unsecured Wi-Fi network could be compromised. Never run these labs on public networks.

Step 1: Establishing the Man-in-the-Middle Position

The core of this lab is placing your monitoring node in the middle of a communication stream without the endpoints knowing it. This is typically achieved using ARP (Address Resolution Protocol) spoofing. In a standard LAN, devices trust the MAC address associated with an IP address learned via ARP requests. By sending forged replies, you can convince victims that your machine is the gateway.

Procedure:
1. Log in to your Attacker machine.
2. Identify the interface names (e.g., eth0, wlan0) using the command:
bash
ip addr show

3. Prepare a script or use Wireshark’s built-in features to send gratuitous ARP replies. If using arpspoof (common in Kali Linux), run:
bash
sudo arpspoof -i eth0 -t 192.168.50.10 192.168.50.1

Assumption: 192.168.50.1 is the gateway IP, and 192.168.50.10 is the victim. This command tells the victim that the gateway’s MAC address is actually your attacker interface’s MAC.

Expected Result:
The victim machine will begin sending traffic to your Attacker machine instead of the real gateway. You can verify this by pinging the victim from the Attacker machine and observing the ARP table:

ip neigh show
# Output should show the victim IP as REACHABLE via your interface MAC

Step 2: Capturing Cleartext Traffic with Wireshark

Once the MitM position is established, you can begin capturing traffic. The goal here is to observe unencrypted protocols like HTTP (port 80) or Telnet (port 23). Modern HTTPS traffic (port 443) is encrypted and cannot be read directly without additional decryption keys, which we will address in the next section.

Procedure:
1. Launch Wireshark on the Attacker machine.
2. Select the network interface capturing the LAN traffic.
3. Click the “Start” button (the blue shark fin icon).
4. On the Victim machine, open a web browser and navigate to a cleartext site (e.g., http://example.com or a local file server you set up).
5. Observe the packet stream in Wireshark.

Analyzing the Capture:
Filter the traffic to view only HTTP packets:

http.request.method == "GET"

Expand the TCP payload section of a packet. You should see plain text URLs, form data (if submitting via HTTP), and cookies visible in hexadecimal or ASCII format depending on the display filter settings (Follow > TCP Stream).

Illustrative Output:
In the packet details window, under Internet Protocol Version 4, you will see the source and destination IPs. In the TCP layer, look at the payload. You might see:

GET /index.html HTTP/1.1\r\nHost: example.com\r\nUser-Agent: Mozilla/5.0...

This confirms that without encryption, sensitive data is exposed to anyone monitoring the wire.

Step 3: Decrypting Traffic (The SSLStrip Concept)

While capturing cleartext traffic demonstrates vulnerability, modern users often switch to HTTPS automatically. To fully demonstrate MitM capabilities in a lab, you must simulate an SSL Strip attack or use a Man-in-the-Middle Proxy configured with your own Certificate Authority (CA).

Practical Approach: Using a Local CA:
1. Generate a self-signed certificate on your Attacker machine using OpenSSL:
bash
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout key.pem -out cert.pem -subj "/CN=LabCA"

2. Install this certificate as the system trust anchor on your Attacker machine.
3. Configure a local proxy (like mitmproxy) to intercept HTTPS requests, present the self-signed cert, and decrypt/modify traffic before re-encrypting it to the victim.

Important Distinction: In a real-world scenario, this requires installing the CA certificate on the victim’s device/browser. If the user does not trust your CA, they will see a “Security Warning” browser alert. This is a common defense mechanism; users must be educated to ignore these warnings only in trusted lab environments.

Common Mistakes and Verification Steps

When conducting this lab, several errors frequently occur:

  • Mistake: Forgetting to enable promiscuous mode or running Wireshark on the wrong interface.
    • Fix: Ensure you are capturing on the interface bridged to your VM network, not just the loopback adapter.
  • Mistake: Trying to decrypt HTTPS without installing the CA certificate on the victim.
    • Fix: You must import the cert.pem generated in Step 3 into the victim’s browser trust store (e.g., via Chrome Settings > Privacy and security > Security > Manage certificates).
  • Mistake: Interpreting ARP spoofing as a permanent routing change.
    • Fix: Remember that ARP caches expire. Once you stop sending spoofed packets, the network returns to normal after the cache timeout (usually 20-60 seconds).

Industry Application and Student Practice Task

Student Task:
Configure your lab machines so that Host A serves a simple HTML page containing a login form with hardcoded credentials (user: admin, pass: password123). Use Wireshark on Host B to capture the login attempt. Document the exact timestamp when the credentials appear in the payload and propose two hardening measures (e.g., implementing TLS 1.3, using HSTS headers).

Industry Application:
Network engineers use these skills for Incident Response. If a breach is suspected, responders may deploy network taps or port mirroring to capture traffic on a switch mirror port. They then use Wireshark to filter for specific IP pairs or domain names to identify data exfiltration. However, ethical hackers must always operate under a “Rule of Two” authorization: explicit permission from both the network owner and the system owner before deploying monitoring tools that alter traffic flow (like ARP spoofing).

Conclusion

This lab demonstrates the fragility of cleartext communications and the mechanics of a Man-in-the-Middle attack. By using Wireshark to capture and analyze traffic, you learn how to identify unencrypted protocols and understand the necessity of end-to-end encryption. Remember that while these techniques are powerful tools for defense and analysis, their misuse can lead to severe legal and professional consequences. Always prioritize data privacy, adhere to local laws regarding computer misuse, and consult with legal counsel or compliance officers before deploying monitoring solutions in real-world environments.

Educational-use notice: This tutorial is for learning and controlled lab use only. Test carefully, use backups, and obtain authorization before making changes. Do not run unfamiliar commands on production systems. We accept no responsibility for misuse, damage, data loss, or production issues.