Fine Stroke: Capturing Traffic

Amidst the much awaited New Years Eve and the sound of ringing jingle bells, still hovering I am much excited to share my next Outreachy update.

So, in the last post I  mentioned about what attracted me to contribute to Electronic Frontier Foundation in particular and how I landed up with this project.There were no technicalities therein but this post is intended for describing what my project exactly is and how far I have come by now.

It has taken exhaustive learning and surfing from my end to be in a situation apt for this write-up, so I will try to pour out as much as I can and I remember going down my memory lane (and my browser history :P) for past few weeks.

As a part of my internship, I am working on developing Privacy Badger for android devices.If you are pondering, what is Privacy Badger, there you go:

” Privacy Badger is a browser add-on that stops advertisers and other third-party trackers from secretly tracking where you go and what pages you look at on the web.  If an advertiser seems to be tracking you across multiple websites without your permission, Privacy Badger automatically blocks that advertiser from loading any more content in your browser.  To the advertiser, it’s like you suddenly disappeared.”


To learn more about it and check how it differs from other ad-blockers or what principles it runs on follow this link: Learn More 

Essentially, privacy badger is available in form of browser plugins for Firefox and Chrome. We need to provide the same for mobiles too.

The question is how? We can make it happen in any of the three ways:

  1. Making a Firefox add on for Android.
  2. Standalone Android  Browser App.
  3. To use a VPN connection in Android to regulate the traffic across the device.

following from discussion with my mentors.

Given the time, scalability ,resources and efficiency constraints, the best suited approach is the third one. So, I began learning about VPN and how can we make such connection on Android devices, in parallel checking out similar apps like Disconnect, AdBlock Browser, Ghostery etc.

We all have used VPN sometime or the other but when it comes to creating one programmatically you need to go to the core of what exactly constitutes it and how can you build one. Technically, VPN connects securely. It uses “tunneling protocols” ; it sets up tunnel between your system and server through all the routers going through, and encrypts all info going through the tunnel. If any hacker is trying to hack at any router, tunnel detects penetration, then the tunnel shuts down and new path gets created.

Android has classes such as VpnService that supports setting up of VPN connection. After trying out few toy examples I was ready to setup my VPN connection. While I was under the notion that VPN will essentially ensure users’ anonymity while surfing, the intended use was not that.

Further communication clarified this out as to what exactly we are looking for: “The idea is that we would run a vpn server locally on the phone to catch any traffic that is going out and look for domains that appear like they could be tracking and then keep a count of those domains and report them to the user in some sort of dashboard” as Cooper guided me.

The very idea of creating a server on android itself fascinated me 🙂 I read couple of blog posts later deliberating on how you can host your websites successfully on spare Android devices. I checked out and created a server on Android using nanohttpd yet another amazing open source project.

So I had my localhost running on Android. I setup a VPN connection to it but then what next? How to channelize all the outgoing traffic via it? This thing was getting app-specific, as in if I use a particular app and make requests via it, they may get directed to the vpn server and I can then do the intended traffic capturing or filtering, but I wanted to capture the entire outgoing traffic from my device.

After surfing and posting in related communities, I found some really good tools and ways to do that. Being stuck for sometime, meanwhile I tried out Charles Proxy and Firesheep, read more about cookie profiling and browser fingerprinting.

Then I decided why not try this by creating a proxy server on Android, so that all requests are first directed to this server, captured and then to the intended server (forward proxy). So I created a proxy server on Android using the inbuilt support for the same. Since, my android device was connected to Wi-Fi I added the manual proxy settings to it that directed all the requests to this server hosted on the device itself.

After failed attempts to establish the much needed connections and get the GET/POSTs requests captured , I was having a broad smile when it actually finally happened. Different  issues come up while dealing HTTP and HTTPS requests respectively. I will be writing a detailed post on my technical blog explaining the major code snippets for the same.

I got a sneak peek into how WhatsApp uses sockets to communicate, while trying out all this.

As of now, I believe the last few days of year 2015 have been quite enthralling and engaging and the year is ending up with good hope to make things work next.

I will be trying out more possibilities and refine the present architecture, along with working on the app’s features and functionalities.

So, that was more or less the log of events at my end.

Oops, I just checked the post went long a bit, so since you have reached till here, I take the opportunity to wish you a very happy and prosperous New  Year 2016 !


See you in next post soon!

Till then stay connected, happy hacking, have your favorite cuisine and if you are a fan of metal covers, do check out this guy:

Lady Gaga goes metal







The blank canvas : Beginning

Hola folks!

So now the time comes when I will  officially contribute to FOSS as an Outreachy intern. Yayy!  😀

Before I begin shedding the technicalities of the project in this blog, I would like to log the journey till now and how I ended up taking this project.

It is the incident, a few months back, when the semester began. I remember taking a morning stroll with two of my friends when we were discussing about how the websites bring in the ads/content we search on in the parallel tabs of our browser. You would have noticed, when you search for some “XYZ” content in your browser tabs, the targeted ads and in fact content of your feed changes accordingly. It seems like someone is keeping a track of our online activity very diligently, and the feeling of being tracked feels so bad.

Later that day, while surfing through the Outreachy projects, I stumbled upon Privacy Badger and it immediately captivated my interest. I read about it, forked its github repo, tried understanding the design and implementation and started contributing 🙂

The more I got to know about the organization, Electronic Frontier Foundation and the umbrella of projects it deals with , the more sure I became that this is the one organization I wish to work with.

And so I submitted my Outreachy application, having made the initial commits and PRs. I still remember the happy shiver down my spine, I got when I saw my name in the selected list.

As of now I am understanding it in a more exhaustive manner along with working on couple of bugs, so that I am able to develop a concrete conceptual base for my application to stand upon. So, frankly its the warm-up phase.

In the next post I will be sharing my discoveries by then and the progress made.

Till then,

Have coffee, keep hacking!

And as I go, some good music explored this week: MUSIICCC

See you in next post!