[python] python
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- #!/usr/bin/env python
- import scapy.all as scapy
- import optparse
- def get_arguments():
- parser = optparse.OptionParser()
- parser.add_option("-t", "--target", dest="target", help="Target IP / IP range.")
- options, arguments = 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=1, 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\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)
Editor
You can edit this paste and save as new: