Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capture network traffic programmatically (no root)

I'm trying to find resources or library which could permit me to capture the traffic of all the network packets of a device programmatically either it be from wifi or mobile network. I believe there no need to be root to be in this promiscuous mode as shark for root would request because there is this app on the play store which can capture all network traffic (even decrypt SSL with MITM) without needing to be root. I simply cannot figure out how to do the same.

My question is: How did this app achieve this capture? What API did they use?

Thank you for your help.

like image 938
E-Kami Avatar asked Jul 30 '16 22:07

E-Kami


People also ask

Can you capture network traffic?

To capture network traffic, you can use tcpdump. This is a packet sniffer that can observe and record network traffic on an interface. In the following example, we capture 1,000 packets using tcpdump. An easier way to analyze network traffic is to use an actual network traffic analyzer, such as Wireshark.

How do I track network traffic on Android?

Fing. Fing is one of the best network monitors for Android. With this app, you can see all the essential information that concerns your device connections. Examples include a list of users connected to your Wi-Fi, information about unauthorized data consumption, and any potentially malicious behavior on the network.


1 Answers

The de-facto appraoch to packet sniffing in Android without root is loop-back VPNService. Creating a VPNService app and activating it, will force all traffic in the device to go through your newly created virtual interface which is managed by a userspace application, where you will be receiving IP Packets by reading from the virtual interface.

You can check a simple code sample for it from Google here

You can check a full working example project here

like image 106
Kariem Avatar answered Nov 08 '22 07:11

Kariem