我想在受强制门户保护的 wifi 网络上连接一个基于 ESP8266 的传感器(我没有其他选择,我不能要求减损)。我有一个登录名/密码来连接。
在一台基本的计算机上,当我连接到网络并发出 Internet 请求时(例如,我在 google 上搜索“bl”),我得到一个这样的页面:https://url:1003/fgtauth?12291a0aff04200a
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
...
</style>
<body>
<div class="oc">
<div class="ic">
<form action="/" method="post">
<input type="hidden" name="4Tredir" value= "https://www.google.com/search?q=test&ie=utf-8&oe=utf-8">
<input type="hidden" name="magic" value="12291a0aff04200a">
<input type="hidden" name="answer" value="0">
<h1 class="logo">
GENERAL CONDITIONS
</h1>
<p>
I. OBJET <br /> <br />
Some blabla..
</p>
<h2>
Do you agree to the above terms?
</h2>
<div class="fec">
<input type="submit" value= "Yes, I agree" onclick="sb('1')">
<input type="submit" value= "No, I decline" onclick="sb('0')">
</div>
</form>
</div>
</div>
<script>
function sb(val) {
document.forms[0].answer.value = val;
document.forms[0].submit();
}
</script>
</body>
</html>
所以,我们在这个页面中看到我们得到了一个“神奇的值”,它实际上是会话的一个 id。当我点击同意按钮时,我得到这个页面https://url:1003/:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
...
</style>
<title>
Firewall Authentication
</title>
</head>
<body>
<div class="oc">
<div class="ic">
<form action="/" method="post">
<input type="hidden" name="4Tredir" value= "https://www.google.com/search?q=bl&ie=utf-8&oe=utf-8">
<input type="hidden" name="magic" value="122713150676bec1">
<h1 class="logo">
Authentication Required
</h1>
<h2>
Please enter your username and password to continue.
</h2>
<div class="fer">
<label for="ft_un">
Username:
</label>
<input name="username" id="ft_un" style="width:245px">
<br>
</div>
<div class="fer">
<label for="ft_pd">
Password:
</label>
<input name="password" id="ft_pd" type="password" style="width:245px">
</div>
<div class="fer">
<input type="submit" value= "Continue">
</div>
</form>
</div>
</div>
</body>
</html>
在这里,我填写用户名和密码,它会将它们发送到返回空白页面的服务器,并返回 OK。
所以,我想从 ESP8266 做这一步。我分两步看到:
- 请求页面
- 得到结果并存储魔法
- 伪造“同意”请求页面
- 伪造一个“user/id/magic”请求页面
ESP8266 请求页面的示例可以在这里找到: https ://github.com/iobridge/ThingSpeak-Arduino-Examples/blob/master/Ethernet/Arduino_to_ThingSpeak.ino 我们在这里看到,我们可以发送 POST 请求:
client.print("POST /update HTTP/1.1\n");
这里有一个解析页面的好例子:http: //blog.nyl.io/esp8266-led-arduino/
所以,我可能会这样做并发布答案,但首先我需要一些关于如何创建上述“假”请求的线索。
有任何想法吗 ?