用于监控手机APP与蓝牙设备之间的双向数据传输,支持实时抓取和解析HCI层数据包。
# 克隆仓库
git clone https://github.com/dgz2026/bt-hci-snoop.git
cd bt-hci-snoop
# 安装依赖
sudo apt-get install bluetooth bluez python3-bluepy
pip3 install -r requirements.txt
# 启动抓包监控
./scripts/start_snoop.sh
# 停止抓包监控
./scripts/stop_snoop.sh
# 使用Python脚本直接运行
python3 src/bt_snoop.py
编辑 config/snoop.conf 文件:
[general]
# 日志输出文件路径
log_file = ./logs/bt_snoop.log
# 是否输出十六进制数据
dump_hex = true
# 是否启用时间戳
enable_timestamp = true
# 蓝牙设备索引(默认为hci0)
hci_device = hci0
# 日志级别 (DEBUG, INFO, WARNING, ERROR)
log_level = INFO
日志文件包含以下信息:
[2025-03-21 14:30:15] [TX] ACL Data | Length: 20 | Handle: 0x0011 Data: 02 01 06 03 03 18 00 19 00 00 00 00 00 00 00 00 00 00 00 00 [2025-03-21 14:30:16] [RX] Event | Type: LE Meta Event (0x3E) | SubEvent: 0x02 Data: 02 01 00 00 19 00 00 00 00 00 00 00 00 00 00 00
本模块通过以下方式实现蓝牙抓包:
本模块专为kernelISU环境优化:
# 检查蓝牙服务状态
sudo systemctl status bluetooth
# 检查蓝牙设备列表
hciconfig -a
# 重启蓝牙服务
sudo systemctl restart bluetooth
确保当前用户有蓝牙设备访问权限:
sudo usermod -a -G bluetooth $USER
# 注销后重新登录
运行测试:
python3 -m pytest tests/
MIT License
dgz2026
欢迎提交Issue和Pull Request!