Home > Net >  How to fetch ADB shell traffic?
How to fetch ADB shell traffic?

Time:04-26

There's an app on my Mac that is running some adb shell commands on my android device. Unfortunately, this app is not open source, so it's hard for me to tell what exactly it's doing. Is there any way of fetching sent shell commands to my adb device? Something like a command history, but for all adb server instances, not only for the 'current' one (as the app creates its own adb server and I'm using another instance to connect to the shell and invoke commands).

CodePudding user response:

Before the adb commands are sent to the device through USB they have to pass the adb server which receives the commands via TCP port 5037 on localhost interface (assuming that special ADB server uses the same TCP port).

Therefore capturing localhost traffic using Wireshark and filtering for TCP port 5037 should show you all commands as ADB is a plain text protocol without security.

Alternatively you could try to capture the commands on USB level, but I don't know if the Wireshark USB capturing backend USBPcap is functional on MacOS.

As far as I remember Wireshark already contains the necessary dissectors. On TCP level you might need to manually assign the adb dissector to the network connection.

  • Related