当前位置: 首页>>代码示例>>Python>>正文


Python bluetooth.discover_devices方法代码示例

本文整理汇总了Python中bluetooth.discover_devices方法的典型用法代码示例。如果您正苦于以下问题:Python bluetooth.discover_devices方法的具体用法?Python bluetooth.discover_devices怎么用?Python bluetooth.discover_devices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bluetooth的用法示例。


在下文中一共展示了bluetooth.discover_devices方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: scan

# 需要导入模块: import bluetooth [as 别名]
# 或者: from bluetooth import discover_devices [as 别名]
def scan(self, device_id: Optional[int] = None, duration: int = 10) -> BluetoothScanResponse:
        """
        Scan for nearby bluetooth devices

        :param device_id: Bluetooth adapter ID to use (default configured if None)
        :param duration: Scan duration in seconds
        """
        from bluetooth import discover_devices

        if device_id is None:
            device_id = self.device_id

        self.logger.debug('Discovering devices on adapter {}, duration: {} seconds'.format(
            device_id, duration))

        devices = discover_devices(duration=duration, lookup_names=True, lookup_class=True, device_id=device_id,
                                   flush_cache=True)
        response = BluetoothScanResponse(devices)

        self._devices = response.devices
        self._devices_by_addr = {dev['addr']: dev for dev in self._devices}
        self._devices_by_name = {dev['name']: dev for dev in self._devices if dev.get('name')}
        return response 
开发者ID:BlackLight,项目名称:platypush,代码行数:25,代码来源:__init__.py

示例2: findDevs

# 需要导入模块: import bluetooth [as 别名]
# 或者: from bluetooth import discover_devices [as 别名]
def findDevs(opts):
    global foundDevs
    devList = bluetooth.discover_devices(lookup_names=True)
    repeat = range(0, int(opts.repeat))

    for (dev, name) in devList:
        if dev not in foundDevs:
            name = str(bluetooth.lookup_name(dev))
            printDev(name, dev)
            foundDevs.append(dev)
            for i in repeat:
                sendFile(dev, opts.file)
            continue

        if opts.spam:
            for i in repeat:
                sendFile(dev, opts.file) 
开发者ID:StevenDias33,项目名称:Offensive-Security-Certified-Professional,代码行数:19,代码来源:bluetoothObexSpam.py

示例3: scandevices

# 需要导入模块: import bluetooth [as 别名]
# 或者: from bluetooth import discover_devices [as 别名]
def scandevices(self):
        logging.warning("Searching for devices...\n"
                        "It may take time, you'd better specify mac address to avoid a scan.")
        valid_names = ['MiaoMiaoJi', 'Paperang']
        nearby_devices = discover_devices(lookup_names=True)
        valid_devices = filter(lambda d: len(d) == 2 and d[1] in valid_names, nearby_devices)
        if len(valid_devices) == 0:
            logging.error("Cannot find device with name %s." % " or ".join(valid_names))
            return False
        elif len(valid_devices) > 1:
            logging.warning("Found multiple valid machines, the first one will be used.\n")
            logging.warning("\n".join(valid_devices))
        else:
            logging.warning(
                "Found a valid machine with MAC %s and name %s" % (valid_devices[0][0], valid_devices[0][1])
            )
        self.address = valid_devices[0][0]
        return True 
开发者ID:ihciah,项目名称:miaomiaoji-tool,代码行数:20,代码来源:message_process.py

示例4: btscanning

# 需要导入模块: import bluetooth [as 别名]
# 或者: from bluetooth import discover_devices [as 别名]
def btscanning():
    ts = time.time()
    st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M')

    if args.gpstrack:
        gpslat = str(gpsd.fix.latitude)
        gpslong = str(gpsd.fix.longitude)
    else:
        gpslat = "nil"
        gpslong = "nil"

    devices = bluetooth.discover_devices(duration=1, lookup_names = True)

    for addr, name in devices:
        if addr not in btclients:
            if not args.quiet:
                print W+ '[' +R+ 'Bluetooth Client' +W+ ':' +B+ addr +W+ '] [' +G+ 'Name' +W+ ': ' +O+ name +W+ ']'
                btclients.append(addr)

     # Logging info
    fields = []
    fields.append(st) # Log Time
    fields.append('BT') # Log Client or AP
    fields.append(addr) # Log Mac Address
    fields.append('nil') # Log Device Manufacture
    fields.append(name) # Log BT Name
    fields.append('nil') # Log Crypto
    fields.append(gpslat) # Log GPS data
    fields.append(gpslong) # Log GPS data
    fields.append(args.location) # Log Location data
    fields.append('nil') # RSSI

    logger.info(args.delimiter.join(fields)) 
