Coder Social home page Coder Social logo

xiaomi-router-patch's Introduction

Xiami Router Patch

Tested on:

I screwed up. I bought too many Xiaomi Routers: nano, mini and some other monster I don't remember. While all of them were a pleasure to setup with OpenWrt, Xiaomi decided to make it a hassle to do so with their newer devices. And here is where my problems began: the bully Xiaomi Router 3 (R3G) was on lock-down. You need to register this device on miwifi.com and override your router with a custom miwifi_ssh.bin that only allows YOU with the listed password on miwifi's website to access ssh. If that's not enough, everything is chinese.

Unlucky me the website wouldn't let me download this image because I had another device registered (Nano). So game over I thought. And then I discovered CVE-2019-18370 and created this useful script to cirvumvent the (paranoid) process and do it the friendly way so you guys can install your router os of choice (OpenWRT ftw).

Prerequisite

Getting Started

By default SSH is deactivated and the root password unknown (or determined from miwifi.com, I don't know how). BUT fear not! We're going to access the router through a known vulnerability (CVE-2019-18370) and change it to xiaomi4Life as well as start/activate dropbear (SSH).

Make sure your router is running and connected via ethernet.

# Did you read the prerequisites? If not, uncomment the lines below 
# and make sure you have python v3 installed
# pip install requests
# pip install tarfile

# Make sure your router is connected (eth) & ready
# This will activate ssh and set the root password to 'xiaomi4Life'
python3 install.py

Enabling SSH & Key-Based Authentication (optional)

In bootstrap/setup.sh you can uncomment the key-file setup and add a id_rsa.pub file into the bootstrap/ folder. And voila... the setup will work too and add your key to authorized_keys of dropbear.

New firmware

Download the newest version from: https://openwrt.org/toh/xiaomi/mir3g For me this is a openwrt-*.kernel1.bin and openwrt-*.rootfs0.bin (* omitted for brevity). Or build your own version if you're brave.

# Copy both binaries to the tmp folder
scp openwrt*.bin [email protected]:/tmp

# Log into the router
ssh [email protected]

# Install images
cd /tmp
mtd write openwrt.kernel1.bin kernel1
mtd write openwrt.rootfs0.bin rootfs0
nvram set flag_try_sys1_failed=1
nvram commit
reboot

# And after some time your router is accessible with
# and the openwrt banner will greet you
ssh [email protected]

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.