WiFidog运行环境及与authpuppy交互数据

0:WiFiDog运行环境

[cpp]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. /wlan/portal/buildroot/etc # ps -w  
  2. \  PID USER       VSZ STAT COMMAND  
  3.     1 root       868 S    init         
  4.     2 root         0 SW<  [kthreadd]  
  5.     3 root         0 SW<  [ksoftirqd/0]  
  6.     4 root         0 SW<  [events/0]  
  7.     5 root         0 SW<  [khelper]  
  8.     6 root         0 SW<  [async/mgr]  
  9.     7 root         0 SW<  [kblockd/0]  
  10.     8 root         0 SW   [pdflush]  
  11.     9 root         0 SW   [pdflush]  
  12.    10 root         0 SW<  [kswapd0]  
  13.    11 root         0 SW<  [crypto/0]  
  14.    32 root         0 SW<  [mtdblockd]  
  15.    37 root         0 SWN  [jffs2_gcd_mtd3]  
  16.   564 root       864 S    /usr/sbin/telnetd   
  17.   566 root       864 S    /usr/sbin/httpd -h /usr/www/   
  18.   568 root       888 R    -sh   
  19.   881 nobody    1004 S    dnsmasq   
  20.  2191 root       868 R    ps -w   
  21.  2340 root       876 S    udhcpd -S /etc/udhcpd.conf   
  22.  3877 root       884 S    udhcpc -i eth0 -p /var/run/udhcpc_wan.pid -s /etc/udhcpc.script   
  23.  3892 root      1788 S    wifidog -c /etc/wifidog.conf   
  24.  4059 root      1788 S    wifidog -c /etc/wifidog.conf   
  25.  4060 root      1788 S    wifidog -c /etc/wifidog.conf   
  26.  4061 root      1788 S    wifidog -c /etc/wifidog.conf   
  27.  4062 root      1788 S    wifidog -c /etc/wifidog.conf   
  28.  /etc # ifconfig   
  29. ath0      Link encap:Ethernet  HWaddr 00:0B:6B:B4:01:63    
  30.           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1  
  31.           RX packets:1036165 errors:0 dropped:0 overruns:0 frame:0  
  32.           TX packets:902768 errors:0 dropped:181 overruns:0 carrier:0  
  33.           collisions:0 txqueuelen:0   
  34.           RX bytes:173265983 (165.2 MiB)  TX bytes:472405245 (450.5 MiB)  
  35.   
  36. br0       Link encap:Ethernet  HWaddr 00:0B:6B:B4:01:63    
  37.           inet addr:192.168.100.10  Bcast:192.168.100.255  Mask:255.255.255.0  
  38.           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1  
  39.           RX packets:1038127 errors:0 dropped:0 overruns:0 frame:0  
  40.           TX packets:895866 errors:0 dropped:0 overruns:0 carrier:0  
  41.           collisions:0 txqueuelen:0   
  42.           RX bytes:136852412 (130.5 MiB)  TX bytes:451119780 (430.2 MiB)  
  43.   
  44. eth0      Link encap:Ethernet  HWaddr 00:03:7F:FF:FF:FF    
  45.           inet addr:192.168.0.143  Bcast:192.168.0.255  Mask:255.255.255.0  
  46.           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1  
  47.           RX packets:100545 errors:0 dropped:0 overruns:0 frame:0  
  48.           TX packets:83617 errors:0 dropped:0 overruns:0 carrier:0  
  49.           collisions:0 txqueuelen:1000   
  50.           RX bytes:94237206 (89.8 MiB)  TX bytes:9617979 (9.1 MiB)  
  51.   
  52. lo        Link encap:Local Loopback    
  53.           inet addr:127.0.0.1  Mask:255.0.0.0  
  54.           UP LOOPBACK RUNNING  MTU:16436  Metric:1  
  55.           RX packets:50 errors:0 dropped:0 overruns:0 frame:0  
  56.           TX packets:50 errors:0 dropped:0 overruns:0 carrier:0  
  57.           collisions:0 txqueuelen:0   
  58.           RX bytes:5181 (5.0 KiB)  TX bytes:5181 (5.0 KiB)  
  59.   
  60. wifi1     Link encap:UNSPEC  HWaddr 00-0B-6B-B4-01-63-00-00-00-00-00-00-00-00-00-00    
  61.           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1  
  62.           RX packets:2682769 errors:0 dropped:0 overruns:0 frame:0  
  63.           TX packets:3642860 errors:8464 dropped:0 overruns:0 carrier:0  
  64.           collisions:0 txqueuelen:511   
  65.           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)  
  66.           Interrupt:64 Memory:b0000000-b0020000   
  67.   
  68. /etc # brctl show  
  69. bridge name bridge id       STP enabled interfaces  
  70. br0     8000.000b6bb40163   no      ath0  
  71. /etc #   
  72. /etc # route  
  73. Kernel IP routing table  
  74. Destination     Gateway         Genmask         Flags Metric Ref    Use Iface  
  75. 192.168.100.0   *               255.255.255.0   U     0      0        0 br0  
  76. 192.168.0.0     *               255.255.255.0   U     0      0        0 eth0  
  77. default         192.168.0.1     0.0.0.0         UG    0      0        0 eth0  
  78. /etc # iptables -t nat -L  
  79. Chain PREROUTING (policy ACCEPT)  
  80. target     prot opt source               destination           
  81.   
  82. Chain POSTROUTING (policy ACCEPT)  
  83. target     prot opt source               destination           
  84. MASQUERADE  all  --  anywhere             anywhere              
  85.   
  86. Chain OUTPUT (policy ACCEPT)  
  87. target     prot opt source               destination      

1: 用户,WiFiDog,Authpuppy交互过程


General Flow Description:

  1. The client does his initial request, as if he was already connected, (e.g.:  http://www.google.ca)
  2. The Gateway's firewall rules mangle the request to redirect it to a local port on the Gateway. When that's the done, the Gateway provides an HTTP Redirect reply that contains the Gateway ID, Gateway FQDN and other informations
  3. The Client does his request to the Auth Server as specified by the Gateway, see Login Protocol
  4. The Auth Server replies with a (potentially custom) splash (login) page
  5. The Client provides his identification informations (username and password)
  6. Upon succesful authentication, the client gets an HTTP Redirect to the Gateway's own web server with his authentication proof (a one-time token), http://GatewayIP:GatewayPort/wifidog/auth?token=[auth token]
  7. The Client then connects to the Gateway and thus gives it his token
  8. The Gateway requests validation of the token from the Auth Server, see Client Protocol
  9. The Auth Server confirms the token
  10. The Gateway then sends a redirect to the Client to obtain the Success Page from the Auth Server, redirects to http://auth_server/portal/
  11. The Auth Server notifies the Client that his request was successful

2:wifidog与authpuppy交互数据包

2.0:wifidog对用户重定向数据包

当用户首次访问一个网址的时候:wifidog会将用户的请求重定义到登陆认证界面。

(http.c:135) Captured 192.168.100.11 requesting [http%3A//apilocate.amap.com/mobile/plaintext] and re-directing them to login page
(http.c:215) Redirecting client browser to http://192.168.0.142:80/authpuppy/web/login/?gw_address=192.168.100.10&gw_port=2060&gw_id=123456789&mac=90:7a:28:01:20:26&url=http%3A//apilocate.amap.com/mobile/plaintext

当用户输入了用户名及密码之后,访问了上面的地址自后,authpuppy就回给运行wifidog的路由器回复一个包:格式如下:http://GatewayIP:GatewayPort/wifidog/auth?token=[auth token]

http%3A//192.168.100.10%3A2060/wifidog/auth%3Ftoken%3D1ea7415482c4af464f1706a92adee9ea824d4242 之后就回出发路由器的login登陆请求。

2.1:wifidog与authpuppy之间的ping数据

[cpp]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. (ping_thread.c:167) HTTP Request to Server: [GET /authpuppy/web/ping/?gw_id=123456789&sys_uptime=75432&sys_memfree=38288&sys_load=0.00&wifidog_uptime=6 HTTP/1.0  
  2. User-Agent: WiFiDog 20090925  
  3. Host: 192.168.0.142  
  4. ]  
  5. (ping_thread.c:171) Reading response  
  6. (ping_thread.c:199) Read 254 bytes, total now 254  
  7. (ping_thread.c:217) Done reading reply, total 254 bytes  
  8. (ping_thread.c:221) HTTP Response from Server: [HTTP/1.0 200 OK  
  9. Date: Tue, 10 Jun 2014 09:32:07 GMT  
  10. Server: Apache/2.2.15 (Fedora)  
  11. X-Powered-By: PHP/5.3.3  
  12. Set-Cookie: authpuppy=s4jijh0k8o7h8dhhp67d1sttb1; path=/  
  13. Content-Length: 5  
  14. Connection: close  
  15. Content-Type: text/html; charset=utf-8  
  16. Pong  
  17. ]  
  18. (ping_thread.c:228) Auth Server Says: Pong  
2.2:用户与authpuppy之间的登陆认证数据

[cpp]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. (centralserver.c:114) Sending HTTP request to auth server: [GET /authpuppy/web/auth/?stage=login&ip=192.168.100.11&mac=90:7a:28:01:20:26&token=9941ed0bc138c12c6edc4b1ed8358bd4516b86f2&incoming=0&outgoing=0&gw_id=123456789 HTTP/1.0  
  2. User-Agent: WiFiDog 20090925  
  3. Host: 192.168.0.142  
  4. ]  
  5. (centralserver.c:117) Reading response  
  6. (centralserver.c:144) Read 256 bytes, total now 256  
  7. (centralserver.c:164) HTTP Response from Server: [HTTP/1.0 200 OK  
  8. Date: Tue, 10 Jun 2014 09:32:48 GMT  
  9. Server: Apache/2.2.15 (Fedora)  
  10. X-Powered-By: PHP/5.3.3  
  11. Set-Cookie: authpuppy=nlq9lq8pjii7hfl80oq5bg0en1; path=/  
  12. Content-Length: 7  
  13. Connection: close  
  14. Content-Type: text/html; charset=utf-8  
  15. Auth: 1]  
  16. (centralserver.c:168) Auth server returned authentication code 1  
2.3:运行wifidog的路由器更新traffic counters到authpuppy

[cpp]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. (centralserver.c:114) Sending HTTP request to auth server: [GET /authpuppy/web/auth/?stage=counters&ip=192.168.100.11&mac=90:7a:28:01:20:26&token=9941ed0bc138c12c6edc4b1ed8358bd4516b86f2&incoming=1161884&outgoing=81646&gw_id=123456789 HTTP/1.0  
  2. User-Agent: WiFiDog 20090925  
  3. Host: 192.168.0.142  
  4. ]  
  5.   
  6. (centralserver.c:117) Reading response  
  7. (centralserver.c:144) Read 256 bytes, total now 256  
  8. (centralserver.c:164) HTTP Response from Server: [HTTP/1.0 200 OK  
  9. Date: Tue, 10 Jun 2014 09:33:06 GMT  
  10. Server: Apache/2.2.15 (Fedora)  
  11. X-Powered-By: PHP/5.3.3  
  12. Set-Cookie: authpuppy=6oclp4cvltb8g43c68vuqv7k40; path=/  
  13. Content-Length: 7  
  14. Connection: close  
  15. Content-Type: text/html; charset=utf-8  
  16. Auth: 1]  
  17. (centralserver.c:168) Auth server returned authentication code 1     
2.4:用户超时下线

[cpp]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. (centralserver.c:114) Sending HTTP request to auth server: [GET /authpuppy/web/auth/?stage=logout&ip=192.168.100.11&mac=90:7a:28:01:20:26&token=9941ed0bc138c12c6edc4b1ed8358bd4516b86f2&incoming=0&outgoing=0&gw_id=123456789 HTTP/1.0  
  2. User-Agent: WiFiDog 20090925  
  3. Host: 192.168.0.142  
  4. ]  
  5. (centralserver.c:117) Reading response  
  6. (centralserver.c:144) Read 256 bytes, total now 256  
  7. (centralserver.c:164) HTTP Response from Server: [HTTP/1.0 200 OK  
  8. Date: Tue, 10 Jun 2014 09:57:07 GMT  
  9. Server: Apache/2.2.15 (Fedora)  
  10. X-Powered-By: PHP/5.3.3  
  11. Set-Cookie: authpuppy=hqo5uln8f2f8254sc2lrkjt3m2; path=/  
  12. Content-Length: 7  
  13. Connection: close  
  14. Content-Type: text/html; charset=utf-8  
  15. Auth: 0]  
  16. (centralserver.c:168) Auth server returned authentication code 0  

3:wifidog代码主要函数执行顺序

http_send_redirect_to_auth()函数是WiFidog路由器发送数据给用户的接口。

l流程1:httpdGetConnection()-->thread_httpd()-->httpdReadRequest()-->httpdProcessRequest()-->http_callback_404()-->http_send_redirect_to_auth()

流程2:httpdGetConnection()-->thread_httpd()-->httpdReadRequest()-->httpdProcessRequest()-->http_callback_auth-->

authenticate_client()-->auth_server_request(&auth_response, REQUEST_TYPE_LOGIN, r->clientAddr, mac, token, 0, 0)-->fw_allow()-->iptables_fw_access()-->iptables_do_command()--->http_send_redirect_to_auth(r, urlFragment, "Redirect to portal");

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值