广告路由器开发(一)数据流

最近无事时对广告路由器进行了一个分析

常用的广告路由器一般是通过普通路由器刷openwrt或是ddwrt等固件后安装wifidog组件做的,我们这里分析的即是wifidog加authpuppy

以下数据为截取自authpuppy和wifidog的交互

1.用户请求页面http://www.gov.cn/guowuyuan/2014-09/23/content_2755108.htm
--------------------------------------------------------------------------------------
request:
/login/?gw_address=192.168.4.1&gw_port=2060&gw_id=default&mac=00:0e:c6:f0:06:b2&url=http%3A//www.gov.cn/guowuyuan/2014-09/23/content_2755108.htm

response:
<form action="http://192.168.1.251:81/login/?gw_address=192.168.4.1&gw_port=2060&gw_id=default&mac=00:0e:c6:f0:06:b2&url=http%3A//www.gov.cn/guowuyuan/2014-09/23/content_2755108.htm" method="POST">
    <input type="hidden" name="gw_id" value="default" />
  <input type="hidden" name="gw_address" value="192.168.4.1" />
  <input type="hidden" name="gw_port" value="2060" />
    	<input type="hidden" id="authenticators" name="authenticator" value="apAuthLocalUser"/>
      <div id="authPlugin_apAuthLocalUser" style="display: none">
            <h1>Local network user authentication</h1>

                    <input type="submit" name="submit[apAuthLocalUserconnect]" id="submit[apAuthLocalUserconnect]" value="Connect" onClick="deleteLinkElement()" />
					<input type="password" name="apAuthLocalUser[password]" value="Pb4AoWdlOhqu4B2T535zDg==" id="apAuthLocalUser_password" />
					<label for="apAuthLocalUser_remember_me">Remember me</label>
					<input type="checkbox" name="apAuthLocalUser[remember_me]" value="1" checked="checked" id="apAuthLocalUser_remember_me" />
</form>

array (
  'REDIRECT_STATUS' => '200',
  'HTTP_HOST' => '192.168.1.251:81',
  'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  'HTTP_COOKIE' => 'authpuppy=usb6bslekske7ek5rlorknvf43; localUserCookie=226f362768d281ff14cf428fa3c3b8c87a6c4834',
  'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/600.1.17 (KHTML, like Gecko) Version/7.1 Safari/537.85.10',
  'HTTP_REFERER' => 'http://news.baidu.com/',
  'SCRIPT_FILENAME' => 'F:/phpStudyAll/WWW/authpuppy/web/index.php',
  'REMOTE_PORT' => '53961',
  'REDIRECT_QUERY_STRING' => 'gw_address=192.168.4.1&gw_port=2060&gw_id=default&mac=00:0e:c6:f0:06:b2&url=http%3A//www.gov.cn/guowuyuan/2014-09/23/content_2755108.htm',
  'REDIRECT_URL' => '/login/',
  'GATEWAY_INTERFACE' => 'CGI/1.1',
  'SERVER_PROTOCOL' => 'HTTP/1.1',
  'REQUEST_METHOD' => 'GET',
  'QUERY_STRING' => 'gw_address=192.168.4.1&gw_port=2060&gw_id=default&mac=00:0e:c6:f0:06:b2&url=http%3A//www.gov.cn/guowuyuan/2014-09/23/content_2755108.htm',
  'REQUEST_URI' => '/login/?gw_address=192.168.4.1&gw_port=2060&gw_id=default&mac=00:0e:c6:f0:06:b2&url=http%3A//www.gov.cn/guowuyuan/2014-09/23/content_2755108.htm',
)
++++++++++++++++++++++++++++++++++++++++++++++++

2.登录成功以后而返回如下
--------------------------------------------------------------------------------------
request:
/login/?gw_address=192.168.4.1&gw_port=2060&gw_id=default&mac=00:0e:c6:f0:06:b2&url=http%3A//www.gov.cn/guowuyuan/2014-09/23/content_2755108.htm

response:
<html><head><meta http-equiv="refresh" content="0;url=http://192.168.4.1:2060/wifidog/auth?token=60bb7efe229270c4d6d36ed60bb5e98886900126"/></head></html>

