-
Notifications
You must be signed in to change notification settings - Fork 340
/
lanscan.py
35 lines (30 loc) · 2.1 KB
/
lanscan.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Import scapy
import scapy.all as scapy
# We need to create regular expressions to ensure that the input is correctly formatted.
import re
# Basic user interface header
print(r""" $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$ _____ _____ __________ _________ _______ __________ $$
$$ | \ / | / ____ \ | ____ \ / ____ \ | ______/ $$
$$ | |\ \/ /| | / / \ \ | | \ | | | |__| | | $$
$$ | | \ / | | | | | | | |____/ _/ | |_____ | |______ $$
$$ | | \__/ | | | | | | | _ \ \______ \ | ______| $$
$$ | | | | | | | | | | \ \ __ | | | | $$
$$ | | | | \ \____/ / | | \ \ | |____| | | |_______ $$
$$ |___| |___| \__________/ |___| \___\ \________/ |__________\ $$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ """)
print("\n* Copyright of Morse, 2021")
# Regular Expression Pattern to recognise IPv4 addresses.
ip_add_range_pattern = re.compile("^(?:[0-9]{1,3}\.){3}[0-9]{1,3}/[0-9]*$")
# Get the address range to ARP
while True:
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): ")
if ip_add_range_pattern.search(ip_add_range_entered):
print(f"{ip_add_range_entered} is a valid ip address range")
break
# Try ARPing the ip address range supplied by the user.
# The arping() method in scapy creates a pakcet with an ARP message
# and sends it to the broadcast mac address ff:ff:ff:ff:ff:ff.
# If a valid ip address range was supplied the program will return
# the list of all results.
arp_result = scapy.arping(ip_add_range_entered)