Beispiel #1
0
	def getNetworkList(self):
		if self.oldInterfaceState is None:
			self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
		if self.oldInterfaceState is False:
			if iNetwork.getAdapterAttribute(self.iface, "up") is False:
				iNetwork.setAdapterAttribute(self.iface, "up", True)
				enigma.eConsoleAppContainer().execute("ifconfig %s up" % self.iface)

		ifobj = Wireless(self.iface) # a Wireless NIC Object

		try:
			scanresults = ifobj.scan()
		except:
			scanresults = None
			print "[Wlan.py] No wireless networks could be found"
		aps = {}
		if scanresults is not None:
			(num_channels, frequencies) = ifobj.getChannelInfo()
			index = 1
			for result in scanresults:
				bssid = result.bssid

				if result.encode.flags & wififlags.IW_ENCODE_DISABLED > 0:
					encryption = False
				elif result.encode.flags & wififlags.IW_ENCODE_NOKEY > 0:
					encryption = True
				else:
					encryption = None

				signal = str(result.quality.siglevel-0x100) + " dBm"
				quality = "%s/%s" % (result.quality.quality,ifobj.getQualityMax().quality)

				extra = []
				for element in result.custom:
					element = element.encode()
					extra.append( strip(self.asciify(element)) )
				for element in extra:
					if 'SignalStrength' in element:
						signal = element[element.index('SignalStrength')+15:element.index(',L')]
					if 'LinkQuality' in element:
						quality = element[element.index('LinkQuality')+12:len(element)]

				# noinspection PyProtectedMember
				aps[bssid] = {
					'active' : True,
					'bssid': result.bssid,
					'channel': frequencies.index(ifobj._formatFrequency(result.frequency.getFrequency())) + 1,
					'encrypted': encryption,
					'essid': strip(self.asciify(result.essid)),
					'iface': self.iface,
					'maxrate' : ifobj._formatBitrate(result.rate[-1][-1]),
					'noise' : '',#result.quality.nlevel-0x100,
					'quality' : str(quality),
					'signal' : str(signal),
					'custom' : extra,
				}

				index += 1
		return aps
Beispiel #2
0
	def getNetworkList(self):
		if self.oldInterfaceState is None:
			self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
		if self.oldInterfaceState is False:
			if iNetwork.getAdapterAttribute(self.iface, "up") is False:
				iNetwork.setAdapterAttribute(self.iface, "up", True)
				system("ifconfig "+self.iface+" up")

		ifobj = Wireless(self.iface) # a Wireless NIC Object

		try:
			scanresults = ifobj.scan()
		except:
			scanresults = None
			print "[Wlan.py] No wireless networks could be found"
		aps = {}
		if scanresults is not None:
			(num_channels, frequencies) = ifobj.getChannelInfo()
			index = 1
			for result in scanresults:
				bssid = result.bssid

				if result.encode.flags & wififlags.IW_ENCODE_DISABLED > 0:
					encryption = False
				elif result.encode.flags & wififlags.IW_ENCODE_NOKEY > 0:
					encryption = True
				else:
					encryption = None

				signal = str(result.quality.siglevel-0x100) + " dBm"
				quality = "%s/%s" % (result.quality.quality,ifobj.getQualityMax().quality)

				extra = []
				for element in result.custom:
					element = element.encode()
					extra.append( strip(self.asciify(element)) )
				for element in extra:
					if 'SignalStrength' in element:
						signal = element[element.index('SignalStrength')+15:element.index(',L')]
					if 'LinkQuality' in element:
						quality = element[element.index('LinkQuality')+12:len(element)]

				# noinspection PyProtectedMember
				aps[bssid] = {
					'active' : True,
					'bssid': result.bssid,
					'channel': frequencies.index(ifobj._formatFrequency(result.frequency.getFrequency())) + 1,
					'encrypted': encryption,
					'essid': strip(self.asciify(result.essid)),
					'iface': self.iface,
					'maxrate' : ifobj._formatBitrate(result.rate[-1][-1]),
					'noise' : '',#result.quality.nlevel-0x100,
					'quality' : str(quality),
					'signal' : str(signal),
					'custom' : extra,
				}

				index += 1
		return aps
