Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 64

Understanding Man-in-the-Middle Attacks and ARP Spoofing

Recommended resources

Introduction

Welcome to our first lesson in the Network Security module! In previous lessons, we've focused on how protocols like HTTP, TCP, and DNS work together to deliver content across the internet. We've seen them operate as designed. Now, we shift our focus to what happens when these protocols are deliberately manipulated for malicious purposes.

In this lesson, we will explore one of the most fundamental network attacks: the Man-in-the-Middle (MitM) attack. You'll learn how an attacker on the same local network can intercept, read, and even modify traffic between your computer and the rest of the internet. Specifically, we'll dissect the mechanics of ARP spoofing, a technique that exploits the inherent trust in the Address Resolution Protocol (ARP) to achieve this.

This lesson directly builds on your knowledge of local network addressing from Module 4 (MAC addresses) and Module 6 (ARP), showing you the dark side of these essential protocols.


The Problem: ARP's Inherent Trust

As a quick refresher from Module 6, the Address Resolution Protocol (ARP) is the mechanism your computer uses to find the MAC address of another device on the same local network when it only knows its IP address. For instance, to send a packet to the internet, your computer sends an ARP request asking, "Who has the router's IP address? Tell me your MAC address." The router then replies with its MAC address.

The critical vulnerability here is that ARP is a stateless and trusting protocol. It was designed for speed and simplicity in what was assumed to be a trusted local environment. Any device on the network can send an ARP reply at any time, even if it wasn't asked, and the receiving device will typically accept it and update its ARP cache. An attacker can exploit this trust to lie about their identity.

To see a quick review of how ARP is supposed to work, please watch this first segment of the following video.

ARP Poisoning | Man-in-the-Middle Attack

The video 'ARP Poisoning | Man-in-the-Middle Attack' by CertBros starts with a clear, animated review of the normal ARP process. This will set the stage for understanding how the attack works.

Watch from 00:32 to 02:05. Focus on how Host A discovers the MAC address of the default gateway and stores it in its ARP cache.


The Attack: Poisoning the ARP Cache

A Man-in-the-Middle attack using ARP spoofing (also called ARP poisoning) involves an attacker sending specially crafted, unsolicited ARP replies to poison the ARP caches of two devices—typically a victim's computer and the network's default gateway (the router).

The attack unfolds in two parts simultaneously:

  1. Poisoning the Victim: The attacker sends an ARP reply to the victim's computer. This packet falsely claims that the router's IP address maps to the attacker's MAC address. The victim's computer dutifully updates its ARP cache, believing the attacker is the router.
  2. Poisoning the Router: The attacker sends an ARP reply to the router. This packet falsely claims that the victim's IP address maps to the attacker's MAC address. The router updates its ARP table, now believing the attacker is the victim.

The result? All traffic from the victim intended for the internet is sent to the attacker, and all traffic from the internet intended for the victim is also sent to the attacker. The attacker is now "in the middle" and can forward the traffic along after inspecting or modifying it, making the attack transparent to the victim.

This diagram clearly illustrates the process:

ARP Spoofing Step-by-Step Illustration
This diagram shows the core mechanic of ARP spoofing. The attacker sends forged ARP replies to both the user (victim) and the router, tricking them into sending traffic to the attacker's machine (MAC: B) instead of directly to each other.

Why is this necessary on a modern network?

Given your interest in how networks operate, you might wonder why an attacker can't just passively listen to all traffic. On a modern switched network, a switch intelligently forwards traffic only to the port connected to the destination MAC address. It doesn't broadcast traffic to everyone like an old-fashioned hub would. ARP spoofing is the technique an attacker uses to trick the switch into forwarding traffic to them.

The following video explains this crucial point and gives an excellent conceptual overview of the attack.

How ARP Poisoning Works // Man-in-the-Middle

In 'How ARP Poisoning Works' by network expert Chris Greer, this segment explains why an attacker on a switched network must actively poison ARP tables to intercept traffic.

Watch from 02:50 to 05:11. Pay close attention to the explanation of how a switch isolates traffic and how ARP spoofing breaks this isolation by deceiving both the victim and the gateway.


A Practical Demonstration

Let's see how this theory translates into a real attack using common penetration testing tools. The following demonstration uses ettercap to perform the attack and Wireshark to observe it, two tools highly relevant to your hands-on learning goals.

