예제 #1
0
    def run(self):
        # loop until it's time to exit
        while True:
            self._hold.wait()
            s = self._state['state']
            if s == _QUITTING_: return
            while True:
                try:
                    # get the next message and clear the data message field
                    tkn,data = self._dq.get_nowait()
                    self._win.addstr(self._iws['data-msg'][0],
                                     self._iws['data-msg'][1],
                                     ' '*self._iws['data-msg'][2],
                                     CPS[WHITE])

                    # process the token
                    if tkn == '!AP-new!':
                        bssid,rss = data
                        self._nets[bssid] = {'ch':None,'rss':rss,'stas':{}}
                        msg = "Found AP w/ BSSID {0}. Total = {1}"
                        msg = msg.format(bssid,len(self._nets))
                        self._win.addstr(self._iws['data-msg'][0],
                                         self._iws['data-msg'][1],
                                         msg,CPS[WHITE])
                    elif tkn == '!AP-upd!':
                        bssid,rss = data
                        self._nets[bssid]['rss'] = rss
                    elif tkn == '!STA-new!':
                        sta,sinfo = data
                        bssid = sinfo['ASW']
                        self._nets[bssid]['stas'][sta] = {
                            'ts':sinfo['ts'],
                            'rss':sinfo['rss'],
                            'spoofed':0,
                            'success':0,
                        }
                        self._nets[bssid]['ch'] = rf2ch(sinfo['rf'])
                        msg = "Found STA {0} ASW BSSID {1}".format(sta,sinfo['ASW'])
                        self._win.addstr(self._iws['data-msg'][0],
                                         self._iws['data-msg'][1],
                                         msg,CPS[WHITE])
                    elif tkn == '!STA-upd!':
                        sta,sinfo = data
                        bssid = sinfo['ASW']
                        self._nets[bssid]['stas'][sta]['ts'] = sinfo['ts']
                        self._nets[bssid]['stas'][sta]['rss'] = sinfo['rss']
                        self._nets[bssid]['ch'] = rf2ch(sinfo['rf'])
                    self._win.refresh()
                except Empty:
                    time.sleep(0.5)
                    break
    def get_channel(self, ifaceName):

        self.log.info('Getting channel for {}:{}'
                      .format(ifaceName, self.device))

        gvals = ['freq']
        # delegate to generic function
        freq = self.get_parameters(gvals)

        # convert channel to freq
        ch = channels.rf2ch(int(freq))

        return ch
예제 #3
0
    def get_channel(self, ifaceName):

        self.log.info('Getting channel for {}:{}'
                      .format(ifaceName, self.device))

        gvals = ['freq']
        # delegate to generic function
        freq = self.get_parameters(gvals)

        # convert channel to freq
        ch = channels.rf2ch(int(freq))

        return ch
예제 #4
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)
예제 #5
0
 def test_devchs(self):
     [channels.rf2ch(rf) for rf in pri["freqs"]]
     self.assertListEqual([channels.rf2ch(rf) for rf in pri["freqs"]],
                          pyw.devchs(self.card))
예제 #6
0
파일: info.py 프로젝트: pgawlowicz/PyRIC
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)
예제 #7
0
def execute(dev):
    print('Setting up...')
    # ensure dev is a wireless interfaces
    ifaces = pyw.interfaces()
    wifaces = pyw.winterfaces()
    if dev not in ifaces:
        print("Device {0} is not valid, use one of {1}".format(dev,ifaces))
        return
    elif dev not in wifaces:
        print("Device {0} is not wireless, use one of {1}".format(dev,wifaces))

    # get a Card & info for dev
    print("Regulatory Domain currently: ", pyw.regget())
    dinfo = pyw.devinfo(dev)
    card = dinfo['card']
    pinfo = pyw.phyinfo(card)
    driver = hw.ifdriver(card.dev)
    chipset = hw.ifchipset(driver)

    # bring the card down and change the mac
    pyw.down(card)
    pyw.macset(card,'00:03:93:57:54:46')

    # print details
    msg = "Using {0} currently in mode: {1}\n".format(card,dinfo['mode'])
    msg += "\tDriver: {0} Chipset: {1}\n".format(driver,chipset)
    if dinfo['mode'] == 'managed':
        msg += "\tcurrently on channel {0} width {1}\n".format(rf2ch(dinfo['RF']),
                                                               dinfo['CHW'])
    msg += "\tSupports modes {0}\n".format(pinfo['modes'])
    msg += "\tSupports commands {0}".format(pinfo['commands'])
    msg += "\thw addr {0}".format(pyw.macget(card))
    print(msg)

    # prepare a virtual interface named pent0 in monitor mode
    # delete all ifaces on the phy to avoid interference
    # bring the card up when down
    print('Preparing pent0 for monitor mode')
    pdev = 'pent0'
    pcard = pyw.devadd(card, pdev, 'monitor')
    for iface in pyw.ifaces(card):
        if iface[0].dev != pcard.dev:
            print("deleting {0} in mode {1}".format(iface[0],iface[1]))
            pyw.devdel(iface[0])
    pyw.up(pcard)
    print("Using", pcard)

    print("Setting channel to 6 NOHT")
    pyw.chset(pcard,6,None)
    msg = "Virtual interface {0} in monitor mode on ch 6".format(pcard)
    print(msg + ", using hwaddr: {0}".format(pyw.macget(pcard)))

    # DO stuff here
    try:
        print('Now ready to do stuff')
        print('For example, run wireshark to verify card is seeing all packets')
        print('Hit Ctrl-C to quit and restore')
        while True: time.sleep(1)
    except KeyboardInterrupt:
        pass

    # restore original
    print('Restoring', card, 'mode =', dinfo['mode'], 'mac =', dinfo['mac'])
    card = pyw.devadd(pcard,card.dev,dinfo['mode'])
    print('Deleting', pcard)
    pyw.devdel(pcard)
    pyw.macset(card,dinfo['mac'])
    pyw.up(card)
    print("card ", card, " restored")
