Sunday, January 10, 2016

Building your own tools with Scapy & Python - ARP Spoofing - code testing

In this post, an ARP Spoofing tool was created. However, creating the tool is one thing, ensuring it works as expected is another. In this post we take a look at validating that the tool works.

First thing to note is that the tool needs "admin" level privileges to work.

Additionally, while we are "listening" for a specific request, we will run tcpdump and or wireshark to assist with our validation.

Let's load "arpSpoof.py"
When "arpSpoof.py" is executed without "appropriate" arguments it brings up the "usage" screen.


To ensure you can capture the ARP request let's add an interface, an IP to listen for and a MAC address to spoof.

./arpSpoof.py eth0 192.168.0.91 AA:BB:CC:DD:EE:FF

From above:
eth0 - is the interface we will listen on
192.168.0.91 - IP for which the ARP is being requested for
AA:BB:CC:DD:EE:FF - The MAC address we would like to assign for 192.168.0.91


Testing from Windows 10
Before we attempt to verify that it works, let's see what we have in the ARP cache and results from "ping"

From the above, we see there is no entry in the ARP cache and when we try to ping, it states "Destination host unreachable".
Continuing with the arguments which were earlier used above, we can now execute our command which will allow the tool to listen for the ARP request.




Now that we are "listening". Let's send a "ping" which will force an ARP request.

From above we see that our "ping" results in "Request timed out" as opposed to the previous message "Destination host unreachable". Additionally, we see that we have managed to provide the MAC address of "aa-bb-cc-dd-ee-ff" for host "192.168.0.1" and that this information has been successfully added to the Windows 10 computer ARP cache.


Note, there can be many reasons why it states "Request timed out" and not an actual "ping" reply. One of these could be a firewall. However, the objective of this post is not to verify all of that but to show how we can spoof the ARP reply and poison the ARP cache of the requesting host.


Taking a look at the packet in Wireshark, we see the following:



Above we see 1 request for "192.168.0.1" being asked for by "192.168.0.30". We then see our 3 responses claiming that
"192.168.0.1" is at "aa:bb:cc:dd:ee:ff".

Additionally, we can verify this is our response by taking a look at the data which was sent in the ARP reply.

Hope you enjoyed!

4 comments:

  1. The article provides a practical demonstration of validating an ARP spoofing tool built with Scapy and Python. Rather than stopping after writing the script, it focuses on testing whether the tool actually produces the expected network behavior. The use of command-line arguments, interface selection, IP addresses, and MAC addresses also makes the example useful for understanding how Python can interact with network-level operations.

    The testing procedure is particularly interesting because the author first checks the Windows ARP cache and ping results before running the spoofing tool. The subsequent comparison shows how the ARP cache changes after the crafted response is received. Readers interested in developing their Python programming foundation can explore Python Course in Chennai alongside practical networking exercises.

    ReplyDelete
  2. The article also demonstrates how tcpdump and Wireshark can be used to validate what is happening at the packet level. Examining the ARP request and the responses that associate an IP address with the supplied MAC address provides a practical way to connect the Python implementation with observable network traffic. This kind of hands-on programming can be complemented by Python Training in Chennai.

    ReplyDelete
  3. From a cybersecurity perspective, the example illustrates why ARP behavior and local network communication are important areas for security testing. Observing how an ARP cache can be affected by crafted responses provides useful context for studying network security concepts in an authorized laboratory environment. These topics are relevant to Cyber Security Projects For Final Year Students, particularly projects involving network monitoring and security analysis.

    ReplyDelete
  4. The Wireshark validation further reinforces the value of examining packets rather than relying only on application output. By comparing the original ARP request with the generated responses, the article shows how packet captures can provide evidence that a network-testing experiment behaved as expected. This practical perspective is also relevant to Information Security Projects, where network and system security techniques can be explored through controlled project environments.

    ReplyDelete