tools

Ettercap: MITM Tutorial, ARP Spoofing and Sniffing on Kali Linux

Ettercap: MITM Tutorial, ARP Spoofing and Sniffing on Kali Linux

What is Ettercap and how does it work? A practical guide to MITM, ARP spoofing, and sniffing on Kali Linux, including installation, filters, packet capture, and commands.

  • Posted on 2026-01-21
  • Reading time: 6 min

Ettercap: Intercepting, Manipulating, and Snooping Network Traffic #

Ettercap is the Swiss Army knife for Man-in-the-Middle (MITM) attacks in penetration testing. Simply put, it allows you to intercept communications between two devices on a local network (like your lab), intercepting, modifying, or recording all traffic. In contexts like HackTheBox, TryHackMe, or your virtual labs, it's an indispensable tool for understanding network vulnerabilities, capturing cleartext credentials, and testing defenses. In this guide, we'll move from theory to action: we'll see how to install it, launch ARP spoofing attacks, write filters to manipulate packets in real time, and how to defend against these techniques. Remember: all this only on your own machines or in specifically authorized environments.

What is Ettercap and Why Use It in a Lab? #

In short: Ettercap is a tool suite for MITM attacks via ARP spoofing, network sniffing, and packet injection. In pentesting, you use it to analyze traffic in a lab, identifying unencrypted credentials and protocol vulnerabilities.

If you're dealing with a machine on HackTheBox that runs cleartext services (HTTP, FTP, Telnet), Ettercap can be the key to sniffing passwords. It's much more lightweight and integrated than Wireshark for certain types of active attacks. It works on multiple systems, but we'll focus on Kali Linux, the reference distro. Its strength? The ability to silently perform ARP poisoning and apply filters (written in C) that modify packets on the fly, before they reach their destination.

Quick Installation and Setup on Kali Linux #

In short: (In Italian only) On Kali Linux, Ettercap is preinstalled. Verify this with ettercap --versionIf it is missing, install it with sudo apt update && sudo apt install ettercap-graphical. The GUI version (-G) is convenient, but let's learn the CLI to automate.

Kali usually has it already. Open a terminal and check:

bash
ettercap --version

If it returns the version (e.g. 0.8.3), you're good to go. Otherwise:

bash
sudo apt update && sudo apt install ettercap-graphical -y

First, edit the configuration file to avoid unnecessary warnings:

bash
sudo nano /etc/ettercap/etter.conf

