Exemple #1
0
def updatesourceinfo(win,iws,c):
    """
     writes current state to info window
     :param win: the info window
     :param iws: the info window output dict should at minimum the keys
            'dev','Driver','Mode','MAC','Manuf','Connected',
     :param c: the current config should be in the form
      config = {'SSID':None, 'dev':None, 'connect':None}
    """
    # set defaults then check the conf dict for a device
    dev = c['dev'] if c['dev'] else '-'*_DEVLEN_
    driver = mode = manuf = '-'*_FIXLEN_
    hwaddr = '-'*_MACLEN_
    conn = '-'
    color = CPS[WHITE]
    if c['dev']:
        try:
            card = pyw.getcard(dev)
            ifinfo = pyw.ifinfo(card)
            driver = ifinfo['driver'][:_FIXLEN_] # trim excess
            hwaddr = ifinfo['hwaddr'].upper()
            manuf = ifinfo['manufacturer'][:_FIXLEN_] # trim excess
            mode = pyw.modeget(card)
            conn = 'Y' if pyw.isconnected(card) else 'N'
            color = CPS[GREEN]
        except pyric.error as _e:
            raise error("ERRNO {0}. {1}".format(_e.errno,_e.strerror))
    win.addstr(iws['dev'][0],iws['dev'][1],dev,color)
    win.addstr(iws['Driver'][0],iws['Driver'][1],driver,color)
    win.addstr(iws['Mode'][0],iws['Mode'][1],mode,color)
    win.addstr(iws['MAC'][0],iws['MAC'][1],hwaddr,color)
    win.addstr(iws['Manuf'][0],iws['Manuf'][1],manuf,color)
    win.addstr(iws['Connected'][0],iws['Connected'][1],conn,color)
def is_wifi_present():
    wlan = pyw.winterfaces()

    if len(wlan) >= 1:
        interface = wlan[0]
        if pyw.isinterface(interface):
            card = pyw.getcard(interface)
            info = pyw.ifinfo(card)
            if pyw.isup(card) is not True:
               print("Turn On wifi Actual estate:", pyw.isup(card))
               wifi_info = {'wifi': interface,
                            'card': pyw.isup(card),
                            'mac': pyw.macget(card),
                            'driver': info.get('driver'),
                            'chip': info.get('chipset'),
                            'man': info.get('manufacturer'),
                            'con': to_json(get_all_info())}
               print(texto.safe_substitute(wifi_info))


            else:
               wifi_info = {'wifi': interface,
                            'card': pyw.isup(card),
                            'mac': pyw.macget(card),
                            'driver': info.get('driver'),
                            'chip': info.get('chipset'),
                            'man': info.get('manufacturer'),
                            'con': to_json(get_all_info())}
               print(texto.safe_substitute(wifi_info))

    else:
         print('wifi no encobtrado')
Exemple #3
0
def DebuggingInterface(iface):
    interfaces = pyw.interfaces()
    print(interfaces)
    print(("Is %s an interface? %s" % (iface, pyw.isinterface(iface))))
    print(("Is %s a wireless device? %s" % (iface, pyw.iswireless(iface))))
    w0 = pyw.getcard(iface)
    print(("Is %s active?  %s" % (iface, pyw.isup(w0))))
    print(("Is %s blocked? %s" % (iface, pyw.isblocked(w0))))
    iinfo = pyw.ifinfo(w0)
    print(iinfo)
    pinfo = pyw.phyinfo(w0)
    print((pinfo['bands']))
Exemple #4
0
    def parse_interface(self, interface):
        if interface in pyw.interfaces():
            print(c.OKGREEN+" [+] "+c.WHITE+"Valid Card Selected.")

            info = pyw.ifinfo(pyw.getcard(interface))

            print("   '->  Driver: "+info["driver"])
            print("   '->  Hardware Address: "+info["hwaddr"])
            print("   '->  manufacturer: "+info["manufacturer"])

            if pyw.modeget(pyw.getcard(interface)) == "monitor":
                self.monitor = True
            else:
                self.monitor = False
            self.interface = interface
            return

        print(c.FAIL+" [+] Invalid Card Selected.")
        exit(0)
        return
