- Ettercap
- Ettercap Help
- Ettercap Usage Example
- How to install Ettercap
- Installation on Linux (Debian, Mint, Ubuntu)
- Ettercap Screenshots
- Ettercap Tutorials
- How to use Ettercap
- What is man in the middle attack ?
- How to install ettercap on kali linux
- Using Ettercap GUI
- ARP poisoning Attack in Ettercap
- DNS spoofing with ettercap
- Ettercap Filters
- How To protect yourself?
- Comments
Ettercap
Ettercap is a comprehensive suite for man in the middle attacks. It features sniffing of live connections, content filtering on the fly and many other interesting tricks. It supports active and passive dissection of many protocols and includes many features for network and host analysis.
Authors: Alberto Ornaghi (ALoR), Marco Valleri (NaGA), Emilio Escobar (exfil), Eric Milam (J0hnnyBrav0), Gianfranco Costamagna (LocutusOfBorg)
Ettercap Help
Usage: ettercap [OPTIONS] [TARGET1] [TARGET2] TARGET is in the format MAC/IP/PORTs (see the man for further detail)
Sniffing and Attack options: -M, --mitm perform a mitm attack -o, --only-mitm don't sniff, only perform the mitm attack -b, --broadcast sniff packets destined to broadcast -B, --bridge use bridged sniff (needs 2 ifaces) -p, --nopromisc do not put the iface in promisc mode -S, --nosslmitm do not forge SSL certificates -u, --unoffensive do not forward packets -r, --read read data from pcapfile -f, --pcapfilter set the pcap filter -R, --reversed use reversed TARGET matching -t, --proto sniff only this proto (default is all) --certificate certificate file to use for SSL MiTM --private-key private key file to use for SSL MiTM User Interface Type: -T, --text use text only GUI -q, --quiet do not display packet contents -s, --script issue these commands to the GUI -C, --curses use curses GUI -D, --daemon daemonize ettercap (no GUI) -G, --gtk use GTK+ GUI Logging options: -w, --write write sniffed data to pcapfile -L, --log log all the traffic to this -l, --log-info log only passive infos to this -m, --log-msg log all the messages to this -c, --compress use gzip compression on log files Visualization options: -d, --dns resolves ip addresses into hostnames -V, --visual set the visualization format -e, --regex visualize only packets matching this regex -E, --ext-headers print extended header for every pck -Q, --superquiet do not display user and password General options: -i, --iface use this network interface -I, --liface show all the network interfaces -Y, --secondary list of secondary network interfaces -n, --netmask force this on iface -A, --address force this local on iface -P, --plugin launch this -F, --filter load the filter (content filter) -z, --silent do not perform the initial ARP scan -j, --load-hosts load the hosts list from -k, --save-hosts save the hosts list to -W, --wifi-key use this key to decrypt wifi packets (wep or wpa) -a, --config use the alterative config file Standard options: -v, --version prints the version and exit -h, --help this help screen
Ettercap Usage Example
Start Ettercap with GUI (-G):
Select Sniff -> Unified -> select Iface:
Now selext Hosts -> Scan for hosts -> Hosts list:
As Target 1 select Router (Add to Target 1), As Target 2 select a device for attack (Add to Target 2).
Mitm -> ARP poisoning… Select Sniff remote connections.
Sniff -> Start sniffing.
How to install Ettercap
The program is pre-installed on Kali Linux.
Installation on Linux (Debian, Mint, Ubuntu)
sudo apt-get install ettercap-common ettercap-graphical # only GUI OR sudo apt-get install ettercap-common ettercap-text-only # only text interface
Installation from source code
Install any missing dependencies
sudo apt-get install git debhelper bison check cmake flex ghostscript libbsd-dev libcurl4-openssl-dev libgtk2.0-dev libltdl-dev libluajit-5.1-dev libncurses5-dev libnet1-dev libpcap-dev libpcre3-dev libssl-dev libgtk-3-dev ghostscript groff libtool libpcre3 libncurses5-dev
git clone https://github.com/Ettercap/ettercap.git cd ettercap/ mkdir build cd build cmake ENABLE_PDF_DOCS=On ../ make sudo make install sudo ettercap -G
Ettercap Screenshots
Ettercap Tutorials
How to use Ettercap
What is ettercap? Ettercap is a utility for analyzing network traffic passing through a computer interface, but with additional functionality. The program allows you to perform attacks like “Man in the middle” to force another computer to transfer packets not to the router, but to you.
With Ettercap, you can check the security of your network, how susceptible it is to this type of attack, and also analyze traffic from several computers, and even modify it on the fly. In this article, we will look at how to use Ettercap to analyze and modify traffic.
What is man in the middle attack ?
By default, the computer sends all network packets that need to be sent to the Internet and sends it to the router, which in turn sends them to the next router until the packet reaches the target. But for certain reasons, the packet can be transmitted not to the router, but immediately to your computer, and only then to the router.
The computer through which the packets will pass can analyze the source, target address, and if they are not encrypted, then their full contents.There are two ways to do MITM (Man In Middle Attack):
- ARP attack – using the features of the ARP protocol, your computer tells others that it is a router, after which all packets begin to indulge in it;
- DNS attack – when a computer tries to get an ip address for a domain, we substitute this address for its own, but for this type to work, you need to use the ARP method.
Ettercap Linux can perform both types of attacks. In addition, the utility can perform denial of service attacks and scan ports. Now let’s take a look at how to install and use Ettercap.
How to install ettercap on kali linux
This is a fairly popular program among network security experts, so it is in the official repositories of most distributions. For example, to install Ettercap in Ubuntu, run:
sudo apt install ettercap-gtk
On Fedora or other distributions based on it, the command will look similar:
sudo yum install ettercap-gtk
We coped with the task of installing Ettercap Linux, but before using it, you need to change a few settings in the configuration file.
sudo vi /etc/ettercap/etter.conf
The ec_uid and ec_gid lines must be set to 0 in order for the program service to work on behalf of the superuser:
[privs] ec_uid = 0 # nobody is the default ec_gid = 0 # nobody is the default
Next you need to find and uncomment these two lines:
redir_command_on = "iptables -t nat -A PREROUTING -i %iface -p tcp --dport %port -j REDIRECT --to-port %rport" redir_command_off = "iptables -t nat -D PREROUTING -i %iface -p tcp --dport %port -j REDIRECT --to-port %rport"
They are used to redirect SSL connections to regular HTTP, if possible. Then save the changes and the program is ready to work.
Using Ettercap GUI
The program can work in several modes – with a graphical interface, without and as a service. We will consider work in the graphical interface. To run a program with a GTK interface, use the -G option:
We use the -E option for sudo to save all of our user’s environment variables. The main window of the program looks very simple. First we look at how the ARP-poisoing attack is performed.
ARP poisoning Attack in Ettercap
As I said, with this attack we can force the target computer to send packets not to the router, but to us. Everything works quite simply. The computer knows the IP of the router, it got it when connected to the network. But every time he needs to send a packet, he needs to convert this universal IP address to a low-level address of the network technology used, for example, for the wired Internet – this is the MAC address.
For this, the ARP protocol is used. The computer sends a request to all devices on the network, for example, “who is 192.168.1.1” and the router, upon seeing its address, will send in response its MAC. Then it will be saved in the cache. But we can use Ettercap to ask the target computer to update its ARP cache and transfer its MAC address instead of the MAC address of the router. Then all the packages will be transferred to us, and we will send them where necessary.
Let us get to the point and execute the attack attercap arp spofing. In Ettercap, open the Sniff menu and select Unified Snifing. Then select your network interface, for example, eth0 or wlan0:
The program window will change and much more functions will be available to us. Now you need to scan the network. To do this, open the Hosts menu and click Scan hosts. Even if something does not work, then you can load the list of hosts from the file:
Further, after a quick scan, if you open Hosts -> Hosts List , you will see a list of devices connected to the network:
To start the attack, we need to specify target 1 and target 2. As the first target, you need to specify the IP of the machine that we are going to attack, and the target 2 is the ip of the router. To add targets, use the Add Target 1 and Add Target 2 buttons :
Next, open the MITM menu and select ARP poisoning :
In the window that opens, check the Sniff remote connections box to intercept all remote connections from this computer:
Now, to start the substitution process, in the Start menu, select Start Sniffing.
After that, the program will start sending packets to the network, with a request for 192.168.1.3 to update the ARP cache and replace the MAC address of the router with yours. The attack is started and successfully executed. You can open the View -> Connections menu and see the active connections for the target device:
If the packet was not encrypted, then we can view the transmitted information by clicking on the connection with the mouse. The sent information is displayed on the left, and the received information is displayed on the right.
DNS spoofing with ettercap
A special service, DNS, is used to convert site names to network IP addresses. When the computer needs an ip of the site, he asks him for the DNS server. But if you are already performing a MITM attack, then we can spoof the server’s response so that instead of the site server’s IP, our IP is returned. First we need to edit the /etc/ettercap/etter.dns file:
sudo vi /etc/ettercap/etter.dns
This record means that we will substitute the main IP google.com with 127.0.0.1. Please note that this attack is not performed without the previous one. Further open the menu Plugins -> Manage Plugin:
Then double click on the dns_spoof plugin :
The plugin will be activated and you can check the ip on the device. DNS is really being replaced. For example, you can run on a target machine:
In addition to these plug-ins, there are others with which you can perform the necessary actions.
Ettercap Filters
Filters allow you to modify the packets passed through the program on the fly. You can drop packets or make necessary changes to them using the replace function. Filters also work only while the MITM attack is running. The syntax of the conditions by which we will filter packets is very similar to wireshark. Let’s consider a simple filter that will replace all the pictures with ours:
if (ip.proto == TCP && tcp.dst == 80) < if (search(DATA.data, "Accept-Encoding")) < replace("Accept-Encoding", "Accept-Rubbish!"); # note: replacement string is same length as original string msg("zapped Accept-Encoding!\n"); >> if (ip.proto == TCP && tcp.src == 80) < replace("img src="https://kalitut.com/how-to-use-ettercap/,"img src=\"https://pbs.twimg.com/profile_images/655061121007616000/NCV0qQnS.png\" "); replace("IMG SRC=", "img src=\"https://pbs.twimg.com/profile_images/655061121007616000/NCV0qQnS.png\" "); msg("Filter Ran.\n"); >
For those who have had experience with programming languages, everything should be clear here. If the TCP protocol and the destination port are 80, we continue searching and look for Accept-Encoding. Then we replace this word with any other, but equivalent in length. Because if the browser will send Accept-Encoding gzip, then the data will be compressed and we will not filter anything there. Next, in the server’s response, the source port is 80, we replace all the images with ours. Now the filter needs to be compiled:
etterfilter test.filter -o test.ef
It remains to load the filter using the menu Filters -> Load Filter :
Select a filter file in the file system:
The filter will be loaded and you can open any site where https is not used to make sure everything works. To stop the MITM attack, open the MITM menu and select Stop All Mitm attacks . Our Ettercap manual is coming to an end, but …
How To protect yourself?
Probably, after reading the article, you have a reasonable question, how to protect your computer from this type of attack? There are several tools for this, including for the Linux operating system:
- XArp is a graphical utility that can detect attempts to spoof MAC addresses using the ARP protocol and counteract this. It can work in Windows and in Linux;
- Snort is a fairly well-known system to counter intrusions, among other things, it detects attacks on the ARP protocol;
- ArpON is a small service that monitors the ARP table and protects it from spoofing MAC addresses.
In this article, we looked at how to use Ettercap, a program for analyzing network packets and performing Man-in-the-Middle attacks. Use the program only to test the security of your networks or applications, and do not forget that illegal actions in the information space are also punishable.