Home Wireless Card returns back to managed mode after a couple seconds | Python
Reply: 0

Wireless Card returns back to managed mode after a couple seconds | Python

Shameer Kashif
1#
Shameer Kashif Published in 2018-01-12 13:45:00Z

I am trying to put my WN722N Wireless Card in Monitor Mode while being in Python environment. I used python-wifi library as well as command-line to put the Wireless card in monitor but after sometime it comes back to its previous state with return of an OSError.

This is what i am trying to do:

iface = raw_input("Wireless Interface") #wlan1 in my case
os.system('ip link set %s down' % iface)
os.system('iwconfig %s mode monitor' % iface)
os.system('ip link set %s up' % iface)

In fact it does work and put my Wireless Card (wlan1) in monitor mode but for not more than 5 to 6 seconds and an error is raised in one of the threads running in the background. The code of thread is:

from scapy.all import *
from threading import Thread
def function(pkt):
    if pkt.haslayer(Dot11Beacon):
    <...snipped...>
sniff(iface=<monitor mode interface here>, prn=function)

Error which raise after 5 to 6 seconds:

Exception in thread Thread-3:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "python.py", line 113, in depDev
p = sendp(pckt, iface=interface)
File "/usr/lib/python2.7/dist-packages/scapy/sendrecv.py", line 278, 
in sendp
return __gen_send(conf.L2socket(iface=iface, *args, **kargs), x, 
inter=inter, loop=loop, count=count,
File "/usr/lib/python2.7/dist-packages/scapy/arch/linux.py", line 434, 
in __init__
_flush_fd(self.ins)
File "/usr/lib/python2.7/dist-packages/scapy/arch/linux.py", line 312, 
in _flush_fd
os.read(fd,MTU)
OSError: [Errno 100] Network is down

I also tried using python-wifi

from pythonwifi.iwlibs import Wireless
dev = Wireless(iface)
dev.setMode("Monitor")

But nothing changed

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.31269 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO