Esempio n. 1
0
    def handleDiscovery(self, dev, isNewDev, isNewData):
        if not isNewDev:
            return
        elif self.opts.mac is not None and dev.addr != self.opts.mac:
            return
        elif dev.rssi < self.opts.sensitivity:
            return

        vendor = vendors.find(dev.addr)
        vlabel = yellow(vendor + ' ') if vendor is not None else '?'
        clabel = green(u'\u2713') if dev.connectable else red(u'\u2715')
        dlabel = "(no data) " if not dev.scanData else ""
        title = " %s (%s dBm) %s" % (bold(dev.addr), dev.rssi, dlabel)
        tdata = [['Vendor', vlabel], ['Allows Connections', clabel],
                 ['Address Type', dev.addrType]]

        for (tag, desc, val) in dev.getScanData():
            if desc == 'Flags':
                tdata.append(['Flags', self._parseFlags(val)])

            # short local name or complete local name
            elif tag in [8, 9]:
                try:
                    tdata.append([desc, yellow(val.decode('utf-8'))])
                except UnicodeEncodeError:
                    tdata.append([desc, yellow(repr(val))])
            else:
                tdata.append([desc, repr(val)])

        table = SingleTable(tdata, title)
        table.inner_heading_row_border = False

        print table.table + "\n"
Esempio n. 2
0
File: scan.py Progetto: ysf/bleah
    def handleDiscovery(self, dev, isNewDev, isNewData):
        if not isNewDev:
            return
        elif self.opts.mac is not None and dev.addr != self.opts.mac:
            return
        elif dev.rssi < self.opts.sensitivity:
            return

        if not dev.addr in self.devdata:
            self.devdata[dev.addr] = {}

        self.devdata[dev.addr]["vendor"] = vendors.find(dev.addr)
        self.devdata[dev.addr]["connectable"] = dev.connectable
        self.devdata[dev.addr]["scanData"] =  dev.getScanData()
        self.devdata[dev.addr]["addr"] = dev.addr
        self.devdata[dev.addr]["rssi"] = dev.rssi
        self.devdata[dev.addr]["addrType"] = dev.addrType


        self.devdata[dev.addr]["descs"] = []
        for ( tag, desc, val ) in dev.getScanData():
            if desc == 'Flags':
                self.devdata[dev.addr]["flags"] = self._parseFlags(val)

            # short local name or complete local name
            elif tag in [8, 9]:
                try:
                    self.devdata[dev.addr][desc] = val.decode('utf-8')
                except UnicodeEncodeError:
                    self.devdata[dev.addr][desc] = repr(val)
            else:
                self.devdata[dev.addr][desc] = repr(val)
                self.devdata[dev.addr]["descs"].append(desc)

        self.printShortTable(dev.addr)
Esempio n. 3
0
    def handleDiscovery(self, dev, isNewDev, isNewData):
        if not isNewDev:
            return

        if not macMatchesArgPattern(self.opts.mac, dev.addr):
            return

        if dev.rssi < self.opts.sensitivity:
            return

        if not dev.addr in self.devdata:
            self.devdata[dev.addr] = {"rssi_log": []}

        self.devdata[dev.addr]["vendor"] = vendors.find(dev.addr)
        self.devdata[dev.addr]["connectable"] = dev.connectable
        self.devdata[dev.addr]["scanData"] = dev.getScanData()
        self.devdata[dev.addr]["addr"] = dev.addr
        self.devdata[dev.addr]["rssi"] = dev.rssi
        if self.nickdata and dev.addr.lower() in self.nickdata["addr"]:
            self.devdata[dev.addr]["nick"] = self.nickdata["addr"][
                dev.addr.lower()]
        else:
            self.devdata[dev.addr]["nick"] = None
        self.devdata[dev.addr]["addrType"] = dev.addrType
        self.devdata[dev.addr]["rssi_log"].append((time.time(), dev.rssi))

        self.devdata[dev.addr]["descs"] = []
        for (tag, desc, val) in dev.getScanData():
            if desc == 'Flags':
                self.devdata[dev.addr]["flags"] = self._parseFlags(val)

            # short local name or complete local name
            elif tag in [8, 9]:
                try:
                    self.devdata[dev.addr][desc] = val.decode('utf-8')
                except UnicodeEncodeError:
                    self.devdata[dev.addr][desc] = repr(val)
                except AttributeError:
                    self.devdata[dev.addr][desc] = repr(val)
            else:
                self.devdata[dev.addr][desc] = repr(val)
                self.devdata[dev.addr]["descs"].append(desc)

        self.printShortTable(dev.addr)
Esempio n. 4
0
    def handleDiscovery(self, dev, isNewDev, isNewData):
        if not isNewDev:
            return 
        elif self.opts.mac is not None and dev.addr != self.opts.mac:
            return 
        elif dev.rssi < self.opts.sensitivity:
            return

        vendor = vendors.find(dev.addr)
        vlabel = yellow( vendor + ' ' ) if vendor is not None else '?'
        clabel = green( u'\u2713' ) if dev.connectable else red( u'\u2715' )
        dlabel = "(no data) " if not dev.scanData else ""
        title  = " %s (%s dBm) %s" % ( bold(dev.addr), dev.rssi, dlabel )
        tdata  = [
            [ 'Vendor', vlabel ],
            [ 'Allows Connections', clabel ],
            [ 'Address Type', dev.addrType]
        ]

        for ( tag, desc, val ) in dev.getScanData():
            if desc == 'Flags':
                tdata.append([ 'Flags', self._parseFlags(val) ])

            # short local name or complete local name
            elif tag in [8, 9]:
                try:
                    tdata.append([ desc, yellow( val.decode('utf-8') ) ])
                except UnicodeEncodeError:
                    tdata.append([ desc, yellow( repr(val) ) ])
            else:
                tdata.append([ desc, repr(val) ])


        table = SingleTable(tdata, title)
        table.inner_heading_row_border = False

        print table.table + "\n"