开发者ID:sensepost,项目名称:peanuts,代码行数:35,代码来源:peanuts.py

示例5: search

# 需要导入模块: import bluetooth [as 别名]
# 或者: from bluetooth import discover_devices [as 别名]
def search():         
    print "searching for devices"
    devices = bluetooth.discover_devices(duration=20, lookup_names = True)
    return devices 
开发者ID:hook-s3c,项目名称:blueborne-scanner,代码行数:6,代码来源:bluebornescan.py

示例6: scan

# 需要导入模块: import bluetooth [as 别名]
# 或者: from bluetooth import discover_devices [as 别名]
def scan():
    '''
    Scan for bluetooth-devices

    :return: list of bluetooth-devices
    :rtype: [blueproximity.device.BluetoothDevice]
    '''
    def _scan():
        for mac, name in bluetooth.discover_devices(lookup_names=True):
            yield BluetoothDevice(mac=mac, name=name)
    return list(_scan()) 
开发者ID:Thor77,项目名称:Blueproximity,代码行数:13,代码来源:device.py

示例7: find_bricks

# 需要导入模块: import bluetooth [as 别名]
# 或者: from bluetooth import discover_devices [as 别名]
def find_bricks(host=None, name=None):
    for h, n in bluetooth.discover_devices(lookup_names=True):
        if _check_brick(host, h) and _check_brick(name, n):
            yield BlueSock(h) 
开发者ID:Eelviny,项目名称:nxt-python,代码行数:6,代码来源:bluesock.py

示例8: test_bluetooth_2_raspberry_can_find_nxt

# 需要导入模块: import bluetooth [as 别名]
# 或者: from bluetooth import discover_devices [as 别名]
def test_bluetooth_2_raspberry_can_find_nxt(self):
        blue_list = blue.discover_devices()
        self.assertIn(self.ID, blue_list) 
开发者ID:felipessalvatore,项目名称:self_driving_pi_car,代码行数:5,代码来源:test_bluetooth.py

示例9: main

# 需要导入模块: import bluetooth [as 别名]
# 或者: from bluetooth import discover_devices [as 别名]
def main():
    print("searching for devices\n")
    results = bluetooth.discover_devices(duration=20, lookup_names=True)
    vuln_devices = []
    if (results):
        for addr, name in results:
            vulnerable = is_device_vulnerable(addr)
            if vulnerable:
                vuln_devices.append((addr,name))
                print("%s %s is " % (addr, name) + bcolors.RED + "vulnerable" + bcolors.ENDC)
            else:
                print("%s %s is" + bcolors.GREEN + "patched" + bcolors.ENDC)
    
    if len(vuln_devices) > 0:
        print(bcolors.ORANGE + "\nExploit" + bcolors.ENDC + "\n" + "-"*35)
        for idx, dev in enumerate(vuln_devices):
            print("[%s] %s %s" % (idx, dev[0], dev[1]))
        selection = input(bcolors.GREEN + "\nchoice: " + bcolors.ENDC)
        try:
            sel = int(selection)
            addr = vuln_devices[sel][0]
            cve20170785.exploit(addr)

        except:
            print("Invalid selection")
    else:
        print(bcolors.GREEN + "No vulnerable devices found!" + bcolors.ENDC) 
开发者ID:pieterbork,项目名称:blueborne,代码行数:29,代码来源:bluebornescan.py

示例10: bluetooth_classic_scan

