Skip to content

A fast adblocking proxy server (which works on HTTPS connections)

Notifications You must be signed in to change notification settings

Ar0xA/mitm-adblock

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MITM Adblock

An adblocker that runs as a proxy server! (And works on HTTPS connections.)

Use this to block ads on your mobile device, or just monitor its traffic.The main advantage of this versus DNS adblocking is that it blocks the items when the page is loaded, much like adblock or ublock origin do. This means that sites that load advertisements over the same domain (like youtube) that get through on DNS adblock get filtered here.

Installation

  1. Install mitmproxy (tested with 4.0.4 binaries)
  2. Install required python3 modules:
$ pip3 install adblockparser

Important: depending on your python version, edit adblock.py sys.path.append to reflect the correct python3 path.

  1. Run ./update-blocklists to download some blocklists

  2. Run ./go to start the proxy server on port 8118 (or run ./go -c for a curses interface, which lets you inspect the requests/responses)

  3. Setup your browser/phone to use localhost:8118 or lan-ip-address:8118 as an HTTP proxy server; then, visit http://mitm.it on that device to install the MITM SSL certificate so that your machine won't throw security warnings whenever the proxy server intercepts your secure connections.

If you'd like to change any of the mitmproxy settings (like port, and where/whether it logs your connections), edit the go script.

How to run in transparant mode

First, you need a linux machine and enable ip forwardig and prevent icmp redirects

sysctl -w net.ipv4.ip_forward=1
sysctl -w net.ipv4.conf.all.send_redirects=0

Secondly you need to enable port redirecting from iptables

iptables -t nat -I PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8118
iptables -t nat -I PREROUTING -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 8118

Lastly, you need to modify the run command

./mitmdump -p 8118 -s adblock.py --mode transparent --showhost --set stream_large_bodies=100k

About

A fast adblocking proxy server (which works on HTTPS connections)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 59.0%
  • Ruby 28.1%
  • Shell 12.9%