2

我想使用 wget 重新启动我的 Fritz!Box 7390。网络界面有一个重启表单,如下所示:

<form action="/system/reboot.lua" method="POST">
<div id="btn_form_foot">
<input type="hidden" name="sid" value="beb5683181c2ab9f">
<button type="submit" name="reboot">Neu starten</button>
</div>
</form>

我想提交这个表格。到目前为止,我像这样尝试过,但它似乎不起作用:

wget --post-data "sid=beb5683181c2ab9f" "http://fritz.box/system/reboot.lua"

每次我加载页面时,sid 似乎都会发生变化。

但我不确定这是否是问题所在,因为我可以通过将 ?sid=example 添加到 url 来修复 sid

4

2 回答 2

2

您不能只发布到该网址。您首先需要获得一个有效的会话 ID。这可以通过执行 GET 请求http://fritz.box/checklogin.lua并从LOCATION标头值中获取来完成。然后您可以使用它发布到http://fritz.box/system/reboot.lua包括会话ID。

以下是自动化它的最小步骤:

SID=$(curl -s -I "http://fritz.box/logincheck.lua" | grep -Fi Location | awk -F'[=]' '{print $2}')
SID=$(curl -s -i -H "Content-Type: application/x-www-form-urlencoded" -H "Origin: http://fritz.box" -H "Referer: http://fritz.box/system/reboot.lua\?sid\=$SID" --data "reboot=&sid=$SID" -L http://fritz.box/system/reboot.lua | grep -Fi Location | awk -F'[=]' '{print $2}')
curl -s http://fritz.box/reboot.lua?ajax=1&sid=$REBOOT_SID

我创建了一个带有一些额外检查的小脚本,您可以在此处找到您可以在此处找到完整的脚本,包括检查:http: //git.io/v3zQs

于 2015-08-12T16:21:48.333 回答
0

建议当前软件(v7.20+)的步骤是什么?
最好用于受密码保护的路由器。

我尝试使用 Chrome 开发工具信息更新它以使用最近的路径。
它给出了一个状态码200和响应:{"reboot_state":"extern"}
但是没有重启。

Chrome 开发者工具说按下RestartUI 中的按钮时的 url 是:

curl 'http://fritz.box/reboot.lua' \
  -H 'Connection: keep-alive' \
  -H 'Pragma: no-cache' \
  -H 'Cache-Control: no-cache' \
  -H 'User-Agent: Mozilla/5.0 (...) Chrome/86.0.4240.111 Safari/537.36' \
  -H 'DNT: 1' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -H 'Accept: */*' \
  -H 'Origin: http://fritz.box' \
  -H 'Referer: http://fritz.box/' \
  -H 'Accept-Language: en,en-US;q=0.9,nl;q=0.8,de;q=0.7,la;q=0.6' \
  --data-raw 'ajax=1&sid=1fd4370b50b14b07&no_sidrenew=1&xhr=1&useajax=1' \
  --compressed \
  --insecure

sid每次登录后明显变化)

于 2020-10-26T10:54:54.060 回答