Firewall Profiles to Block Apps From Using 3G/Wifi and Save Battery

Raul720

Well-known member
May 7, 2011
167
11
0
Visit site
Where are you stuck?

Place the file "sush" in the same folder as adb.exe and follow those commands from command prompt. You need to have root privileges to do this.

There we go, thanks. I didn't know where to put the file "sush" as I don't use adb apart from when i first rooted my phone
 

jjane45

New member
Jul 5, 2011
4
0
0
Visit site
Re: Firewall Profiles to Block Apps From Using 3G/Wifi and Save B

I am really on the fence here, may have to update droidwall-off.sh too often to allow new apps.
(droidwall-on.sh OTOH probably will be very minimalistic and barely changes for me)
Is it possible to have a script that updates the script or it is done manually? Thank you again!
 

clor

Member
Feb 27, 2011
24
0
0
Visit site
Just to be on the safe side am I suppose to have screen on/off and droidwall-on.sh in tasker? Sometimes when using the phone from sleep, 3g or wifi doesn't work. I'll have to reboot to make it work. Any suggestions?

Sent from my LG-VM670 using Tapatalk
 

mmarz

Well-known member
Mar 9, 2011
1,130
447
0
Visit site
Re: Firewall Profiles to Block Apps From Using 3G/Wifi and Save B

Just to be on the safe side am I suppose to have screen on/off and droidwall-on.sh in tasker? Sometimes when using the phone from sleep, 3g or wifi doesn't work. I'll have to reboot to make it work. Any suggestions?

Sent from my LG-VM670 using Tapatalk


You should have all of the script files in the folder: /sdcard/sl4a/scripts/
In Tasker, you should only link to screen-on.sh and screen-off.sh, not to droidwall-on.sh or droidwall-off.sh.
If you have droidwall installed, you should "freeze" it using titanium backup, or have the firewall disabled within the app so that it doesn't mess with your setup.

Tasker is buggy sometimes and fails to run the script it is supposed to. Make a shortcut on your android "desktop" and link it to screen-on.sh. If Tasker ever fails to run the correct script, you can run screen-on.sh manually through the link and disable the firewall. If an app fails to connect even after you disable the firewall, stop the app and start it again and it should work.
 

clor

Member
Feb 27, 2011
24
0
0
Visit site
Thanks alot for the info. Seems to be the droidwall I used in tasker. Small confusion but much appreciation!

Sent from my LG-VM670 using Tapatalk
 

matthewDD

Member
Jul 13, 2011
6
0
0
Visit site
Re: Firewall Profiles to Block Apps From Using 3G/Wifi and Save B

Having problems. The DroidWall scripts work from GScript. The unrestricted profile goes without a hitch and the one were I deny access does complain some, but seems to work. The output in GScript is:

iptables v1.4.10
stderr: FIX ME! implement getprotobyname()
bionic/libc/bionic/stubs.c.378

However, it does still block the access to cellular and WiFi ias expect.

It's not occurring with the screen off & on events. Tasker appears to be setup properly. If I remove the screen-on.sh and screen-off.sh scripts, I can see a popup on screen with Tasker complaining the scripts aren't there.

For troubleshooting I've tried running the screen-on.sh and screen-off.sh scripts with GScript, they do not work. This is what is on the screen:

