1. Work
  2. ▲ Ethical hacking
  3. ARP Spoofing & MITM

ARP spoofing & MITM

A man-in-the-middle attack chain built from the ground up in Python and Scapy: a credential-sniffing packet capture tool, a host-discovery scanner, and an ARP cache poisoner used together to intercept live traffic between two other hosts on the LAN. Built and verified against a real Windows target and a Metasploitable 2 victim — all on my own authorised home lab.

Platform
Kali Linux · Scapy
Difficulty
Intermediate
Targets
Windows 11 · Metasploitable 2
Known good — verified against live output
  • Sniffer verified two ways — credentials seen in the script and in a parallel Wireshark capture
  • Host discovery cross-checked against arp-scan — same IP/MAC pairs
  • Poison confirmed on the victim's own ARP table — gateway IP mapped to the attacker's MAC
  • 750 packets of the victim's live traffic captured — as a side effect of the poisoning
  • ARP tables cleanly restored on exit — network returned to normal, not left broken
Obstacles — two faults, all resolved
  • iICMP redirects silently undid the poison resolved
  • iiWi-Fi client isolation dropped the L2 frames resolved
Four chapters — the figure follows your readingHover a device to inspect it
01Topology

One flat LAN, four hosts.

One flat LAN, four hosts. The gateway and the victim talk directly — a conversation the attacker was never part of.

One flat LAN segment, four hosts. The attack box forges its way into the middle of a conversation between two hosts that were never talking to it in the first place — the real gateway at 192.168.0.1 and a Windows victim at 192.168.0.32. A Metasploitable 2 host provides a cleartext FTP/HTTP target for the credential capture.

Evidence — hosts
Kali             192.168.0.85   attacker — sniffer, scanner, poisoner
Router           192.168.0.1    real gateway, spoofed to the victim
Windows laptop   192.168.0.32   victim — ARP cache poisoned to route via Kali
Metasploitable2  192.168.0.95   cleartext FTP/HTTP target
02Poison

The core lie, sent on repeat.

Kali forges is-at replies to each side, so both cache the attacker's MAC for the other's IP.

The poisoner resolves both targets' real MACs first and aborts cleanly if either can't be reached at Layer 2, then continuously sends forged is-at replies — telling the victim the gateway is at the attacker's MAC, and the gateway the victim is at the attacker's MAC. Repeating every two seconds overwrites the real mapping faster than the genuine owners re-announce themselves, so the lie wins.

Evidence — victim's arp -a, while under attack
Interface: 192.168.0.32
  Internet Address      Physical Address      Type
  192.168.0.1           00-0c-29-4f-1a-7e     dynamic   (attacker's MAC, not the router's)
03Intercept

On the path, and staying quiet.

Traffic now routes victim → Kali → gateway, forwarded to stay live and sniffed on the way through.

With net.ipv4.ip_forward=1 set on the attack box, the victim's connection keeps working exactly as before — it just passes through an extra, uninvited hop first. 750 packets of the victim's live traffic — TLS sessions to external hosts it had no reason to route through the attack box — were captured and written to disk purely as a side effect of the poisoning, and the ARP tables were cleanly restored on exit.

Evidence — poisoner output
[*] Interface eth0 | my MAC 00:0c:29:4f:1a:7e
[+] Victim  192.168.0.32 is-at 0c:8b:fd:2c:05:9a
[+] Gateway 192.168.0.1 is-at c0:a3:6e:7b:31:e0
[*] Poisoning. Ctrl-C to stop and restore.
[*] Sniffing traffic to/from 192.168.0.32 ...
^C
[*] Restoring ARP tables...
[*] Done.
[+] Wrote 750 packets to arper.pcap
04Troubleshoot

The one that got me.

On Wi-Fi the poison never lands: the AP drops Layer 2 frames between clients before they reach the victim.

Against a laptop on a consumer Wi-Fi network, the poison never landed — confirmed by checking the victim's own ARP table directly rather than assuming a code or routing bug. The forged replies were leaving the attacker's NIC correctly (verified with tcpdump), but the router's AP/client isolation was dropping Layer 2 traffic between wireless clients before it ever reached the target. No amount of Scapy code fixes a router blocking the frames outright; switching to a network without client isolation resolved it immediately.

