{"id":13440697,"url":"https://github.com/acecilia/OpenWRTInvasion","last_synced_at":"2025-03-20T10:32:24.552Z","repository":{"id":37395106,"uuid":"248380503","full_name":"acecilia/OpenWRTInvasion","owner":"acecilia","description":"Root shell exploit for several Xiaomi routers: 4A Gigabit, 4A 100M, 4, 4C, 3Gv2, 4Q, miWifi 3C...","archived":false,"fork":false,"pushed_at":"2023-12-10T23:27:41.000Z","size":68362,"stargazers_count":1452,"open_issues_count":15,"forks_count":257,"subscribers_count":31,"default_branch":"master","last_synced_at":"2024-07-08T20:00:49.796Z","etag":null,"topics":["4a-gigabit","firmware","miwifi-3c","openwrt","router","routers","xiaomi","xiaomi-routers"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/acecilia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-03-19T01:16:18.000Z","updated_at":"2024-07-06T07:24:31.000Z","dependencies_parsed_at":"2023-10-20T16:18:38.227Z","dependency_job_id":null,"html_url":"https://github.com/acecilia/OpenWRTInvasion","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acecilia%2FOpenWRTInvasion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acecilia%2FOpenWRTInvasion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acecilia%2FOpenWRTInvasion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acecilia%2FOpenWRTInvasion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/acecilia","download_url":"https://codeload.github.com/acecilia/OpenWRTInvasion/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":213299323,"owners_count":15566602,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["4a-gigabit","firmware","miwifi-3c","openwrt","router","routers","xiaomi","xiaomi-routers"],"created_at":"2024-07-31T03:01:25.262Z","updated_at":"2025-03-20T10:32:24.546Z","avatar_url":"https://github.com/acecilia.png","language":"Lua","funding_links":[],"categories":["HarmonyOS","Lua"],"sub_categories":["Windows Manager"],"readme":"# Root shell exploit for several Xiaomi routers: 4A Gigabit, 4A 100M, 4C, 3Gv2, 4Q, miWifi 3C...\n\n## How to run\n\n**NOTE: FROM VERSION `0.0.2` THE ROUTER NEEDS INTERNET ACCESS**. If you require to run the exploit without internet access please try version `0.0.1`. Find the versions here: https://github.com/acecilia/OpenWRTInvasion/releases\n\n**NOTE: THERE ARE REPORTED ISSUES WITH ROUTER IN AP MODE**. If you're not able to succeed in the AP mode, try to switch to some other (WiFi Repeater or Gateway)\n\n**NOTE: THERE ARE COMPATIBILITY ISSUES REPORTED WHEN USING WINDOWS**. This script only runs on Mac or Linux. If you run from Windows, please use docker (explained below)\n\n### Using Docker (also works on Windows)\n\n```console\ndocker build -t openwrtinvasion https://github.com/acecilia/OpenWRTInvasion.git\ndocker run --network host -it openwrtinvasion\n```\n\n### Using the command line\n\n```shell\npip3 install -r requirements.txt # Install requirements\npython3 remote_command_execution_vulnerability.py # Run the script\n```\n\nYou will be asked for the router IP address and for the `stok`. You can grab the `stok` from the router URL after you log in to the admin interface:\n\n![](readme/readme-001.png)\n\nNote that [the script must be run from the same IP address used when login into the router](https://github.com/acecilia/OpenWRTInvasion/issues/97).\n\nAfter that, a telnet server will be up and running. You can connect to it by running:\n\n```\ntelnet \u003crouter_ip_address\u003e\n```\n\n* User: `root`\n* Password: `root`\n\nThe script also starts an ftp server at port 21, so you can get access to the filesystem using a GUI (for example [cyberduck](https://cyberduck.io)).\n\n## Supported routers and firmware versions\n\n* MiRouter 4A Gigabit: \n  * `2.28.62`: user [ksc91u](https://forum.openwrt.org/u/ksc91u) claims that this method works \n  * `2.28.65`: [OpenWrt forum](https://forum.openwrt.org/t/xiaomi-mi-router-4a-gigabit-edition-r4ag-r4a-gigabit-fully-supported-but-requires-overwriting-spi-flash-with-programmer/36685/359)\n  * `2.28.132`: [OpenWrt forum](https://forum.openwrt.org/t/xiaomi-mi-router-4a-gigabit-edition-r4ag-r4a-gigabit-fully-supported-but-requires-overwriting-spi-flash-with-programmer/36685/359)\n  * `3.0.10`: see [here](https://github.com/acecilia/OpenWRTInvasion/issues/145)\n  * `3.0.24`: [OpenWrt forum](https://forum.openwrt.org/t/xiaomi-mi-router-4a-gigabit-edition-r4ag-r4a-gigabit-fully-supported-and-flashable-with-openwrtinvasion/36685/1135)\n  * `3.0.27`: see [here](https://github.com/acecilia/OpenWRTInvasion/issues/156)\n  * `3.2.30`: see [here](https://github.com/acecilia/OpenWRTInvasion/issues/160)\n  * `3.10.18`: see [here](https://github.com/acecilia/OpenWRTInvasion/issues/150)\n* MiRouter 4A 100M (non gigabit): \n  * `2.18.51`: [OpenWrt forum](https://forum.openwrt.org/t/xiaomi-mi-router-4a-gigabit-edition-r4ag-r4a-gigabit-fully-supported-but-requires-overwriting-spi-flash-with-programmer/36685/372)\n  * `2.18.58`: [OpenWrt forum](https://forum.openwrt.org/t/xiaomi-mi-router-4a-gigabit-edition-r4ag-r4a-gigabit-fully-supported-but-requires-overwriting-spi-flash-with-programmer/36685/373)\n  * `3.0.12`: see [here](https://github.com/acecilia/OpenWRTInvasion/issues/165)\n  * Find a troubleshooting guide [here](https://github.com/acecilia/OpenWRTInvasion/issues/92)\n* MiRouter 4C: \n  * `2.14.81`: [OpenWrt forum](https://forum.openwrt.org/t/support-for-xiaomi-mi-router-4c-r4cm/36418/31)\n  * `2.14.87`: see [here](https://github.com/acecilia/OpenWRTInvasion/issues/73) \n  * `2.14.92`: see [here](https://github.com/acecilia/OpenWRTInvasion/issues/162) \n  * Find [here](https://github.com/acecilia/OpenWRTInvasion/issues/89) a troubleshooting guide for this router\n* Mi Router 3Gv2: \n  * `2.28.8`: user [Massimiliano Mangoni](massimiliano.mangoni@gmail.com) claims that this method works (message posted in Slack)\n* Mi Router 4Q (aka R4C): \n  * `2.28.48`: user cadaverous claims that this method works (message posted in Slack), but because the router is mips architecture (not mipsel), he needed to use version `0.0.1` of the script (the other versions use a busybox binary built for the mipsel architecture that is used to start a telnet sever)\n* MiWifi 3C:\n  * `2.8.51_INT`: [OpenWrt forum](https://forum.openwrt.org/t/support-for-xiaomi-miwifi-3c/11643/23), [OpenWrt forum](https://forum.openwrt.org/t/support-for-xiaomi-miwifi-3c/11643/17)\n  * `2.9.217`: [OpenWrt forum](https://forum.openwrt.org/t/support-for-xiaomi-miwifi-3c/11643/23), [OpenWrt forum](https://forum.openwrt.org/t/support-for-xiaomi-miwifi-3c/11643/17)\n  * `2.14.45`: [OpenWrt forum](https://forum.openwrt.org/t/support-for-xiaomi-miwifi-3c/11643/23), [OpenWrt forum](https://forum.openwrt.org/t/support-for-xiaomi-miwifi-3c/11643/17)\n* [Mi Router 4](https://www.mi.com/miwifi4):\n  * `2.18.62`: see [here](https://github.com/acecilia/OpenWRTInvasion/issues/73)\n  * `2.26.175`: see [here](https://github.com/acecilia/OpenWRTInvasion/issues/21#issuecomment-748619870) \n* Xiaomi Mi R3P: \n  * Xiaomi Dev firmware: see [here](https://github.com/acecilia/OpenWRTInvasion/issues/58)\n* [Xiaomi 3Gv1](https://openwrt.org/toh/hwdata/xiaomi/xiaomi_miwifi_3g): \n  * The stock firmware coming with the router: see [here](https://github.com/acecilia/OpenWRTInvasion/issues/68#issue-814768067)\n* [AC2350 AIOT](https://www.mi.com/global/mi-aiot-router-ac2350/): \n  * `1.3.8CN`: see [here](https://github.com/acecilia/OpenWRTInvasion/issues/46#issuecomment-774784301)\n\n## Unsupported routers and firmware versions\n\n* MiRouter 4A Gigabit:\n  * `2.30.20`: see details [here](https://github.com/acecilia/OpenWRTInvasion/issues/141)\n  * `3.2.26`: see details and alternatives [here](https://github.com/acecilia/OpenWRTInvasion/issues/140)\n* Mi Extender AC1200 (RA75): see [here](https://github.com/acecilia/OpenWRTInvasion/issues/159)\n\n## Xiaomi 4A Gigabit Global Edition\n\nFind [here](https://www.youtube.com/watch?v=a4fDwG3aEb8) a very complete introductory video to the router and the OpenWrt installation\n\n### Firmwares\n\nThis repository contains the following firmwares:\n\n* Official Xiaomi - `2.28.62` - in Chinese. SHA256: `a3db7f937d279cf38c2a3bec09772d65`\n  * URL in this repository: https://github.com/acecilia/OpenWRTInvasion/raw/master/firmwares/stock/miwifi_r4a_firmware_72d65_2.28.62.bin\n* Official Xiaomi - `3.0.24` - in English. MD5: `9c4a60addaad76dc13b6df6b4ac03233`\n  * URL in this repository: https://github.com/acecilia/OpenWRTInvasion/raw/master/firmwares/stock/miwifi_r4a_all_03233_3.0.24_INT.bin\n  * URL in the official Xiaomi site: http://cdn.awsde0-fusion.fds.api.mi-img.com/xiaoqiang/rom/r4a/miwifi_r4a_all_03233_3.0.24_INT.bin\n\nIf you have a pending update in your Xiaomi stock firmware, you can check its md5 hash and the download url by navigating to:\n\n```\nhttp://192.168.31.1/cgi-bin/luci/;stok=\u003cstok\u003e/api/xqsystem/check_rom_update\n```\n\n### Install OpenWrt\n\nWhen installing OpenWrt on the Xiaomi 4A Gigabit, there are several options:\n\n* **[PREFERRED OPTION]**: use the latest supported stable release of OpenWrt. Find it in the [official OpenWrt wiki page](https://openwrt.org/inbox/toh/xiaomi/xiaomi_mi_router_4a_gigabit_edition)\n\n* Build your own image with `imagebuilder`, using the latest source code on `master`:\n\n  ```\n  docker pull openwrtorg/imagebuilder:ramips-mt7621-master\n  docker run --rm -v \"$(pwd)\"/bin/:/home/build/openwrt/bin -it openwrtorg/imagebuilder:ramips-mt7621-master\n  make PROFILE=xiaomi_mir3g-v2 image\n  ```\n\nIf **after reading above text** you still want to proceed, after login to the router through telnet run the following commands:\n\n```shell\ncd /tmp\ncurl https://raw.githubusercontent.com/acecilia/OpenWRTInvasion/master/firmwares/OpenWrt/06-06-2020/openwrt-ramips-mt7621-xiaomi_mir3g-v2-squashfs-sysupgrade.bin --output firmware.bin # Put here the URL you want to use to download the firmware\n./busybox sha256sum firmware.bin # Verify the firmware checksum before flashing, very important to avoid bricking your device!\nmtd -e OS1 -r write firmware.bin OS1 # Install OpenWrt\n```\n\nThis will install the snapshot version of OpenWrt (without Luci). You can now use ssh to connect to the router (and install Luci if you prefer it).\n\n### Performance:\n\nPlease see [here](https://www.youtube.com/watch?v=a4fDwG3aEb8) for a complete performance analysis\n\n## For more info and support go to:\n\n* [OpenWrt forum thread](https://forum.openwrt.org/t/xiaomi-mi-router-4a-gigabit-edition-r4ag-r4a-gigabit-fully-supported-but-requires-overwriting-spi-flash-with-programmer/36685)\n\n## If you brick your device\n\nYou can find solutions in the following links:\n\n* User [albertcp](https://forum.openwrt.org/u/albertcp) posted a very detailed guide: [OpenWrt forum](https://forum.openwrt.org/t/xiaomi-mi-router-4a-gigabit-edition-r4ag-r4a-gigabit-fully-supported-but-requires-overwriting-spi-flash-with-programmer/36685/402)\n* User [micky0867](https://forum.openwrt.org/u/micky0867) has some more comments about the topic: [OpenWrt forum](https://forum.openwrt.org/t/xiaomi-mi-router-4a-gigabit-edition-r4ag-r4a-gigabit-fully-supported-but-requires-overwriting-spi-flash-with-programmer/36685/391)\n* User [hoddy](https://forum.openwrt.org/u/hoddy) created a [video tutorial](https://youtu.be/SLbkce-M2nE)\n\n## Acknowledgments\n\n* Original vulnerabilities and exploit: [UltramanGaia](https://github.com/UltramanGaia/Xiaomi_Mi_WiFi_R3G_Vulnerability_POC)\n* Instructions to install OpenWrt after exploit execution: [rogerpueyo](https://forum.openwrt.org/t/xiaomi-mi-router-4a-gigabit-edition-r4ag-r4a-gigabit-fully-supported-but-requires-overwriting-spi-flash-with-programmer/36685/21)\n* Testing and detailed install instructions: [hey07](https://forum.openwrt.org/t/xiaomi-mi-router-4a-gigabit-edition-r4ag-r4a-gigabit-fully-supported-but-requires-overwriting-spi-flash-with-programmer/36685/349)\n* Checking the URL of pending updates: [sicklesareterrible](https://forum.openwrt.org/t/xiaomi-mi-router-4a-gigabit-edition-r4ag-r4a-gigabit-fully-supported-and-flashable-with-openwrtinvasion/36685/1114?u=acecilia)\n\n## Demo\n\n### Version 0.0.2 and higher: telnet\n\n![Alt Text](readme/exploit-002.gif)\n\n### Version 0.0.1: netcat (legacy)\n\n![Alt Text](readme/exploit-001.gif)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facecilia%2FOpenWRTInvasion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Facecilia%2FOpenWRTInvasion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facecilia%2FOpenWRTInvasion/lists"}