stderr: [: not found
stderr: [: not found

I've also tried running it from a root console via the SDK, again it doesn't work.

sush is there:

ls -l /system/bin/sush
-rwxr-xr-x root root 374 2011-03-31 15:54 sush

This is on a Optimus V stock ROM and Kernel.

What am I missing?

Thanks!
 

mmarz

Well-known member
Mar 9, 2011
1,130
447
0
Visit site
Re: Firewall Profiles to Block Apps From Using 3G/Wifi and Save B

Hmmm, first, I would recreate the droidwall scripts using droidwall. That error bothers me. Secondly, make sure the droidwall scripts are named correctly and are located here: /sdcard/sl4a/scripts/

If you open the screen-on/off scripts, you will see that they point directly to /sdcard/sl4a/scripts/droidwall-off.sh and /sdcard/sl4a/scripts/droidwall-on.sh

My guess is that you have them in the wrong folder or named slightly wrong. Case matters for folders and file names. Make sure everything is lower case.
 

matthewDD

Member
Jul 13, 2011
6
0
0
Visit site
Re: Firewall Profiles to Block Apps From Using 3G/Wifi and Save B

That all checks out. I also tried to run sush from console, and that fails. if I change the screen off/on scripts and remove sush, they work from a root console.

Seems to be a problem with sush binary.
 

matthewDD

Member
Jul 13, 2011
6
0
0
Visit site
Re: Firewall Profiles to Block Apps From Using 3G/Wifi and Save B

I switched to "DroidWall -- Old" and now the those scripts run without error with GScript, but same errors with screen off screen on scripts (sush).
 

mmarz

Well-known member
Mar 9, 2011
1,130
447
0
Visit site
Re: Firewall Profiles to Block Apps From Using 3G/Wifi and Save B

What about when you run them through SL4A?

You need sush, otherwise SL4A can't run them as root. SL4A can't run anything as root by design. Try downloading sush again. Maybe it became corrupt while you were moving it into position the first time.

Also, which rom are you running? I've used this on almost all of the Froyo roms, but I haven't tried it on Gingerbread.

Here is an explanation of what is happening with this setup:

Tasker detects the screen turns on. It then notifies SL4A to run the screen-on script. SL4A runs the screen-on script. The screen-on script tells your system to run the droidwall-off script as root through sush. Droidwall-off behaves the same as droidwall and removes all the entries from the ip-tables.

FYI, droidwall-old stores the script in a different folder. If you installed old on top of the new droidwall, then the scripts you are copying over are just left over from the previous version. I think it is in the /data/data/com.googlecode.droidwall/cache folder or something like that.

I've been using this for a while now. It should work. Something is wrong with your setup, and I'm not sure what. Maybe you want to start from the beginning and re-download everything.
 

matthewDD

Member
Jul 13, 2011
6
0
0
Visit site
Re: Firewall Profiles to Block Apps From Using 3G/Wifi and Save B

What about when you run them through SL4A?

You need sush, otherwise SL4A can't run them as root. SL4A can't run anything as root by design. Try downloading sush again. Maybe it became corrupt while you were moving it into position the first time.

Also, which rom are you running? I've used this on almost all of the Froyo roms, but I haven't tried it on Gingerbread.

Here is an explanation of what is happening with this setup:

Tasker detects the screen turns on. It then notifies SL4A to run the screen-on script. SL4A runs the screen-on script. The screen-on script tells your system to run the droidwall-off script as root through sush. Droidwall-off behaves the same as droidwall and removes all the entries from the ip-tables.

FYI, droidwall-old stores the script in a different folder. If you installed old on top of the new droidwall, then the scripts you are copying over are just left over from the previous version. I think it is in the /data/data/com.googlecode.droidwall/cache folder or something like that.

I've been using this for a while now. It should work. Something is wrong with your setup, and I'm not sure what. Maybe you want to start from the beginning and re-download everything.
This is a stock Optimus V ROM and Kernel.

I think the problem is around my root'ing of the device. I had to improvise as I have only computers running Ubuntu.

The fact that DroidWall works at all must mean I was successful in root'ing. I installed Root Check to check my work and it reports, "Congratulations! You have root access1" On the Advanced check it had said I was missing /system/xbin/su and permission denied to /sbin/su.

I copied over su from SuperOneClick to /system/xbin and the first error went awy, but I still have the permission denied to /sbin/su (which is alot like the sush error).

What do you get when running the Advanced Root check?
 

mmarz

Well-known member
Mar 9, 2011
1,130
447
0
Visit site
Re: Firewall Profiles to Block Apps From Using 3G/Wifi and Save B

This is a stock Optimus V ROM and Kernel.

I think the problem is around my root'ing of the device. I had to improvise as I have only computers running Ubuntu.

The fact that DroidWall works at all must mean I was successful in root'ing. I installed Root Check to check my work and it reports, "Congratulations! You have root access1" On the Advanced check it had said I was missing /system/xbin/su and permission denied to /sbin/su.

I copied over su from SuperOneClick to /system/xbin and the first error went awy, but I still have the permission denied to /sbin/su (which is alot like the sush error).

What do you get when running the Advanced Root check?

Hmmm, do you have superuser installed?

Try gingerbreak: GingerBreak.apk

It will do all the rooting stuff for you and install superuser. Then run su or sush once, and give root permission to it. Place the apk on your sdcard, install it with a file browser by double clicking it. Then run the app and select "root device". It will do everything for you and then reboot when it is done.
 

matthewDD

Member
Jul 13, 2011
6
0
0
Visit site
Re: Firewall Profiles to Block Apps From Using 3G/Wifi and Save B

Hmmm, do you have superuser installed?

Try gingerbreak: GingerBreak.apk

It will do all the rooting stuff for you and install superuser. Then run su or sush once, and give root permission to it. Place the apk on your sdcard, install it with a file browser by double clicking it. Then run the app and select "root device". It will do everything for you and then reboot when it is done.
Ran the Ginger Break, it did something as the reboot was much longer than usual, like after I did the root by hand on it. But afterwards, same problem.

Well, I went a dirtier way, but it's working!

screen-off.sh

#!/sytem/bin/sh
echo "#!/sytem/bin/sh
sh /sdcard/sl4a/scripts/droidwall-on.sh" > /data/local/tmp/droidwall-on.sh
su -c "sh /data/local/tmp/droidwall-on.sh"

screen-on.sh

#!/sytem/bin/sh
echo "#!/sytem/bin/sh
sh /sdcard/sl4a/scripts/droidwall-off.sh" > /data/local/tmp/droidwall-off.sh
su -c "sh /data/local/tmp/droidwall-off.sh"

Tested those in GScript and they worked. Then tested from Tasker and was given a SuperUser prompt and I allowed it and let it remember it (once for each).

Not sure of the security implications of this, but it seems to be working working!

To test it with screen events I left everything blocked with screen off, started Pandora then turned off the screen. No matter how soon after the start of the song I turn off the screen, the current song always finishes. I guess it already has an established connection. But it doesn't play a second song.

In practice however, I will allow Pandora access with the screen off.
 

mmarz

Well-known member
Mar 9, 2011
1,130
447
0
Visit site
Re: Firewall Profiles to Block Apps From Using 3G/Wifi and Save B

Awesome! I'm glad it worked out. I'm going to bookmark your setup. That was clever. Security wise, you are probably safe. I doubt a virus is going to be written in hopes of catching the 12 people that have a similar setup in the world.

Since it uses the iptables, it only effects new connections. So what you experienced was normal. Make sure to keep droidwall on hand for when you install new apps. I suggest using a blacklist for screen on, and a whitelist for screen off. That way your new apps will function when the screen is on, unless you choose to block them, and the reverse will be true for screen off.

I also have a gscript script on hand that copies and renames the droidwall scripts for me. It has been very handy.
 

matthewDD

Member
Jul 13, 2011
6
0
0
Visit site
Re: Firewall Profiles to Block Apps From Using 3G/Wifi and Save B

Awesome! I'm glad it worked out. I'm going to bookmark your setup. That was clever. Security wise, you are probably safe. I doubt a virus is going to be written in hopes of catching the 12 people that have a similar setup in the world.

Since it uses the iptables, it only effects new connections. So what you experienced was normal. Make sure to keep droidwall on hand for when you install new apps. I suggest using a blacklist for screen on, and a whitelist for screen off. That way your new apps will function when the screen is on, unless you choose to block them, and the reverse will be true for screen off.

I also have a gscript script on hand that copies and renames the droidwall scripts for me. It has been very handy.
As far as the prerequisite of root'ing that I did from Ubuntu, this was the outline I followed

DJMJR - Rooting the LG Optimus V in Linux

The scripts for screen events was modified from example in this discussion

Issue 184 - android-scripting - Allow running scripts as root on rooted phones - Scripting Layer for Android brings scripting languages to Android. - Google Project Hosting
 

corexero

Member
Jun 5, 2011
13
1
0
Visit site
Re: Firewall Profiles to Block Apps From Using 3G/Wifi and Save B

Juicedefender also has a setting where you can enable/disable an app's net access.


Based on the screen being on or off?

Juice Defender Ultimate (I'm not sure if the other versions do) have an option to configure apps independently.

4 states:
-Do nothing
-Enabled (Enables connectivity when the screen is on)
-Enabled/Screen off (From what I understand: this setting doesn't cut connectivity if the app is running and the screen turns off. If the app isn't running it does not matter).
-Disabled

1024.jpg


1024.jpg


I didn't see this question answered so I did. Sorry if it's been already covered.