Merge pull request #75 from Niller303/refactor
Added fix for bad drivers
This commit is contained in:
@@ -15,6 +15,10 @@ class Airmon(object):
|
|||||||
base_interface = None
|
base_interface = None
|
||||||
killed_network_manager = False
|
killed_network_manager = False
|
||||||
|
|
||||||
|
#see if_arp.h
|
||||||
|
ARPHRD_ETHER = 1 #managed
|
||||||
|
ARPHRD_IEEE80211_RADIOTAP = 803 #monitor
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
@@ -56,6 +60,24 @@ class Airmon(object):
|
|||||||
interfaces.append(Interface(fields))
|
interfaces.append(Interface(fields))
|
||||||
return interfaces
|
return interfaces
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def start_baddriver(iface): #fix for bad drivers like the rtl8812AU
|
||||||
|
os.system("ifconfig %s down; iwconfig %s mode monitor; ifconfig %s up" % (iface, iface, iface))
|
||||||
|
with open("/sys/class/net/" + iface + "/type", "r") as f:
|
||||||
|
if (int(f.read()) == Airmon.ARPHRD_IEEE80211_RADIOTAP):
|
||||||
|
return iface
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def stop_baddriver(iface):
|
||||||
|
os.system("ifconfig %s down; iwconfig %s mode managed; ifconfig %s up" % (iface, iface, iface))
|
||||||
|
with open("/sys/class/net/" + iface + "/type", "r") as f:
|
||||||
|
if (int(f.read()) == Airmon.ARPHRD_ETHER):
|
||||||
|
return iface
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def start(iface):
|
def start(iface):
|
||||||
'''
|
'''
|
||||||
@@ -91,6 +113,8 @@ class Airmon(object):
|
|||||||
|
|
||||||
if mon_iface is None:
|
if mon_iface is None:
|
||||||
# Airmon did not enable monitor mode on an interface
|
# Airmon did not enable monitor mode on an interface
|
||||||
|
mon_iface = Airmon.start_baddriver(iface)
|
||||||
|
if mon_iface is None:
|
||||||
Color.pl("{R}failed{W}")
|
Color.pl("{R}failed{W}")
|
||||||
|
|
||||||
mon_ifaces = Airmon.get_interfaces_in_monitor_mode()
|
mon_ifaces = Airmon.get_interfaces_in_monitor_mode()
|
||||||
@@ -134,6 +158,9 @@ class Airmon(object):
|
|||||||
mon_iface = match.groups()[0]
|
mon_iface = match.groups()[0]
|
||||||
break
|
break
|
||||||
|
|
||||||
|
if not mon_iface:
|
||||||
|
mon_iface = Airmon.stop_baddriver(iface)
|
||||||
|
|
||||||
if mon_iface:
|
if mon_iface:
|
||||||
Color.pl('{R}disabled %s{W}' % mon_iface)
|
Color.pl('{R}disabled %s{W}' % mon_iface)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user