Find the section [privs] and make sure there is ec_uid = 0 e ec_gid = 0. Then, look for redir_command_on e redir_command_off and uncomment them (remove the #). This will allow you to use port forwarding if necessary. Save and exit (Ctrl+X, Y, Invio).

Anatomy of an MITM Attack with ARP Spoofing #

In short: The basic attack poisons the ARP caches of both the victim and the gateway, making both believe that your IP is the other's. Thus, all traffic passes through your machine.

The heart of Ettercap is ARP spoofing. In a typical lab network (e.g., 192.168.1.0/24), the victim (192.168.1.10) communicates with the gateway (192.168.1.1). You (192.168.1.100) you say to the victim, “Hey, I’m the gateway,” and to the gateway, “Hey, I’m the victim.” Result: packets from both go through you.

Warning: This only works on local area networks (LANs) and if the target has no defenses such as static ARP inspection. In virtual labs (VirtualBox, VMware), make sure the network adapters are in bridge or NAT network mode to see real traffic.

Terminal Commands: Passive and Active Sniffing #

In short: (In Italian only) Usa ettercap -Tq -i eth0 for passive text sniffing. For active MITM, specify target with -M arp:remote /VITTIMA// /GATEWAY//.

Passive sniffing only listens, without injecting traffic. Useful for network mapping.

bash
sudo ettercap -Tq -i eth0
  • -T: use text interface (no GUI).
  • -q: “quiet”, less noisy output.
  • -i: specify the network interface (replace eth0 with yours, found with ip a).

For the actual MITM attack, the classic command is:

bash
sudo ettercap -T -i eth0 -M arp:remote /192.168.1.10// /192.168.1.1//
  • -M arp:remote: start mitm with ARP poisoning method (remote).
  • // separate IP and port (if you want to specify a port, e.g. /192.168.1.10/80/). This command starts the attack and will display all intercepted traffic in real time. To stop it, press q.

Common problem: Not seeing any traffic? Check your Kali firewall: sudo systemctl stop firewalld. Also make sure IP forwarding is enabled: echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward.

Writing and Using Custom Filters to Manipulate Traffic #

In short: (In Italian only) Ettercap filters are small C programs that modify packages. You compile them with etterfilter and charge them during the attack with -F file.ef.

This is where Ettercap breaks down. Imagine you want to replace every occurrence of the word "password" with "HACKED" in an HTTP request. You create a file filter.ex:

c
if (ip.proto == TCP && tcp.dst == 80) {
    if (search(DATA.data, "password")) {
        replace("password", "HACKED");
        msg("Filtro HTTP triggered!\n");
    }
}

Then you fill it out:

bash
etterfilter filter.ex -o filter.ef

And you load it during MITM:

bash
sudo ettercap -T -i eth0 -M arp:remote /192.168.1.10// /192.168.1.1// -F filter.ef

Now, every time the victim sends "password" in a web request, the packet will be altered. You can write filters for redirects, packet drops, download string substitutions... the only limit is creativity (in the lab!).

10-Minute Playbook: Sniffing FTP Credentials in a Lab #

Step 1 – Network Mapping #

Before you attack, find out who's on the network. Use a simple ARP scan with netdiscover o nmap to find the victim's IP and gateway in your lab.

bash
sudo netdiscover -r 192.168.1.0/24 -i eth0

Step 2 – Launch MITM on Specific Targets #

Victim identified (192.168.1.10) and gateway (192.168.1.1). Launch Ettercap in silent, targeted sniffing, logging everything to files.

bash
sudo ettercap -Tqi eth0 -M arp:remote /192.168.1.10// /192.168.1.1// -L logfile

The option -L logfile create three files: logfile.ecp, logfile.eci e logfile.eco with packages, info and traffic.

Step 3 – Filter and Isolate FTP Traffic #

The log will fill up quickly. In another terminal, analyze the captured traffic in real time for strings like "USER" and "PASS" that are typical of FTP.

bash
sudo tail -f logfile.eco | grep -E "USER|PASS"

Step 4 – Credential Extraction #

When the victim performs an unencrypted FTP login, you will see something like this in the log. USER mario e PASS secret123. Take note: those are the compromised credentials.

Step 5 – ARP Cleanup and Realignment #

Once the exercise is finished, stop Ettercap (q) and sends “honest” ARP packets to reset network caches. You can use ettercap -M arp:remote /192.168.1.10// /192.168.1.1// with the option --reverse or simply reboot the machines in your virtual lab.

Ettercap Quick Checklist #

  1. Verify that Ettercap is installed and configured (sudo ettercap --version).
  2. Identify the correct network interface for sniffing (ip a).
  3. Disable Kali's local firewall to avoid blocks (sudo systemctl stop firewalld).
  4. Enable IP forwarding to not interrupt the victim's traffic (echo 1 > /proc/sys/net/ipv4/ip_forward).
  5. Map the lab network to locate victim IPs and gateways (netdiscover o nmap -sn).
  6. Use the option -L to log captured traffic and analyze it offline.
  7. Test custom filters on a test machine before using them in a complex scenario.
  8. Always have the command to stop the MITM handy (press q in the TUI interface).
  9. Remember to reset the victims' ARP tables after testing (reboot or send correct ARP packets).
  10. Use Ettercap only on networks and devices that you have explicit permission to test.

80/20 Ettercap Summary #

TargetPractical actionCommand/Tool
Passive network sniffingLaunch Ettercap in text mode without MITM attackettercap -Tq -i eth0
Initiate MITM via ARP spoofingSpecify target1 (victim) and target2 (gateway)-M arp:remote /VITTIMA// /GATEWAY//
Log traffic for analysisSave the capture to a file to review later-L nomefile
Compiling a custom filterWriting C code in .ex and generate files .efetterfilter miofiltro.ex -o miofiltro.ef
Load filter during MITMApply the compiled filter to manipulate packets-F miofiltro.ef
Intercept HTTP/FTP credentialsLook for strings “USER”, “PASS”, “Authorization:” in the loggrep -E "USER|PASS" logfile.eco
Stop the MITM attackExit the TUI and reset ARPto press q, then restart target machines

Counterintuitive Concepts About Ettercap #

“MITM works always and on everyone”
False. Modern switches with protections (Port Security, DHCP Snooping) can detect and block ARP spoofing. Furthermore, encrypted connections (HTTPS, SSH) make sniffing useless without additional techniques such as SSL stripping (which only works under specific conditions).

“Ettercap is invisible”
Not really. A system with a network IDS/IPS or even a client with tools like arpwatch It can detect ARP anomalies and generate alarms. In the real world, an active MITM attack is noisy.

“Stop sniffing to get passwords”
This is only true for unencrypted protocols. Most traffic today is encrypted. The use of Ettercap in the lab serves precisely to demonstrate the dangers of services like FTP, Telnet, or basic HTTP, pushing for the adoption of encryption.

FAQ about Ettercap #

Q: Ettercap can't find the network interface, what should I do?
A: Verify the interface name with ip a. On Kali in VM, it is often eth0 o ens33. If you are using a wireless connection, it may be wlan0. Use that exact name in the option -i.

Q: Can I use Ettercap to intercept HTTPS traffic?
A: Not directly. Ettercap alone can't decrypt HTTPS. You can try techniques like SSL stripping (with tools like sslstrip) to downgrade HTTPS to HTTP, but this only works if the victim isn't using HSTS. The goal in the lab is to highlight the importance of HSTS.

Q: How do I sniff only traffic from a specific port?
A: You can use capture filters in the GUI, or from the CLI to specify the port in the targets. Example: /192.168.1.10/80/ It will only capture HTTP traffic from that victim. Alternatively, use view filters in the post-capture log.

Q: Why does my victim computer lose its Internet connection during the attack?
A: You probably don't have IP forwarding enabled on Kali. The system receives packets but doesn't forward them. Run echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward before launching Ettercap.

Q: Is there an alternative to Ettercap for MITM?
A: Yes, tools like bettercap (more modern and extensible) and arpspoof (simpler) can do parts of the work. Ettercap remains a historical and complete tool, but bettercap is becoming the standard for many pentesters.

Authoritative References #


If this guide helped you take control of a network lab, consider supporting HackIta with a donation. It allows us to maintain the site and produce quality content for the entire community.

Want to turn this knowledge into a professional skill? Discover our customized , one- on-one training courses, where we explore tools like Ettercap in depth in complex, realistic scenarios.

Does your company need to test its resilience to MITM techniques? Our security assessment services include internal and external penetration testing to identify and address these vulnerabilities.

#ettercap #sniffing #mitm

leave a message

I'm not a robot