예제 #1
0
def handle_band(attr, fpol):
    e, battr = nl.py_nla_parse_nested(nl80211.NL80211_BAND_ATTR_MAX, attr,
                                      None)
    print("\tband %d:" % nl.nla_type(attr))
    if nl80211.NL80211_BAND_ATTR_FREQS in battr:
        for fattr in nl.nla_get_nested(battr[nl80211.NL80211_BAND_ATTR_FREQS]):
            handle_freq(fattr, fpol)
예제 #2
0
파일: base.py 프로젝트: oprsystem/py80211
 def create_map(self, map_attr, pol):
     nest_map = {}
     for key in nl.nla_get_nested(map_attr):
         nest_list = self.create_list(key, pol)
         if len(nest_list) > 0:
             nest_map[nl.nla_type(key)] = nest_list
     return nest_map
예제 #3
0
파일: base.py 프로젝트: arend/py80211
	def create_map(self, map_attr, pol):
		nest_map = {}
		for key in nla_get_nested(map_attr):
			nest_list = self.create_list(key, pol)
			if len(nest_list) > 0:
				nest_map[nla_type(key)] = nest_list
		return nest_map
예제 #4
0
def msg_handler(m, a):
    try:
        e, attr = genl.py_genlmsg_parse(nl.nlmsg_hdr(m), 0,
                                        nl80211.NL80211_ATTR_MAX, None)
        if nl80211.NL80211_ATTR_WIPHY_NAME in attr:
            print('wiphy %s' %
                  nl.nla_get_string(attr[nl80211.NL80211_ATTR_WIPHY_NAME]))
        if nl80211.NL80211_ATTR_WIPHY_BANDS in attr:
            fpol = nl.nla_policy_array(nl80211.NL80211_FREQUENCY_ATTR_MAX + 1)
            fpol[nl80211.NL80211_FREQUENCY_ATTR_FREQ].type = nl.NLA_U32
            fpol[nl80211.NL80211_FREQUENCY_ATTR_DISABLED].type = nl.NLA_FLAG
            fpol[
                nl80211.NL80211_FREQUENCY_ATTR_PASSIVE_SCAN].type = nl.NLA_FLAG
            fpol[nl80211.NL80211_FREQUENCY_ATTR_NO_IBSS].type = nl.NLA_FLAG
            fpol[nl80211.NL80211_FREQUENCY_ATTR_RADAR].type = nl.NLA_FLAG
            fpol[nl80211.NL80211_FREQUENCY_ATTR_MAX_TX_POWER].type = nl.NLA_U32

            nattrs = nl.nla_get_nested(attr[nl80211.NL80211_ATTR_WIPHY_BANDS])
            for nattr in nattrs:
                handle_band(nattr, fpol)
        if nl80211.NL80211_ATTR_CIPHER_SUITES in attr:
            ciphers = nl.nla_data(attr[nl80211.NL80211_ATTR_CIPHER_SUITES])
            num = len(ciphers) / 4
            if num > 0:
                print("\tSupported Ciphers:")
                for i in range(0, num, 4):
                    print("\t\t* %s" % cipher_name(ciphers[i:i + 4]))
        if nl80211.NL80211_ATTR_SUPPORTED_IFTYPES in attr:
            print("\tSupported interface modes:")
            ifattr = nl.nla_get_nested(
                attr[nl80211.NL80211_ATTR_SUPPORTED_IFTYPES])
            for nl_mode in ifattr:
                print("\t\t* %s" %
                      nl80211.nl80211_iftype2str[nl.nla_type(nl_mode)])
        if nl80211.NL80211_ATTR_SOFTWARE_IFTYPES in attr:
            print("\tsoftware interface modes (can always be added):")
            ifattr = nl.nla_get_nested(
                attr[nl80211.NL80211_ATTR_SOFTWARE_IFTYPES])
            for nl_mode in ifattr:
                print("\t\t* %s" %
                      nl80211.nl80211_iftype2str[nl.nla_type(nl_mode)])
        return nl.NL_SKIP
    except Exception as e:
        (t, v, tb) = sys.exc_info()
        print v.message
        traceback.print_tb(tb)
예제 #5
0
파일: base.py 프로젝트: oprsystem/py80211
 def create_nested_list(self, attr_list, aid):
     nest_list = []
     for nest_element in nl.nla_get_nested(attr_list):
         nest_obj = self.create_nested(nest_element, aid)
         if isinstance(nest_obj, nl80211_object):
             nest_obj.nla_type = nl.nla_type(nest_element)
         nest_list.append(nest_obj)
     return nest_list
예제 #6
0
파일: base.py 프로젝트: arend/py80211
	def create_nested_list(self, attr_list, aid):
		nest_list = []
		for nest_element in nla_get_nested(attr_list):
			nest_obj = self.create_nested(nest_element, aid)
			if isinstance(nest_obj, nl80211_object):
				nest_obj.nla_type = nla_type(nest_element)
			nest_list.append(nest_obj)
		return nest_list
예제 #7
0
파일: base.py 프로젝트: FomkaV/wifi-arsenal
	def store_nested(self, attr, aid):
		nest_class = None
		if aid in self.nest_attr_map.keys():
			nest_class = self.nest_attr_map[aid]
		self._attrs[aid] = []
		for nest_element in nl.nla_get_nested(attr):
			if nest_class == None:
				self._attrs[aid].append(nl.nla_type(nest_element))
			else:
				e, nattr = nl.py_nla_parse_nested(nest_class.max_attr, nest_element, nest_class.policy)
				self._attrs[aid].append(nest_class(nattr))
