Blocking access to IP using iptables on Android
Long time since I last posted anything here. The shift of topic would is another kind of surprise 😎
So moving to subject of this post.
Today I got an application on my Android phone which was using IP geolocation to determine where I am and block some features based on the IP address. Lets refer it as NastyApp going forward.
The most obvious solution would be to use proxy/VPN to mask my location, but that would require me to remember run VPN each time I need an application.
So going the hard way from here...
So moving to subject of this post.
Today I got an application on my Android phone which was using IP geolocation to determine where I am and block some features based on the IP address. Lets refer it as NastyApp going forward.
The most obvious solution would be to use proxy/VPN to mask my location, but that would require me to remember run VPN each time I need an application.
So going the hard way from here...
Step 1. Determine which IP needs to be blocked
There is a couple of application in the market to track where application is going. After playing with those I found NoRoot Firewall to be a perfect fit: you just enable it and all the traffic becomes routed through virtual VPN and intercepted by application. At this point I allowed all the destination IPs for NastyApp and started disabling those 1 by one and checking application until it finally failed to track a IP location. Let's say the IP used for geolocation services is 12.34.56.78.Step 2. Make sure IPTables are set up
To check if iptables are working, enable USB debugging on your phone, connect it to PC through USB and run in your command line:ADB shell
iptables --list
Step 3. Add IPTables record blocking access to IP
Now the only thing left is to drop incoming data from the enemy IP:sudo iptables -I INPUT -s 12.34.56.78 -j DROP
(adding this to OUTPUT chain did not work for some reason).To make sure IP is blocked, you can simply do a ping or any other request:
ping 12.34.56.78
Comments
Post a Comment