A self-accountability content blocking tool that prevents access to adult websites by modifying the system hosts file. Available for Linux, Windows, and Android.
PBLOCK/
├── README.md
├── .gitignore
│
├── LinuxVersion/
│ └── mainPBLOCK.cpp # Linux CLI tool (C++)
│
├── WindowsVersion/
│ └── mainPBLOCK.cpp # Windows CLI tool (C++)
│
├── AndroidVersion/ # Android app (Java, no root needed)
│ ├── build.gradle / settings.gradle / gradle.properties
│ └── app/src/main/
│ ├── AndroidManifest.xml
│ ├── java/com/pblock/app/
│ │ ├── MainActivity.java # UI, password, unlock challenges
│ │ ├── PBlockVpnService.java # Local DNS-filtering VPN (no root)
│ │ ├── PBlockService.java # Foreground protection watchdog
│ │ ├── BootReceiver.java # Restarts blocking after reboot
│ │ ├── BootHostsManager.java # Root mode: hosts file re-apply
│ │ ├── PBlockDeviceAdminReceiver.java# Uninstall protection
│ │ ├── UninstallProtectionActivity.java, *PuzzleDialog.java
│ │ ├── ConsoleActivity.java # Root console (root mode only)
│ │ └── PBlockHelper.java # Blocklist + hosts helpers
│ └── res/ # layouts, strings, themes, icons
│
└── scripts/ # NSFW blocking scripts (no root needed)
├── README.md # Detailed usage instructions
├── nsfw_hosts.txt # Hosts file with 200+ blocked domains
├── block_nsfw_adb.sh # ADB-based hosts file push script
└── setup_private_dns.sh # Private DNS setup (Android 9+, no root)
- Set a password - You create a strong password (min 8 characters) that will be required to disable blocking
- Enable blocking - The tool adds entries to your system's hosts file, redirecting blocked domains to
127.0.0.1 - Intentional delay - When you try to disable blocking, there is a mandatory 30-second wait period to help you reconsider
- Password required - After the delay, you must enter your password to remove the blocks
The hosts file entries are wrapped with # CONTENT_BLOCKER_START and # CONTENT_BLOCKER_END markers for clean insertion and removal.
- System-level domain blocking via hosts file modification
- Password-protected unblocking with SHA-256 hashing
- 30-second intentional delay before unblocking (time to reconsider)
- Status display showing active/inactive state and domain count
- Cross-platform: Linux, Windows, and Android
- NSFW blocking scripts for non-rooted Android phones (no root needed!)
Don't have a rooted phone? Use the scripts in the scripts/ folder to block NSFW content without root access.
Set this up directly on your phone — no computer needed:
- Open Settings → Network & Internet → Private DNS
- Select Private DNS provider hostname
- Enter:
family-filter-dns.cleanbrowsing.org - Tap Save
All adult content is now blocked on every app and browser. See scripts/README.md for more options.
| Method | Root | Computer | Details |
|---|---|---|---|
| Private DNS | No | No | Set a family-safe DNS on your phone. Guide |
| ADB Hosts File | No | Yes | Push a blocking hosts file via USB. Guide |
| PBLOCK App (VPN mode) | No | No | Local DNS-filtering VPN, SafeSearch forced, survives reboot. |
| PBLOCK App (root mode) | Yes | No | Writes /system/etc/hosts and re-applies it on boot. |
- Download the latest
PBLOCK-x.y.z.apkfrom Releases. - Follow docs/INSTALL.md step by step. It covers:
- getting past "App blocked to protect your device" (Install anyway, Play Protect, Samsung/Xiaomi/Oppo/Vivo blockers, or
adb install) - turning on protection
- keeping it on after a restart (Always-on VPN + Autostart)
- Search Shield ("This is not good for you" on adult searches), including Android 13+ "Allow restricted settings"
- troubleshooting
- getting past "App blocked to protect your device" (Install anyway, Play Protect, Samsung/Xiaomi/Oppo/Vivo blockers, or
- Optional: make it permanent until factory reset with docs/LOCK_MODE.md.
Roadmap: docs/ANDROID_PLAN.md.
- C++17 - Core blocking logic (all platforms)
- Java - Android app (VpnService DNS filter, device admin, foreground services)
- Android SDK 35 - Android build target (minSdk 21)
- Gradle 8.8 + Android Gradle Plugin 8.5 - Android build tool (JDK 17+)
- g++ with C++17 support
- Root/sudo access (required to modify
/etc/hosts)
- MSVC or MinGW with C++17 support
- Administrator privileges (required to modify the hosts file)
- Android Studio or the Android SDK, with JDK 17+
- Any Android 5.0+ phone. Root is optional: without it the app uses VPN mode;
with it, the app also writes
/system/etc/hosts.
- Android 9+ for Private DNS method (no other requirements)
- ADB for hosts file method (requires a computer with USB cable)
cd LinuxVersion
g++ -std=c++17 -o blocker mainPBLOCK.cpp -lcrypt -lpthread
sudo ./blocker setup # Set password
sudo ./blocker block # Enable blocking
sudo ./blocker unblock # Disable blocking (requires password + 30s delay)
sudo ./blocker status # Show current statusCompile WindowsVersion/mainPBLOCK.cpp with MSVC or MinGW (requires linking against advapi32):
cl /EHsc /std:c++17 mainPBLOCK.cpp /link advapi32.lib
# Run as Administrator:
blocker.exe setup
blocker.exe block
blocker.exe unblock
blocker.exe statuscd AndroidVersion
# Set your Android SDK path in local.properties
# Then build with Gradle:
chmod +x gradlew
./gradlew assembleDebug
# Or open the project in Android StudioThe APK will be generated at AndroidVersion/app/build/outputs/apk/debug/PBLOCK.apk.
To install on your phone:
- Transfer the APK to your phone
- Open it and tap Install (you may need to enable "Install from unknown sources")
- Open PBLOCK and follow the on-screen instructions
cd scripts/
# Option 1: Set up Private DNS (recommended, Android 9+)
chmod +x setup_private_dns.sh
./setup_private_dns.sh
# Option 2: Push hosts file via ADB
chmod +x block_nsfw_adb.sh
./block_nsfw_adb.shSee scripts/README.md for detailed instructions.
- Run with appropriate privileges - Linux requires
sudo, Windows requires Administrator; the Android app needs root only for hosts-file mode - Use a strong password - Minimum 8 characters, write it down somewhere safe
- The 30-second delay is intentional - It gives you time to reconsider before unblocking
- Hosts file modification - This app modifies system files; back up your hosts file before first use
- Private DNS is the safest method for non-rooted Android phones — it blocks content at the DNS level across all apps
Contributions are welcome. If you find security vulnerabilities, please report them responsibly.
MIT License
For issues or questions:
- Open an issue on GitHub
- Email: modistotube2004@gmail.com