【问题标题】:wget post form to reboot routerwget 发布表单以重新启动路由器
【发布时间】:2014-09-12 09:03:04
【问题描述】:

我想使用 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

【问题讨论】:

  • 您的 wget 命令看起来正确。您可以在浏览器中启用网络检查器并尝试重新启动路由器吗?分享正在发送的数据包的详细信息。它应该揭示问题所在。
  • 如何在chrome中启用网络检查器?
  • 右击页面,选择检查元素,然后移动到网络选项卡。然后点击网页上的重置按钮

标签: wget router reboot fritzbox


【解决方案1】:

您不能只发布到该网址。您首先需要获得一个有效的会话 ID。这可以通过在http://fritz.box/checklogin.lua 上执行GET 请求并从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

【讨论】:

    【解决方案2】:

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

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

    Chrome 开发者工具显示在 UI 中按下 Restart 按钮时的 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每次登录后明显变化)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-04-13
      • 1970-01-01
      • 2015-11-24
      • 2014-09-05
      • 1970-01-01
      • 2018-02-11
      • 1970-01-01
      相关资源
      最近更新 更多