FORUMS
Remove All Ads from XDA

[Magisk][Module][Deprecated] Unified Hosts Adblocker

3,391 posts
Thanks Meter: 5,175
 
By Zackptg5, Senior Member on 18th February 2017, 07:58 PM
Post Reply Email Thread
This mod has since been discontinued in favor of Adaway. Read on for information on how to use Unified Hosts with Adaway

What are Unified Host Files?
Unified host files combine many reputable sources into a single hosts file (with duplicates removed). Some examples include adaway, mvps, yoyo.org, and malware domain list (see Steven Black's page here for a complete list).

Adaway Installation for Magisk:
Adaway version 4.x now works properly with magisk systemless hosts. To enable it, just install the latest version from here (the main xda thread for it hasn't been updated for it yet). Then go to Preferences -> Enable systemless mode. This automatically enables the Systemless hosts option in magisk manager so no need to bother with that. Then use the app as normal.

How to Add Unified Hosts to Adaway:
In the adaway app, go to Preferences -> Redirection IP (NOT Allow Redirects). Change the value to 0.0.0.0. Read the readme on Steven Black's GitHub linked above for why.

Then go to Hosts Sources. Then add the url of the unified hosts you want (ONLY CHOOSE 1):You can then uncheck the host sources already added by default to adaway since they're included in unified hosts sources already

**Note that the 'Social' filter does exactly what you think: blocks social networks. So if you use any kind of social networking, DO NOT CHOOSE THIS ANY SOURCE WITH THIS IN IT**

Using a APN that uses a proxy server or a subsidiary provider and unable to get adblocking working? See here for a fix


Original Mod Information:

Description
Blocks ads by using Steven Black's Unified Hosts
Comes with a small utility based off of LarappsOfDongle's RP modular host module that allows you to choose which kind of host file you want (adware/malware, fakenews, gambling, porn, social, or any combination)

Installation
Go to Settings in Magisk Manager and enable 'Systemless Hosts'
Flash module
Open terminal and type:
Code:
su
hosts
Then follow the prompts to install the host file of your choice.
OR
- Open terminal and type:
Code:
su -c hosts arg1 arg2 arg3
- The script will apply your arguments all at once and close. Useful for automation purposes
- For example: `su -c hosts m wr b`
- Script will apply the master filter, then your regex whitelist, then your blacklist

Updating Hosts:
Just run the hosts file again in terminal and it'll overwrite the old one
Note: The script will now notify you to say if you need to update or not at the top of it

Disabling Host Mod:
Just toggle the enable systemless hosts option in magisk manager

Whitelist Instructions:
  • Create an empty file on sdcard card called "whitelist"
  • Either add exact lines you want remove to it -> Run hosts script and choose whitelist option
    For example:
    Code:
    0.0.0.0 facebook.com
    Will unblock facebook.com
  • Or add regex for lines you want removed -> Run hosts script and choose whitelist regex option
    For example:
    Code:
    .*facebook.*
    Will unblock all domains with "facebook" in them

Blacklist Instructions:
  • Create an empty file on sdcard card called "blacklist"
  • Add exact lines you want to remove it (do not include the 0.0.0.0 -> so for example: "facebook.com")
  • Run hosts script and choose blacklist option
    For example:
    Code:
    google-analytics.com
    Will block the google-analytics.com domain (it will add the entry "0.0.0.0 google-analytics.com" to the hosts file - note the lack of the 0's here. The script takes care of it automatically for the blacklist feature)

To Remove Whitelist:
Just run hosts script and reinstall host file of choice

Latest Magisk Version Compatibility:
15.x

Source

Can't Boot?
Try rebooting into the bootloader, then boot into system. Thanks @rignfool for the tip

Bonus!
I made a quick automate flow to update the hosts file. Just import it, add a shortcut to your home screen, and you can update it in one click
Just change the 2nd block to whatever options you want

@Didgeridoohan made a tasker profile here for any who use tasker: https://forum.xda-developers.com/sho...&postcount=451

Download
The Following 150 Users Say Thank You to Zackptg5 For This Useful Post: [ View ] Gift Zackptg5 Ad-Free
 
 
19th February 2017, 03:47 PM |#2  
Member
Thanks Meter: 33
 
More
How does this differ from AdAway?
The Following 5 Users Say Thank You to serubin323 For This Useful Post: [ View ] Gift serubin323 Ad-Free
19th February 2017, 05:31 PM |#3  
OP Senior Member
Thanks Meter: 5,175
 
More
Quote:
Originally Posted by serubin323

How does this differ from AdAway?

The unified hosts file combine many sources including AdAway, mvps, malware domains, and more. Check out steve black's page in the op for a full list.

Also, for some reason, adaway wouldn't detect the systemless hosts file for me so i had to set a custom path and symlink it
The Following 15 Users Say Thank You to Zackptg5 For This Useful Post: [ View ] Gift Zackptg5 Ad-Free
20th February 2017, 03:00 AM |#4  
OP Senior Member
Thanks Meter: 5,175
 
More
Updated module for latest magisk manager update (required changes to the readme). Doesn't change the functionality of the module at all so if you're in 1.1, there's no need to upgrade since these readme changes will only be reflected in magisk manager once this module is approved into the repo.
The Following User Says Thank You to Zackptg5 For This Useful Post: [ View ] Gift Zackptg5 Ad-Free
20th February 2017, 07:47 PM |#5  
rignfool's Avatar
Senior Member
Flag The Poconos
Thanks Meter: 2,692
 
More
Damnit... Wrong thread...

OK...

Syntax...

su -c hosts ______

Please fill in the blank...
20th February 2017, 07:59 PM |#6  
OP Senior Member
Thanks Meter: 5,175
 
More
Quote:
Originally Posted by rignfool

Damnit... Wrong thread...

OK...

Syntax...

su -c hosts ______

Please fill in the blank...

Code:
su
Give root permissions
Code:
hosts
Program will prompt for input. For example, if you want malware/adware (master) + fakenews + gambling, you're input would be:
Code:
fg
The reason for not including the master (adware/malware) in the arguments is that it's already included by default in each host file. So the fakenews host file is actually master + fakenews. It's how steven set it up so I have no control over it (and who wouldn't want the malware block anyways)
The Following 5 Users Say Thank You to Zackptg5 For This Useful Post: [ View ] Gift Zackptg5 Ad-Free
20th February 2017, 08:03 PM |#7  
OP Senior Member
Thanks Meter: 5,175
 
More
Found a typo in the directions for the host file. Once again doesn't effect functionality at all but does eliminate confusion so uploaded fixed version (sorry)
The Following User Says Thank You to Zackptg5 For This Useful Post: [ View ] Gift Zackptg5 Ad-Free
20th February 2017, 08:04 PM |#8  
rignfool's Avatar
Senior Member
Flag The Poconos
Thanks Meter: 2,692
 
More
Quote:
Originally Posted by Zackptg5

Give root permissions

Program will prompt for input. For example, if you want malware/adware (master) + fakenews + gambling, you're input would be:

I'm looking to execute as a one line shell command with tasker...

So I'm using 'su -c' cuz SU detection in tasker with magisksu is broken...

Then hosts... But I want to run with an argument so I don't need to interact with the script... Just have it update the hosts file...
20th February 2017, 08:12 PM |#9  
OP Senior Member
Thanks Meter: 5,175
 
More
Quote:
Originally Posted by rignfool

I'm looking to execute as a one line shell command with tasker...

So I'm using 'su -c' cuz SU detection in tasker with magisksu is broken...

Then hosts... But I want to run with an argument so I don't need to interact with the script... Just have it update the hosts file...

I've never used tasker (use automate instead). Perhaps
su -c; hosts; sleep 1; fgps; sleep 2; q

Not sure if the sleep command works for tasker (linux thing) but if there's a way to have it wait a half a second or so before inputting the next command, and then waiting 2 seconds or so to quit after the hosts is applied (not sure on the time, just guessing).


Edit, just saw you didn't want to deal with the script. The 'hosts' command is the script. If you look my source for the hosts script, it lists each url for the file and what it does. So all of the terminal code for fgps would be:
Code:
su -c
cd /magisk/.core
wget -O hosts --no-check-certificate https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts
This will replace the systemless hosts file with the one you want. Note you will at least need the wget portion of the module (system/bin) since it's not included in most roms
The Following 4 Users Say Thank You to Zackptg5 For This Useful Post: [ View ] Gift Zackptg5 Ad-Free
20th February 2017, 08:27 PM |#10  
OP Senior Member
Thanks Meter: 5,175
 
More
v1.3 update: Noticed that the disable option was broken so I removed it since it's not needed (see OP for disable instructions)
The Following User Says Thank You to Zackptg5 For This Useful Post: [ View ] Gift Zackptg5 Ad-Free
21st February 2017, 01:11 AM |#11  
Senior Member
Thanks Meter: 9
 
More
Using ze551ml, after rebooting, module disappeared. I can't find hosts command anywhere.
Post Reply Subscribe to Thread

Tags
adblock, magisk, module, unified

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes