perspector / Pihole-404

A nice 404 page for pihole with an added automatic script that can be used to whitelist the domain with the click of a button.
MIT License
11 stars 3 forks source link

Pihole 404 test #4

Closed francouai closed 1 year ago

francouai commented 2 years ago

Hey! doubleclick.net has been bough by google few months ago. once 404 installed, I'm still able to click on it. Do you have another blocked webpage to test? Because at the moment, I don't see the famous 404 page :( thanks.

perspector commented 2 years ago

Hello francouai, That's strange. Try admob.com Also, is doubleclick.net in your adlist? Are you on the correct wifi? Hope it works!

francouai commented 2 years ago

ok, so My install doesn't work.. I have to check deeper why.. :) I never seen this 404 screen.

perspector commented 2 years ago

Hello, Could you first try running the installer script again? cd Pihole-404 sudo python3 install.py If you have the latest version, you will be asked if you want to use a previous configuration. You can type "P" to use the previously saved configuration (you don't have to re-enter email, password, etc.). You can also type "R" to redo the setup if you wish. If you do not have the latest version, you will not be asked to use a previous configuration. To install the latest version: cd Pihole-404 sudo sh uninstall.sh cd .. git clone https://github.com/pythoncoder8888/Pihole-404.git cd Pihole-404 sudo python3 install.py Hope this works!

francouai commented 1 year ago

I'm still getting this error message "imap_tool" missing:

What email provider do you use? (gmail/outlook/aol/yahoo/other) gmail Your provider's IMAP address is: imap.gmail.com [...] Adding credentials to files EmailChecker.py and CustomBlockPage.php so the script can work [✓] Finished adding credentials to files [✓] Webpage PHP file is located at /var/www/html/pihole/CustomBlockPage.php Feel free to edit! [✓] Changed configuration file for lighttpd located at /etc/lighttpd/lighttpd.conf The next part of the installer script will set the Pihole blocking mode to IP. More details can be found at: https://docs.pi-hole.net/ftldns/blockingmode/ If you do not want to change this, press CTRL + C (you have 10 seconds) Would you like the EmailChecker program to run on boot? (Y/n) n [✓] Setup complete

[✓] Email checker program is running! Everything is setup and ready to go! Try going to http://doubleclick.net to test it out! If you like this script, please star my repository! Thanks :] pi@Pi-hole:~/Pihole-404 $ Traceback (most recent call last): File "/home/pi/Pihole-404/EmailChecker.py", line 4, in from imap_tools import MailBox, AND ModuleNotFoundError: No module named 'imap_tools' Traceback (most recent call last): File "/home/pi/Pihole-404/EmailChecker.py", line 4, in from imap_tools import MailBox, AND ModuleNotFoundError: No module named 'imap_tools' Traceback (most recent call last): File "/home/pi/Pihole-404/EmailChecker.py", line 4, in from imap_tools import MailBox, AND ModuleNotFoundError: No module named 'imap_tools' Traceback (most recent call last): File "/home/pi/Pihole-404/EmailChecker.py", line 4, in from imap_tools import MailBox, AND ModuleNotFoundError: No module named 'imap_tools'

perspector commented 1 year ago

Did you try uninstalling, then cloning the repository and reinstalling Pihole-404 Alternatively, you could just try sudo pip3 install imap-tools See if that works.

francouai commented 1 year ago

I have deleted the Pi-hole404 folder and started from scratch.

this command line given doesn't work. I'm getting this message: pi@Pi-hole:~/Pihole-404 $ sudo pip3 install imap-tools sudo: pip3: command not found

I'm always getting this message: " File "/home/pi/Pihole-404/EmailChecker.py", line 4, in from imap_tools import MailBox, AND ModuleNotFoundError: No module named 'imap_tools' Traceback (most recent call last):"

it is complicate ! :(

francouai commented 1 year ago

I'm going to install PIP3 and IMAP TOOLS .. and I'll try again.

perspector commented 1 year ago

Great! Please give me an update on the result.

perspector commented 1 year ago

You should be able to do: sudo apt-get install python3 python3-pip Hope that helps!

francouai commented 1 year ago

PIP3 and IMAP TOOL installed. Then I redo a full install of your script without anymore errors showed like before.

sudo apt-get install python3 python3-pip
sudo pip3 install imap-tools
cd Pihole-404
sudo python3 install.py

I can see:

What email provider do you use? (gmail/outlook/aol/yahoo/other) gmail
Your provider's IMAP address is: imap.gmail.com
[...] Adding credentials to files EmailChecker.py and CustomBlockPage.php so the script can work
[✓] Finished adding credentials to files
[✓] Webpage PHP file is located at /var/www/html/pihole/CustomBlockPage.php  Feel free to edit!
[✓] Changed configuration file for lighttpd located at /etc/lighttpd/lighttpd.conf
The next part of the installer script will set the Pihole blocking mode to IP. More details can be found at:
 https://docs.pi-hole.net/ftldns/blockingmode/
 If you do not want to change this, press CTRL + C (you have 10 seconds)
Would you like the EmailChecker program to run on boot? (Y/n) Y
[...] Adding line to /etc/rc.local for running EmailChecker program on boot
[✓] EmailChecker program will automatically run on next boot
[✓] Setup complete

[✓] Email checker program is running! Everything is setup and ready to go!
    Try going to http://doubleclick.net to test it out!
    If you like this script, please star my repository!
    Thanks :]

I did a sudo reboot of my RPI to be all clean. If I navigate to http://doubleclick.net/, it jump out to https://marketingplatform.google.com/about/enterprise/ (httpS !!) I don't see the famous pihole 404 image. I tried 3 others sites blocked like admob.com without success.. I can see the full webpage. I need to check why Pi-hole do not block these pages now !

perspector commented 1 year ago

That is strange. Here's what I would check:

francouai commented 1 year ago

Your pihole is enabled: YES

The domains are in your adlists: YES, I added (.|^)ad.doubleclick.net$

Pihole-404 only works with http, not https. But http://doubleclick.net/ should be blocked, and the 404 page should be displayed. I know it sounds ridiculous, but are you on the correct wifi/ethernet? YES, only one LAN. Is your pihole configured properly with DNS or DHCP settings? Has it worked before? YES! DNS and DHCP Disabled (using router) Also, did the pihole work before installing Pihole-404 or did it never block anything? YES; since 4 months without problems

http://doubleclick.net is blocked but I'm only getting "Could not connect to the server NSURLErrorDomain" mean PI-hole is working. I really don't know what's wrong here.. this is weird.

perspector commented 1 year ago

That is really weird. To clarify: It works but the custom 404 page is not displayed? Could you please send a screenshot of the "Could not connect to the server NSURLErrorDomain"? Also, in the file /etc/lighttpd/lighttpd.conf what is the value for server.error-handler-404?

francouai commented 1 year ago

yes, Custom 404 page is not displayed.

here it is my lighttp.config file:

# Pi-hole: A black hole for Internet advertisements
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
# Network-wide ad blocking via your own hardware.
#
# Lighttpd config for Pi-hole
#
# This file is copyright under the latest version of the EUPL.
# Please see LICENSE file for your rights under this license.

###############################################################################
#     FILE AUTOMATICALLY OVERWRITTEN BY PI-HOLE INSTALL/UPDATE PROCEDURE.     #
# ANY CHANGES MADE TO THIS FILE AFTER INSTALL WILL BE LOST ON THE NEXT UPDATE #
#                                                                             #
#              CHANGES SHOULD BE MADE IN A SEPARATE CONFIG FILE:              #
#                         /etc/lighttpd/external.conf                         #
###############################################################################

server.modules = (
    "mod_access",
    "mod_accesslog",
    "mod_auth",
    "mod_expire",
    "mod_redirect",
    "mod_setenv",
    "mod_rewrite"
)

server.document-root        = "/var/www/html"
server.error-handler-404    = "/pihole/CustomBlockPage.php"
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error-pihole.log"
server.pid-file             = "/run/lighttpd.pid"
server.username             = "www-data"
server.groupname            = "www-data"
# For lighttpd version 1.4.46 or above, the port can be overwritten in `/etc/lighttpd/external.conf` using the := operator
# e.g. server.port := 8000
server.port                 = 8500
accesslog.filename          = "/var/log/lighttpd/access-pihole.log"
accesslog.format            = "%{%s}t|%V|%r|%s|%b"

# Allow streaming response
# reference: https://redmine.lighttpd.net/projects/lighttpd/wiki/Server_stream-response-bodyDetails
server.stream-response-body = 1
#ssl.read-ahead              = "disable"

index-file.names            = ( "CustomBlockPage.php", "index.html", "index.lighttpd.html" )
url.access-deny             = ( "~", ".inc", ".md", ".yml", ".ini" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

mimetype.assign = (
    ".ico"   => "image/x-icon",
    ".jpeg"  => "image/jpeg",
    ".jpg"   => "image/jpeg",
    ".png"   => "image/png",
    ".svg"   => "image/svg+xml",
    ".css"   => "text/css; charset=utf-8",
    ".html"  => "text/html; charset=utf-8",
    ".js"    => "text/javascript; charset=utf-8",
    ".json"  => "application/json; charset=utf-8",
    ".map"   => "application/json; charset=utf-8",
    ".txt"   => "text/plain; charset=utf-8",
    ".eot"   => "application/vnd.ms-fontobject",
    ".otf"   => "font/otf",
    ".ttc"   => "font/collection",
    ".ttf"   => "font/ttf",
    ".woff"  => "font/woff",
    ".woff2" => "font/woff2"
)

# Add user chosen options held in external file
# This uses include_shell instead of an include wildcard for compatibility
include_shell "cat external.conf 2>/dev/null"

# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port

# Prevent Lighttpd from enabling Let's Encrypt SSL for every blocked domain
#include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
include_shell "find /etc/lighttpd/conf-enabled -name '*.conf' -a ! -name 'letsencrypt.conf' -printf 'include \"%p\"\n' 2>/dev/null"

# If the URL starts with /admin, it is the Web interface
$HTTP["url"] =~ "^/admin/" {
    # X-Pi-hole is a response header for debugging using curl -I
    # X-Frame-Options prevents clickjacking attacks and helps ensure your content is not embedded into other sites via < frame >, < iframe > or < object >.
    # X-XSS-Protection sets the configuration for the cross-site scripting filters built into most browsers. This is important because it tells the browser to block the response if a malicious script has been inserted from a user input.
    # X-Content-Type-Options stops a browser from trying to MIME-sniff the content type and forces it to stick with the declared content-type. This is important because the browser will only load external resources if their content-type matches what is expected, and not malicious hidden code.
    # Content-Security-Policy tells the browser where resources are allowed to be loaded and if it’s allowed to parse/run inline styles or Javascript. This is important because it prevents content injection attacks, such as Cross Site Scripting (XSS).
    # X-Permitted-Cross-Domain-Policies is an XML document that grants a web client, such as Adobe Flash Player or Adobe Acrobat (though not necessarily limited to these), permission to handle data across domains.
    # Referrer-Policy allows control/restriction of the amount of information present in the referral header for links away from your page—the URL path or even if the header is sent at all.
    setenv.add-response-header = (
        "X-Pi-hole" => "The Pi-hole Web interface is working!",
        "X-Frame-Options" => "DENY",
        "X-XSS-Protection" => "1; mode=block",
        "X-Content-Type-Options" => "nosniff",
        "Content-Security-Policy" => "default-src 'self' 'unsafe-inline';",
        "X-Permitted-Cross-Domain-Policies" => "none",
        "Referrer-Policy" => "same-origin"
    )
}

# Block . files from being served, such as .git, .github, .gitignore
$HTTP["url"] =~ "^/admin/\.(.*)" {
    url.access-deny = ("")
}

# allow teleporter and API qr code iframe on settings page
$HTTP["url"] =~ "/(teleporter|api_token)\.php$" {
    $HTTP["referer"] =~ "/admin/settings\.php" {
        setenv.add-response-header = ( "X-Frame-Options" => "SAMEORIGIN" )
    }
}

# Default expire header
expire.url = ( "" => "access plus 0 seconds" )
francouai commented 1 year ago

I think, I'll reinstall PI-hole from scratch.

perspector commented 1 year ago

Yeah, I think that might be the easiest solution. Backup your adlists before (or write down which ones they are). Sorry you have to do this!

nicyu5774y commented 1 year ago

i have a question why require the password-mail?

perspector commented 1 year ago

Great question! The password is only required since imap-tools needs the password to be able to access your inbox and to see what emails are in your inbox. The password is not shared anywhere.

perspector commented 1 year ago

I will close this as it has been a few months.