yashsingh1/xdaforums huggingface dataset:
[Magisk] Zackptg5:
It's giving error 255 immediately which makes me think that the EOL got changed to windows again (I freaking hate git sometimes). Try this zip
[Magisk] Zackptg5:
Did you enable systemless hosts in magisk settings?
[Magisk] Mike Foxtrot:
Yes

---------- Post added at 10:54 PM ---------- Previous post was at 10:54 PM ----------

Yes
[Magisk] HamsterHam:
This works!

Same issue with applying whitelist though. It clears the hosts file when I apply it.
[Magisk] Zackptg5:
Sweet! Updated the OP and magisk repo with the fixed zip. Are you using the

.*apkmirror.com

with the -wr option? That should remove only all entries that end in apkmirror.com
[Magisk] HamsterHam:
I'm typing in this.
[Magisk] Zackptg5:
Can you attach your whitelist?
[Magisk] HamsterHam:
Here it is. Bet it's something I'm doing wrong.
[Magisk] Zackptg5:
So here's a starting one.

.*apkmirror.*

You'll still have that adblock message though. So you'll need to investigate what websites need to be whitelisted. 2 ways are through ublock origin extension and through tcpdump with adaway and compare them to your hosts file. Personally, since firefox mobile supports addons now, I use the ublock origin for firefox mobile too and I don't have that message (if you want to do it the easy way). It has some filters that can block that kind of behavior
[Magisk] HamsterHam:
Interesting.

I changed my whitelist file but same issue.

The reason I don't want to use adaway is so I can actually use one less app. If I had it installed I could add the host file to it and even use the whitelist function on it with *.apkmirror.com and it works.
[Magisk] SignetSphere:
deleted
[Magisk] guest4711:
I've just re-tested it: There seems to be a bug with "wr". Applying even a simple entry like "abc.de" results in clearing the host file... [MENTION=6037748]Zackptg5[/MENTION]
[Magisk] Zackptg5:
wr is for regex so if you use the wrong regex, stuff like that could happen. But I just made a whitelist containing only "abc.de" and it worked fine so I'm not sure what's happening on your end
[Magisk] shanishkag:
after flashing my s7 edge got stuck never got to even boot screen
[Magisk] HamsterHam:
Can you send me a whitelist with regex so I can test it? I can't get it to work at all.
[Magisk] Zackptg5:
This one unblocks anything with apkmirror, twitter, or Facebook in it. Apply the social filter, take a look at it, then apply this whitelist and compare them. Also, I'm assuming your doing the whitelist after applying hosts
[Magisk] HamsterHam:
Doing exactly what you said.

No joy.
[Magisk] Zackptg5:
Do you have busybox installed?
[Magisk] Zackptg5:
Magisk issue, try uninstalling and reinstalling magisk
[Magisk] HamsterHam:
I'm guessing not. Not sure. I'm using OOS.

Installed busybox. Same outcome.
[Magisk] Neverendingxsin:
I found a solution, I can't take credit for the sites as I found them on another site but can't remember which site or who posted but the links came from here all I did was set them so they'd universally be whitelisted in the slickdeals app. Just copy the following below and into a ffile called whitelist and run the whitelistregx command :)

*.7eer.*

*ad.doubleclick.*

*.affiliatefuture.*

*.anrdoezrs.*

*.apmebf.*

*.avantlink.*

*.bfast.*

*.cc-dt.*

*.cj.*

*.clickserve.cc-dt.*

*.commission-junction.*

*.doubleclick.*

*.dpbolvw.*

*.emjcd.*

*.evyy.*

*.gan.doubleclick.*

*.go2jump.*

*.gopjn.*

*.jdoqocy.*

*.kqzyfj.*

*.linksynergy.*

*.ojrq.*

*.onenetworkdirect.*

*.pjatr.*

*.pjtra.*

*.pntra.*

*.pntrac.*

*.pntrack.*

*.qksrv.*

*.redirect.*

*.redirect.viglink.*

*.redirectingat.*

*.shareasale.*

