简体   繁体   中英

Could not activate the pcap handler

I try to sniff.network adapter(TP-LINK, 0bda:b711) with python3, But I get an OSError: Could not activate the pcap handler

from scapy.all import *
from scapy.config import conf
from scapy.layers.dot11 import Dot11


conf.use_pcap = True


def callBack(pkg):
    if pkg.haslayer(Dot11):
        if pkg.type == 0 and pkg.subtype == 8:
            print("dBm_AntSignal=", pkg.dBm_AntSignal)
            print("dBm_AntNoise=", pkg.dBm_AntNoise)


sniff(iface='wlp1s1', monitor='True', prn=callBack)

I think there is something wrong with libpcap, I want to get dBm_AntSignal and dBm_AntNoise from sniff, the code can run Macbook according to other people(you can browse my last question). Is there somebody can solve this issue?

If you posted issue #1136 on the libpcap issues list , then you presumably somehow managed to determine that pcap_activate() returned PCAP_ERROR . If you did that by modifying the Scapy code, try modifying it further to, if pcap_activate() returns PCAP_ERROR , report the result of pcap_geterr() , in order to try to find out why , in this particular instance, pcap_activate() returned PCAP_ERROR . The problem is that PCAP_ERROR can be returned for a number of different reasons, and it's difficult if not impossible to guess which one it was.

(And then file an issue on Scapy's issue list indicating that the error message for pcap_activate() failing should be based on both the return value from pcap_activate() and, for certain errors, the result of pcap_geterr() . They should also distinguish between error returns from pcap_activate() , which are negative numbers, and warning returns from pcap_activate() , which indicate that the "pcap handler" could be activated, but something unexpected happened, and are positive numbers.)

Update:

No need to file the Scapy issue; I've already submitted a pull request for the change to fix the error reporting , and it's been merged. Apply the changes from that pull request to Scapy and try again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM