Code Monkey home page Code Monkey logo

xiaomi-router-4a-gigabit-openwrt's Introduction

小米路由器 4a 千兆版刷 OpenWRT

须知:本方案仅支持小米路由器 4a 千兆版 v1 版,即固件版本为2.28.x的小米路由器 4a 千兆版路由器

刷机思路

根据小米路由器 4a 千兆版 2.28.62 版本固件中的配置备份/恢复漏洞获取 RootShell,在 RootShell 中刷入 OpenWRT

工具准备

  • 网线一条

  • linux 电脑一台

    本文以 manjaro 系统为例

环境准备

  1. 安装 Git

    pacman -Sy git

  2. 安装 Python3

    pacman -Sy python3

  3. 克隆项目代码

    git clone https://github.com/devcxl/R4AG-OpenWRT.git

  4. 进入 R4AG-OpenWRT 目录创建 Python venv 环境

    cd R4AG-OpenWRT && python3 -m venv .env && source .env/bin/activate

  5. 安装依赖

    pip3 install -r requirements.txt

固件降级

在小米 wifi 后台手动更改固件为项目目录中的

firmwares/miwifi_r4a_firmware_72d65_2.28.62.bin固件

开始刷机

  1. 启动新终端启动本地 http 服务器

    uvicorn main:app --host 0.0.0.0 --port 8000

  2. 获取本机内网 IP

    ifconfig

    192.168.31.123为例

  3. 修改files文件夹中的 script.shspeedtest_urls.xml将文件中的 ip 替换为本机内网 IP

    sed -i 's/192.168.31.123:8000/192.168.31.115:8000/g' files/script.sh

    sed -i 's/192.168.31.123:8000/192.168.31.115:8000/g' files/speedtest_urls.xml

  4. 登陆路由器后台获取stok

    地址栏中的链接示例 stok6cb7bf8731d8ffcd4e0d71d752178a0e

    http://miwifi.com/cgi-bin/luci/;stok=6cb7bf8731d8ffcd4e0d71d752178a0e/

  5. 修改run.py脚本中的stok值为当前stok

  6. 运行run.py

    python3 run.py

  7. 当执行uvicorn main:app --host 0.0.0.0 --port 8000的终端出现以下内容时,RootShell 获取成功

    INFO:     192.168.31.1:42678 - "GET /ping HTTP/1.1" 200 OK
    INFO:     192.168.31.1:34062 - "GET /files/busybox-mipsel HTTP/1.1" 200 OK
    INFO:     192.168.31.1:44882 - "GET /files/dropbearStaticMipsel.tar.bz2 HTTP/1.1" 200 OK
    
  8. 此时可以使用telnet命令连接路由器

    telnet 192.168.31.1

    • 账号 root
    • 密码 root
  9. 下载OpenWRT镜像

    cd /tmp && curl -L http://192.168.31.123:8000/files/openwrt-22.03.5-ramips-mt7621-xiaomi_mi-router-4a-gigabit-squashfs-sysupgrade.bin --output firmware.bin

  10. 刷入镜像

    mtd -e OS1 -r write firmware.bin OS1

  11. 等待路由器重启后,使用网线连接路由器

    • 使用OpenSSH连接192.168.1.1

      ssh [email protected]

    • ssh连接成功即OpenWRT刷入成功

OpenWRT配置

  1. 更换软件镜像源

    • sed -i 's/downloads.openwrt.org/mirrors.ustc.edu.cn\/openwrt/g' /etc/opkg/distfeeds.conf
    • opkg update
  2. 安装汉化/美化主题

    • opkg install luci-i18n-base-zh-cn luci-theme-material
  3. 开启wifi

    • todo
  4. 安装wireguard组网

    • todo

参考文档

xiaomi-router-4a-gigabit-openwrt's People

Contributors

devcxl avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

ilch10n9

xiaomi-router-4a-gigabit-openwrt's Issues

运行run.py文件报错

root@yoko-To-Be-Filled-By-O-E-M:~# python3 '/4A/R4AG-OpenWRT/run.py'
Traceback (most recent call last):
File "/4A/R4AG-OpenWRT/run.py", line 8, in
with tarfile.open("build/2023-09-02--21 51 04.tar.gz", "w:gz") as tar:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/tarfile.py", line 1822, in open
return func(name, filemode, fileobj, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/tarfile.py", line 1870, in gzopen
fileobj = GzipFile(name, mode + "b", compresslevel, fileobj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/gzip.py", line 192, in init
fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'build/2023-09-02--21 51 04.tar.gz'
这文件有啥用啊?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.