*.tkqlhce.*

*.tkqlhce.*
[Magisk] guest4711:
So, I tried again. It seems that applying any whitelist (RE) kills host file:

jactivelte:/ $ su
ls -l /system/etc/hosts <
-rw-r--r-- 1 root root 2241998 2017-12-03 12:49 /system/etc/hosts

rm /sdcard/whitelist <
1|jactivelte:/ # hosts wr
Unified Hosts Adblocker
Updates are available

*No Whitelist detected*
Copy your whilelist to /sdcard
ls -l /system/etc/hosts <
-rw-r--r-- 1 root root 2241998 2017-12-03 12:49 /system/etc/hosts
echo "abc\.de" > /sdcard/whitelist <
jactivelte:/ # hosts wr
Unified Hosts Adblocker
Updates are available

Applying Whitelist (regex)
ls -l /system/etc/hosts <
-rw-r--r-- 1 root root 0 2017-12-04 09:12 /system/etc/hosts
jactivelte:/ #

While a nonexistent whiteliste does not harm an existent one destroys all contents in the host file (the old content does not match "abc\.de").

Installed BusyBox:

* location: /system/xbin

* version: v1.27.2-osm0sis (magisk module)
[Magisk] shanishkag:
so i have to uninstall magisk and install .? even Xpose give ne bootloop you think it will also be k ?
[Magisk] RealPsygnosis:
can I add my source to this module? like prebake? adaway doesn't work anymore for me from when i switch from supersu to magisk
[Magisk] Didgeridoohan:
Use the blacklist and whitelist functions described in the OP. This together with the automation command (example in the OP) makes for a very nice and flexible adblocking tool.
[Magisk] guest4711:
BTW, AdAway works with magisk too. You should uninstall it and reinstall it if you switch from SuperSu to Magisk. Enable "systemless hosts" in MagiskManager before installing AdAway and you are done...
[Magisk] MisterVik:
Hi,

Here's my problem:

Hosts only are blocked if i'm connected to a wifi Network. In mobile data mode it isn't working.

Data saver is is not activated in Chrome.

What do you need to provide help?

Thanks in advance, regards
[Magisk] guest4711:
Please have a look onto your APNs. Probably there is a proxy defined in your current APN. Note the settings, e.g. on paper, and wipe the proxy entry. Then disconnect your data connection and reconnect afterwards. Now it should work...
[Magisk] MisterVik:
Damn... It's a basic know-how... I'm feeling like a dumb
[Magisk] guest4711:
Glad it works...
[Magisk] MisterVik:
Yeah buddy, thanks!
[Magisk] alma23:
Hi! I'm having a problem with this module: everytime I try to update the hosts file I get this errors: /magisk/.core/hosts: Read-only file system and /system/bin/hosts[161]: can't create /magisk/unifiedhostsadblock/filter: Read-only file system.

I tried reinstalling the module and, when I first launched it, it successfully created the hosts file, but the problem with the update still persists. Any help would be appreciated :D
[Magisk] Zackptg5:
You need to follow the op usage instructions:

su
hosts

If you don't called superuser first, that'll happen
[Magisk] alma23:
Wooops, I think I could not be more noob than this.

After calling su hosts the first time I simply called hosts (without su).

Sorry for the silly question and thanks for your quick help, keep up the good work!

EDIT: No luck, unfortunately it doesn't work.

EDIT2: Solved, it seems there were problems between my kernel and Magisk, thanks for the help :)
[Magisk] guest4711:
It sounds like you forgot to raise the permissions by preceeding the command with "su -c " or by swiching to a root shell by calling "su" and entering the hosts command afterwards.
[Magisk] alma23:
I can't figure this out... I'll tell you what I do: I open terminal, type su and get bacon:/ #, then I type hosts and try to update the hosts file with no luck.

EDIT: Solved, it seems that there were problems between my kernel and Magisk, thanks for the help :)
[Magisk] immi:
Hello Master [MENTION=6037748]Zackptg5[/MENTION] I have a request to make, I apologies if it's already been asked and answered (I'm at my job & don't have time to use the search option).

Master can you please make a SYSTEM version of your Mod. I used your mod for a long time when I was on Magisk, but now I'm on System version of SuperSU & I'd love to have your mod again. The decision is of course your to make :). Thank You Master.
[Magisk] Zackptg5:
I considered it but adaway is already a much better alternative. You can add unified hosts by just going to Steven blacks GitHub (see first post on thread) and adding it as a filter to adaway. But if you do, you'll want to uncheck the others since that would be redudant
[Magisk] gianmaxfactor:
Same problem here. Any update?

Honor 8 with latest stock rom
[Magisk] sic0048:
Me too. I had it working previously, but out seems the latest stock rom update broke something.
[Magisk] Razor10707:
Terminal says the file is read only? And i cant find the file to make it write and read?

Nvm fixed it
[Magisk] gianmaxfactor:
I have abandoned the systemless way.

Booted from TWRP, removed the /system/etc/hosts file (it was a symbolic link to the read only filesystem /vendor/etc/hosts)

Created a Tasker action that once a day Run Shell the following:

wget -O /system/etc/hosts https://github.com/StevenBlack/hosts/blob/master/hosts

Too much simpler ;)
[Magisk] :
[FIXED] It was a problem with Manager 5.4.3 only

I've used this module with no problems till now, I reflash the rom, same kernel, same everything and now it says:

/system/bin/hosts[161]: /magisk/unifiedhostsadblock/wget: not found

/system/bin/hosts[161]: can't create /magisk/unifiedhostsadblock/filter: No such file or directory

Any idea why this happens?

Edit: Going back to Manager 5.4.0 fixed it.
[Magisk] dunderball:
Whenever I try this I find that the /system/etc/hosts file is modified so I just gave up on it. Systemless hosts seems kind of pointless when AdAway can revert back to the default whenever you need.
[Magisk] Didgeridoohan:
If you have systemless hosts enabled, the Magisk hosts file will be mounted over /system/etc/hosts. Thus, any changes you see in /system/etc/hosts are in reality made to the Magisk hosts file. Systemless...
[Magisk] deepankarverma:
first great work, i am new to magisk and all this advance features, so here is my experience, i downloaded your magisk module , flash it in magisk, the reboot,

after that i am not able to understand what to do. somebody can explain me what to do after that in layman terms!

i though there will be system app after magisk module flash to toggle no ads but as such there is no system app for that.
[Magisk] Nevermindthelabel:
It's explained in the OP. Make sure systemless hosts are enabled in magisk manager settings, then open a terminal and type su. Grant superuser to the terminal and then type hosts. It will pull up the options from there. For example I block fgp (fake news, gambling and porn). Should be self explanatory from there. Works really well in my experience
[Magisk] guest4711:
You have to initialize the hostfile as described in post#1 .

(Open a terminal window on your device and type

su
hosts

and selecting a proper variant or type

su -c hosts m

...)

If no terminal app is available on your phone you may install one, e.g. Terminal Emulator for Android (Access Android's built-in Linux command line shell. Unleash your inner geek!) - https://f-droid.org/app/jackpal.androidterm
[Magisk] jenslody:
If adb works, you can also run "adb shell" and then run the needed commands.
[Magisk] deepankarverma:
thank you for detailed explanations guys, i got this working now. :):)
[Magisk] yass:
Hi,

Trying to get this to work, but I am getting "failed: Connection refused" from github when it downloads the hosts file? The terminal has superuser rights, enabled systemless hosts in MagiskManager, connection is available since I can ping out successfully. Can't figure out what is missing, any help would be appreciated.

Another question, is the module able to redirect like AdAway can? Mainly asking for use of Pandora outside the US.

with regards

Yass
[Magisk] Zackptg5:
Merry Christmas everyone! UHA has been updated to magisk module template v1500 which means that it's only compatible with magisk v15+
[Magisk] nkay08:
I had Segmentation fault error while trying to apply my whitelist with w or wr.

My whitelist looks like:

0.0.0.0 s.youtube.com
0.0.0.0 s2.youtube.com

Doing some tests and manually testing the grep command I found out that the -x parameter caused this. On a different file -x caused no error, only on the hosts file. This may be a bug of the ROM I'm on.

I fixed this by editing hosts in the zip and changing every -Fvxf to -Fvf , reflashing and then only using w option.
[Magisk] angelus_kun:
Thanks :D your module is aweasome
[Magisk] angelus_kun:
Hi :) i don't know if its possible but when i apply M F and G filters, youtube dosent save my viewed history from the youtube app so, could you please delete the s.youtube link from host blocking? Thanks :D
[Magisk] Didgeridoohan:
The hosts file is not provided by anyone in this thread. You need to do that yourself with a whitelist. See the OP for details...
[Magisk] angelus_kun:
Ok, :) happy new year
[Magisk] madbat99:
[MENTION=6037748]Zackptg5[/MENTION]

I'm new to automate. For your flow for updating, I just change the letters after "hosts" for the ones I want? (In 2nd block)
[Magisk] Zackptg5:
Yup :)
[Magisk] bc1977:
Hi all,

Dumb question maybe:

I've got this warning about a certificate.

Is the host file eventually updated despite this warning?

OnePlus3T:/ $ su

OnePlus3T:/ # hosts

Unified Hosts Adblocker

* Last updated: **January 02 2018**.

No updates available

...

--2018-01-02 22:39:03-- https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts

Resolving raw.githubusercontent.com... 151.101.120.133

Connecting to raw.githubusercontent.com|151.101.120.133|:443... connected.

WARNING: cannot verify raw.githubusercontent.com's certificate, issued by '/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert SHA2 High Assurance Server CA':

Unable to locally verify the issuer's authority.

HTTP request sent, awaiting response... 200 OK

Length: 1276934 (1.2M) [text/plain]

Saving to: '/magisk/.core/hosts'

100%[=========================>] 1,276,934 2.28MB/s in 0.5s

2018-01-02 22:39:03 (2.28 MB/s) - '/magisk/.core/hosts' saved [1276934/1276934]
[Magisk] Zackptg5:
Ya, wget doesn't play nice with https so I have it just ignore it. Doesn't cause any harm and that'll show up everytime
[Magisk] korom42:
[MENTION=6037748]Zackptg5[/MENTION]

Please add link for 3.1 not everyone use magisk 15 since it fails (bootloops) on man for many devices .. still stuck on 14.5 for now
[Magisk] Zackptg5:
Even 15.2? Okay, I just added release tags on the github repo starting with v3.1 (and will continue to do so in the future). So if something like this happens in the future, just go to the source link in the OP and go to the releases section. Github zips stuff weirdly though so you'll need to unzip it and then rezip the contents of the unified-hosts-adblock folder (not the folder but what's in it). I'm only keeping the newest version on the OP to not confuse users. Here's 3.1
[Magisk] thatguy222:
Works for me using Magisk 15.2.
[Magisk] Zheds:
Hi, each time I flash this module in my s7 with magisk 15.2, when I restart the phone it starts in twrp and I cant boot my phone unless I uninstall the module. Why?
[Magisk] onliner:
Logs.
[Magisk] vMAC:
OK so if I had previous manual hosts how do I add those?

For example:

210.67.x.x ipc1.yadayada.com

Sorry if asked/answered but searching manual hosts yielded too many hits.

Here is what the github states:

How do I include my own custom domain mappings?
If you have custom hosts records, place them in file myhosts. The contents of this file are prepended to the unified hosts file during the update process.

The myhosts file is not tracked by git, so any changes you make won't be overridden when you git pull this repo from origin in the future.
[Magisk] Didgeridoohan:
That's from Steven Black's Unified Hosts GitHub, not this module...

Go to the OP and follow the instructions on how to make a blacklist.
[Magisk] Zheds:
So what should I do? Thanks for reply
[Magisk] vMAC:
Blacklist? But these are sites that I want to open, not to blacklist.
[Magisk] guest4711:
You'll find the description how to whitelist at the first post too...

