import scapy.all as scapyimport argparsedefget_args(): parser = argparse.ArgumentParser() parser.add_argument('-t', '--target', dest='target', help='Target IP Address/Adresses') options = parser.parse_args()#Check for errors i.e if the user does not specify the target IP Address#Quit the program if the argument is missing#While quitting also display an error messageifnot options.target:#Code to handle if interface is not specified parser.error("[-] Please specify an IP Address or Addresses, use --help for more info.")return optionsdefscan(ip): arp_req_frame = scapy.ARP(pdst = ip) broadcast_ether_frame = scapy.Ether(dst ="ff:ff:ff:ff:ff:ff") broadcast_ether_arp_req_frame = broadcast_ether_frame / arp_req_frame answered_list = scapy.srp(broadcast_ether_arp_req_frame, timeout =1, verbose =False)[0] result = []for i inrange(0,len(answered_list)): client_dict ={"ip": answered_list[i][1].psrc,"mac": answered_list[i][1].hwsrc} result.append(client_dict)return resultdefdisplay_result(result):print("-----------------------------------\nIP Address\tMAC Address\n-----------------------------------")for i in result:print("{}\t{}".format(i["ip"], i["mac"]))options =get_args()scanned_output =scan(options.target)display_result(scanned_output)