5

I am looking for a way to sniff the network traffic my Android app is generating. The reason is I want to check and send statistics of the traffic generated by a third party tracking library I am using in my app.

Because of this, I cannot use any tPacketCapture or similars.

I have no access to the http client of this tracking library, so I cannot intercept any request.

I already took a look to VpnService, but I cannot force the user to connect to a VPN every time he is using my app of course.

So I am looking for any advice on how to do this in Android, if it is possible.

I found that there is this library, NetworkEye, which is doing exactly what I would like to do... but for iOS.

Daniele Vitali
  • 3,848
  • 8
  • 48
  • 71
  • not sure that you can do that if your device is not rooted. Also DDMS could be useful: http://developer.android.com/tools/debugging/ddms.html#network – someUser Feb 16 '16 at 17:58
  • can you pass your tracking library a custom http client? (btw, which tracking lib is it?) in which case [Stetho](https://facebook.github.io/stetho/) might work for you – njzk2 Feb 16 '16 at 18:32
  • @njzk2 no I cannot. It's called Adjust. You can find it on github too. – Daniele Vitali Feb 16 '16 at 18:36
  • since the lib is open-source, yes you can. here: https://github.com/adjust/android_sdk/blob/master/Adjust/adjust/src/main/java/com/adjust/sdk/Util.java#L293 you can inject stetho sniffing. (or whatever other sniffing you want ot use) – njzk2 Feb 16 '16 at 18:42
  • I am not really fan of code injection, but anyway, what if I am using also GTM? which is not open source – Daniele Vitali Feb 16 '16 at 18:45
  • Btw, by injecting code you mean writing a gradle script which inject code into that point when compiling right? In that case, I need to download the source code of Adjust, loosing the chance to get any update coming from maven. Am I correct? – Daniele Vitali Feb 16 '16 at 18:50

1 Answers1

0

As far I know, to achieve 'global' packet sniffing in Android OS you have to run on a rooted device. For the library,I would go through the NDK and libpcap for Android

karvoynistas
  • 1,295
  • 1
  • 14
  • 30