B]Whitelist Instructions:[/B]

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 (w)

For example:

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 (wr)

For example:

.*facebook.*

Will unblock all domains with "facebook" in them
[Magisk] Didgeridoohan:
You said you wanted to add to the hosts file, that's what you use the blacklist for. If you want to remove addresses from the hosts file, you use the whitelist.

Edit: If you want to add entries to the hosts file that use another ip than 0.0.0.0, you'll have to do that manually (or with a script of your own) for now. Maybe that's an idea for a new feature [MENTION=6037748]Zackptg5[/MENTION]. If there's an entry in the blacklist file with an ip in front of the address that's not 0.0.0.0, add the whole line.
[Magisk] vMAC:
Got it. Thanks.
[Magisk] Zordak7:
Difference between 2 methods

Maybe a newbie question, sorry if it's already answered, but I did not find a precise answer.

What is the advantage of using this systemless adblock method with magisk, versus the classic host file in system/etc? Which applications generate conflict when using a modified host file? Is it faster, or more secure?

Can I use this host file, and replace the one in system / etc (I currently use MoaAB file)?

Saludos!
[Magisk] Didgeridoohan:
For the actual adblocking there's no difference. The only difference lies in how you replace the hosts file...

Magisk does it systemlessly (that's the advantage), by Magic Mounting it's own hosts file over /system/etc/hosts. You can then edit that one to your hearts delight.
[Magisk] mimo_s16:
Is it possible to modify the hosts file entry manually? Ive tried creating blacklist, add sites in it, but i always end up with segmentation fault
[Magisk] kamarilla:
I get ads from Google ads. Can I block them in some way? I have m+f+g applied. Thanks
[Magisk] Didgeridoohan:
Yes, it's possible. The file to edit is in /sbin/.core/img/.core/hosts (if you're on Magisk v15+). The segfault with grep has been reported before, but is rare.

Where do you get these ads? Adblocking by editing hosts can't remove all in-app ads.
[Magisk] kamarilla:
At Google chrome for example, here at XDA.

Enviado desde mi MI 6 mediante Tapatalk
[Magisk] guest4711:
Did you disable "data compression/reduction" in chrome? Otherwise google injects its advs on his proxies...
[Magisk] kamarilla:
I have it disabled. I have more apps where I get adds, not only at Google chrome, I don't know why. I have host file enabled at magisk.... And I run a terminal to configure it.

Enviado desde mi MI 6 mediante Tapatalk
[Magisk] Didgeridoohan:
Make sure you don't have any proxy or anything else intercepting your traffic. Search through the thread, it's been talked about before...
[Magisk] Neverendingxsin:
Working great on Magisk 15.3 :D
[Magisk] mimo_s16:
Im on magisk 15.3. ive tried editing the hosts file manually, and it somehow breaks the adblock functionality. I had to re run the " su, hosts" steps once again to make it work again.

Both blacklist and whitelist does not work for me
[Magisk] Didgeridoohan:
That's strange. How did you edit the hosts file?

Anyway... I want to test something, and you're the perfect candidate. :D I've sent you a PM.
[Magisk] mimo_s16:
Its quite simple. I open the hosts file as a text, edit, 0.0.0.0 site_name and save
[Magisk] Yaemish:
I'm not getting this to work on the Pixel 2. I rooted last night, Magisk 15.3 installed. Do I actually need to make a file called "blacklist"? It doesn't seem like I need it. I've looked at /system/etc/hosts and it is full of entries after running "fg" for "fake news" and "gambling". The toggle is on in Magisk, I've rebooted and the toggle remains on. I still have adds inside of Chrome. Anyone else experiencing this?
[Magisk] jascolli:
Try installing this companion app. It was created specifically as a front end to this module in case you don't want to use the command prompt.