def get_mac_from_this_equip():

    try:

       log.console_info('Retrieving Mac Adrees From Wifi Card ( Inside Method )  : ' + __name__)
       wlan = (pyw.winterfaces())[0]
       card = pyw.getcard(wlan)
       mac =  pyw.ifinfo(card)
       m = None
       m = mac['hwaddr']
       log.console_success('Success Retrieving Mac Adrees From Wifi Card ( {} )  : ' .format(error)+ __name__)
       return m

    except UnboundLocalError as error:
        log.log_warning('Except raised, Retrieving Mac Adrees From Wifi Card ( {} )  : '.format(error) + __name__)
        return False
    except IndexError as error:
        log.log_warning('Except raised, Retrieving Mac Adrees From Wifi Card ( {} )  : '.format(error) + __name__)
        return False
    except dbus.exceptions.DBusException as error:
        log.log_warning('Except raised, Retrieving Mac Adrees From Wifi Card ({})  : '.format(error) + __name__)
        return False
Exemple #6
0
def interface_command(interface, verbose):
    faces = pyw.winterfaces() if interface == "all" else [interface]
    for face in faces:
        if face not in pyw.winterfaces():
            sys.exit(f"{face} is not an interface")

    print(f"{Fore.GREEN}Interfaces:{Fore.YELLOW}")
    for interface in faces:
        face = pyw.getcard(interface)
        up = Fore.YELLOW if pyw.isup(face) else Fore.RED

        print(f"  {up}{interface:<10} {Style.RESET_ALL}")
        if verbose >= 1:
            iinfo = pyw.ifinfo(face)
            for i in iinfo:
                print(
                    f"\t{i.title():<15} {Fore.CYAN}{iinfo[i]}{Style.RESET_ALL}"
                )
        if verbose >= 2:
            dinfo = pyw.devinfo(face)
            for d in dinfo:
                print(
                    f"\t{d.title():<15} {Fore.CYAN}{dinfo[d]}{Style.RESET_ALL}"
                )

        if verbose >= 3:
            pinfo = pyw.phyinfo(face)
            for p in pinfo:
                if type(pinfo[p]) == list:
                    print(
                        f"\t{p.title():<15} {Fore.CYAN}{', '.join(pinfo[p])}{Style.RESET_ALL}"
                    )
                elif p == "bands":
                    print(
                        f"\t{p.title():<15} {Fore.CYAN}{', '.join(pinfo[p].keys())}{Style.RESET_ALL}"
                    )
 def get_info(self, iface=None):
     '''
     Get info about the wifi card: vendor, driver, ...
     '''
     w0 = self.get_wifi_chard(iface)  # get a card for interface
     return pyw.ifinfo(w0)
