解锁SSH
刷入低版本固件
登录AX3600路由器后台查看固件版本号,依次点击 常用设置→系统状态 在系统版本一栏中查看当前的系统版本
当前版本1.1.25,正在检测更新,请稍候...
检查系统版本是否为 1.0.17,如果不是则点击手动升级,上传 miwifi-ax3600-1.0.17.bin,将路由器固件版本刷至 1.0.17(不勾选清除当前所有用户配置)。升级过程大约需要5-8分钟,路由器指示灯重新变蓝后,可以通过miwifi.com进入管理后台,查看系统版本号,确认版本号为 1.0.17
当前版本1.0.17,正在检测更新,请稍候...
解锁SSH
运行 run.bat 脚本,成功运行后会出现以下内容。小米路由器默认的后台IP为 192.168.31.1,直接按回车进入下一步。如果有修改过后台IP请输入对应的IP
==================================================
Xiaomi Router SSH Enable Tool
==================================================
Enter Router IP [Default: 192.168.31.1]:
接着会出现 Enter STOK (You can paste the entire URL from browser): 在浏览器中打开路由器后台并登录,待页面跳转到路由器首页后,复制当前页面的网址(http://192.168.31.1/cgi-bin/luci/;stok=7570a4836daf4b30b39709320585d509/web/home#router),回到命令窗口按鼠标右键进行粘贴。脚本会自动启用SSH端口并重置登录密码。运行成功后结果如下
==================================================
Xiaomi Router SSH Enable Tool
==================================================
Enter Router IP [Default: 192.168.31.1]:
Enter STOK (You can paste the entire URL from browser): http://192.168.31.1/cgi-bin/luci/;stok=7570a4836daf4b30b39709320585d509/web/home#router
Extracted STOK: 7570a4836daf4b30b39709320585d509
[1/2] Sending exploit to enable SSH port...
[Success] SSH port enabled.
[2/2] Changing SSH password to 'admin'...
[Success] SSH password set to 'admin'.
==================================================
Success! SSH is now enabled.
IP: 192.168.31.1
User: root
Password: admin
==================================================
Press Enter to exit...:
连接SSH
使用SSH工具(MobaXterm、finalshell等)对路由器进行SSH连接,这里以 MobaXterm 为例,打开软件后点击左上角的 新建会话→SSH,远程主机输入路由器IP:192.168.31.1 ,用户名:root,点击确定,首次连接会弹出身份认证,接受即可。终端中出现 [email protected]'s password: 时输入密码,密码不会显示,直接输入后按回车即可。成功连接后显示如下内容
[email protected]'s password:
┌──────────────────────────────────────────────────────────────────────┐
│ • MobaXterm Professional Edition v26.3 • │
│ (SSH client, X server and network tools) │
│ │
│ ⮞ SSH session to [email protected] │
│ • Direct SSH : ✓ │
│ • SSH compression : ✗ (disabled or not supported by server) │
│ • SSH-browser : ✓ │
│ • X11-forwarding : ✓ (remote display is forwarded through SSH) │
│ │
│ ⮞ For more info, ctrl+click on help or visit our website. │
└──────────────────────────────────────────────────────────────────────┘
sh: /usr/bin/xauth: not found
BusyBox v1.25.1 (2020-02-19 10:57:26 UTC) built-in shell (ash)
-----------------------------------------------------
Welcome to XiaoQiang!
-----------------------------------------------------
$$$$$$\ $$$$$$$\ $$$$$$$$\ $$\ $$\ $$$$$$\ $$\ $$\
$$ __$$\ $$ __$$\ $$ _____| $$ | $$ | $$ __$$\ $$ | $$ |
$$ / $$ |$$ | $$ |$$ | $$ | $$ | $$ / $$ |$$ |$$ /
$$$$$$$$ |$$$$$$$ |$$$$$\ $$ | $$ | $$ | $$ |$$$$$ /
$$ __$$ |$$ __$$< $$ __| $$ | $$ | $$ | $$ |$$ $$<
$$ | $$ |$$ | $$ |$$ | $$ | $$ | $$ | $$ |$$ |\$$\
$$ | $$ |$$ | $$ |$$$$$$$$\ $$$$$$$$$ | $$$$$$ |$$ | \$$\
\__| \__|\__| \__|\________| \_________/ \______/ \__| \__|
root@XiaoQiang:~#
刷入U-Boot
备份mtd9分区
mtd9 分区包含了路由器的出厂校验信息、MAC 地址等核心数据,先进行备份,防止出现意外情况时能够恢复,在当前 SSH 窗口中运行以下命令进行备份:
mkdir /tmp/syslogbackup/
dd if=/dev/mtd9 of=/tmp/syslogbackup/mtd9
保持 SSH 连接,在电脑浏览器中访问:http://192.168.31.1/backup/log/mtd9 即可将备份下载到电脑本地。请妥善保存此文件!
刷入 QSDK 临时过渡固件
修改启动环境变量,在SSH终端中依次输入以下命令
nvram set flag_last_success=0
nvram set flag_boot_rootfs=0
nvram set boot_wait=on
nvram set uart_en=1
nvram set telnet_en=1
nvram set ssh_en=1
nvram commit
在 MobaXterm 左侧文件管理器中找到 tmp 目录或直接路径栏输入 /tmp/ 进入tmp目录中,将 xiaomimtd12.bin 拖动上传到tmp目录中。接着执行写入临时固件命令:
mtd write /tmp/xiaomimtd12.bin rootfs
刷写完成后不要使用 reboot 命令重启路由器,直接拔掉路由器电源线,等待 5 秒后重新插上电源。
root@XiaoQiang:~# nvram set flag_last_success=0
root@XiaoQiang:~# nvram set flag_boot_rootfs=0
root@XiaoQiang:~# nvram set boot_wait=on
root@XiaoQiang:~# nvram set uart_en=1
root@XiaoQiang:~# nvram set telnet_en=1
root@XiaoQiang:~# nvram set ssh_en=1
root@XiaoQiang:~# nvram commit
root@XiaoQiang:~# mtd write /tmp/xiaomimtd12.bin rootfs
Unlocking rootfs ...
Writing from /tmp/xiaomimtd12.bin to rootfs ...
root@XiaoQiang:~#
在临时固件中刷写U-Boot和大分区表
重启后路由器的IP会变为 192.168.1.1,打开 MobaXterm ,在左上角的 新建会话→SSH,远程主机输入IP:192.168.1.1 ,用户名:root,点击确定,首次连接会弹出身份认证,接受即可。成功连接后终端出现以下内容
┌──────────────────────────────────────────────────────────────────────┐
│ • MobaXterm Professional Edition v26.3 • │
│ (SSH client, X server and network tools) │
│ │
│ ⮞ SSH session to [email protected] │
│ • Direct SSH : ✓ │
│ • SSH compression : ✗ (disabled or not supported by server) │
│ • SSH-browser : ✓ │
│ • X11-forwarding : ✓ (remote display is forwarded through SSH) │
│ │
│ ⮞ For more info, ctrl+click on help or visit our website. │
└──────────────────────────────────────────────────────────────────────┘
sh: /usr/bin/xauth: not found
BusyBox v1.28.3 () built-in shell (ash)
MM NM MMMMMMM M M
$MMMMM MMMMM MMMMMMMMMMM MMM MMM
MMMMMMMM MM MMMMM. MMMMM:MMMMMM: MMMM MMMMM
MMMM= MMMMMM MMM MMMM MMMMM MMMM MMMMMM MMMM MMMMM'
MMMM= MMMMM MMMM MM MMMMM MMMM MMMM MMMMNMMMMM
MMMM= MMMM MMMMM MMMMM MMMM MMMM MMMMMMMM
MMMM= MMMM MMMMMM MMMMM MMMM MMMM MMMMMMMMM
MMMM= MMMM MMMMM, NMMMMMMMM MMMM MMMM MMMMMMMMMMM
MMMM= MMMM MMMMMM MMMMMMMM MMMM MMMM MMMM MMMMMM
MMMM= MMMM MM MMMM MMMM MMMM MMMM MMMM MMMM
MMMM$ ,MMMMM MMMMM MMMM MMM MMMM MMMMM MMMM MMMM
MMMMMMM: MMMMMMM M MMMMMMMMMMMM MMMMMMM MMMMMMM
MMMMMM MMMMN M MMMMMMMMM MMMM MMMM
MMMM M MMMMMMM M M
M
---------------------------------------------------------------
For those about to rock... (Chaos Calmer, unknown)
---------------------------------------------------------------
root@OpenWrt:~#
在 MobaXterm 左侧文件管理器中找到 tmp 目录或直接路径栏输入 /tmp/ 进入tmp目录中,上传 ax3600-mibib.bin 和 uboot-xiaomi-ax3600.bin 文件到 tmp 目录中。在SSH终端中依次执行以下命令:
# 1. 刷写大分区表
mtd erase /dev/mtd1
mtd write /tmp/ax3600-mibib.bin /dev/mtd1
# 2. 刷写不锁死 U-Boot
mtd erase /dev/mtd7
mtd write /tmp/uboot-xiaomi-ax3600.bin /dev/mtd7
注意:如果报错提示找不到 mtd1 或 mtd7,先运行 cat /proc/mtd 查看分区表是否一致,确认无误再操作。
全部提示成功后,再次直接拔掉路由器电源线,不要在命令行重启。
root@OpenWrt:~# mtd erase /dev/mtd1
Unlocking /dev/mtd1 ...
Erasing /dev/mtd1 ...
root@OpenWrt:~# mtd write /tmp/ax3600-mibib.bin /dev/mtd1
Unlocking /dev/mtd1 ...
Writing from /tmp/ax3600-mibib.bin to /dev/mtd1 ...
root@OpenWrt:~# mtd erase /dev/mtd7
Unlocking /dev/mtd7 ...
Erasing /dev/mtd7 ...
root@OpenWrt:~# mtd write /tmp/uboot-xiaomi-ax3600.bin /dev/mtd7
Unlocking /dev/mtd7 ...
Writing from /tmp/uboot-xiaomi-ax3600.bin to /dev/mtd7 ...
root@OpenWrt:~#
刷入 OpenWrt 固件
注:Uboot只支持factory固件的刷入!
双击 ip_switcher.bat 然后输入 1,脚本会将电脑的网卡IP地址更改为如下固定IP
注:需确保电脑只有一个有线设备连接,防止脚本修改错有线网口造成无法进入路由器
IP 地址:192.168.1.111
子网掩码:255.255.255.0
默认网关:192.168.1.1
设置好固定IP后用网线连接电脑和路由器的LAN口(路由器上蓝色或第一个口为WAN口,其余为LAN口),在路由器不插电的情况下,按住路由器背面的 Reset(重置)键。 插上电源线,同时手不要松开 Reset 键,持续按住约 10 秒(直到看到灯光颜色发生变化,比如橙灯常亮或闪烁)后松开。
打开电脑浏览器,输入 192.168.1.1 并回车,此时会进入 U-Boot 恢复页面。在页面中选择你要刷写的 大分区版 OpenWrt 固件(通常是 .ubi 格式或带有 factory 字样的包),上传固件后点击 Update firmware 开始刷写。
等待浏览器提示刷写完成,且路由器自动重启(指示灯恢复正常)。双击 ip_switcher.bat 然后输入 2 将电脑的网卡 IP 重新改回 “自动获取 IP 地址 (DHCP)”。
浏览器输入 OpenWrt 固件的默认后台 IP(一般是 192.168.1.1 或 192.168.5.1,具体取决于你下载的固件说明),即可进入全新的 OpenWrt 系统。