Giter Club home page Giter Club logo

esphole's Introduction

Ad blocker for ESP

Esphole is a proof-of-concept of an ad blocking DNS server for the esp8266.

Note: The solution is far from being production ready. I just wanted to see if it was possible to develop a simple DNS ad blocker inside the ESP

It uses a modified version of the DNS Server library included with the Esp8266 core for Arduino

How to install

Preprocess the hosts file

The first versions uploaded the full hosts file to the SPIFFS. The performance of finding the domain in the full hosts file was really poor, so for the current version the hosts file is preprocessed and stored in smaller files based on the lenght of the domain

$ cd utils
$ gen_block_lists.sh

This downloads the hosts file and saves it in different files in the data directory

Upload the SPIFFS

Follow the guide of Arduino ESP8266 filesystem uploader to install the SPIFFS uploader and then select: Tools > ESP8266 Sketch Data Upload in order to upload data directory to the ESP

Upload the sketch

Open the sketch directory with Arduino editor and edit esphole.ino in order to change the WIFI settings

#define wifi_ssid "........"
#define wifi_password "........"

Then, upload it to the ESP

Usage/Test

Open the serial monitor or minicom in order to find the IP of the ESP device (or scan your network in order to find it) and use nslookup in order to test some domains:

$ nslookup - 192.168.0.161
> github.com
Server:		192.168.0.161
Address:	192.168.0.161#53

Non-authoritative answer:
Name:	github.com
Address: 192.30.253.112

> analytics.google.com
Server:		192.168.0.161
Address:	192.168.0.161#53

Non-authoritative answer:
Name:	analytics.google.com
Address: 0.0.0.0

In the serial monitor the debug information is shown:

WiFi connected | IP address: 192.168.0.161
DNS Server ready

Domain: github.com | IP:192.30.253.112
Resolv took 70 ms | Find took 57 ms

Domain: analytics.google.com Blocked | Find took 30 ms

Note: Esphole was tested with a Wemos D1 min and an Amica NodeMCU.

esphole's People

Contributors

rubfi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

esphole's Issues

Generation Script Errors on Mac

Hi, thank you for your effort. I installed it on my Wemos D1 Mini and it works very well and fastern then expected.
Unfortunately I've had problems with the script. I'm on macos 10.14.6.
I had to change a bit to make it work.

  • I transfered the files to my Arduino Sketchbook
  • For me it must be bash instead of sh. Otherwise I got errors. I made a chmod 755 gen_block_lists.sh then ./gen_block_lists.sh. Or other ways work too.
  • I had to change the temp dir to something within my home folder. So I took the Ardunio Sketchbook folder. Alter for personal preferences.
  • The first for loop didn't work for me either. I had to rewrite it a little bit.
#!/bin/bash
# Script for downloading and converting the ad server lists to smaller files

HOSTS_URL="https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&mimetype=plaintext&useip=0.0.0.0"
#HOSTS_URL="http://someonewhocares.org/hosts/zero/hosts"

#edit: your personal sketchbook folder
PATH_ARDUINO_SKETCHBOOK="/Users/XYZ/Arduino"
#edit if your esphole repo is not located in the sketch folder or was renamed already:
HOSTS_TEMP_DIR=$PATH_ARDUINO_SKETCHBOOK"/esphole-master/utils/temp"

mkdir -p $HOSTS_TEMP_DIR
HOST_LIST="$HOSTS_TEMP_DIR/host_list"

wget $HOSTS_URL -O - | grep -v '#' | grep "0.0.0.0" | sed 's/0\.0\.0\.0 //g' > $HOST_LIST

# saves each domain in a file depending on its characters
for i in $(cat $HOST_LIST)
do
    x=$(echo -n $i | tr '\n' ' ' | tr "\r" " ")
    name=$(echo -n $x | wc -m)
    echo -n ",$x" >> hosts_$(echo -n $name)
done

# adds a kind of EOF for making easier the findUntil
for i in $(ls -1 hosts_*)
do
    echo ",@@@" >> $i
done

mkdir -p $HOSTS_TEMP_DIR/../../data
mv hosts_* $HOSTS_TEMP_DIR/../../data/

cant creat file with .sh script(under windows)

I don't use a Unix operating system so I can't do .sh scripts
so I can't process the host file

btw when I changed the wifi name, it just doesn't change. (the wifi name was "esp_24f813")
and when I connect to the wifi it says no internet and nothing happens.

Alternative DNS Server?

I wonder how the ESPhole gets the IP addresses for the non-blocked DNS. I assume it's been resolved by the DNS IP from the DHCP Server. I want to setup the ESPHole for a whole little side network. That's why I want to leave the clients (mobile, computer, etc) DNS settings untouched, but alter the DNS settings in my DHCP server, pointing to the ESPHole. But then the ESPHole needs it's own DNS fallback IP, not the one from the router. Otherwise it would create an infinite loop. Is it possible to assign a primary DNS IP address on the ESPHole other than that from the router? Thanks a lot!

Wildcard blocking

I love this project! But instead of having over 30,000 domains, is it possible to make wildcard blocking? So that there can few thousand domains and there's going to be faster lookups and resolution. Is it possible?

How to import other hosts ads blacklist ?

Hi, i want to add some other hosts ads blacklist for blocked ads and popup in vietnam
How to add that to my esp8266 4mb
My blacklist is 20kb
Very light!

Pls, support me! :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.