我正在使用一个嵌入式 Linux 设备(即没有显示器)。我可以连接到酒店 Wifi(没有密码)并获取 IP 地址:
# ifconfig wlan0
wlan0 Link encap:Ethernet HWaddr REMOVED
inet addr:172.20.2.27 Bcast:172.20.15.255 Mask:255.255.240.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:13 errors:0 dropped:2 overruns:0 frame:0
TX packets:34 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1587 (1.5 KiB) TX bytes:6356 (6.2 KiB)
但ping 8.8.8.8
不起作用。该设备在其他 Wifi 网络上运行良好。
答案1
无密码的酒店 Wifi 通常使用某种转发,这在我的笔记本电脑和手机上运行良好(如果没有,您可以使用http://neverssl.com/触发登录屏幕)。但在无头设备上我无法做到这一点。
我尝试了curl -L google.com
(-L
打开重定向的地方)并得到:
<HEAD><TITLE>Redirecting...</TITLE>
<meta http-equiv="no-cache">
<meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
</HEAD><BODY>
<SPAN STYLE="font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 11px;">
</SPAN>
<SCRIPT LANGUAGE="JavaScript">
document.location.href="https://dalan.cust.blueprintrf.com:8001/index.php?zone=guest&redirurl=https%3A%2F%2Fgoogle.com%2F";
</SCRIPT>
</BODY>
</HTML>
看着https://dalan.cust.blueprintrf.com:8001/index.php?zone=guest&redirurl=https%3A%2F%2Fgoogle.com%2F在我的笔记本电脑上,以隐身模式转到另一个页面,其中包含我需要的弹出窗口:
如果我右键单击 Inspect(在 Chrome 上),我可以看到此按钮是使用一堆预设变量执行 POST 的表单的一部分:
<form name="form-lower-plan" class="js-form-sign-in" action="https://dalan.cust.blueprintrf.com:8001" method="post" novalidate="">
<div class="l-center-align l-margin-bottom-five-quarters l-padding-five-quarters t-bg-standard-30">
<p class="t-font-weight-semibold t-font-l t-line-height-xxxl l-margin-top-none l-margin-subsection-bottom-small"> Internet </p>
<div class="l-margin-subsection-bottom-small">
<p class="l-margin-none t-font-s">Free for everyone</p>
<p class="l-margin-none t-font-s">Best for: email, web browsing</p>
</div>
</div>
<div class="l-margin-bottom-five-quarters ">
<input type="hidden" name="MAC_ADDRESS" value="REMOVED">
<input type="hidden" name="AUTO_AUTH_STATUS" value="NEW">
<div class="l-form-group">
<input id="id-remember-device-free-plan" type="checkbox" name="REMEMBER_THIS_DEVICE" value="TRUE">
<label for="id-remember-device-free-plan" class="t-label-standard-100 l-margin-none"> Connect with one click at future stays </label>
</div> <p class="t-font-xs t-line-height-xs l-margin-top-five-quarters">Connect faster whenever a free connection is available. Sign in to your Marriott Bonvoy account on the next screen to automatically receive free internet during your stays.</p>
</div>
<input type="hidden" name="AUTH_ON_FREE" value="FALSE">
<input type="hidden" name="ROOM_NUMBER" value="">
<input type="hidden" name="LAST_NAME" value="">
<input type="hidden" name="CURRENCY" value="USD">
<input type="hidden" name="PROPERTY_CODE" value="DALAN">
<input type="hidden" name="iZONE" value="GUEST">
<input type="hidden" name="iRELEASE" value="4">
<input type="hidden" name="OTHER_PLAN" value="P_PLAN2">
<input type="hidden" name="OTHER_PLAN_PRICE" value="4.95">
<input type="hidden" name="SELECTED_PLAN" value="P_PLAN1">
<input type="hidden" name="SELECTED_PLAN_PRICE" value="0.00">
<input type="hidden" name="SELECTED_PLAN_TEXT" value="Internet Services">
<input type="hidden" name="DURATION" value="7">
<div class="l-center-align ">
<button class="m-button m-button-primary l-padding-left-seven-quarters l-padding-right-seven-quarters l-padding-top-three-quarters l-padding-bottom-three-quarters" type="submit">Connect Now</button>
</div>
</form>
由此我可以看出:
- 这是一个帖子。
- URL 是https://dalan.cust.blueprintrf.com:8001
- 有很多参数设置为默认值。
我用它来调用curl中的表单:
curl -L -d "AUTH_ON_FREE=FALSE&ROOM_NUMBER=&LAST_NAME=&CURRENCY=USD&PROPERTY_CODE=DALAN&iZONE=GUEST&iRELEASE=4&OTHER_PLAN=P_PLAN2&OTHER_PLAN_PRICE=4.95&SELECTED_PLAN=P_PLAN1&SELECTED_PLAN_PRICE=0.00&SELECTED_PLAN_TEXT=Internet Services&DURATION=7" -X POST https://dalan.cust.blueprintrf.com:8001
返回:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<HTML>
<HEAD><TITLE>Redirecting...</TITLE>
<meta http-equiv="no-cache">
<meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
</HEAD><BODY>
<SPAN STYLE="font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 11px;">
</SPAN>
<SCRIPT LANGUAGE="JavaScript">
document.location.href="https://www.marriott.com/hotels/einterface/DALAN?MAC_ADDRESS=REMOVED&REMEMBER_THIS_DEVICE=&AUTO_AUTH_STATUS=&OTHER_PLAN=P_PLAN2&iRELEASE=4&iZONE=GUEST&CURRENCY=USD&SELECTED_PLAN_PRICE=0.00&DURATION=7&SELECTED_PLAN=P_PLAN1&AUTH_ON_FREE=FALSE&ACTION_TYPE=FREE&LSP_URL=dalan.cust.blueprintrf.com:8001&OTHER_PLAN=P_PLAN2";
</SCRIPT>
</BODY>
</HTML>
现在我可以 ping 通 8.8.8.8 和 google.com!