5

Can I capture packets for certain process or package on Android or even through adb?

dpro
  • 73
  • 1
  • 3
  • 2
    What do you exactly mean by "packets"? – Shashank Kadne Nov 25 '12 at 14:26
  • I'm sorry that my English is not so good! I know how to capture the entire network packet by using tcpdump, but it difficult for me to monitor just one process on Android. Thanks for all replies. – dpro Nov 25 '12 at 14:33

2 Answers2

6

If you are looking at a specific application, disable background data for other processes through the settings app. Install tcpdump on the phone and setup wireshark on the pc to filter the data. There's no way to filter by a specific process directly, but you can make the rest of the phone quiet enough so you can sift through the noise.

Here is a good tutorial: analyzing android network traffic

If you're looking for traffic to known sites, like if you're trying to sniff private api calls, then it's trivial in wireshark to filter outbound and inbound traffic to and from that address.

Dave Snigier
  • 2,404
  • 2
  • 19
  • 27
3

No, sorry, you cannot spy on applications' use of the Internet via adb. With root access, you have more options, but even then not simply using adb.

Community
  • 1
  • 1
CommonsWare
  • 910,778
  • 176
  • 2,215
  • 2,253
  • Thank you first for your reply. I have my phone rooted, can I capture network packet for given app by whatever means? – dpro Nov 25 '12 at 14:40
  • 1
    @dpro: Please see [the SO question that I linked to in my question](http://stackoverflow.com/questions/9555403/capturing-mobile-phone-traffic-on-wireshark) and its various answers for more assistance. – CommonsWare Nov 25 '12 at 14:47
  • What about spying after my own app? Is there a way to see all it's traffic? Lets assume that I am a library in my app and I can't change any code but I can change the manifest and even run in debug mode and the device is rooted. – Ilya Gazman Jun 14 '16 at 14:09
  • @Ilya_Gazman: "Is there a way to see all it's traffic?" -- nothing specific to that app. Use standard network monitoring tools on your WiFi access point, or use Wireshark as is noted in the accepted answer. I am not aware of any `adb` options. – CommonsWare Jun 14 '16 at 14:14
  • I was thinking more about android.net.TrafficStats or something with the KeyStore. I know that starting from marshmallow(Or lolipop) you can ask for admin permission and install user certificate using DevicePolicyManager. It makes me think that there could be a way... – Ilya Gazman Jun 14 '16 at 15:29