Exemple #8
0
def execute(dev, itype):
    # ensure dev is a wireless interfaces
    wifaces = pyw.winterfaces()
    if dev not in wifaces:
        print("Device {0} is not wireless, use one of {1}".format(
            dev, wifaces))

    # get info dicts
    dinfo = pyw.devinfo(dev)
    card = dinfo['card']
    pinfo = pyw.phyinfo(card)
    iinfo = pyw.ifinfo(card)

    if itype == 'all' or itype == 'if':
        msg = "Interface {0}\n".format(card.idx)
        msg += "\tDriver: {0} Chipset: {1}\n".format(iinfo['driver'],
                                                     iinfo['chipset'])
        msg += "\tHW Addr: {0} Manufacturer: {1}\n".format(
            iinfo['hwaddr'], iinfo['manufacturer'])
        msg += "\tInet: {0} Bcast: {1} Mask: {2}\n".format(
            iinfo['inet'], iinfo['bcast'], iinfo['mask'])
        print(msg)

    if itype == 'all' or itype == 'dev':
        msg = "Device {0}\n".format(card.dev)
        msg += "\tifindex: {0}\n".format(card.idx)
        msg += "\twdev: {0}\n".format(dinfo['wdev'])
        msg += "\taddr: {0}\n".format(dinfo['mac'])
        msg += "\tmode: {0}\n".format(dinfo['mode'])
        msg += "\twiphy: {0}\n".format(card.phy)
        if dinfo['mode'] != 'managed': msg += "\tDevice not associated\n"
        else:
            msg += "\tchannel: {0} ({1} MHz), width: {2}, CF: {3} MHz\n".format(
                rf2ch(dinfo['RF']), dinfo['RF'], dinfo['CHW'], dinfo['CF'])
        print(msg)

    if itype == 'all' or itype == 'phy':
        msg = "Wiphy phy{0}\n".format(card.phy)
        msg += "\tGeneration: {0}m Coverage Class: {1}\n".format(
            pinfo['generation'], pinfo['cov_class'])
        msg += "\tMax # scan SSIDs: {0}\n".format(pinfo['scan_ssids'])
        msg += "\tRetry Short: {0}, Long: {1}\n".format(
            pinfo['retry_short'], pinfo['retry_long'])
        msg += "\tThreshold Frag: {0}, RTS: {1}\n".format(
            pinfo['frag_thresh'], pinfo['rts_thresh'])
        msg += "\tSupported Modes:\n"
        for mode in pinfo['modes']:
            msg += "\t  * {0}\n".format(mode)
        msg += "\tSupported Commands:\n"
        for cmd in pinfo['commands']:
            msg += "\t  * {0}\n".format(cmd)
        msg += "\tSupported Ciphers:\n"
        for cipher in pinfo['ciphers']:
            msg += "\t  * {0}\n".format(cipher)
        for band in pinfo['bands']:
            msg += "\tBand {0}: (HT: {1} VHT: {2})\n".format(
                band, pinfo['bands'][band]['HT'], pinfo['bands'][band]['VHT'])
            msg += "\t   Rates:\n"
            for rate in pinfo['bands'][band]['rates']:
                msg += "\t    * {0} Mbps\n".format(rate)
            msg += "\t   Frequencies:\n"
            for i, rf in enumerate(pinfo['bands'][band]['rfs']):
                dbm = pinfo['bands'][band]['rf-data'][i]['max-tx']
                msg += "\t    * {0} MHz ({1} dBm)".format(rf, dbm)
                if not pinfo['bands'][band]['rf-data'][i]['enabled']:
                    msg += " (disabled)\n"
                else:
                    msg += "\n"
        print(msg)
Exemple #9
0
 def test_ifinfo(self):
     iinfo = pyw.ifinfo(self.card)
     self.assertTrue(pri["driver"] == iinfo["driver"])
     self.assertTrue(pri["chipset"] == iinfo["chipset"])
Exemple #10
0
def execute(dev,itype):
    # ensure dev is a wireless interfaces
    wifaces = pyw.winterfaces()
    if dev not in wifaces:
        print("Device {0} is not wireless, use one of {1}".format(dev,wifaces))

    # get info dicts
    dinfo = pyw.devinfo(dev)
    card = dinfo['card']
    pinfo = pyw.phyinfo(card)
    iinfo = pyw.ifinfo(card)

    if itype == 'all' or itype == 'if':
        msg = "Interface {0}\n".format(card.idx)
        msg += "\tDriver: {0} Chipset: {1}\n".format(iinfo['driver'],iinfo['chipset'])
        msg += "\tHW Addr: {0} Manufacturer: {1}\n".format(iinfo['hwaddr'],
                                                           iinfo['manufacturer'])
        msg += "\tInet: {0} Bcast: {1} Mask: {2}\n".format(iinfo['inet'],
                                                           iinfo['bcast'],
                                                           iinfo['mask'])
        print(msg)

    if itype == 'all' or itype == 'dev':
        msg = "Device {0}\n".format(card.dev)
        msg += "\tifindex: {0}\n".format(card.idx)
        msg += "\twdev: {0}\n".format(dinfo['wdev'])
        msg += "\taddr: {0}\n".format(dinfo['mac'])
        msg += "\tmode: {0}\n".format(dinfo['mode'])
        msg += "\twiphy: {0}\n".format(card.phy)
        if dinfo['mode'] != 'managed': msg += "\tDevice not associated\n"
        else:
            msg += "\tchannel: {0} ({1} MHz), width: {2}, CF: {3} MHz\n".format(rf2ch(dinfo['RF']),
                                                                                dinfo['RF'],
                                                                                dinfo['CHW'],
                                                                                dinfo['CF'])
        print(msg)

    if itype == 'all' or itype == 'phy':
        msg = "Wiphy phy{0}\n".format(card.phy)
        msg += "\tGeneration: {0}m Coverage Class: {1}\n".format(pinfo['generation'],
                                                                 pinfo['cov_class'])
        msg += "\tMax # scan SSIDs: {0}\n".format(pinfo['scan_ssids'])
        msg += "\tRetry Short: {0}, Long: {1}\n".format(pinfo['retry_short'],
                                                        pinfo['retry_long'])
        msg += "\tThreshold Frag: {0}, RTS: {1}\n".format(pinfo['frag_thresh'],
                                                          pinfo['rts_thresh'])
        msg += "\tSupported Modes:\n"
        for mode in pinfo['modes']: msg += "\t  * {0}\n".format(mode)
        msg += "\tSupported Commands:\n"
        for cmd in pinfo['commands']: msg += "\t  * {0}\n".format(cmd)
        msg += "\tSupported Ciphers:\n"
        for cipher in pinfo['ciphers']: msg += "\t  * {0}\n".format(cipher)
        for band in pinfo['bands']:
            msg += "\tBand {0}: (HT: {1} VHT: {2})\n".format(band,
                                                             pinfo['bands'][band]['HT'],
                                                             pinfo['bands'][band]['VHT'])
            msg += "\t   Rates:\n"
            for rate in pinfo['bands'][band]['rates']:
                msg += "\t    * {0} Mbps\n".format(rate)
            msg += "\t   Frequencies:\n"
            for i,rf in enumerate(pinfo['bands'][band]['rfs']):
                dbm = pinfo['bands'][band]['rf-data'][i]['max-tx']
                msg += "\t    * {0} MHz ({1} dBm)".format(rf,dbm)
                if not pinfo['bands'][band]['rf-data'][i]['enabled']:
                    msg += " (disabled)\n"
                else:
                    msg += "\n"
        print(msg)