Evidence — what carried through
Poison confirmed leaving the NIC (tcpdump), but the
victim's ARP table never changed. AP/client isolation
was dropping L2 frames between wireless clients. Check
Layer 2 reachability before blaming the tool.
Topology 1 / 4
Fig. 1 — 01 Topology
on pathfaultinspecting
05 — What I built

Three Scapy tools, chained.

Three standalone Scapy tools, each doing one job, chained together into a working attack.

Credential sniffer

Filters traffic on POP3/IMAP/SMTP ports at the BPF level, then inspects the TCP payload for user/pass strings and prints the source and destination when found.

Host discovery scanner

Broadcasts an ARP “who-has” request across the subnet and collects every reply, rebuilding what a tool like arp-scan does in about twenty lines of Scapy.

ARP cache poisoner

Resolves both targets' real MACs first, aborts cleanly if either can't be reached at Layer 2, then continuously sends forged is-at replies to each side while relaying and sniffing their traffic — restoring the genuine entries on exit.

The core lie — forging the ARP replies
# Tell the victim: "the gateway is at my MAC"
poison_victim = Ether(dst=victim_mac)/ARP(
    op=2, psrc=gateway_ip, pdst=victim_ip,
    hwdst=victim_mac, hwsrc=my_mac)

# Tell the gateway: "the victim is at my MAC"
poison_gateway = Ether(dst=gateway_mac)/ARP(
    op=2, psrc=victim_ip, pdst=gateway_ip,
    hwdst=gateway_mac, hwsrc=my_mac)

# Repeat every 2s — ARP entries expire, and the real owner
# keeps re-announcing itself unless drowned out.
while poisoning:
    sendp(poison_victim, iface=iface)
    sendp(poison_gateway, iface=iface)
    time.sleep(2)
06 — Why it works

One property of ARP, not a bug.

The entire attack rests on one property of ARP, not a flaw in any specific implementation.

ARP has no authentication

Any host on the segment can claim to own any IP address, and there is no signature or challenge to verify it. Whichever reply arrives is simply trusted and cached.

Forged replies beat real ones by volume

Sending the lie every two seconds keeps overwriting the entry faster than the real gateway's own occasional re-announcements, so the poisoned mapping wins.

Forwarding keeps the illusion alive

With net.ipv4.ip_forward=1 set on the attack box, the victim's connection keeps working exactly as before — it just passes through an extra, uninvited hop first.

07 — Real-world relevance

Why it matters outside the lab.

Internal pentest staple

ARP spoofing remains a standard technique for intercepting traffic during an internal network engagement, particularly on flat, unsegmented LANs without port security or Dynamic ARP Inspection.

Verify the topology before the code

The Wi-Fi isolation issue cost far more time than any bug in the Python itself. Checking Layer 2 reachability directly — rather than assuming the attack tool is broken — is the faster path to a real answer.

Defensive takeaway

Dynamic ARP Inspection, static ARP entries on critical hosts, and 802.1X port authentication all directly close this attack path; on wireless networks, client/AP isolation defeats it by design.

Appendix A — Faults & fixes

Linux ICMP redirects silently undid the poison

Forwarding worked, but the kernel noticed a more direct route existed between two hosts on the same subnet and sent an ICMP Redirect telling the victim to bypass the attacker entirely — defeating the MITM at the IP layer even though ARP poisoning was succeeding. Fixed with net.ipv4.conf.all.send_redirects=0 on the relevant interfaces.

Wi-Fi client isolation the one that got me

Against a laptop on consumer Wi-Fi the poison never landed — confirmed by checking the victim's ARP table directly. The forged replies left the attacker's NIC correctly (verified with tcpdump), but the router's AP/client isolation dropped Layer 2 traffic between wireless clients before it reached the target. No Scapy code fixes a router blocking the frames outright; a network without client isolation resolved it immediately.

Let's build something that stays up.

Open to network engineering roles and interesting infrastructure work, in and around Milton Keynes.

bernard@bernardeshun.co.uk