A quick but important ethical note: The techniques shown are for educational purposes only. Performing these attacks on a network you do not own or have explicit permission to test is illegal and unethical.

ARP Poisoning | Man-in-the-Middle Attack

This extended clip from the CertBros video provides a complete, step-by-step demonstration of an ARP poisoning attack against a Windows machine from Kali Linux.

Watch from 02:05 to 10:09. This is a longer segment, but it covers the entire attack lifecycle. Focus on these key moments: Initial State (arp -a): Note the victim's legitimate ARP table before the attack. The Attack (ettercap): Observe how the attacker targets the victim and the router. Wireshark Evidence: See the flood of malicious ARP replies being sent by the attacker to maintain the poisoned state. Poisoned State (arp -a): Look at the victim's ARP table again to see that the router's IP now maps to the attacker's MAC address. The Impact: The video demonstrates the interception of unencrypted HTTP login credentials, highlighting the danger of the attack.

A Deeper Look at the Packets

The CertBros video showed the effect of the attack in Wireshark. Since you have a background in computer science, you'll appreciate a closer look at the malicious packets themselves. The key is the "unsolicited ARP reply." The attacker sends ARP reply packets that the victim and router never requested.

This next clip zooms in on the Wireshark capture to dissect these packets.

How ARP Poisoning Works // Man-in-the-Middle

Returning to Chris Greer's video, this segment provides a packet-level analysis of the forged ARP replies generated by the attack tool.

Watch from 08:58 to 11:34. The presenter breaks down the sender MAC, sender IP, target MAC, and target IP fields within the malicious ARP replies to show exactly how the deception is crafted for both the victim and the gateway.

When you are analyzing traffic in Wireshark, a tell-tale sign of ARP poisoning is seeing a constant stream of ARP packets announcing that an IP address has a certain MAC address, especially if you see another packet claiming the same IP has a different MAC address.

Detecting ARP Poisoning with Wireshark
A Wireshark capture filtered for ARP traffic. The highlighted messages indicating 'duplicate use' of an IP address are a strong indicator of an ongoing ARP spoofing attack.

Mitigation and Modern Context

While ARP spoofing is a powerful local network attack, its ability to compromise data confidentiality is significantly reduced in the modern internet. Why? Encryption.

If the victim is browsing a website using HTTPS, the HTTP traffic is encrypted with TLS. The attacker can still place themselves in the middle and forward the encrypted data, but they cannot read or modify its contents without breaking the encryption, which is a much more difficult task.

This is a prime example of how security at a higher layer (the Application Layer via TLS) can mitigate a vulnerability at a lower layer (the Data Link Layer via ARP).

Understanding ARP Poisoning and detection using wireshark

For a concise written summary of the attack and its detection, you can review this article from Judy Ahmad. It also presents an alternative command-line tool, arpspoof.

Skim through the sections 'What is ARP Poisoning?', 'Performing ARP Poisoning', and 'Detecting ARP Poisoning using Wireshark'. This will reinforce the concepts we've covered and show you the attack from a command-line perspective, which may align well with your interests.

On enterprise networks, more robust defenses like Dynamic ARP Inspection (DAI) can be configured on switches to validate ARP packets against a trusted database, effectively preventing this attack at the infrastructure level.


Conclusion

In this lesson, we dissected the mechanics of a Man-in-the-Middle attack by focusing on the classic technique of ARP spoofing. You've seen how a fundamental protocol's trust can be exploited and how to observe this attack at the packet level.

Key Takeaways:

  • A Man-in-the-Middle (MitM) attack positions an attacker between two communicating parties to intercept or alter their traffic.
  • ARP spoofing is a Layer 2 MitM technique that works by sending forged ARP replies to poison the ARP caches of a victim and a gateway.
  • The attack's success relies on the stateless and trusting nature of ARP.
  • Tools like ettercap can automate this attack, while tools like Wireshark are essential for detecting it by identifying suspicious traffic, like frequent, unsolicited ARP replies or IP address conflicts.
  • The primary defense against the eavesdropping consequence of MitM attacks is end-to-end encryption (e.g., HTTPS/TLS).

Preview of the Next Lesson:

We've just seen how an attacker can intercept traffic. In the next lesson, we will explore another major category of network attacks: Denial-of-Service (DoS) and Distributed Denial-of-Service (DDoS) attacks. Instead of stealthily listening in, these attacks aim to overwhelm a target's resources, making a service or network unavailable to its legitimate users.