Exemple #11
0
def get_info(card):
    return pyw.ifinfo(card)
Exemple #12
0
    def getinfo(self):
        try:
            self.data['macaddress'] = netifaces.ifaddresses(
                self._if)[netifaces.AF_LINK][0]['addr']
        except:
            self.data['macaddress'] = None
        try:
            self.data['ipaddress'] = netifaces.ifaddresses(
                self._if)[netifaces.AF_INET][0]['addr']
        except:
            self.data['ipaddress'] = None
        try:
            self.data['vendorstr'] = self.udevnet.data[
                self._if + "_id_vendor_from_database"]
        except:
            self.data['vendorstr'] = None
        try:
            self.data['vendoroui'] = self.udevnet.data[self._if +
                                                       "_id_oui_from_database"]
        except:
            self.data['vendoroui'] = None
        try:
            self.data['vendor'] = self.udevnet.data[self._if + "_id_vendor"]
        except:
            self.data['vendor'] = None
        # Hack for onboard raspberry devices
        if type(self.data['vendoroui']) is str:
            if re.search("^Raspberry", self.data['vendoroui']):
                self.data['vendor'] = "RaspberryPi"

        try:
            self.data['driver'] = self.udevnet.data[self._if +
                                                    "_id_net_driver"]
        except:
            try:
                self.data['driver'] = self.udevnet.data[self._if +
                                                        "_id_usb_driver"]
            except:
                self.data['driver'] = None
        try:
            self.data['model'] = self.udevnet.data[self._if + "_id_model_id"]
        except:
            self.data['model'] = None
        try:
            self.data['modelstr'] = self.udevnet.data[
                self._if + "_id_model_from_database"]
        except:
            self.data['modelstr'] = None
        try:
            self.data['netname'] = self.udevnet.data[
                self._if + "_id_net_name_from_database"]
        except:
            try:
                self.data['netname'] = self.udevnet.data[
                    self._if + "_id_net_name_onboard"]
            except:
                try:
                    self.data['netname'] = self.udevnet.data[
                        self._if + "_id_net_name_slot"]
                except:
                    try:
                        self.data['netname'] = self.udevnet.data[
                            self._if + "_id_net_name_path"]
                    except:
                        try:
                            self.data['netname'] = self.udevnet.data[
                                self._if + "_id_net_name_mac"]
                        except:
                            self.data['netname'] = None
        try:
            self.data['type'] = self.udevnet.data[self._if + "_devtype"]
            if self.data['type'] == "wlan": self.data['type'] = "Wireless"
        except:
            try:
                if re.search("^en", self.data['netname']):
                    self.data['type'] = "Ethernet"
                elif re.search("^wl", self.data['netname']):
                    self.data['type'] = "Wireless"
                else:
                    self.data['type'] = None
            except:
                self.data['type'] = None

        # Stop here if we don't have a wireless card
        if self.data['type'] != "Wireless":
            return
        # Retrieve wireless info
        try:
            _ifobj = pyw.getcard(self._if)
            _ifinfo = pyw.ifinfo(_ifobj)
            _devinfo = pyw.devinfo(_ifobj)
            _physinfo = pyw.phyinfo(_ifobj)
            _linkinfo = pyw.link(_ifobj)
        except:
            pass
        try:
            self.data['isup'] = pyw.isup(_ifobj)
        except:
            self.data['isup'] = None
        try:
            self.data['blocked'] = pyw.isblocked(_ifobj)
        except:
            self.data['blocked'] = None
        try:
            self.data['mode'] = _devinfo['mode']
        except:
            self.data['mode'] = None
        try:
            self.data['modes'] = _physinfo['modes']
        except:
            self.data['modes'] = None
        try:
            self.data['bands'] = _physinfo['bands']
        except:
            self.data['bands'] = None
        try:
            self.data['standards'] = pyw.devstds(_ifobj)
        except:
            self.data['standards'] = None
        try:
            self.data['freqs'] = pyw.devfreqs(_ifobj)
        except:
            self.data['freqs'] = None
        try:
            self.data['txpower'] = pyw.txget(_ifobj)
        except:
            self.data['txpower'] = None
        try:
            self.data['chans'] = pyw.devchs(_ifobj)
        except:
            self.data['chans'] = None
        try:
            self.data['reg'] = pyw.regget(_ifobj)
        except:
            self.data['reg'] = None
        try:
            self.data['chipset'] = _ifinfo['chipset']
        except:
            self.data['chipset'] = None
        try:
            self.data['state'] = _linkinfo['stat']
        except:
            self.data['state'] = None
        try:
            self.data['ssid'] = _linkinfo['ssid']
        except:
            self.data['ssid'] = None
        try:
            self.data['chw'] = _devinfo['CHW']
        except:
            self.data['chw'] = None
        try:
            self.data['frequency'] = _devinfo['RF']
        except:
            self.data['frequency'] = None
        try:
            self.data['rss'] = _linkinfo['rss']
        except:
            self.data['rss'] = None
        try:
            self.data['wtx'] = _linkinfo['tx']
        except:
            self.data['wtx'] = None
        try:
            self.data['wrx'] = _linkinfo['rx']
        except:
            self.data['wrx'] = None