Beispiel #3
0
    def getNetworkList(self):
        if self.oldInterfaceState is None:
            self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
        if self.oldInterfaceState is False:
            if iNetwork.getAdapterAttribute(self.iface, "up") is False:
                iNetwork.setAdapterAttribute(self.iface, "up", True)
                system("ifconfig " + self.iface + " up")

        ifobj = Wireless(self.iface)  # a Wireless NIC Object

        try:
            scanresults = ifobj.scan()
        except:
            scanresults = None
            print "[Wlan.py] No wireless networks could be found"
        aps = {}
        if scanresults is not None:
            (num_channels, frequencies) = ifobj.getChannelInfo()
            index = 1
            for result in scanresults:
                bssid = result.bssid

                if result.encode.flags & wififlags.IW_ENCODE_DISABLED > 0:
                    encryption = False
                elif result.encode.flags & wififlags.IW_ENCODE_NOKEY > 0:
                    encryption = True
                else:
                    encryption = None

                signal = str(result.quality.siglevel - 0x100) + " dBm"
                quality = "%s/%s" % (result.quality.quality, ifobj.getQualityMax().quality)

                extra = []
                for element in result.custom:
                    element = element.encode()
                    extra.append(strip(self.asciify(element)))
                for element in extra:
                    if "SignalStrength" in element:
                        signal = element[element.index("SignalStrength") + 15 : element.index(",L")]
                    if "LinkQuality" in element:
                        quality = element[element.index("LinkQuality") + 12 : len(element)]

                        # noinspection PyProtectedMember
                aps[bssid] = {
                    "active": True,
                    "bssid": result.bssid,
                    "channel": frequencies.index(ifobj._formatFrequency(result.frequency.getFrequency())) + 1,
                    "encrypted": encryption,
                    "essid": strip(self.asciify(result.essid)),
                    "iface": self.iface,
                    "maxrate": ifobj._formatBitrate(result.rate[-1][-1]),
                    "noise": "",  # result.quality.nlevel-0x100,
                    "quality": str(quality),
                    "signal": str(signal),
                    "custom": extra,
                }

                index += 1
        return aps
Beispiel #4
0
	def getNetworkList(self):
		system("ifconfig "+self.iface+" up")
		ifobj = Wireless(self.iface) # a Wireless NIC Object
		
		#Association mappings
		#stats, quality, discard, missed_beacon = ifobj.getStatistics()
		#snr = quality.signallevel - quality.noiselevel

		try:
			scanresults = ifobj.scan()
		except:
			scanresults = None
			print "[Wlan.py] No Wireless Networks could be found"
		
		if scanresults is not None:
			aps = {}
			(num_channels, frequencies) = ifobj.getChannelInfo()
			index = 1
			for result in scanresults:
				bssid = result.bssid

				if result.encode.flags & wififlags.IW_ENCODE_DISABLED > 0:
					encryption = False
				elif result.encode.flags & wififlags.IW_ENCODE_NOKEY > 0:
					encryption = True
				else:
					encryption = None
				
				signal = str(result.quality.siglevel-0x100) + " dBm"
				quality = "%s/%s" % (result.quality.quality,ifobj.getQualityMax().quality)
				
				extra = []
				for element in result.custom:
					element = element.encode()
					extra.append( strip(self.asciify(element)) )
				for element in extra:
					print element
					if 'SignalStrength' in element:
						signal = element[element.index('SignalStrength')+15:element.index(',L')]					
					if 'LinkQuality' in element:
						quality = element[element.index('LinkQuality')+12:len(element)]				

				aps[bssid] = {
					'active' : True,
					'bssid': result.bssid,
					'channel': frequencies.index(ifobj._formatFrequency(result.frequency.getFrequency())) + 1,
					'encrypted': encryption,
					'essid': strip(self.asciify(result.essid)),
					'iface': self.iface,
					'maxrate' : ifobj._formatBitrate(result.rate[-1][-1]),
					'noise' : '',#result.quality.nlevel-0x100,
					'quality' : str(quality),
					'signal' : str(signal),
					'custom' : extra,
				}
				#print "GOT APS ENTRY:",aps[bssid]
				index = index + 1
			return aps
