By setting up a provioxy proxy server on the vro, the author filters the webpage through it and embeds corresponding ads.
If you don't talk nonsense, go directly to the experiment:
Step 1: Prepare the firmware
Compile openwrt firmware-select Privoxy
Step 2: modify the configuration file
Configure the user. filter, user. Action, and config files.
In the config file, you must specify the listening address and port number.
[email protected]:/etc/privoxy# cat config confdir /etc/privoxylogdir /var/logfilterfile default.filterfilterfile user.filter#logfile privoxyactionsfile match-all.action # Actions that are applied to all sites and maybe overruled later on.actionsfile default.action # Main actions fileactionsfile user.action # User customizationslisten-address 10.1.1.1:8118toggle 1enable-remote-toggle 1enable-remote-http-toggle 0enable-edit-actions 1enforce-blocks 0buffer-limit 4096forwarded-connect-retries 0accept-intercepted-requests 1allow-cgi-request-crunching 0split-large-forms 0keep-alive-timeout 300socket-timeout 300permit-access 10.1.1.0/24debug 1 # show each GET/POST/CONNECT requestdebug 4096 # Startup banner and warningsdebug 8192 # Errors - *we highly recommended enabling this*#admin-address [email protected]#proxy-info-url http://www.example.com/proxy-service.html[email protected]:/etc/privoxy#
Inject the advertisement script XXX. js into user. Action
See my script https://gist.github.com/qianguozheng for details
Add filter rules in user. Filter
FILTER: block-weedss|
User. Action{+filter{block-weeds}}.*
Forward all requests whose target address is port 80 to port 8118iptables -t nat -A PREROUTING -s 0.0.0.0/0.0.0.0 -p tcp --dport 80 -j REDIRECT --to-ports 8118
Step 3: experience the results
At this time, when you open the web page, you will find that the world is so easy to control, every web page has what you want to see.
Openwrt ad implantation prototype construction