nccgroup / BLESuite

BLESuite is a Python package that provides an easier way to test Bluetooth Low Energy (BLE) device
MIT License
176 stars 40 forks source link

Scan (or any other socket-related operation) hangs at recv(). #11

Open 3riatarka opened 5 years ago

3riatarka commented 5 years ago

The program hangs whenever it uses a bluetooth socket. The following examples are extracted from a simple scan executed with the following command:

sudo blesuite -i 1 scan

Fiddling with the code, I set up a timeout of 15 seconds where the socket gets created, and then I get the following traceback:

Traceback (most recent call last):
  File "/usr/local/bin/blesuite", line 10, in <module>    
    blesuite_cli.main()
  File "/usr/local/lib/python2.7/dist-packages/blesuite/cli/blesuite_cli.py", line 364, in main
    process_args(args)
  File "/usr/local/lib/python2.7/dist-packages/blesuite/cli/blesuite_cli.py", line 171, in process_args 
    with BLEConnectionManager(args.adapter[0], 'central') as connection_manager:
  File "/usr/local/lib/python2.7/dist-packages/blesuite/connection_manager.py", line 131, in __init__
    self._create_central()
  File "/usr/local/lib/python2.7/dist-packages/blesuite/connection_manager.py", line 174, in _create_central
    att_operation_event_hook=self.att_operation_event_hook)
  File "/usr/local/lib/python2.7/dist-packages/blesuite/pybt/roles.py", line 26, in __init__ 
    self.stack = BTStack(adapter=adapter)
  File "/usr/local/lib/python2.7/dist-packages/blesuite/pybt/stack.py", line 144, in __init__
    r = self.command(HCI_Cmd_Read_BD_Addr())
  File "/usr/local/lib/python2.7/dist-packages/blesuite/pybt/stack.py", line 375, in command
    return self.s.send_command(HCI_Hdr()/HCI_Command_Hdr()/cmd)
  File "/usr/local/lib/python2.7/dist-packages/scapy-2.4.3rc1.dev132-py2.7.egg/scapy/layers/bluetooth.py", line 1415, in send_command
    r = self.recv()
  File "/usr/local/lib/python2.7/dist-packages/scapy-2.4.3rc1.dev132-py2.7.egg/scapy/layers/bluetooth.py", line 1423, in recv
    return HCI_Hdr(self.ins.recv(x))

The debug output of the same command shows:

BTLE Scan beginning
DEBUG:blesuite.connection_manager:creating central
DEBUG:blesuite.pybt.stack:[!] Creating socket failed: BluetoothSocketError('Unable to bind',)

DEBUG:blesuite.pybt.stack:[+] have root, attempting to take iface down

DEBUG:blesuite.pybt.stack:Trying to set reuseaddr
DEBUG:blesuite.pybt.stack:Settings ins reuse

and then stays there. I tried versions 2.4.0 and 2.4.3rc1.dev132 of scapy, with the same results.

I have no clue where to keep looking, if there is any other information needed, I will reply as soon as I can.

Thank you all.

ovakisan commented 5 years ago

Same situation here, any new info how to solve this?

Edit: tried with scapy 2.4.0 , 2.42 and 2.4.3

burntCherryCake commented 4 years ago

This is still a problem.

Whatever special mods mentioned in the readme seems to have been merged with the main scapy branch? I think the latest commit points to the most recent scapy build. I saw 2.4.4 installed, and I see 2.4.4.dev7 as currently installed.

I've installed and am using Fedora 28 as indicated in the readme. (Was on Ubuntu 20.04 and hit the same issues.) There are a few libraries being used, and I've tried (and failed on the same error with): pysocks 1.6.8, 1.6.0, 1.5.6, 1.5.5, 1.5.0, 1.4.2 scapy 2.4.4.dev7, 2.4.4, 2.4.3, 2.4.3rc4 ,2.4.2, 2.4.1, 2.4.0, 2.3.9.

I have also tried checking out BLEsuite v1, same error.

Still not sure what the error is.