예제 #8
0
def msg_handler(m, a):
	try:
		e, attr = genl.py_genlmsg_parse(nl.nlmsg_hdr(m), 0,
						nl80211.NL80211_ATTR_MAX, None)
		if nl80211.NL80211_ATTR_WIPHY_NAME in attr:
			print('wiphy %s' % nl.nla_get_string(attr[nl80211.NL80211_ATTR_WIPHY_NAME]))
		if nl80211.NL80211_ATTR_WIPHY_BANDS in attr:
			fpol = nl.nla_policy_array(nl80211.NL80211_FREQUENCY_ATTR_MAX + 1)
			fpol[nl80211.NL80211_FREQUENCY_ATTR_FREQ].type = nl.NLA_U32
			fpol[nl80211.NL80211_FREQUENCY_ATTR_DISABLED].type = nl.NLA_FLAG
			fpol[nl80211.NL80211_FREQUENCY_ATTR_PASSIVE_SCAN].type = nl.NLA_FLAG
			fpol[nl80211.NL80211_FREQUENCY_ATTR_NO_IBSS].type = nl.NLA_FLAG
			fpol[nl80211.NL80211_FREQUENCY_ATTR_RADAR].type = nl.NLA_FLAG
			fpol[nl80211.NL80211_FREQUENCY_ATTR_MAX_TX_POWER].type = nl.NLA_U32

			nattrs = nl.nla_get_nested(attr[nl80211.NL80211_ATTR_WIPHY_BANDS])
			for nattr in nattrs:
				handle_band(nattr, fpol)
		if nl80211.NL80211_ATTR_CIPHER_SUITES in attr:
			ciphers = nl.nla_data(attr[nl80211.NL80211_ATTR_CIPHER_SUITES])
			num = len(ciphers) / 4
			if num > 0:
				print("\tSupported Ciphers:");
				for i in range(0, num, 4):
					print("\t\t* %s" % cipher_name(ciphers[i:i+4]))
		if nl80211.NL80211_ATTR_SUPPORTED_IFTYPES in attr:
			print("\tSupported interface modes:")
			ifattr = nl.nla_get_nested(attr[nl80211.NL80211_ATTR_SUPPORTED_IFTYPES])
			for nl_mode in ifattr:
				print("\t\t* %s" % nl80211.nl80211_iftype2str[nl.nla_type(nl_mode)])
		if nl80211.NL80211_ATTR_SOFTWARE_IFTYPES in attr:
			print("\tsoftware interface modes (can always be added):")
			ifattr = nl.nla_get_nested(attr[nl80211.NL80211_ATTR_SOFTWARE_IFTYPES])
			for nl_mode in ifattr:
				print("\t\t* %s" % nl80211.nl80211_iftype2str[nl.nla_type(nl_mode)])
		return nl.NL_SKIP
	except Exception as e:
		(t,v,tb) = sys.exc_info()
		print v.message
		traceback.print_tb(tb)
예제 #9
0
파일: base.py 프로젝트: szehl/wifi-arsenal
 def store_nested(self, attr, aid):
     nest_class = None
     if aid in self.nest_attr_map.keys():
         nest_class = self.nest_attr_map[aid]
     self._attrs[aid] = []
     for nest_element in nl.nla_get_nested(attr):
         if nest_class == None:
             self._attrs[aid].append(nl.nla_type(nest_element))
         else:
             e, nattr = nl.py_nla_parse_nested(nest_class.max_attr,
                                               nest_element,
                                               nest_class.policy)
             self._attrs[aid].append(nest_class(nattr))
예제 #10
0
파일: base.py 프로젝트: oprsystem/py80211
 def create_list(self, attr_list, pol):
     nest_list = []
     item_type = pol.list_type
     for item in nl.nla_get_nested(attr_list):
         if item_type == NLA_NUL_STRING:
             nest_obj = nl.nla_get_string(item)
         elif item_type == nl.NLA_U64:
             nest_obj = nl.nla_get_u64(item)
         elif item_type == nl.NLA_U32:
             nest_obj = nl.nla_get_u32(item)
         elif item_type == nl.NLA_U16:
             nest_obj = nl.nla_get_u16(item)
         elif item_type == nl.NLA_U8:
             nest_obj = nl.nla_get_u8(item)
         else:
             raise Exception("type (%d) not supported for list" % item_type)
         nest_list.append(nest_obj)
     return nest_list
예제 #11
0
파일: base.py 프로젝트: arend/py80211
	def create_list(self, attr_list, pol):
		nest_list = []
		item_type = pol.list_type
		for item in nla_get_nested(attr_list):
			if item_type == NLA_NUL_STRING:
				nest_obj = nla_get_string(item)
			elif item_type == NLA_U64:
				nest_obj = nla_get_u64(item)
			elif item_type == NLA_U32:
				nest_obj = nla_get_u32(item)
			elif item_type == NLA_U16:
				nest_obj = nla_get_u16(item)
			elif item_type == NLA_U8:
				nest_obj = nla_get_u8(item)
			else:
				raise Exception("type (%d) not supported for list" % item_type)
			nest_list.append(nest_obj)
		return nest_list
예제 #12
0
def handle_band(attr, fpol):
	e, battr = nl.py_nla_parse_nested(nl80211.NL80211_BAND_ATTR_MAX, attr, None)
	print("\tband %d:" % nl.nla_type(attr))
	if nl80211.NL80211_BAND_ATTR_FREQS in battr:
		for fattr in nl.nla_get_nested(battr[nl80211.NL80211_BAND_ATTR_FREQS]):
			handle_freq(fattr, fpol)
예제 #13
0
	def create_nested_list(self, attr_list, aid):
		nest_list = []
		for nest_element in nl.nla_get_nested(attr_list):
			nest_obj = self.create_nested(nest_element, aid)
			nest_list.append(nest_obj)
		return nest_list