예제 #8
0
 def test_devchs(self):
     [channels.rf2ch(rf) for rf in pri['freqs']]
     self.assertListEqual([channels.rf2ch(rf) for rf in pri['freqs']],
                           pyw.devchs(self.card))
예제 #9
0
파일: pentest.py 프로젝트: wifiphisher/WiPy
def execute(dev):
    print('Setting up...')
    # ensure dev is a wireless interfaces
    ifaces = pyw.interfaces()
    wifaces = pyw.winterfaces()
    if dev not in ifaces:
        print("Device {0} is not valid, use one of {1}".format(dev, ifaces))
        return
    elif dev not in wifaces:
        print("Device {0} is not wireless, use one of {1}".format(
            dev, wifaces))

    # get a Card & info for dev
    print("Regulatory Domain currently: ", pyw.regget())
    dinfo = pyw.devinfo(dev)
    card = dinfo['card']
    pinfo = pyw.phyinfo(card)
    driver = hw.ifdriver(card.dev)
    chipset = hw.ifchipset(driver)

    # bring the card down and change the mac
    pyw.down(card)
    pyw.macset(card, '00:03:93:57:54:46')

    # print details
    msg = "Using {0} currently in mode: {1}\n".format(card, dinfo['mode'])
    msg += "\tDriver: {0} Chipset: {1}\n".format(driver, chipset)
    if dinfo['mode'] == 'managed':
        msg += "\tcurrently on channel {0} width {1}\n".format(
            rf2ch(dinfo['RF']), dinfo['CHW'])
    msg += "\tSupports modes {0}\n".format(pinfo['modes'])
    msg += "\tSupports commands {0}".format(pinfo['commands'])
    msg += "\thw addr {0}".format(pyw.macget(card))
    print(msg)

    # prepare a virtual interface named pent0 in monitor mode
    # delete all ifaces on the phy to avoid interference
    # bring the card up when down
    print('Preparing pent0 for monitor mode')
    pdev = 'pent0'
    pcard = pyw.devadd(card, pdev, 'monitor')
    for iface in pyw.ifaces(card):
        if iface[0].dev != pcard.dev:
            print("deleting {0} in mode {1}".format(iface[0], iface[1]))
            pyw.devdel(iface[0])
    pyw.up(pcard)
    print("Using", pcard)

    print("Setting channel to 6 NOHT")
    pyw.chset(pcard, 6, None)
    msg = "Virtual interface {0} in monitor mode on ch 6".format(pcard)
    print(msg + ", using hwaddr: {0}".format(pyw.macget(pcard)))

    # DO stuff here
    try:
        print('Now ready to do stuff')
        print(
            'For example, run wireshark to verify card is seeing all packets')
        print('Hit Ctrl-C to quit and restore')
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        pass

    # restore original
    print('Restoring', card, 'mode =', dinfo['mode'], 'mac =', dinfo['mac'])
    card = pyw.devadd(pcard, card.dev, dinfo['mode'])
    print('Deleting', pcard)
    pyw.devdel(pcard)
    pyw.macset(card, dinfo['mac'])
    pyw.up(card)
    print("card ", card, " restored")