Hey everyone, (Edited by Grok, so ignore the garbage…)
I’ve seen some confusion in our custom ROM community, especially with kosher ROMs, about blocking unwanted content like social media or shmutz in in-app browsers. My customers often report that certain apps access these domains via in-app browsers. No problem—it’s a common issue, and you can fix it yourself by updating the /system/etc/hosts
file. This guide walks you through the process, and I’m sharing my current hosts.txt
file (~9.1MB, ~100K lines) that blocks shmutz, social media, and in-app browser (IAB) links. Use it, tweak it, and share your updates!
Why Update the Hosts File?
In-app browsers (e.g., in messaging or news apps) can load unfiltered websites, bypassing app restrictions. By adding problematic domains to /system/etc/hosts
, you redirect them to 0.0.0.0
(null), effectively blocking access. This is key for kosher ROMs, which aim to keep browsing clean by restricting social media and shmutz.
Prerequisites
- Rooted Device: Your ROM must support
su
(root access). - ADB: Install Android Debug Bridge (download here).
- Text Editor: Use Notepad++ (Windows), VS Code, or VIM to edit
hosts.txt
. - Storage: Ensure ~10MB free in
/system
for the 9.1MBhosts.txt
. - Backup: Always back up before modifying system files.
Step 1: Pull the Current Hosts File
Extract /system/etc/hosts
to your computer for editing.
adb shell
su
mount -o remount,rw /
cp /system/etc/hosts /sdcard/hosts
exit
exit
adb pull /sdcard/hosts hosts.txt
- This copies
/system/etc/hosts
to your computer ashosts.txt
. - Open
hosts.txt
in a text editor (e.g., Notepad++ for large files).
Step 2: Edit the Hosts File
Add domains you want to block, matching the format of existing entries. For example:
0.0.0.0 www.facebook.com
0.0.0.0 m.twitter.com
0.0.0.0 shmutzsite.example.com
- Tips:
- Use
0.0.0.0
(null route) instead of127.0.0.1
for faster blocking. - Include only domains (e.g.,
example.com
), not URLs (e.g.,https://example.com
). - Wildcards (e.g.,
*.example.com
) don’t work inhosts
files. List specific subdomains instead. - Add one domain per line or multiple per line (space-separated).
- Use
My attached hosts.txt
(~9.1MB, ~100K lines) includes:
- Shmutz Blocklist: ~100K domains, trimmed from a 480MB list (
columndeeply/hosts
, 11.4M lines) to focus on high-risk shmutz sites. - Social Media Blocks: Domains like
www.facebook.com
,m.twitter.com
,scontent.f*.fbcdn.net
(note: wildcards are ineffective; I’ve included known subdomains). - IAB Links: Common domains reported in in-app browsers.
- SafeSearch Redirects: Enforces SafeSearch for Google, Bing, YouTube, etc., to filter explicit search results.
If you notice unblocked domains (e.g., new social media subdomains like scontent.faaa1-1.fbcdn.net
), add them and share your updated file!
Step 3: Push the Updated Hosts File
Copy the modified hosts.txt
back to your device.
adb push hosts.txt /sdcard/hosts
adb shell
su
mount -o remount,rw /
rm /system/etc/hosts
cp /sdcard/hosts /system/etc/hosts
chmod 644 /system/etc/hosts
- Flush DNS Cache (required for changes to take effect):
reboot
Step 4: Backup the Super Partition
To persist changes across ROM updates, back up the super
partition.
adb shell
su
dd if=/dev/block/by-name/super of=/sdcard/supermodified.img
exit
adb pull /sdcard/supermodified.img
- Warning: This creates a large file (~4–8GB). Ensure sufficient storage on your device and computer.
- Store
supermodified.img
safely. To restore or flash:- Push:
adb push supermodified.img /sdcard/
- Flash:
adb shell "su -c 'dd if=/sdcard/supermodified.img of=/dev/block/by-name/super'"
- Verify partition paths (
by-name/super
) with your device’s documentation, as they vary.
- Push:
Step 5: Test the Changes
- Open an in-app browser (e.g., in a messaging app).
- Try accessing blocked domains (e.g.,
www.facebook.com
, shmutz sites). They should fail to load. - Search on Google/Bing to confirm SafeSearch is active (no explicit results).
- If apps like Google Play break, check for broad entries (e.g.,
0.0.0.0 google.com
) and remove them.
My Hosts File
Attached is my current hosts.txt
([hosts.txt|attachment], 9.1MB, ~100K lines), refined with Python scripts:
- Source: Started with a 480MB blocklist (
columndeeply/hosts
, 11.4M lines), trimmed to ~100K lines for performance on kosher ROMs. - Content: Blocks shmutz, social media, IAB links, and includes SafeSearch redirects.
- Cleaning: Removed ~15 duplicates, fixed ~180 URLs (e.g.,
https://c.tenor.com
), standardized127.0.0.1
to0.0.0.0
, removed trailing slashes.
Community Input
If you find unblocked domains (e.g., new social media or shmutz sites), please:
- Add them to
hosts.txt
(format:0.0.0.0 domain.com
). - Upload your updated file as a reply.
- Share the app/context (e.g., “Twitter link in WhatsApp in-app browser”).
Example additions:
0.0.0.0 scontent.faaa1-1.fbcdn.net
0.0.0.0 tiktok.com
0.0.0.0 threads.net
Feedback
This hosts.txt
works well for my kosher ROM users, but I need your help to make it better! Share updated files, report unblocked domains, or suggest improvements. Let’s keep our ROMs clean and fast!
hosts.txt (9.1 MB)