Beispiel #5
0
	def getNetworkList(self):
		system("ifconfig "+self.iface+" up")
		ifobj = Wireless(self.iface) # a Wireless NIC Object
		
		#Association mappings
		#stats, quality, discard, missed_beacon = ifobj.getStatistics()
		#snr = quality.signallevel - quality.noiselevel

		try:
			scanresults = ifobj.scan()
		except:
			scanresults = None
			print "[Wlan.py] No Wireless Networks could be found"
		
		if scanresults is not None:
			aps = {}
			(num_channels, frequencies) = ifobj.getChannelInfo()
			index = 1
			for result in scanresults:
				bssid = result.bssid

				if result.encode.flags & wififlags.IW_ENCODE_DISABLED > 0:
					encryption = False
				elif result.encode.flags & wififlags.IW_ENCODE_NOKEY > 0:
					encryption = True
				else:
					encryption = None
				
				signal = str(result.quality.siglevel-0x100) + " dBm"
				quality = "%s/%s" % (result.quality.quality,ifobj.getQualityMax().quality)
				
				extra = []
				for element in result.custom:
					element = element.encode()
					extra.append( strip(self.asciify(element)) )
				for element in extra:
					print element
					if 'SignalStrength' in element:
						signal = element[element.index('SignalStrength')+15:element.index(',L')]					
					if 'LinkQuality' in element:
						quality = element[element.index('LinkQuality')+12:len(element)]				

				aps[bssid] = {
					'active' : True,
					'bssid': result.bssid,
					'channel': frequencies.index(ifobj._formatFrequency(result.frequency.getFrequency())) + 1,
					'encrypted': encryption,
					'essid': strip(self.asciify(result.essid)),
					'iface': self.iface,
					'maxrate' : ifobj._formatBitrate(result.rate[-1][-1]),
					'noise' : '',#result.quality.nlevel-0x100,
					'quality' : str(quality),
					'signal' : str(signal),
					'custom' : extra,
				}
				#print "GOT APS ENTRY:",aps[bssid]
				index = index + 1
			return aps
Beispiel #6
0
    def getNetworkList(self):
        if self.oldInterfaceState is None:
            self.oldInterfaceState = iNetwork.getAdapterAttribute(
                self.iface, "up")
        if self.oldInterfaceState is False:
            if iNetwork.getAdapterAttribute(self.iface, "up") is False:
                iNetwork.setAdapterAttribute(self.iface, "up", True)
                enigma.eConsoleAppContainer().execute("ifconfig %s up" %
                                                      self.iface)
                if existBcmWifi(self.iface):
                    enigma.eConsoleAppContainer().execute("wl up")

        ifobj = Wireless(self.iface)  # a Wireless NIC Object

        try:
            scanresults = ifobj.scan()
        except:
            scanresults = None
            print("[WirelessLan] No wireless networks could be found")
        aps = {}
        if scanresults is not None:
            (num_channels, frequencies) = ifobj.getChannelInfo()
            index = 1
            for result in scanresults:
                bssid = result.bssid

                # skip hidden networks
                if not result.essid:
                    continue

                if result.encode.flags & wififlags.IW_ENCODE_DISABLED > 0:
                    encryption = False
                elif result.encode.flags & wififlags.IW_ENCODE_NOKEY > 0:
                    encryption = True
                else:
                    encryption = None

                signal = str(result.quality.siglevel - 0x100) + " dBm"
                quality = "%s/%s" % (result.quality.quality,
                                     ifobj.getQualityMax().quality)

                extra = []
                for element in result.custom:
                    element = element.encode()
                    extra.append(strip(self.asciify(element)))
                for element in extra:
                    if 'SignalStrength' in element:
                        signal = element[element.index('SignalStrength') +
                                         15:element.index(',L')]
                    if 'LinkQuality' in element:
                        quality = element[element.index('LinkQuality') +
                                          12:len(element)]

                channel = "Unknown"
                try:
                    channel = frequencies.index(
                        ifobj._formatFrequency(
                            result.frequency.getFrequency())) + 1
                except:
                    channel = "Unknown"

                aps[bssid] = {
                    'active': True,
                    'bssid': result.bssid,
                    'channel': channel,
                    'encrypted': encryption,
                    'essid': strip(self.asciify(result.essid)),
                    'iface': self.iface,
                    'maxrate': ifobj._formatBitrate(result.rate[-1][-1]),
                    'noise': '',  #result.quality.nlevel-0x100,
                    'quality': str(quality),
                    'signal': str(signal),
                    'custom': extra,
                }

                index = index + 1
        return aps
Beispiel #7
0
print(wifi.getWirelessName())

for key in keys:
    print(key)

scan = wifi.scan()

a = 4
(num_channels, frequencies) = wifi.getChannelInfo()
index = 1
for ap in scan.aplist:
    print("          Cell %02d - Address: %s" % (index, ap.bssid))
    print("                    ESSID:\"%s\"" % (ap.essid, ))
    print("                    Mode:%s" % (ap.mode, ))
    print("                    Frequency:%s (Channel %d)" % \
        (wifi._formatFrequency(ap.frequency.getFrequency()),
        frequencies.index(wifi._formatFrequency(
            ap.frequency.getFrequency())) + 1))
    if (ap.quality.updated & \
                pythonwifi.flags.IW_QUAL_QUAL_UPDATED):
        quality_updated = "="
    else:
        quality_updated = ":"
    if (ap.quality.updated & \
                pythonwifi.flags.IW_QUAL_LEVEL_UPDATED):
        signal_updated = "="
    else:
        signal_updated = ":"
    if (ap.quality.updated & \
                pythonwifi.flags.IW_QUAL_NOISE_UPDATED):
        noise_updated = "="
Beispiel #8
0
    def getNetworkList(self):
        apList = {}
        self.activateIface()
        wirelessObj = Wireless(self.iface)
        Iwscanresult = self.getScanResult(wirelessObj)

        if Iwscanresult is None or len(Iwscanresult.aplist) == 0:
            return apList

        try:
            (num_channels, frequencies) = wirelessObj.getChannelInfo()
        except:
            pass

        for ap in Iwscanresult:
            bssid = ap.bssid
            apList[bssid] = {}
            apList[bssid]['active'] = True
            apList[bssid]['bssid'] = bssid
            apList[bssid]['essid'] = ap.essid or None

            apList[bssid]['Address'] = apList[bssid]['bssid']
            apList[bssid]['ESSID'] = apList[bssid]['essid']
            apList[bssid]['Protocol'] = ap.protocol
            apList[bssid]['Frequency'] = wirelessObj._formatFrequency(
                ap.frequency.getFrequency())

            channel = "Unknown"
            try:
                channel = frequencies.index(
                    self.apList[index]["Frequency"]) + 1
            except:
                channel = "Unknown"
            apList[bssid]['Channel'] = channel

            apList[bssid]['Quality'] = "%s/%s" % (
                ap.quality.quality, wirelessObj.getQualityMax().quality)
            apList[bssid]['Signal Level'] = "%s/%s" % (
                ap.quality.getSignallevel(), "100")
            apList[bssid]['Noise Level'] = "%s/%s" % (
                ap.quality.getNoiselevel(), "100")

            # get encryption key on/off
            key_status = "Unknown"
            if (ap.encode.flags & wifi_flags.IW_ENCODE_DISABLED):
                key_status = "off"
            elif (ap.encode.flags & wifi_flags.IW_ENCODE_NOKEY):
                if (ap.encode.length <= 0):
                    key_status = "on"
            apList[bssid]['Encryption key'] = key_status

            # get bitrate
            if ap.rate and ap.rate[0]:
                apList[bssid]['BitRate'] = wirelessObj._formatBitrate(
                    ap.rate[0][-1])
            else:
                apList[bssid]['BitRate'] = ""


#		print apList

        return apList