Exemple #13
0
 def test_ifinfo(self):
     iinfo = pyw.ifinfo(self.card)
     self.assertTrue(pri['driver'] == iinfo['driver'])
     self.assertTrue(pri['chipset'] == iinfo['chipset'])
Exemple #14
0
 def test_ifinfo(self):
     iinfo = pyw.ifinfo(self.card)
     self.assertTrue(pri['driver'] == iinfo['driver'])
     self.assertTrue(pri['chipset'] == iinfo['chipset'])
Exemple #15
0
    def getinfo(self):
        try:
            self.data['macaddress'] = netifaces.ifaddresses(self._if)[netifaces.AF_LINK][0]['addr']
        except:
            self.data['macaddress'] = None
        try:
            self.data['ipaddress'] = netifaces.ifaddresses(self._if)[netifaces.AF_INET][0]['addr']
        except:
            self.data['ipaddress'] = None
        try:
            self.data['vendorstr'] = self.udevnet.data[self._if+"_id_vendor_from_database"]
        except:
            self.data['vendorstr'] = None
        try:
            self.data['vendoroui'] = self.udevnet.data[self._if+"_id_oui_from_database"]
        except:
            self.data['vendoroui'] = None
        try:
            self.data['vendor'] = self.udevnet.data[self._if+"_id_vendor"]
        except:
            self.data['vendor'] = None
        # Hack for onboard raspberry devices
        if type(self.data['vendoroui']) is str:
            if re.search("^Raspberry", self.data['vendoroui']):
                self.data['vendor'] = "RaspberryPi"

        try:
            self.data['driver'] = self.udevnet.data[self._if+"_id_net_driver"]
        except:
            try:
                self.data['driver'] = self.udevnet.data[self._if+"_id_usb_driver"]
            except:
                self.data['driver'] = None
        try:
            self.data['model'] = self.udevnet.data[self._if+"_id_model_id"]
        except:
            self.data['model'] = None
        try:
            self.data['modelstr'] = self.udevnet.data[self._if+"_id_model_from_database"]
        except:
            self.data['modelstr'] = None
        try:
            self.data['netname'] = self.udevnet.data[self._if+"_id_net_name_from_database"]
        except:
            try:
                self.data['netname'] = self.udevnet.data[self._if+"_id_net_name_onboard"]
            except:
                try:
                    self.data['netname'] = self.udevnet.data[self._if+"_id_net_name_slot"]
                except:
                    try:
                        self.data['netname'] = self.udevnet.data[self._if+"_id_net_name_path"]
                    except:
                        try:
                            self.data['netname'] = self.udevnet.data[self._if+"_id_net_name_mac"]
                        except:
                            self.data['netname'] = None
        try:
            self.data['type'] = self.udevnet.data[self._if+"_devtype"]
            if self.data['type'] == "wlan": self.data['type'] = "Wireless"
        except:
            try:
                if re.search("^en", self.data['netname']):
                    self.data['type'] = "Ethernet"
                elif re.search("^wl", self.data['netname']):
                    self.data['type'] = "Wireless"
                else:
                    self.data['type'] = None
            except:
                self.data['type'] = None

        # Stop here if we don't have a wireless card
        if self.data['type'] != "Wireless":
            return
        # Retrieve wireless info
        try:
            _ifobj = pyw.getcard(self._if)
            _ifinfo = pyw.ifinfo(_ifobj)
            _devinfo = pyw.devinfo(_ifobj)
            _physinfo = pyw.phyinfo(_ifobj)
            _linkinfo = pyw.link(_ifobj)
        except:
            pass
        try:
            self.data['isup'] = pyw.isup(_ifobj)
        except:
            self.data['isup'] = None
        try:
            self.data['blocked'] = pyw.isblocked(_ifobj)
        except:
            self.data['blocked'] = None
        try:
            self.data['mode'] = _devinfo['mode']
        except:
            self.data['mode'] = None
        try:
            self.data['modes'] = _physinfo['modes']
        except:
            self.data['modes'] = None
        try:
            self.data['bands'] = _physinfo['bands']
        except:
            self.data['bands'] = None
        try:
            self.data['standards'] = pyw.devstds(_ifobj)
        except:
            self.data['standards'] = None
        try:
            self.data['freqs'] = pyw.devfreqs(_ifobj)
        except:
            self.data['freqs'] = None
        try:
            self.data['txpower'] = pyw.txget(_ifobj)
        except:
            self.data['txpower'] = None
        try:
            self.data['chans'] = pyw.devchs(_ifobj)
        except:
            self.data['chans'] = None
        try:
            self.data['reg'] = pyw.regget(_ifobj)
        except:
            self.data['reg'] = None
        try:
            self.data['chipset'] = _ifinfo['chipset']
        except:
            self.data['chipset'] = None
        try:
            self.data['state'] = _linkinfo['stat']
        except:
            self.data['state'] = None
        try:
            self.data['ssid'] = _linkinfo['ssid']
        except:
            self.data['ssid'] = None
        try:
            self.data['chw'] = _devinfo['CHW']
        except:
            self.data['chw'] = None
        try:
            self.data['frequency'] = _devinfo['RF']
        except:
            self.data['frequency'] = None
        try:
            self.data['rss'] = _linkinfo['rss']
        except:
            self.data['rss'] = None
        try:
            self.data['wtx'] = _linkinfo['tx']
        except:
            self.data['wtx'] = None
        try:
            self.data['wrx'] = _linkinfo['rx']
        except:
            self.data['wrx'] = None
Exemple #16
0
 def get_iface_info(self):
     try:
         w = pyw.getcard(self._interface)
         return pyw.ifinfo(w)
     except pyric.error as e:
         logger.error(e)