Exemplo n.º 1
0
	def getStatus(self):
		ifobj = Wireless(self.iface)
		fq = Iwfreq()
		try:
			self.channel = str(fq.getChannel(str(ifobj.getFrequency()[0:-3])))
		except:
			self.channel = 0
		#print ifobj.getStatistics()
		status = {
				  'BSSID': str(ifobj.getAPaddr()),
				  'ESSID': str(ifobj.getEssid()),
				  'quality': str(ifobj.getStatistics()[1].quality),
				  'signal': str(ifobj.getStatistics()[1].sl),
				  'bitrate': str(ifobj.getBitrate()),
				  'channel': str(self.channel),
				  #'channel': str(fq.getChannel(str(ifobj.getFrequency()[0:-3]))),
		}
		
		for (key, item) in status.items():
			if item is "None" or item is "":
					status[key] = _("N/A")
				
		return status
Exemplo n.º 2
0
    def getStatus(self):
        ifobj = Wireless(self.iface)
        fq = Iwfreq()
        try:
            self.channel = str(fq.getChannel(str(ifobj.getFrequency()[0:-3])))
        except:
            self.channel = 0
        #print ifobj.getStatistics()
        status = {
            'BSSID': str(ifobj.getAPaddr()),
            'ESSID': str(ifobj.getEssid()),
            'quality': str(ifobj.getStatistics()[1].quality),
            'signal': str(ifobj.getStatistics()[1].sl),
            'bitrate': str(ifobj.getBitrate()),
            'channel': str(self.channel),
            #'channel': str(fq.getChannel(str(ifobj.getFrequency()[0:-3]))),
        }

        for (key, item) in status.items():
            if item is "None" or item is "":
                status[key] = _("N/A")

        return status
Exemplo n.º 3
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 = {}
			for result in scanresults:
			
				bssid = result.bssid
		
				encryption = map(lambda x: hex(ord(x)), result.encode)
		
				if encryption[-1] == "0x8":
					encryption = True
				else:
					encryption = False
		
				extra = []
				for element in result.custom:
					element = element.encode()
					extra.append( strip(self.asciify(element)) )
				
				if result.quality.sl is 0 and len(extra) > 0:
					begin = extra[0].find('SignalStrength=')+15
									
					done = False
					end = begin+1
					
					while not done:
						if extra[0][begin:end].isdigit():
							end += 1
						else:
							done = True
							end -= 1
					
					signal = extra[0][begin:end]
					#print "[Wlan.py] signal is:" + str(signal)

				else:
					signal = str(result.quality.sl)
				
				aps[bssid] = {
					'active' : True,
					'bssid': result.bssid,
					'channel': result.frequency.getChannel(result.frequency.getFrequency()),
					'encrypted': encryption,
					'essid': strip(self.asciify(result.essid)),
					'iface': self.iface,
					'maxrate' : result.rate[-1],
					'noise' : result.quality.getNoiselevel(),
					'quality' : str(result.quality.quality),
					'signal' : signal,
					'custom' : extra,
				}
				print aps[bssid]
			return aps
Exemplo n.º 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 = {}
            for result in scanresults:

                bssid = result.bssid

                encryption = map(lambda x: hex(ord(x)), result.encode)

                if encryption[-1] == "0x8":
                    encryption = True
                else:
                    encryption = False

                extra = []
                for element in result.custom:
                    element = element.encode()
                    extra.append(strip(self.asciify(element)))

                if result.quality.sl is 0 and len(extra) > 0:
                    begin = extra[0].find('SignalStrength=') + 15

                    done = False
                    end = begin + 1

                    while not done:
                        if extra[0][begin:end].isdigit():
                            end += 1
                        else:
                            done = True
                            end -= 1

                    signal = extra[0][begin:end]
                    #print "[Wlan.py] signal is:" + str(signal)

                else:
                    signal = str(result.quality.sl)

                aps[bssid] = {
                    'active':
                    True,
                    'bssid':
                    result.bssid,
                    'channel':
                    result.frequency.getChannel(
                        result.frequency.getFrequency()),
                    'encrypted':
                    encryption,
                    'essid':
                    strip(self.asciify(result.essid)),
                    'iface':
                    self.iface,
                    'maxrate':
                    result.rate[-1],
                    'noise':
                    result.quality.getNoiselevel(),
                    'quality':
                    str(result.quality.quality),
                    'signal':
                    signal,
                    'custom':
                    extra,
                }
                print aps[bssid]
            return aps