7

我在 Ubuntu 20.04 和 Raspberry Pi OS 5.10 上使用它,但这不是 Linux 相关问题。

当我使用它的功能扫描蓝牙设备时,我遇到了一个名为 Bettercap 2(https://www.bettercap.org/和存储库:https ://github.com/bettercap/bettercap)的 Go 程序的问题“ ble.recon on" 使用不同的蓝牙加密狗。

当我将它与使用 Realtek RTL8761b 驱动程序( MPOW MPBH456AB )的加密狗一起使用时,您可以在亚马逊上找到它运行良好,但是当我使用 NordicSemi nrf52840 加密狗时(https://www.nordicsemi.com/Products/Development-hardware/nrf52840 -dongle这是我的目标,用 Zephyr RTOS 的 hci_usb 示例(https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/bluetooth/hci_usb)闪烁,它应该使用蓝牙打开任何微控制器进入任何计算机都应该识别的常规蓝牙加密狗,它会引发此错误:

>> ble.recon on
   panic: runtime error: slice bounds out of range [:1] with capacity 0

   goroutine 1 [running]:
   github.com/bettercap/gatt/linux/cmd.(*Cmd).SendAndCheckResp(0x1c637c0, 0xa0c760, 0x1c64fe8, 0x1c6501c, 0x1, 0x1, 0x0, 0x0)
    /home/pi/go/pkg/mod/github.com/bettercap/gatt@v0.0.0-20210514133428-df6e615f2f67/linux/cmd/cmd.go:98 +0x1b4
   github.com/bettercap/gatt/linux.(*HCI).resetDevice(0x18ac0a0, 0x93dc10, 0x18ac0a0)
    /home/pi/go/pkg/mod/github.com/bettercap/gatt@v0.0.0-20210514133428-df6e615f2f67/linux/hci.go:273 +0x2f0
   github.com/bettercap/gatt/linux.NewHCI(0xffffffff, 0x184fd01, 0xff, 0x2, 0x0, 0x0)
    /home/pi/go/pkg/mod/github.com/bettercap/gatt@v0.0.0-20210514133428-df6e615f2f67/linux/hci.go:90 +0x4c0
   github.com/bettercap/gatt.NewDevice(0x184fd1c, 0x2, 0x2, 0x3c, 0x184fd24, 0x1, 0x1)
    /home/pi/go/pkg/mod/github.com/bettercap/gatt@v0.0.0-20210514133428-df6e615f2f67/device_linux.go:57 +0x114
   github.com/bettercap/bettercap/modules/ble.(*BLERecon).Configure(0x18a2780, 0x0, 0x4)
    /home/pi/go/pkg/mod/github.com/bettercap/bettercap@v2.24.1+incompatible/modules/ble/ble_recon.go:165 +0x1cc
   github.com/bettercap/bettercap/modules/ble.(*BLERecon).Start(0x18a2780, 0x1, 0x1b2c001)
    /home/pi/go/pkg/mod/github.com/bettercap/bettercap@v2.24.1+incompatible/modules/ble/ble_recon.go:183 +0x1c
   github.com/bettercap/bettercap/modules/ble.NewBLERecon.func1(0x0, 0x0, 0x0, 0x84f358, 0xc)
    /home/pi/go/pkg/mod/github.com/bettercap/bettercap@v2.24.1+incompatible/modules/ble/ble_recon.go:56 +0x1c
   github.com/bettercap/bettercap/session.(*ModuleHandler).Exec(0x1b2c0c0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/pi/go/pkg/mod/github.com/bettercap/bettercap@v2.24.1+incompatible/session/module_handler.go:74 +0x80
   github.com/bettercap/bettercap/session.(*Session).Run(0x18fb2c0, 0x1c64e30, 0xc, 0x1, 0x1)
    /home/pi/go/pkg/mod/github.com/bettercap/bettercap@v2.24.1+incompatible/session/session.go:416 +0x284
   main.main()
    /home/pi/go/pkg/mod/github.com/bettercap/bettercap@v2.24.1+incompatible/main.go:94 +0x8c8

我不知道这意味着什么,因为我不是 Go 开发人员并且从未使用过这种语言,我查看了错误,它似乎在代码中但不了解 Go,我更愿意在修改任何内容之前询问.

问题仅在我使用 nrf 加密狗时,否则它可以与主机的蓝牙和其他 realtek 加密狗一起使用。

nrf 加密狗与 BlueZ 堆栈一起使用,结果如下:

bluetoothctl ( 有一个 BD 地址 ) 扫描确实有效

$ sudo bluetoothctl
  Agent registered
  [bluetooth]# list
  Controller EB:XX:XX:XX:XX:XX BlueZ 5.50 [default]

btmgmt(找到控制器)扫描确实有效

$ sudo btmgmt --index 0
   [hci0]# auto-power
   Found controller with index 0
   [hci0]# find -l

但是,虽然已弃用,但 hciconfig 和 hcitool 可以识别 realtek 加密狗,但对于这个,结果如下:

hciconfig(无BD地址)

$ hciconfig
  hci0:   Type: Primary  Bus: USB
    BD Address: 00:00:00:00:00:00  ACL MTU: 27:7  SCO MTU: 0:0
    UP RUNNING
    RX bytes:1593 acl:0 sco:0 events:88 errors:0
    TX bytes:285 acl:0 sco:0 commands:51 errors:0

hcitool(找不到控制器)

$ hcitool scan
  Scanning ...
  Inquiry failed: Operation not supported

所以,我认为加密狗与 BlueZ 配合得很好,作为 Linux 官方蓝牙堆栈,这是一个好兆头,但我认为 Bettercap 也在使用 BlueZ,从这个意义上说,加密狗应该可以工作。

我认为没有为加密狗安装任何驱动程序,因为当它被刷新(J-Link)时,它会变成一个通用的蓝牙加密狗。

你知道问题可能是什么吗?

4

1 回答 1

3

我相信错误来自https://github.com/bettercap/gatt/blob/master/linux/cmd/cmd.go#L98

该程序正在尝试向设备写入一些内容,并希望只要没有发送错误,它就会收到响应。但显然 Send 调用成功但收到一个空响应。

我建议在那里打开一个问题并问你的问题。

于 2021-09-10T10:44:32.827 回答