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 + C++ JNI)
│ ├── build.gradle
│ ├── settings.gradle
│ ├── gradle.properties
│ ├── setup.sh
│ ├── app/
│ │ ├── build.gradle
│ │ └── src/main/
│ │ ├── AndroidManifest.xml
│ │ ├── cpp/
│ │ │ ├── CMakeLists.txt
│ │ │ └── mainPBLOCK.cpp # Native JNI code
│ │ ├── java/com/pblock/app/
│ │ │ └── MainActivity.java # Android UI + logic
│ │ └── res/
│ │ ├── layout/activity_main.xml
│ │ └── values/
│ │ ├── strings.xml
│ │ └── colors.xml
│ └── gradle/wrapper/
│
└── 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 | Yes | No | Full app with password protection. See below. |
- C++17 - Core blocking logic (all platforms)
- JNI (Java Native Interface) - Android native integration
- Java - Android app UI and system interaction
- Android SDK 35 - Android build target
- CMake 3.22 - Native build system for Android
- Gradle 8.x - Android build tool
- 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 Android SDK
- NDK (for native C++ compilation)
- Rooted device (required to modify
/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/app-debug.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, Android requires root (for the app) - 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
