How to sniff web traffic from Marketplace-based Android applications
Join the DZone community and get the full member experience.Join For Free
There are cases when it is necessary to track the outgoing and incoming traffic related to Android applications. However, Android as a platform is not really friendly towards this kind of operations. The most common way I am analyzing the traffic that is targetting a mobile device is by setting an ad-hoc wireless network while my computer is connected to a wired connection. Both Windows Phone 7 and Android support connecting to secondary networks (aka ad-hoc), but Android doesn't support this by default.
So there are three choices I was thinking about:
- Sniffing all WiFi packets for the needed data
- Sniffing data from the emulator
Both ways had major limitations. Sniffing the general WiFi traffic would require additional configuration in my case. The emulator doesn't have the Marketplace and I don't have direct access to the APK. Or at least that's the default behavior.
Since my device is un-rootable and there is no way I could connect it to an ad-hoc network at this moment, I though that the emulator is the best way to go. So the first thing I though of is unlocking the default image to carry the Marketplace. This wasn't a complicated task, so I eventually enabled the Marketplace.
But there was one problem - due to some limitations of the image "hack", the Marketplace isn't associated with the correct location. Therefore, the application I was looking for was not available. The next step was obtaining the actual application APK, so I can put it on the emulator.
The file browser on Android doesn't offer the possbility to access the data folder. However, there are applications that allow APK backup, and appInstaller is one of them:
Just what I needed! Once I copied the APK package on the SD card (that is required), I copied it locally and then used adb install PATH_TO_APK to install it on the emulator (given that the device is disconnected. One thing to make sure is that the emulator is running the correct version of the OS.
Simple as that. Once the app is installed, all communications are done through the local network pipe and general tools like WireShark and Fiddler can be used.
Opinions expressed by DZone contributors are their own.