#!/usr/bin/env python3

import subprocess
import optparse
import scapy.all as scapy

def scan(ip):
    broadcast = scapy.Ether(dst='ff:ff:ff:ff:ff:ff')
    arp_request = scapy.ARP(pdst=ip)
    arp_request_broadcast = broadcast/arp_request
    answered = scapy.srp(arp_request_broadcast, timeout=1, verbose=False)[0]
    print("IP\t\t\tMAC")
    print("-----------------------------------------")
    for element in answered:
        print(element[1].psrc + "\t\t" + element[1].hwsrc)

def get_ip():
    parser = optparse.OptionParser()
    parser.add_option('-t', '--target', dest='target', help='Target IP: may be individual or range.')
    (options, arguments) = parser.parse_args()
    if not options.target:
        parser.error('[-] Please specify a target IP or range of IPs using -t or --target.')
    return options.target

scan(get_ip())