def arp_network_range(iprange):
logging.info('Sending ARPs to network range')
ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=iprange), timeout=5)
ip_collection = []
eth_collection = []
for snd, rcv in ans:
host_ip_address = rcv.sprintf(r"%ARP.psrc%")
host_eth_address = rcv.sprintf(r"%Ether.src%")
logging.info('%s' % host_ip_address)
logging.info('%s' % host_eth_address)
ip_collection.append(host_ip_address)
eth_collection.append(host_eth_address)
print "Host List IP Addresses:"
for host_ip in ip_collection:
print host_ip
print "Host List Ethernet Addresses:"
for host_eth in eth_collection:
print host_eth
with open("toucan_hosts.txt", "w") as output:
output.write(str(ip_collection))
output.write(str(eth_collection))
评论列表
文章目录