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

Unable to complete a basic scan #9

Open pandasauce opened 5 years ago

pandasauce commented 5 years ago

Running a scan for the first time comes back with empty results.

Running it for the second consecutive time generates the error below.

Running any blesuite command inbetween makes it keep coming back with empty results and no error.

Running the same scan with bettercap successfully discovers a dozen devices in range and enumerates their services, so I know the adapter (Intel 8265) works.

This is on Ubuntu 18.04.01.

(ve2) root@bletester:/home/bletester/XXXXX/root# blesuite scan
BTLE Scan beginning
Discovered:
(ve2) root@bletester:/home/bletester/XXXXX/root# blesuite scan
BTLE Scan beginning
Traceback (most recent call last):
  File "src/gevent/greenlet.py", line 766, in gevent._greenlet.Greenlet.run
  File "/home/bletester/XXXXX/root/BLESuite/ve2/local/lib/python2.7/site-packages/blesuite/pybt/core.py", line 283, in run
    event = self.conn.role.stack.handle_data()
  File "/home/bletester/XXXXX/root/BLESuite/ve2/local/lib/python2.7/site-packages/blesuite/pybt/stack.py", line 217, in handle_data
    return BTEvent(BTEvent.SCAN_DATA, (p.addr, p.atype, p.data))
  File "/home/bletester/XXXXX/root/BLESuite/ve2/local/lib/python2.7/site-packages/scapy-2.4.3rc1.dev53-py2.7.egg/scapy/packet.py", line 327, in __getattr__
    return self.payload.__getattr__(attr)
  File "/home/bletester/XXXXX/root/BLESuite/ve2/local/lib/python2.7/site-packages/scapy-2.4.3rc1.dev53-py2.7.egg/scapy/packet.py", line 327, in __getattr__
    return self.payload.__getattr__(attr)
  File "/home/bletester/XXXXX/root/BLESuite/ve2/local/lib/python2.7/site-packages/scapy-2.4.3rc1.dev53-py2.7.egg/scapy/packet.py", line 327, in __getattr__
    return self.payload.__getattr__(attr)
  File "/home/bletester/XXXXX/root/BLESuite/ve2/local/lib/python2.7/site-packages/scapy-2.4.3rc1.dev53-py2.7.egg/scapy/packet.py", line 327, in __getattr__
    return self.payload.__getattr__(attr)
  File "/home/bletester/XXXXX/root/BLESuite/ve2/local/lib/python2.7/site-packages/scapy-2.4.3rc1.dev53-py2.7.egg/scapy/packet.py", line 325, in __getattr__
    fld, v = self.getfield_and_val(attr)
  File "/home/bletester/XXXXX/root/BLESuite/ve2/local/lib/python2.7/site-packages/scapy-2.4.3rc1.dev53-py2.7.egg/scapy/packet.py", line 1431, in getfield_and_val
    raise AttributeError(attr)
AttributeError: addr
2019-03-29T10:07:04Z <Greenlet at 0x7fe10fea0158: <bound method SocketHandler.run of <blesuite.pybt.core.SocketHandler object at 0x7fe10feb5ed0>>> failed with AttributeError

Discovered:

--debug output:

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
DEBUG:blesuite.connection_manager:creating PyBT connection
DEBUG:blesuite.connection_manager:creating listeners
ERROR:blesuite.pybt.stack:[!] Controller error for command: LE Set Scan Parameters Error: Command 200b failed with c

ERROR:blesuite.pybt.stack:[!] Controller error for command: LE Set Scan Enable Error: Command 200c failed with c

DEBUG:blesuite.connection_manager:Starting sleep loop
DEBUG:blesuite.connection_manager:Scanning...
DEBUG:blesuite.connection_manager:Scanning...
DEBUG:blesuite.connection_manager:Scanning...
DEBUG:blesuite.connection_manager:Scanning...
DEBUG:blesuite.connection_manager:Scanning...
DEBUG:blesuite.connection_manager:Done scanning!
Discovered:
DEBUG:blesuite.connection_manager:Exiting bleConnectionManager. exc_type:None exc_val:None exc_tb:None
DEBUG:blesuite.pybt.core:Connection quit(), killing remaining connection threads
DEBUG:blesuite.pybt.roles:Destroying LECentral
DEBUG:blesuite.pybt.stack:Destroying PyBT, closing HCI device
DEBUG:blesuite.pybt.stack:Stop advertising
DEBUG:blesuite.pybt.stack:Stop Scanning
ERROR:blesuite.pybt.stack:[!] Controller error for command: LE Set Scan Enable Error: Command 200c failed with c