# 需要导入模块: import bluetooth [as 别名]
# 或者: from bluetooth import discover_devices [as 别名]
def bluetooth_classic_scan(timeout=10):
    """
    This scan finds ONLY Bluetooth classic (non-BLE) devices in *pairing mode*
    """
    return bt.discover_devices(duration=scansec, flush_cache=True, lookup_names=True) 
开发者ID:scivision,项目名称:pybluez-examples,代码行数:7,代码来源:bluetooth_scan.py

示例11: discover

# 需要导入模块: import bluetooth [as 别名]
# 或者: from bluetooth import discover_devices [as 别名]
def discover():
    print("Scanning for devices ...")

    if usingBluetooth:
        devices = bluetooth.discover_devices()
        print(devices)

    if usingLightBlue:
        devices = lightblue.finddevices()
        print(devices)

    return devices 
开发者ID:MozillaSecurity,项目名称:peach,代码行数:14,代码来源:bluetooth.py

示例12: run

# 需要导入模块: import bluetooth [as 别名]
# 或者: from bluetooth import discover_devices [as 别名]
def run(self):
        print("Searching devices...")
        duration = int(self.args["timeout"])
        devices = discover_devices(
                duration=duration, lookup_names=True, flush_cache=True, lookup_class=True)
        msg = f"found {len(devices)} devices"
        print_info(msg)
        print("-"*len(msg))
        for addr, name, cl in devices:
            try:
                print_info(f"{addr} - {name}  ({hex(cl)})")
            except UnicodeEncodeError:
                print_info(f"{addr} - {name.encode('utf-8', 'replace')}  ({hex(cl)})") 
开发者ID:ElevenPaths,项目名称:HomePWN,代码行数:15,代码来源:bluetooth.py

示例13: run

# 需要导入模块: import bluetooth [as 别名]
# 或者: from bluetooth import discover_devices [as 别名]
def run(self):
        print_info("Searching bluetooth devices to check MAC...")
        devices  = discover_devices(lookup_names=True, lookup_class=True)
        device_name = None
        device_class = None
        for mac, name, cl in devices:
            if self.args["bmac"] == mac:
                print_info("A nearby device has been found")
                device_name = name
                device_class = hex(cl)
                break

        if not device_name:
            print_info("No nearby device found")
            if self.args['name']:
                device_name = self.args['name']
            else:
                print_error("We can't find the name")
                return

        if not device_class:
            if self.args['class']:
                device_class = self.args['class']
            else:
                print_error("We can't find the profile")
                return
        print_info("Trying to change name and MAC")
        result = system(f"apps/spooftooph -i {self.args['iface']} -a {self.args['bmac']}")
        if int(result) == 0:
            print_ok("Done!")
            print_info("Starting Bluetooth service to allow connections")
            self._start_service(device_name, device_class)
        else:
            print_error("Execution fault...") 
开发者ID:ElevenPaths,项目名称:HomePWN,代码行数:36,代码来源:mac-spoof.py

示例14: scan_button_clicked

# 需要导入模块: import bluetooth [as 别名]
# 或者: from bluetooth import discover_devices [as 别名]
def scan_button_clicked(self, widget):
        self.quit_button.set_sensitive(False)
        self.scan_button.set_sensitive(False)
#        self.chat_button.set_sensitive(False)
        
        self.discovered.clear()
        for addr, name in bluetooth.discover_devices (lookup_names = True):
            self.discovered.append ((addr, name))

        self.quit_button.set_sensitive(True)
        self.scan_button.set_sensitive(True)
#        self.chat_button.set_sensitive(True) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:14,代码来源:bluezchat.py

示例15: btscanning

# 需要导入模块: import bluetooth [as 别名]
# 或者: from bluetooth import discover_devices [as 别名]
def btscanning():
    devices = bluetooth.discover_devices(duration=1, lookup_names = True)

    for addr, name in devices:
        if addr not in btclients:
            print W+ '[' +R+ 'Bluetooth Client' +W+ ':' +B+ addr +W+ '] [' +G+ 'Name' +W+ ': ' +O+ name +W+ ']'
            btclients.append(addr) 
开发者ID:NoobieDog,项目名称:Peanuts,代码行数:9,代码来源:peanuts.py


注:本文中的bluetooth.discover_devices方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。