array (
  'REDIRECT_STATUS' => '200',
  'HTTP_HOST' => '192.168.1.251:81',
  'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
  'HTTP_ORIGIN' => 'http://192.168.1.251:81',
  'HTTP_COOKIE' => 'authpuppy=usb6bslekske7ek5rlorknvf43; localUserCookie=226f362768d281ff14cf428fa3c3b8c87a6c4834',
  'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/600.1.17 (KHTML, like Gecko) Version/7.1 Safari/537.85.10',
  'HTTP_REFERER' => 'http://192.168.1.251:81/login/?gw_address=192.168.4.1&gw_port=2060&gw_id=default&mac=00:0e:c6:f0:06:b2&url=http%3A//www.gov.cn/guowuyuan/2014-09/23/content_2755108.htm',
  'HTTP_ACCEPT_LANGUAGE' => 'en-us',
  'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
  'REMOTE_ADDR' => '192.168.1.106',
  'REMOTE_PORT' => '53950',
  'REDIRECT_QUERY_STRING' => 'gw_address=192.168.4.1&gw_port=2060&gw_id=default&mac=00:0e:c6:f0:06:b2&url=http%3A//www.gov.cn/guowuyuan/2014-09/23/content_2755108.htm',
  'REDIRECT_URL' => '/login/',
  'GATEWAY_INTERFACE' => 'CGI/1.1',
  'SERVER_PROTOCOL' => 'HTTP/1.1',
  'REQUEST_METHOD' => 'POST',
  'QUERY_STRING' => 'gw_address=192.168.4.1&gw_port=2060&gw_id=default&mac=00:0e:c6:f0:06:b2&url=http%3A//www.gov.cn/guowuyuan/2014-09/23/content_2755108.htm',
  'REQUEST_URI' => '/login/?gw_address=192.168.4.1&gw_port=2060&gw_id=default&mac=00:0e:c6:f0:06:b2&url=http%3A//www.gov.cn/guowuyuan/2014-09/23/content_2755108.htm',
  'REQUEST_TIME' => 1411547194,
)
++++++++++++++++++++++++++++++++++++++++++++++++

3. 在2中进行跳转后则WiFiDog服务器向授权服务器端发送GET授权请求 若成功则而返回Auth: 1
--------------------------------------------------------------------------------------
request:
/auth/?stage=login&ip=192.168.4.186&mac=00:0e:c6:f0:06:b2&token=60bb7efe229270c4d6d36ed60bb5e98886900126&incoming=0&outgoing=0&gw_id=default

response://千万要注意这里Auth:与1之间有一个空格否则不能通过验证
Auth: 1

array (
  'REDIRECT_STATUS' => '200',
  'HTTP_USER_AGENT' => 'WiFiDog 20130917',
  'HTTP_HOST' => '192.168.1.251',
  'SERVER_PORT' => '81',
  'REMOTE_ADDR' => '192.168.1.106',
  'REMOTE_PORT' => '33264',
  'REDIRECT_QUERY_STRING' => 'stage=login&ip=192.168.4.186&mac=00:0e:c6:f0:06:b2&token=60bb7efe229270c4d6d36ed60bb5e98886900126&incoming=0&outgoing=0&gw_id=default',
  'REDIRECT_URL' => '/auth/',
  'GATEWAY_INTERFACE' => 'CGI/1.1',
  'SERVER_PROTOCOL' => 'HTTP/1.0',
  'REQUEST_METHOD' => 'GET',
  'QUERY_STRING' => 'stage=login&ip=192.168.4.186&mac=00:0e:c6:f0:06:b2&token=60bb7efe229270c4d6d36ed60bb5e98886900126&incoming=0&outgoing=0&gw_id=default',
  'REQUEST_URI' => '/auth/?stage=login&ip=192.168.4.186&mac=00:0e:c6:f0:06:b2&token=60bb7efe229270c4d6d36ed60bb5e98886900126&incoming=0&outgoing=0&gw_id=default',
  'REQUEST_TIME' => 1411547194,
)
++++++++++++++++++++++++++++++++++++++++++++++++

4.WiFiDog在接收到Auth:1之后向服务器端发送/portal/?gw_id=default的GET请求 授权服务器返回立即跳转的页面如下:
--------------------------------------------------------------------------------------
request:
/portal/?gw_id=default

reponse:
<html><head><meta http-equiv="refresh" content="0;url=http://www.gov.cn/guowuyuan/2014-09/23/content_2755108.htm"/></head></html>

array (
  'REDIRECT_STATUS' => '200',
  'HTTP_HOST' => '192.168.1.251:81',
  'HTTP_ORIGIN' => 'http://192.168.1.251:81',
  'HTTP_COOKIE' => 'authpuppy=usb6bslekske7ek5rlorknvf43; localUserCookie=226f362768d281ff14cf428fa3c3b8c87a6c4834',
  'HTTP_CONNECTION' => 'keep-alive',
  'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/600.1.17 (KHTML, like Gecko) Version/7.1 Safari/537.85.10',
  'HTTP_ACCEPT_LANGUAGE' => 'en-us',
  'HTTP_REFERER' => 'http://192.168.1.251:81/login/?gw_address=192.168.4.1&gw_port=2060&gw_id=default&mac=00:0e:c6:f0:06:b2&url=http%3A//www.gov.cn/guowuyuan/2014-09/23/content_2755108.htm',
  'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
  'REDIRECT_QUERY_STRING' => 'gw_id=default',
  'REDIRECT_URL' => '/portal/',
  'GATEWAY_INTERFACE' => 'CGI/1.1',
  'SERVER_PROTOCOL' => 'HTTP/1.1',
  'REQUEST_METHOD' => 'GET',
  'QUERY_STRING' => 'gw_id=default',
  'REQUEST_URI' => '/portal/?gw_id=default',
  'SCRIPT_NAME' => '/index.php',
  'PHP_SELF' => '/index.php',
  'REQUEST_TIME' => 1411547194,
)
++++++++++++++++++++++++++++++++++++++++++++++++

5.WiFiDog服务器向授权服务器发送ping操作请求 服务器端通过后发送Pong响应串(纯文本)
--------------------------------------------------------------------------------------
request:
/ping/?gw_id=default&sys_uptime=28824&sys_memfree=99284&sys_load=0.08&wifidog_uptime=61

response:
Pong

array (
  'REDIRECT_STATUS' => '200',
  'HTTP_USER_AGENT' => 'WiFiDog 20130917',
  'HTTP_HOST' => '192.168.1.251',
  'SERVER_SIGNATURE' => '',
  'SERVER_SOFTWARE' => 'Apache/2.4.9 (Win32) OpenSSL/0.9.8y PHP/5.3.28',
  'SERVER_NAME' => '192.168.1.251',
  'SERVER_ADDR' => '192.168.1.251',
  'SERVER_PORT' => '81',
  'REMOTE_ADDR' => '192.168.1.106',
  'DOCUMENT_ROOT' => 'F:/phpStudyAll/WWW/authpuppy/web',
  'REQUEST_SCHEME' => 'http',
  'CONTEXT_PREFIX' => '',
  'CONTEXT_DOCUMENT_ROOT' => 'F:/phpStudyAll/WWW/authpuppy/web',
  'SERVER_ADMIN' => '[email protected]',
  'SCRIPT_FILENAME' => 'F:/phpStudyAll/WWW/authpuppy/web/index.php',
  'REMOTE_PORT' => '33265',
  'REDIRECT_QUERY_STRING' => 'gw_id=default&sys_uptime=28824&sys_memfree=99284&sys_load=0.08&wifidog_uptime=61',
  'REDIRECT_URL' => '/ping/',
  'GATEWAY_INTERFACE' => 'CGI/1.1',
  'SERVER_PROTOCOL' => 'HTTP/1.0',
  'REQUEST_METHOD' => 'GET',
  'QUERY_STRING' => 'gw_id=default&sys_uptime=28824&sys_memfree=99284&sys_load=0.08&wifidog_uptime=61',
  'REQUEST_URI' => '/ping/?gw_id=default&sys_uptime=28824&sys_memfree=99284&sys_load=0.08&wifidog_uptime=61',
  'SCRIPT_NAME' => '/index.php',
  'PHP_SELF' => '/index.php',
  'REQUEST_TIME' => 1411547224,
)
++++++++++++++++++++++++++++++++++++++++++++++++

6.WiFiDog向服务器发送计费通知
--------------------------------------------------------------------------------------

request:
/auth/?stage=counters&ip=192.168.4.186&mac=00:0e:c6:f0:06:b2&token=60bb7efe229270c4d6d36ed60bb5e98886900126&incoming=4660796&outgoing=192338&gw_id=default

response:
Auth: 1//中间一定要有一个空格

array (
  'REDIRECT_STATUS' => '200',
  'HTTP_USER_AGENT' => 'WiFiDog 20130917',
  'HTTP_HOST' => '192.168.1.251',
  'SERVER_NAME' => '192.168.1.251',
  'SERVER_ADDR' => '192.168.1.251',
  'SERVER_PORT' => '81',
  'REMOTE_ADDR' => '192.168.1.106',
  'REMOTE_PORT' => '33266',
  'REDIRECT_QUERY_STRING' => 'stage=counters&ip=192.168.4.186&mac=00:0e:c6:f0:06:b2&token=60bb7efe229270c4d6d36ed60bb5e98886900126&incoming=4660796&outgoing=192338&gw_id=default',
  'REDIRECT_URL' => '/auth/',
  'GATEWAY_INTERFACE' => 'CGI/1.1',
  'SERVER_PROTOCOL' => 'HTTP/1.0',
  'REQUEST_METHOD' => 'GET',
  'QUERY_STRING' => 'stage=counters&ip=192.168.4.186&mac=00:0e:c6:f0:06:b2&token=60bb7efe229270c4d6d36ed60bb5e98886900126&incoming=4660796&outgoing=192338&gw_id=default',
  'REQUEST_URI' => '/auth/?stage=counters&ip=192.168.4.186&mac=00:0e:c6:f0:06:b2&token=60bb7efe229270c4d6d36ed60bb5e98886900126&incoming=4660796&outgoing=192338&gw_id=default'
)
++++++++++++++++++++++++++++++++++++++++++++++++

7.退出登录
--------------------------------------------------------------------------------------

request:
/auth/?stage=logout&ip=192.168.4.186&mac=00:0e:c6:f0:06:b2&token=60bb7efe229270c4d6d36ed60bb5e98886900126&incoming=0&outgoing=0&gw_id=default

response:
Auth: 0

array (
  'REDIRECT_STATUS' => '200',
  'HTTP_USER_AGENT' => 'WiFiDog 20130917',
  'HTTP_HOST' => '192.168.1.251',
  'SERVER_NAME' => '192.168.1.251',
  'SERVER_ADDR' => '192.168.1.251',
  'SERVER_PORT' => '81',
  'REMOTE_ADDR' => '192.168.1.106',
  'REQUEST_SCHEME' => 'http',
  'CONTEXT_PREFIX' => '','stage=logout&ip=192.168.4.186&mac=00:0e:c6:f0:06:b2&token=60bb7efe229270c4d6d36ed60bb5e98886900126&incoming=0&outgoing=0&gw_id=default',
  'REDIRECT_URL' => '/auth/',
  'GATEWAY_INTERFACE' => 'CGI/1.1',
  'SERVER_PROTOCOL' => 'HTTP/1.0',
  'REQUEST_METHOD' => 'GET',
  'QUERY_STRING' => 'stage=logout&ip=192.168.4.186&mac=00:0e:c6:f0:06:b2&token=60bb7efe229270c4d6d36ed60bb5e98886900126&incoming=0&outgoing=0&gw_id=default',
  'REQUEST_URI' => '/auth/?stage=logout&ip=192.168.4.186&mac=00:0e:c6:f0:06:b2&token=60bb7efe229270c4d6d36ed60bb5e98886900126&incoming=0&outgoing=0&gw_id=default',
  'SCRIPT_NAME' => '/index.php',
  'PHP_SELF' => '/index.php',
  'REQUEST_TIME' => 1411549984,
)
++++++++++++++++++++++++++++++++++++++++++++++++

时间: 2024-09-30 15:36:19

广告路由器开发(一)数据流的相关文章

广告路由器开发(二)实践

上篇文章中分析了wifidog下authpuppy之间的数据流这篇文章中我就介绍一下如何书写一个简单的广告路由器 经过以上分析不难看出 实现一个广告路由器还是非常简单的 由于我本人对symfony框架不感冒 故以下示例代码使用了phalcon框架进行书写(只是演示用而已) <?php namespace controllers; class InterfaceController extends \Phalcon\Mvc\Controller { public function initiali

广告路由器web认证系统设置笔记

最近广告路由器很火啊,在网上翻了半天教程,今天对接成功了web认证后台. 大概整理一下,其实按着步骤来, 也就是1分钟就能对接好. 自己从0开始摸索的话,很多概念不清除,会浪费了很多时间. 这里以wifidog为例,只要设置好下面几个项就行了.菜单路径是 service->wifidog设置: 设备id(gatewayID):              10003 认证服务器:主机名:            115.29.12.130 认证服务器:web服务端口:  8080 认证服务器:url

路由器开发板上的TTL线连接方法

手头有个MTK双频路由器的开发板,做工良好,但让人蛋疼的是,TTL线没有标注TX/RX/GND/VCC,这个小细节的缺失给使用带来了巨大麻烦. 网上搜了半天也没找到相关电路图,只好遍历测试找到正确的连接方式,VCC线不用连,所以共有24种连接方式. 注意:即便不连接串口板的VCC线,依然有烧板(串口板)的可能性!如果板子过热或冒烟,那就是中招了,牢牢记下这个错误的连接方式,防止再次踩雷,然后,擦干眼泪,换块板子继续. 正确连接方式: 开发板--串口板 TX--------RX RX-------

路由器开发(一)—— 路由器硬件结构及软件体系

一.路由器的硬件构成  路由器主要由以下几个部分组成:输入/输出接口部分.包转发或交换结构部分(switching fabric).路由计算或处理部分.如图所示 图1    路由器的基本组成 输入端口是物理链路和输入包的进口处.端口通常由线卡提供,一块线卡一般支持4.8或16个端口,一个输入端口具有许多功能.第一个功能是进行数据链路层的封装和解封装.第二个功能是在转发表中查找输入包目的地址从而决定目的端口(称为路由查找),路由查找可以使用一般的硬件来实现,或者通过在每块线卡上嵌入一个微处理器来完

千米红包LBS广告系统开发“内幕”

千米红包LBS软件系统开发找[陈洋:1 5 0-1 3 1 5-1 7 4 0电/微]App.小程序技术定制开发服务!用社群媒体思路做营销,应该更加注重优质的内容和精细的用户维护.一方面,好内容能够吸引更加精英的用户:另一方面,精英用户能倒逼社群产生更加优质的内容,甚至还会组织社群成员共同创造UGC内容. 千米红包是一款基于LBS技术的共享红包App.用户可在附近一公里红包领地内,查看红包信息并领取现金红包,领取的红包金额将支持提现至微信零钱!同时用户可通过千米红包,发布广告或者祝福的信息,每条

小白系列-免费广告路由器web认证设置(2)

要设置认证页面图片.须要到后台注冊一个帐号,绑定路由器. 路由器管理后台网址 http://115.29.12.130/router 第一步:自己主动获取一个路由器ID(上一篇文章中的路由器ID也要改成自己主动获取的), 然后保存 第二步: 大功告成,已经设置好了.

路由器开发(二)—— 路由器工作原理

当信息需要在两个网络之间传输时,常用路由器这种互连设备来负责数据的传输.路由器的主要工作是:路径的决定和数据包的转发(从路由器一个接口输入,然后选择合适接口输出):维护路由表. 路由器工作的方式非常简洁明了,从接收报文中抽取目的地址,并确定地址中的网络号,查找路由选择表以获得与目标网络相匹配的表项.在路由选择表中的匹配表项中包括下一站.目的地.输出接口和其它与路由有关的参数.报文被封装在适合输出接口的帧中,并由输出接口输出. 下面具体分析路由器两种工作的工作原理. 一.路由的概念  路由是将对象

微信朋友圈广告开发总结

最近做了一个H5项目,是有关微信朋友圈广告,个人认真的学习了一下相关的流程,现将个人学习心得总结如下,如有不妥之处,还望各位网友同行们给予批评指正.   微信广告开发规范:http://wximg.qq.com/wxp/wxmoment-doc/3.1.html WxMoment :https://github.com/wxc-team/WxMoment 第一步:开发前的准备 由于微信朋友圈广告是基于微信公众号生态体系,以类似朋友的 原创内容形式 在用户朋友圈进行展示的原生广告.通过整合亿级优质

AppCan开发:机遇总是眷顾有准备的顽固派

近期AppCan社区新招募了一批版主,热心积极地帮助各位开发者解答开发问题.其中有位版主的昵称相信大家一定不会陌生--回忆的翅膀. "打开论坛准备回答一下问题,结果发现全是翅膀!" "我最大的希望是,没有人问问题." 本期的主人公就是这位回忆的翅膀,<多识生活>的开发者--Toby. 热心回帖源于自身经历 被问到最近在忙些什么,Toby的回答是--回答帖子问题和做自己的一个官方网站."其实我之所以积极回答大家问题,最主要的原因是自己的经历吧.&