DEBUG:blesuite.pybt.stack:Flushing socket
DEBUG:blesuite.cli.blesuite_cli:Args: Namespace(adapter=[0], address=None, address_type=['public'], async=False, command=['scan'], data=[], debug=True, files=[], handles=[], mode=[1], payload_delimiter=['EOF'], skip_device_info_query=False, smart_read=False, subscribe_timeout=[None], timeout=[5], uuids=[])
-----
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
DEBUG:blesuite.connection_manager:creating PyBT connection
DEBUG:blesuite.connection_manager:creating listeners
ERROR:blesuite.pybt.stack:[!] Controller error for command: LE Set Scan Parameters Error: Command 200b failed with c

ERROR:blesuite.pybt.stack:[!] Controller error for command: LE Set Scan Enable Error: Command 200c failed with c

DEBUG:blesuite.connection_manager:Starting sleep loop
DEBUG:blesuite.connection_manager:Scanning...
Traceback (most recent call last):
  File "src/gevent/greenlet.py", line 766, in gevent._greenlet.Greenlet.run
  File "/home/bletester/XXXXX/root/BLESuite/ve2/local/lib/python2.7/site-packages/blesuite/pybt/core.py", line 283, in run
    event = self.conn.role.stack.handle_data()
  File "/home/bletester/XXXXX/root/BLESuite/ve2/local/lib/python2.7/site-packages/blesuite/pybt/stack.py", line 217, in handle_data
    return BTEvent(BTEvent.SCAN_DATA, (p.addr, p.atype, p.data))
  File "/home/bletester/XXXXX/root/BLESuite/ve2/local/lib/python2.7/site-packages/scapy-2.4.3rc1.dev53-py2.7.egg/scapy/packet.py", line 327, in __getattr__
    return self.payload.__getattr__(attr)
  File "/home/bletester/XXXXX/root/BLESuite/ve2/local/lib/python2.7/site-packages/scapy-2.4.3rc1.dev53-py2.7.egg/scapy/packet.py", line 327, in __getattr__
    return self.payload.__getattr__(attr)
  File "/home/bletester/XXXXX/root/BLESuite/ve2/local/lib/python2.7/site-packages/scapy-2.4.3rc1.dev53-py2.7.egg/scapy/packet.py", line 327, in __getattr__
    return self.payload.__getattr__(attr)
  File "/home/bletester/XXXXX/root/BLESuite/ve2/local/lib/python2.7/site-packages/scapy-2.4.3rc1.dev53-py2.7.egg/scapy/packet.py", line 327, in __getattr__
    return self.payload.__getattr__(attr)
  File "/home/bletester/XXXXX/root/BLESuite/ve2/local/lib/python2.7/site-packages/scapy-2.4.3rc1.dev53-py2.7.egg/scapy/packet.py", line 325, in __getattr__
    fld, v = self.getfield_and_val(attr)
  File "/home/bletester/XXXXX/root/BLESuite/ve2/local/lib/python2.7/site-packages/scapy-2.4.3rc1.dev53-py2.7.egg/scapy/packet.py", line 1431, in getfield_and_val
    raise AttributeError(attr)
AttributeError: addr
2019-03-29T10:28:27Z <Greenlet at 0x7fea9399c158: <bound method SocketHandler.run of <blesuite.pybt.core.SocketHandler object at 0x7fea939550d0>>> failed with AttributeError

DEBUG:blesuite.connection_manager:Scanning...
DEBUG:blesuite.connection_manager:Scanning...
DEBUG:blesuite.connection_manager:Scanning...
DEBUG:blesuite.connection_manager:Scanning...
DEBUG:blesuite.connection_manager:Done scanning!
Discovered:
DEBUG:blesuite.connection_manager:Exiting bleConnectionManager. exc_type:None exc_val:None exc_tb:None
DEBUG:blesuite.pybt.core:Connection quit(), killing remaining connection threads
DEBUG:blesuite.pybt.roles:Destroying LECentral
DEBUG:blesuite.pybt.stack:Destroying PyBT, closing HCI device
DEBUG:blesuite.pybt.stack:Stop advertising
DEBUG:blesuite.pybt.stack:Stop Scanning
ERROR:blesuite.pybt.stack:[!] Controller error for command: LE Set Scan Enable Error: Command 200c failed with c

DEBUG:blesuite.pybt.stack:Flushing socket
DEBUG:blesuite.cli.blesuite_cli:Args: Namespace(adapter=[0], address=None, address_type=['public'], async=False, command=['scan'], data=[], debug=True, files=[], handles=[], mode=[1], payload_delimiter=['EOF'], skip_device_info_query=False, smart_read=False, subscribe_timeout=[None], timeout=[5], uuids=[])
pandasauce commented 5 years ago

Looks like this is a compatibility issue with scapy. The workaround is to checkout the version of scapy fork that was current at the time of BLESuite release 2.0: 2.4.0.

simpleunknown commented 5 years ago

Hi i use scapy version 2.3.2 and do get the same error. blesuiteerror