嗅探/记录您自己的 Android 蓝牙流量

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23877761/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 07:33:54  来源:igfitidea点击:

Sniffing/logging your own Android Bluetooth traffic

androidbluetoothreverse-engineering

提问by peku33

I recently bought chinesse device that connects via bluetooth with android phone / tablet. Since there is no application availible for windows / linux I want to create one for personal usage.

我最近购买了通过蓝牙与安卓手机/平板电脑连接的中国设备。由于没有适用于 windows / linux 的应用程序,我想创建一个供个人使用。

Usually phone connects to the device and exchanges some data. I connected PC to the device and looked into serial debugger and menaged to discover the protocol (one way only). Phone sends only one command to the device. But this time I'm not able to find out what it containts.

通常手机连接到设备并交换一些数据。我将 PC 连接到设备并查看串行调试器并管理以发现协议(仅一种方式)。电话仅向设备发送一个命令。但这一次我无法找出它包含的内容。

Is there any software that will allow me to look into data sent via bluetooth? I tried decompiling the app, but it looks really unfriendly.

有没有什么软件可以让我查看通过蓝牙发送的数据?我尝试反编译该应用程序,但它看起来非常不友好。

Thanks.

谢谢。

回答by Stephan Branczyk

Android 4.4 (Kit Kat) does have a new sniffing capability for Bluetooth. You should give it a try.

Android 4.4 (Kit Kat) 确实具有新的蓝牙嗅探功能。你应该试一试。

If you don't own a sniffing device however, you aren't necessarily out of luck. In many cases we can obtain positive results with a new feature introduced in Android 4.4: the ability to capture all Bluetooth HCI packets and save them to a file.

When the Analyst has finished populating the capture file by running the application being tested, he can pull the file generated by Android into the external storage of the device and analyze it (with Wireshark, for example).

Once this setting is activated, Android will save the packet capture to /sdcard/btsnoop_hci.log to be pulled by the analyst and inspected.

但是,如果您没有嗅探设备,那么您不一定不走运。在许多情况下,我们可以通过 Android 4.4 中引入的一项新功能获得积极的结果:能够捕获所有蓝牙 HCI 数据包并将其保存到文件中。

当分析师通过运行被测试的应用程序完成填充捕获文件时,他可以将 Android 生成的文件拉入设备的外部存储并对其进行分析(例如使用 Wireshark)。

激活此设置后,Android 会将数据包捕获保存到 /sdcard/btsnoop_hci.log 以供分析师拉取并检查。

Type the following in case /sdcard/is not the right path on your particular device:

如果/sdcard/在您的特定设备上不是正确的路径,请键入以下内容:

adb shell echo $EXTERNAL_STORAGE

We can then open a shell and pull the file: $adb pull /sdcard/btsnoop_hci.log and inspect it with Wireshark, just like a PCAP collected by sniffing WiFi traffic for example, so it is very simple and well supported:

screenshot of wireshark capture using Android HCI Snoop

[source]

然后我们可以打开一个shell并拉取文件: $adb pull /sdcard/btsnoop_hci.log 并使用Wireshark检查它,就像通过嗅探WiFi流量收集的PCAP一样,所以它非常简单并且得到很好的支持:

使用 Android HCI Snoop 捕获wireshark 的屏幕截图

[来源]

You can enable this by going to Settings->Developer Options, then checking the box next to "Bluetooth HCI Snoop Log."

您可以通过转到“设置”->“开发人员选项”,然后选中“蓝牙 HCI 监听日志”旁边的框来启用此功能。

回答by maximevince

Also, this might help finding the actual location the btsnoop_hci.log is being saved:

此外,这可能有助于找到保存 btsnoop_hci.log 的实际位置:

adb shell "cat /etc/bluetooth/bt_stack.conf | grep FileName"