BiTree
  • Search For Lessons
  • Curriculum
  • Pricing
  • For Educators
  • Become a Tutor
  • About
  • Contact
Log InGet Started

Questions, concerns, bug reports, or suggestions? We read every message, write to us at [email protected].

More ways to reach us →
BiTree

Live coding lessons for aspiring developers and security professionals.

[email protected]

(201) 785-7951

Mon–Fri, 9 AM–5 PM EST

Learn

  • Search For Lessons
  • Curriculum
  • Pricing

Company

  • About
  • For Educators & Schools
  • Become a Tutor
  • Contact Us

Legal

  • Terms of Service
  • Privacy Policy
© 2026 BiTree. All rights reserved.
Curriculum/Cybersecurity/Networking and Protocol Security/Man-in-the-Middle Attacks
45 minIntermediate

Man-in-the-Middle Attacks

After this lesson, you will be able to: Explain man-in-the-middle attacks and their vectors, use Bettercap/Ettercap/mitmproxy conceptually and in a lab, understand SSL stripping and why HSTS preloading defeats it, and the role of certificate pinning.

A man-in-the-middle sits between two parties without either knowing. This lesson covers MITM vectors (ARP poisoning, rogue Wi-Fi, DNS spoofing, BGP hijacking), the tools (Bettercap as the modern choice, Ettercap, mitmproxy), SSL stripping and HSTS, MITM against TLS and certificate pinning, and a Bettercap lab.

Prerequisites:ARP Spoofing and Poisoning

💡 Authorization first

Run MITM tooling only in an isolated lab you own or a sanctioned platform (TryHackMe). Intercepting other people's traffic is a serious crime.

What MITM is and its vectors

In a man-in-the-middle attack, the attacker relays and possibly alters communication between two parties who believe they are talking directly. Vectors include ARP poisoning (local LAN), rogue Wi-Fi access points (an 'evil twin' with the same SSID), DNS spoofing (answering lookups with attacker IPs), and at internet scale, BGP hijacking (announcing routes you do not own). The position is the same; only the technique to reach it differs.

The tools

Bettercap is the modern, actively maintained framework for LAN MITM: ARP spoofing, sniffing, and HTTP/HTTPS proxying in one tool. Ettercap is the older classic that automates MITM on a LAN. mitmproxy is an interactive HTTP/HTTPS intercepting proxy used heavily for app testing (you install its certificate on a device you control to inspect that device's traffic). Each is a different blend of automation and control.

SSL stripping and HSTS

SSL stripping downgrades a victim from HTTPS to HTTP: the attacker intercepts the initial plain-HTTP request (before TLS is negotiated) and keeps the victim on HTTP while talking HTTPS to the real server. The victim never gets the secure connection. HSTS defeats this by telling the browser to only ever use HTTPS for the domain, and HSTS preloading ships that rule in the browser itself, so even the very first request is HTTPS and there is no plain-HTTP moment to strip.

MITM against TLS and certificate pinning

To MITM TLS itself, an attacker must present a certificate the victim trusts. Normally the victim's browser rejects an untrusted certificate with a warning. Two failure modes: users click through certificate warnings (a systemic human problem), and on managed devices a malicious root certificate may be installed. Certificate pinning (common in mobile apps) hardcodes the expected certificate or public key, so even a 'valid' attacker certificate is rejected. Pinning is strong but operationally tricky (rotating a pinned cert can brick clients).

Lab: Bettercap MITM in an isolated environment

Two containers and Kali on a private network.

  1. 1

    1. On an isolated Docker network, run Kali plus a victim and a simple HTTP service container.

  2. 2

    2. On Kali: bettercap -iface eth0, then in the session enable net.probe and arp.spoof on the victim.

  3. 3

    3. Enable net.sniff and generate plain HTTP traffic from the victim; capture credentials.

  4. 4

    4. Switch the service to HTTPS with HSTS and repeat; observe the interception fail.

  5. 5

    5. For guided practice, complete the TryHackMe Bettercap room.

Quick Check

Why does HSTS preloading defeat SSL stripping even on the user's first visit?

Pick one.

Common mistakes only experienced testers catch

Assuming MITM 'breaks' TLS; it does not, it requires a trusted certificate the victim must accept. Relying on Ettercap when Bettercap is better maintained. Forgetting that a certificate warning is the defense working, not a bug to click past. Testing pinning bypass without realizing the app may have multiple pins. Running any of this outside an authorized lab.

Sign in and purchase access to unlock this lesson.

Sign in to purchase
←ARP Spoofing and Poisoning
Back to Networking and Protocol Security
SYN Floods and DDoS Attacks→