From e9e4e956c7684736d88f22c1ddfaf9a3ce4b9f3d Mon Sep 17 00:00:00 2001 From: Shubham Saini Date: Wed, 25 Jan 2023 01:16:15 -0800 Subject: renamed --- netscan.py | 30 ++++++++++++++++++++++++++++++ network_scanner.py | 30 ------------------------------ 2 files changed, 30 insertions(+), 30 deletions(-) create mode 100644 netscan.py delete mode 100644 network_scanner.py diff --git a/netscan.py b/netscan.py new file mode 100644 index 0000000..e505b6e --- /dev/null +++ b/netscan.py @@ -0,0 +1,30 @@ +import scapy.all as scapy +import argparse + +def get_arguments(): + parser = argparse.ArgumentParser() + parser.add_argument("-t", "--targer", dest="target", help="Target IP / IP Range") + options = parser.parse_args() + return options + +def scan(ip): + arp_request = scapy.ARP(pdst=ip) + broadcast = scapy.Ether(dst="ff:ff:ff:ff:ff:ff") + arp_request_broadcast = broadcast/arp_request + answered_list = scapy.srp(arp_request_broadcast, timeout=3, verbose=False)[0] + + clients_list = [] + + for element in answered_list: + client_dict = {"ip": element[1].psrc, "mac": element[1].hwsrc} + clients_list.append(client_dict) + return clients_list + +def print_result(results_list): + print("IP Address\t\t\tMAC Address\n------------------------------------------------") + for client in results_list: + print(client["ip"] + "\t\t" + client["mac"]) + +options = get_arguments() +scan_result = scan(options.target) +print_result(scan_result) diff --git a/network_scanner.py b/network_scanner.py deleted file mode 100644 index e505b6e..0000000 --- a/network_scanner.py +++ /dev/null @@ -1,30 +0,0 @@ -import scapy.all as scapy -import argparse - -def get_arguments(): - parser = argparse.ArgumentParser() - parser.add_argument("-t", "--targer", dest="target", help="Target IP / IP Range") - options = parser.parse_args() - return options - -def scan(ip): - arp_request = scapy.ARP(pdst=ip) - broadcast = scapy.Ether(dst="ff:ff:ff:ff:ff:ff") - arp_request_broadcast = broadcast/arp_request - answered_list = scapy.srp(arp_request_broadcast, timeout=3, verbose=False)[0] - - clients_list = [] - - for element in answered_list: - client_dict = {"ip": element[1].psrc, "mac": element[1].hwsrc} - clients_list.append(client_dict) - return clients_list - -def print_result(results_list): - print("IP Address\t\t\tMAC Address\n------------------------------------------------") - for client in results_list: - print(client["ip"] + "\t\t" + client["mac"]) - -options = get_arguments() -scan_result = scan(options.target) -print_result(scan_result) -- cgit v1.2.3