I have a Pixel 2 and it works fantastic.
[Magisk] Didgeridoohan:
Go back a few posts and look for info on Chrome's data compression, proxy, etc.
[Magisk] Yaemish:
Thanks. I went back and looked but I'm still a little confused. Data Saver was already off. When I went into the phone setting for an "APN", it had Verizon checked. I was unaware that APN settings were on the phone. Is that something that I should delete?

---------- Post added at 10:40 PM ---------- Previous post was at 10:25 PM ----------

You aren't on Verizon are you?
[Magisk] jascolli:
Yes I'm on Verizon
[Magisk] Yaemish:
jascolli, thank you. I installed the app, it doesn't make a difference and I still see the ads while connected to Verizon. I confirmed "Data Saver" is off in Chrome and I can look at the hosts file to see a ton of entries. Is there anything else that you had to do in order to make it work while connected over LTE? Anything with the APN settings?
[Magisk] mimo_s16:
Try not to use chrome then. Try firefox+adblock extension or samsung internet browser+adblock plus. I've been using samsung internet for more than a month now, i can say it's very fast. I only use chrome for banking which i believe to be more secured.
[Magisk] guest4711:
Disable (write down and delete) the proxy settings in your current APN, stop mobile data, restart data and try again...
[Magisk] militiaOfDeath:
Is this module supposed to also remove the space the ads originally used on the webpage? Not sure if I'm doing something wrong or not, but after running sudo -c hosts m most ads in Chrome are blocked, but instead there's a white field where the ad originally was - possible to get rid of this as well somehow? When I had AdAway (i think) it removed (some of?) these as well (unless my memory is total goldfish memory these days), but there were other things about AdAway I didn't like hence why I wanted to try this module.
[Magisk] OldMidnight:
Nah those boxes are there to stay, when designing a website , specific dividers are set aside to contain the ads, so if you see a white box claiming a lack of connection, everything is working as it should
[Magisk] militiaOfDeath:
Thanks for the quick reply. Maybe it was back on Android 5 w/ Xposed and MinMinGuard that I managed to remove them, but Xposed is out of the question now so it'll do with the white spaces. At least there are no ads.
[Magisk] OldMidnight:
Glad I could help :)
[Magisk] Zackptg5:
Updated to v3.3 - now use magisk busybox for script (thanks to [MENTION=4667597]Didgeridoohan[/MENTION] for the idea)
[Magisk] atarek:
After updating to v3.3 i got below error.

Any advise.

PS: i installed through magisk manager and rebooted.

Regards,

Ahmed
[Magisk] Zackptg5:
what the heck, okay, I just reverted back to v3.2 till I get this worked out. Refresh magisk repo and v3.2 will be back up so download and install that. Sorry!

edit: fixed and reuploaded v3.3 to OP and magisk repo
[Magisk] atarek:
Hello,

Thanks alot for your great effort. :o

Installed and working flawlessly :good:

Regards,

Ahmed
[Magisk] rignfool:
Why is this not packaged with the module?

This would work around 99% of the user error!
[Magisk] guest4711:
To remove the space reserved for the ads you may use a browser plugin like ublock-origin (for firefox). Similar addons exist for chromium... They analyze the html-data and disable some frames or pictures..
[Magisk] jascolli:
It's definitely a nice simple UI. That's why I plugged it. It hasn't been mentioned in the thread in a while.
[Magisk] Yaemish:
I finally got it to work, I figured that I would post if someone had the same problem. On my Verizon Pixel 2 I could install the module and update it. From the adb shell, if I did a "cat hosts", I was able to see all the entries. I had set everything correctly, I still saw ads in Chrome. On a whim, I installed AdAway and used it to update the hosts file and then rebooted. When the phone came back up I checked the hosts file and it had the lines added by AdAway and this time, Chrome didn't have any ads.

I toggled the Stateless hosts back off and on, the hosts file was cleared as expected. This time, I used the Unified Host Module and made the hosts changes again. This time it worked. AdAway must have overwritten something, prior to using it, this module wouldn't work.
[Magisk] Zackptg5:
I asked the dev of the app awhile ago but never got a response :/