Lab 5: Tools & Tips for Address Resolution Protocol
Total Page:16
File Type:pdf, Size:1020Kb
Lab 5: Tools & Tips for Address Resolution Protocol How does ARP work and what does it accomplish? IPv4 is still the most common level of Internet Protocol that is in use. The destination address of packets that are routed using IPv4 is a four octet number where octets are separated by a period. An example of such as address is 10.52.19.234. But devices, such as computers, that should receive sent packets are not built as systems that can be identified by a unique four octet IPv4 address. These devices do have a unique address, called a MAC address, which is 6 octets in length, where octets are separated by colons, such as 0D:17:EF:30:3A:0C. So, in order for a packet to reach the intended destination some translation from IPv4 address to MAC address is necessary. For a given LAN such a translation is maintained in a table called an ARP cache. So, when a packet arrives at a LAN gateway a table lookup in the ARP cache hopefully finds the device that should receive the packet through its MAC address and the packet is then sent to that device. If the ARP cache contains no translation for a given IPv4 address then a call is broadcast to devices in the LAN asking for the MAC address of the device that is expecting to receive packets with the given IPv4 address destination. The device that is set up to receive the given IPv4 addressed packet then sends a reply stating that it (identified by its MAC address) is the device that should receive the packet. The ARP cache is updated and the packet is sent to the claiming device. Security of ARP: IPv4 was designed in 1980 long before the word cybersecurity was coined. It was designed at a time when the Internet was populated mainly with academics and researchers. Internet browsers showed up 10 years later, along with concerns for security and safety on the Internet. But in 1980 a lot of implicit trust existed on the Internet and people were allowed to freely grab files from and deposit files on connected machines, even if they were not acquainted with the owner and had no account, through anonymous ftp. Richard Stallman was a firm believer in not having passwords saying “I don't believe that it's really desirable to have security on a computer, I shouldn't be willing to help uphold the security regime [with passwords].” So, in a world of trust, ARP was fine but now ARP can cause serious security problems: an imposter can claim a packet for itself even if it is not the intended recipient; an attacker can change entries in the ARP cache causing packets to miss their intended recipients and be redirected to malicious sites. ARP tools: Wireshark Wireshark may be used to observe LAN traffic and therefore observe ARP requests and responses. If Wireshark is properly set up, open wireshark, choose ‘Capture’ then ‘Options’, then select the interface over which you want to observe traffic and click ‘Start’. Figure 1 and Figure 2 show results over interface wlo1 on a laptop during a video meeting. The top window of Figure 1 shows an ARP request packet in which the Cisco gateway router at address 192.168.1.1 asks which connected machine expects packets bound for 192.168.1.107. The middle window of Figure 1 shows the fields of the ARP request packet. Clicking on any one field highlights the contents of the field in the bottom window. In this figure the ‘Target IP Address’ field is highlighted and is 192.168.1.107. Notice the field next to that is the ‘Target MAC Address’ which is 00:00:00:00:00:00 because this is the object of query. The field ‘Sender MAC Address’ has the MAC address of the Cisco router (the sender of the request) which is 68:7f:74:26:28:86. Figure 2 shows an ARP reply. Field names are the same as for the ARP request but the ‘Sender MAC Address’ (the sender is now the intended recipient) is now filled in with 80:86:f2:2f:89:42 which is the answer the router is looking for. The ‘Target MAC Address’ is the former ‘Sender MAC Address’ which is the router’s MAC address. Figure 1: Wireshark listening to interface wlo1 highlighting an ARP request packet Figure 2: Wireshark listening to interface wlo1 and with highlighted ARP reply packet Wireshark will reveal the frequency with which ARP requests and replies occur and any surprises, such as ARP poisoning attempts. arp: This is a tool for manipulating the ARP cache. It can add or delete table entries and can display entries. Figure 3 shows arp invoked with no arguments displays the contents of the ARP cache. Figure 3: Invoke arp with no arguments to see ARP cache contents – jelly-near is 192.168.1.107 Figure 4 shows arp used to delete an ARP cache table entry. Notice this requires super user access so there is a level of security here. Figure 4: Invoke arp -d 192.168.1.113 to remove ARP cache table entry 192.168.1.113 Figure 5 shows arp used to add an entry to the ARP cache table. This also requires super user access. Figure 5: Invoke arp -s 192.168.1.113 11:22:33:44:55:66 to add the 192.168.1.113 entry to the ARP cache table For other uses of arp one may consult the complete documentation – in Linux ‘man arp’ is sufficient. arping: Sends ARP or IP pings to a host and displays replys. One request is sent per second. When pinging an IP address an ARP who-has query is sent. When pinging a MAC address a directed broadcast ICMP Echo request is sent. Figure 6 shows a simple application of arping using a host’s IP address. Replies include the host’s MAC address. An arping can be used to change an ARP table entry of a host’s ARP table. Figure 7 shows the command sudo arping -f -A -U -I wlo1 -s 192.168.1.113 192.168.1.108 run from a machine we will call the target machine with two IP addresses: 192.168.1.113 on interface enp0s25 and 192.168.1.114 on interface wlo1. The ARP cache of the target, at IP address 192.168.1.108, before this arping command is run and after logging into 192.168.1.108 from 192.168.1.113 (interface enp0s25) is shown as the output of the first call to arp in Figure 8. This simulates a change to the target’s ARP cache that an attacker may have made earlier. Observe the MAC address associated with 192.168.1.113 in the ARP cache is 64:51:06:9f:3a:b3 (this happens to be the MAC address of interface enp0s25 on the target machine and is used here to simulate a changed MAC address that an attacker may have made). The ARP cache of the target after the command of Figure 7 is run is shown as the output of the second call to arp in Figure 8. Observe the MAC address associated with 192.168.1.113 in the target’s ARP cache has changed to a0:a8:cd:9d:07:d8 which is the MAC address of interface wlo1 on the victim machine. Thus, the arping command above enabled the victim to change the target’s victim ARP cache entry to the correct association without requiring the victim to have an account on the target machine (for clarity: enp0s25 was used merely as a convenient way to simulate the action of an attacker in changing an APR cache entry of the victim – wlo1 was the victim’s interface in this simulation). Figure 6: Example of arping query specifying host IP address Figure 7: arping command run from machine 192.168.1.113, interface enp0s15, targeting ARP cache of machine 192.168.1.108. Figure 8: The first call to arp shows the ARP cache of the target at 192.168.1.108 before the command of Figure 7 is run and after logging in from 192.168.1.113, interface enp0s25. The second call to arp shows the target’s ARP cache after the command of Figure 7 is run. arpon: Utility that makes the ARP standardized protocol secure in order to avoid a Man-In-the-Middle (MITM) attack through ARP spoofing, ARP cache poisoning or ARP poison routing. Anti-ARP spoofing methods are intended for 1) statically configured networks without DHCP; 2) dynamically configured networks (DHCP only); and 3) hybrid networks where some addresses are static and some are dynamic. More than one of the above anti-spoofing methods may be active collaterally. The easiest way to use arpon is through the configuration file /etc/arpon.conf an example of which is shown in Figure 9. Figure 9: Example of /etc/arpon.conf The utility can be run using the following command: sudo arpon -i wlo1 -d -S where -d means daemonize arpon, -S means entries in /etc/arpon.conf are for static IP addresses, and -i wlo1 means the IP addresses of /etc/arpon.conf are accessible via ether interface wlo1. Figure 10 shows the command being issued and the state of the ARP cache afterwards. Figure 10: A call to arpon followed by a display of the ARP cache Similarly, the command for a DHCP interface is sudo arpon -i wlo1 -d -D and for a hybrid interface is sudo arpon -i wlo1 -d -H For more than one interface with static IP addresses, the addresses over all the interfaces may be added to the configuration file.