|
| 1 | +# Import scapy |
| 2 | +import scapy.all as scapy |
| 3 | +# We need to create regular expressions to ensure that the input is correctly formatted. |
| 4 | +import re |
| 5 | + |
| 6 | +# Basic user interface header |
| 7 | +print(r"""______ _ _ ______ _ _ |
| 8 | +| _ \ (_) | | | ___ \ | | | | |
| 9 | +| | | |__ ___ ___ __| | | |_/ / ___ _ __ ___ | |__ __ _| | |
| 10 | +| | | / _` \ \ / / |/ _` | | ___ \/ _ \| '_ ` _ \| '_ \ / _` | | |
| 11 | +| |/ / (_| |\ V /| | (_| | | |_/ / (_) | | | | | | |_) | (_| | | |
| 12 | +|___/ \__,_| \_/ |_|\__,_| \____/ \___/|_| |_| |_|_.__/ \__,_|_|""") |
| 13 | +print("\n****************************************************************") |
| 14 | +print("\n* Copyright of David Bombal, 2021 *") |
| 15 | +print("\n* https://www.davidbombal.com *") |
| 16 | +print("\n* https://www.youtube.com/davidbombal *") |
| 17 | +print("\n****************************************************************") |
| 18 | + |
| 19 | +# Regular Expression Pattern to recognise IPv4 addresses. |
| 20 | +ip_add_range_pattern = re.compile("^(?:[0-9]{1,3}\.){3}[0-9]{1,3}/[0-9]*$") |
| 21 | + |
| 22 | +# Get the address range to ARP |
| 23 | +while True: |
| 24 | + ip_add_range_entered = input("\nPlease enter the ip address and range that you want to send the ARP request to (ex 192.168.1.0/24): ") |
| 25 | + if ip_add_range_pattern.search(ip_add_range_entered): |
| 26 | + print(f"{ip_add_range_entered} is a valid ip address range") |
| 27 | + break |
| 28 | + |
| 29 | + |
| 30 | +# Try ARPing the ip address range supplied by the user. |
| 31 | +# The arping() method in scapy creates a pakcet with an ARP message |
| 32 | +# and sends it to the broadcast mac address ff:ff:ff:ff:ff:ff. |
| 33 | +# If a valid ip address range was supplied the program will return |
| 34 | +# the list of all results. |
| 35 | +arp_result = scapy.arping(ip_add_range_entered) |
0 commit comments