跳转至

小米AX1800实现科学上网

参考文档:https://zhaohongxuan.github.io/2023/12/17/xiaomi-ax1800-shellclash/

一、开启ssh并设置root密码

JavaScript 脚本复制到浏览器控制台,回车执行:

JavaScript
function getSTOK() {
    let match = location.href.match(/;stok=(.*?)\//);
    if (!match) {
        return null;
    }
    return match[1];
}

function execute(stok, command) {
    command = encodeURIComponent(command);
    let path = `/cgi-bin/luci/;stok=${stok}/api/misystem/set_config_iotdev?bssid=SteelyWing&user_id=SteelyWing&ssid=-h%0A${command}%0A`;
    console.log(path);
    return fetch(new Request(location.origin + path));
}

function enableSSH() {
    let stok = getSTOK();
    if (!stok) {
        console.error('stok not found in URL');
        return;
    }
    console.log(`stok = "${stok}"`);

    let password = prompt('Input new SSH password');
    if (!password) {
        console.error('You must input password');
        return;
    }

    let cmd = `
        nvram set ssh_en=1
        nvram commit
        sed -i 's/channel=.*/channel="debug"/g' /etc/init.d/dropbear
        /etc/init.d/dropbear enable
        /etc/init.d/dropbear restart
        echo -e "${password}\\n${password}" | passwd root
    `;

    execute(stok, cmd)
        .then((res) => res.text())
        .then(console.log);

    console.log('New SSH password: ' + password);
}

enableSSH();

在弹出框中填入ssh root账号的密码,这里设置为admin

img

打开CMD执行,连接小米路由

Text Only
ssh -oHostKeyAlgorithms=+ssh-rsa root@192.168.1.16

image-20250517231642056