打印

OpenWrt 广告植入原型搭建

[复制链接]
156|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
Spikess|  楼主 | 2018-8-22 10:44 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
  笔者通过在路由器上搭建Provioxy代理服务器来实现过滤通过其对网页,并植入相应对广告。

  废话不多说直接上实验:

  第一步:准备固件

  编译OpenWrt固件-选择Privoxy

  第二步:修改配置文件

  配置user.filter, user.action, config文件。

  config文件中需要指定监听都地址与端口号

  root@YSWiFi:/etc/privoxy# cat config

  confdir /etc/privoxy

  logdir /var/log

  filterfile default.filter

  filterfile user.filter

  #logfile privoxy

  actionsfile match-all.action # Actions that are applied to all sites and maybe overruled later on.

  actionsfile default.action # Main actions file

  actionsfile user.action # User customizations

  listen-address 10.1.1.1:8118

  toggle 1

  enable-remote-toggle 1

  enable-remote-http-toggle 0

  enable-edit-actions 1

  enforce-blocks 0

  buffer-limit 4096

  forwarded-connect-retries 0

  accept-intercepted-requests 1

  allow-cgi-request-crunching 0

  split-large-forms 0

  keep-alive-timeout 300

  socket-timeout 300

  permit-access 10.1.1.0/24

  debug 1 # show each GET/POST/CONNECT request

  debug 4096 # Startup banner and warnings

  debug 8192 # Errors - *we highly recommended enabling this*

  #admin-address privoxy-admin@example.com

  #proxy-info-url http://www.example.com/proxy-service.html

  root@YSWiFi:/etc/privoxy#

  在user.action中注入广告脚本 xxx.js

  具体参考我的脚本 https://gist.github.com/qianguozheng

  user.filter中添加过滤规则

  FILTER: block-weeds

  s||$0|user.action中调用过滤规则{+filter{block-weeds}}

  .*将所有目标地址为80端口的请求转到8118端口iptables -t nat -A PREROUTING -s 0.0.0.0/0.0.0.0 -p tcp --dport 80 -j REDIRECT --to-ports 8118

  第三步:体验结果

  这时候,当你打开网页的时候,你会发现原来世界那么容易控制, 每个网页都有你所想看到都东西

使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

417

主题

421

帖子

0

粉丝