-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Hi,
The issue is that Scapy does not inject packets in monitor mode. Sniffing works fine. The following are some packets captured in monitor mode:
This is my environment:
- WiFi chipset and driver: Atheros AR9285 and ath9k. The chipset supports monitor mode and packet injection. I have checked it with
aireplay-ng
. - OS: Ubuntu 18.04 Desktop (kernel version: 5.4.0-89)
- Python version: 3.6.9
- Scapy version: 2.4.5
For installing Scapy I used:
- sudo python3 -m pip install --pre scapy[basic]
For setting the interface into Monitor mode:
airmon-ng check kill
airmon-ng start wlp2s0 9
(but I also tried with ifconfig and iwconfig)
My code for injecting packets with scapy is the following:
#!/usr/bin/python3
from scapy.all import *
conf.use_pcap = True
conf.iface = 'wlp2s0mon'
my_addr = '22:22:22:22:22:22'
dst_addr = 'ff:ff:ff:ff:ff:ff'
capture = sniff(count = 5,iface = conf.iface)
capture.summary()
beacon_pkt = RadioTap() / Dot11(addr1=dst_addr, addr2=my_addr, addr3=my_addr) \
/ Dot11Beacon() / Dot11Elt(ID='SSID', info='My_SSID', len=len('My_SSID'))
beacon_pkt.show()
print("\nHexdump of frame:")
hexdump(beacon_pkt)
input("\nPress enter to start\n")
sendp(beacon_pkt, inter=0.1, count=10, iface=conf.iface, monitor = True)
The injected packets look like this:
But the packet injection fails, reporting the following errors:
Traceback (most recent call last):
File "ScapyCodePython3.py", line 19, in
sendp(beacon_pkt, inter=0.1, count=10, iface=interface, monitor = True)
File "/usr/local/lib/python3.6/dist-packages/scapy/sendrecv.py", line 463, in sendp
**kargs
File "/usr/local/lib/python3.6/dist-packages/scapy/sendrecv.py", line 394, in _send
socket = socket or _func(iface)(iface=iface, **kargs)
File "/usr/local/lib/python3.6/dist-packages/scapy/arch/libpcap.py", line 407, in init
monitor=monitor)
File "/usr/local/lib/python3.6/dist-packages/scapy/arch/libpcap.py", line 247, in init
raise OSError("Could not activate the pcap handler")
OSError: Could not activate the pcap handler
I have already checked this issue #2076, and I tried to solve the problem by:
- Adding libpcap to my python environment
sudo python3 -m pip install libpcap
- Installing both pcapy and pypcap
- Using the Master branch
- I saw they solved the problem using another version of the driver, so I installed a different version of the ath9k driver using backports. Specifically, I downloaded the stable backport backports-5.10.68-1.tar.gz and then used the following commands:
sudo make defconfig-ath9k
sudo make
sudo make install
But unfortunately, the problem persists.
Please, could anyone help me by suggesting something different to try? Is there anything wrong with the procedure/configuration that I described above?
Thank you very much in advance for your help.
Regards,
Dayrene