Create interactive firewall app in Android - android

I want create firewall app for Android that when an app wants to connect to internet shows app's name and let the user block it for permanent or block it temporarily or allow it and when that app wants to receive data from network shows app name and user can allow or deny it.
I viewed this question: create firewall, but it doesn't cover my needs.
Any suggestion to detect which apps have access to network and / or receive data from it?
Thanks!

This is quite possible, and has been done before.
See these applications/implementations:
https://github.com/ukanth/afwall
https://code.google.com/p/iptableslog/
https://code.google.com/p/droidwall/
https://github.com/n8fr8/orbot
https://github.com/Soyokaze99/VPNFirewall
Depending on implementation it may require your device to be rooted.
Universal, non-ROOT, way is to create custom VPN service and track connections using NFLOG/ULOG kernel-userspace module.
See other QAs for reference:
Building a firewall application
https://android.stackexchange.com/questions/34181/droidwall-firewall-app-alternative-for-non-rooted-phones
https://android.stackexchange.com/questions/37067/allow-only-specific-apps-to-use-cell-data-only-when-on-3g

Non-Root firewall can also be create using VPNService and a few C code to handle tcp/udp. NetGuard is a good example:
https://github.com/M66B/NetGuard

Related

How to block specific urls in Android

I am developing a parental kind of App in which there is a requirement to block specific urls from all the browsers in the Device. I think this is an old question but couldn't find any solution yet on stack.
Do you have any working solutions. Assumption - The device is rooted.
Regards,
sha
I have two resources for you:
Since the device is rooted you can work directly with iptables. iptables will give you very precise control over all coming and going data packets. Check out open source projects like AFWall+ on GitHub for iptables in action.
If you want to be able to run your app on unrooted devices look into creating a fake VPN. You don't send any data to an actual VPN server, you simply use the VPN API to filter all the information coming and going. Check out Disconnect (whenever they actually share their open source code...) or OpenVPN which is what Disconnect builds on.

How to make only traffic from some APPs go through VPN in Android?

I want to build a VPN APP on Android basing VPN service. one special requirement of this VPN APP is it has a white list, only traffic come from APPs in this list will go to VPN server. All rest traffic go to what they used to go.
For example, I have a VPN server in USA, and I am in China. I want Facebook goes through VPN. but Youku goes to Youku's server directly.
My first problem here is how can determine some traffic come from which APP?
I know it's possible, because there an APP called no root firewall can block traffic per APP, which is also basing Android VPN service.
https://play.google.com/store/apps/details?id=app.greyshirts.firewall
I'm new to Android, can anybody tell me how to do this?
Thanks in advance!
Have a look at the addAllowedApplication() method, it accepts the packageName who's traffic should be allowed to go through VpnService.

android - Force my app to use WiFi only

I'm a PHP developer, but I'm now finishing Android App that different developer started.
One of the requirements is to make it possible to disallow mobile connection. For that I already created checkbox preference on settings page I got.
But I can't find correct way to globaly disallow my app to use mobile connection for data transactions. I don't need to disable connection, I just need to forbid my app to use it and use only WiFi. I got too much places, where connection is done and no time to refactor it.
TL;DR
I need to globally forbid my app to use mobile connection without disabling connection itself.
Just can say one thing is that Android allows to turn on/off WiFi manually only because of security.

Automatically accept wifi direct connections through root

In Android SDK the Wireless P2P (WiFi Direct) API is provided.
I am developing an application that would require for the app to connect to other devices on the fly that have the same application and share information among them (text data). In order to do so I require that the devices could connect automatically between each other. I was wondering if there is a way to do it if you have root permissions on your device. And another thing is if it is possible to work around by creating some kind of automate response of clicking the OK button on the dialog of the user request.
Best regards.
It can be done with the help of some classloader patching framework, like Xposed or Substrate. See my answer here for detailes.

Enable data connection on android system app

I'm trying to make a android system app (for me and friends), to let me control my android phone over my server.
Actually I've problem to enable/disable data connection. When I search, I found topic that said there is no possibility, or giving a no longer supported way (by using breach). This was exactly the same for GPS controle, but I found a way because my app is a system app.
So I want to know if someone know a way to enable and disable data connection without user consent on a system app. I didn't find anything on the api.
Thanks !

Categories

Resources