Skip to content

TypeError: AF_PACKET address must be a tuple of two to five elements #3775

@usama7628674

Description

@usama7628674

Brief description

I've a script deauth-ng.py upon running I get the following exception. Downgrading scapy version to 2.4.4 makes the script work fine.

Exception in thread Thread-1 (channel_hop):
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/home/kali/Desktop/deauth-ng.py", line 161, in channel_hop
    self.deauth()
  File "/home/kali/Desktop/deauth-ng.py", line 259, in deauth
    send(p, inter=float(self.mTimeout), count=self.mPackets)
  File "/usr/local/lib/python3.10/dist-packages/scapy/sendrecv.py", line 425, in send
    return _send(
  File "/usr/local/lib/python3.10/dist-packages/scapy/sendrecv.py", line 395, in _send
    results = __gen_send(socket, x, inter=inter, loop=loop,
  File "/usr/local/lib/python3.10/dist-packages/scapy/sendrecv.py", line 360, in __gen_send
    s.send(p)
  File "/usr/local/lib/python3.10/dist-packages/scapy/arch/linux.py", line 605, in send
    self.outs.bind(sdto)
TypeError: AF_PACKET address must be a tuple of two to five elements

Scapy version

2.4.5

Python version

3.10.7

Operating system

Linux kali 5.18.0-kali7-amd64 #1 SMP PREEMPT_DYNAMIC Debian 5.18.16-1kali1 (2022-08-31) x86_64 GNU/Linux

Additional environment information

No response

How to reproduce

Here is the part of script that generates error

from scapy.all import *
def deauth(self):
        pkts = []
        # print(len(self.clients), len(self.APs))

        if len(self.clients) > 0:
            with threadLock:
                for x in self.clients:
                    client = x[0]
                    ap = x[1]
                    ch = x[2]
                    # print(str(ch)+":"+str(self.mChannel))
                    if int(ch) == int(self.mChannel):
                        deauth_pkt1 = Dot11(addr1=client, addr2=ap, addr3=ap)/Dot11Deauth()
                        deauth_pkt2 = Dot11(addr1=ap, addr2=client, addr3=client)/Dot11Deauth()
                        disas_pkt1 = Dot11(addr1=ap, addr2=client, addr3=client)/Dot11Disas()
                        disas_pkt2 = Dot11(addr1=client, addr2=ap, addr3=ap)/Dot11Disas()
                        pkts.append(deauth_pkt1)
                        pkts.append(deauth_pkt2)

                        pkts.append(disas_pkt1)
                        pkts.append(disas_pkt2)

        if len(self.APs) > 0:
            if not self.mDirected:
                with threadLock:
                    for a in self.APs:
                        ap = a[0]
                        ch = a[1]
                        # print(str(ch)+":"+str(self.mChannel))
                        if int(ch) == int(self.mChannel):
                            deauth_ap = Dot11(addr1='ff:ff:ff:ff:ff:ff', addr2=ap, addr3=ap)/Dot11Deauth()
                            pkts.append(deauth_ap)

        if len(pkts) > 0:
            for p in pkts:
                send(p, inter=float(self.mTimeout), count=self.mPackets)

The error occurs at the last line send(p, inter=float(self.mTimeout), count=self.mPackets)

Actual result

image

Expected result

image

Related resources

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions