如何在不使用浏览器的情况下对无线提供商的“开放”网络进行身份验证?

Oct*_*pus 15 wifi wpa-supplicant

这种设置在购物中心和机场似乎很常见。在加拿大西部,Shaw 提供了这样的服务,并将其称为“Shaw Open”。我很确定其他地区也有来自 T-Mobile 等提供商的类似服务。

从手机之类的东西做起来并不复杂。连接到 wifi 热点不需要身份验证,因为它是“开放的”供公众访问。但是,在我使用浏览器并登录 ISP 提供的特定网页之前,我的手机无法通过应用程序连接到网站或远程服务。

我的问题简单地说是:如何从通常没有传统浏览器的设备自动执行身份验证步骤?

在我的特殊情况下,我有一个配置了软件的树莓派,我想在贸易展览等上使用。这些位置具有相同类型的“开放”热点。Raspi 是自给自足的。它只是做自己的生意并与网站交谈。但是这个出站连接被 ISP 的“开放”连接阻止了,因为我没有,也无法完成该过程的浏览器部分。

假设我拥有在特定提供商网络上执行此操作的凭据,如何在不需要我打开与 Pi 的终端会话的情况下自动执行该部分流程? 这里甚至使用了什么样的技术,我可以搜索?

slm*_*slm 13

解决此类问题的关键是知道如何提出问题。我在谷歌上搜索“如何访问 panera 面包 wifi”并打开了这个宝石。

本文有几个脚本可用于促进自动登录。我选择包含利用 Python 的 Mechanize 库的 Panera Bread 示例。

该解决方案利用NetworkManager 的dispatcher.d目录在特定网络接口启动或关闭时随时运行脚本。该文章详细介绍了一个脚本,你会在这个目录下放置,/etc/NetworkManager/dispatch.d叫做07-autologin_openwifi。这是那个脚本:

#!/bin/bash
#------------------------------
# By Fahad Alduraibi
# Last update: June 12, 2012
# Version: 1.1
#------------------------------

export LC_ALL=C
LogFile="/var/log/07-WIFI_ACCESS.log"

# The parameters that get passed to the script are:
# $1 = The interface name ( eth0, wlan0 ...etc)
# $2 = Interface status ( "up" or "down" )

# Check if wireless status is up
# I have two wifi cards in my laptop, named "wlan0 and wlan1"
# so I use regular expression "wlan[01]" to match both of them.
if [[ "$1" =~ wlan[01] && $2 == "up" ]]; then

    # Get the network name from "iwconfig" or (can also locate the network based on IP or MAC address if needed)
    ESSID=$(/sbin/iwconfig $1 | grep ESSID | cut -d'"' -f2)

    # Record the date and time for debugging purposes only
    echo "[`date`] ESSID=($ESSID)" >> $LogFile

    # If the wireless name matches then run its python script
    if [[ "$ESSID" == "BCPL-PUBLIC-WIFI" ]]; then
        /usr/bin/python /myscripts/baltimore-county_library_wifi.py 1>> $LogFile 2>&1
    elif [[ "$ESSID" == "PANERA" ]]; then
        /usr/bin/python /myscripts/panera.py 1>> $LogFile 2>&1
    elif [[ "$ESSID" == "Nordstrom_Wi-Fi" ]]; then
        /usr/bin/python /myscripts/nordstrom.py 1>> $LogFile 2>&1
    #elif .... (you can add more open wifi here)

    fi
fi

#if [[ "$1" =~ wlan[01] && $2 == "down" ]]; then
    ##If you want to do somehting when the network is down
#fi
Run Code Online (Sandbox Code Playgroud)

这是 Panera 面包脚本,panera.py

#------------------------------
# By Fahad Alduraibi
# Last update: June 12, 2012
# Version: 1.1
#------------------------------
import mechanize
import sys

br = mechanize.Browser()
br.set_handle_equiv(True)
#br.set_handle_gzip(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)
br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20100101 Firefox/13.0')]

testURL = 'http://fadvisor.net/blog/'
response = br.open(testURL)

if response.geturl() == testURL:
  print "FAD: You are already logged in to Panera."
  sys.exit()

try:
  forms = mechanize.ParseResponse(response, backwards_compat=False)
except:
  print "FAD: Error in parsing forms, Am I already logged in to Panera?"
  sys.exit()

response.close

form = forms[0]
#print form
#print "----------------------------------- Login"
request = form.click()
response = mechanize.urlopen(request)
forms = mechanize.ParseResponse(response, backwards_compat=False)
response.close()

form = forms[0]
#print form
#print "----------------------------------- Validate"
#print
request = form.click()
response = mechanize.urlopen(request)
forms = mechanize.ParseResponse(response, backwards_compat=False)
response.close()

form = forms[0]
#print form
#print "----------------------------------- ConfirmLogin New"
#print
request = form.click()
response = mechanize.urlopen(request)
forms = mechanize.ParseResponse(response, backwards_compat=False)
response.close()

form = forms[0]
#print form
#print "----------------------------------- ConfirmLogin Validate"
#print
request = form.click()
response = mechanize.urlopen(request)
forms = mechanize.ParseResponse(response, backwards_compat=False)
response.close()

form = forms[0]
#print form
#print "----------------------------------- CompleteLogin New"
#print

request = form.click()
response = mechanize.urlopen(request)
forms = mechanize.ParseResponse(response, backwards_compat=False)
response.close()

form = forms[0]
#print form
#print "----------------------------------- HttpLoginRequest"
#print

request = form.click()
response = br.open(request)
#print response.read()

response.close()
print "--- Panera Done ---"
Run Code Online (Sandbox Code Playgroud)

如果您对自动登录的其他方法感兴趣,我鼓励您阅读整篇文章。这篇文章有几个其他开放的 WiFi 网络,这些网络是为马里兰州巴尔的摩地区编写的脚本。


Dav*_*ins 1

根据身份验证的实施方式,您也许能够发送 HTTP 请求来获取访问权限。但这取决于特定实现的许多方面。

请记住,这些类型的身份验证是为了阻止自治系统进入,同时只允许浏览器访问,这正是您想要规避的。

理想情况下,您将拥有一部可以设置为 WiFi 热点的手机,并将您的 Pi 连接到该网络,这样您就可以做任何您想做的事情,但这不是免费的。

TL;DR:乞丐不能挑剔