├── .gitattributes ├── libraries └── placeholder ├── .gitignore ├── .github └── FUNDING.yml ├── docker-compose.yml ├── run.sh ├── docs ├── README-zh.md ├── README-ja.md └── README.md ├── status.md └── bypass.php /.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=lf 2 | -------------------------------------------------------------------------------- /libraries/placeholder: -------------------------------------------------------------------------------- 1 | # Do NOT remove this folder -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | adb.php 2 | libraries/* 3 | !libraries/placeholder 4 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | patreon: MlgmXyysd 2 | custom: ['https://paypal.me/MlgmXyysd', 'https://afdian.net/@MlgmXyysd'] 3 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | php-cli: 3 | image: php:8.2-apache 4 | privileged: true 5 | restart: unless-stopped 6 | volumes: 7 | - .:/var/www/html 8 | - /dev/bus/usb:/dev/bus/usb 9 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #### 3 | # Setup environment to run application in a docker container 4 | # 5 | # @todo: 6 | # 7 | # 8 | # @author: stev leibelt 9 | # @since: 2024-01-31 10 | #### 11 | 12 | function _build () 13 | { 14 | # stop execution if one comand fails 15 | set -e 16 | 17 | local PATH_OF_THIS_SCRIPT 18 | 19 | PATH_OF_THIS_SCRIPT=$(realpath "$(dirname "${0}")") 20 | 21 | if [[ ! -f "${PATH_OF_THIS_SCRIPT}"/adb.php ]]; 22 | then 23 | wget -O "${PATH_OF_THIS_SCRIPT}"/adb.php https://raw.githubusercontent.com/MlgmXyysd/php-adb/master/src/adb.php 24 | fi 25 | 26 | if [[ ! -f "${PATH_OF_THIS_SCRIPT}"/libraries/adb ]]; 27 | then 28 | wget -O "${PATH_OF_THIS_SCRIPT}"/libraries/tools.zip https://dl.google.com/android/repository/platform-tools_r34.0.5-linux.zip 29 | unzip -d "${PATH_OF_THIS_SCRIPT}"/libraries "${PATH_OF_THIS_SCRIPT}"/libraries/tools.zip 30 | rm "${PATH_OF_THIS_SCRIPT}"/libraries/tools.zip 31 | mv "${PATH_OF_THIS_SCRIPT}"/libraries/platform-tools/* "${PATH_OF_THIS_SCRIPT}"/libraries/ 32 | rmdir "${PATH_OF_THIS_SCRIPT}"/libraries/platform-tools 33 | fi 34 | } 35 | 36 | function _main () 37 | { 38 | case "${1}" in 39 | build) 40 | _build 41 | ;; 42 | login) 43 | _login 44 | ;; 45 | start) 46 | _start 47 | ;; 48 | stop) 49 | _stop 50 | ;; 51 | *) 52 | echo "Usage: ${0} {build|login|start|stop}" 53 | return 1 54 | ;; 55 | esac 56 | } 57 | 58 | function _login () 59 | { 60 | _start 61 | docker compose exec php-cli bash 62 | } 63 | 64 | function _start () 65 | { 66 | _stop 67 | _build 68 | if command -v adb &> /dev/null; 69 | then 70 | adb kill-server 71 | fi 72 | docker compose up -d 73 | } 74 | 75 | function _stop () 76 | { 77 | docker compose down 78 | } 79 | 80 | _main "${@}" 81 | -------------------------------------------------------------------------------- /docs/README-zh.md: -------------------------------------------------------------------------------- 1 | # Xiaomi HyperOS BootLoader Bypass 2 | 3 | ![Version: 1.0](https://img.shields.io/badge/Version-1.0-brightgreen?style=for-the-badge) [![English](https://img.shields.io/badge/English-brightgreen?style=for-the-badge)](README.md) [![日本語](https://img.shields.io/badge/日本語-brightgreen?style=for-the-badge)](README-ja.md) 4 | 5 | 利用漏洞绕过小米 HyperOS 对 BootLoader 解锁账户绑定限制社区等级的 PoC。 6 | 7 | 您可随时向本项目提出改进方案 :) 8 | 9 | ## 💘 php-adb 10 | 11 | 本项目使用了 [php-adb](https://github.com/MlgmXyysd/php-adb) 运行库。 12 | 13 | ## ☕ 支持开发 14 | 15 | ✨ 如果您喜欢我的项目,可以请我喝咖啡: 16 | 17 | - [爱发电](https://afdian.net/@MlgmXyysd) 18 | - [PayPal](https://paypal.me/MlgmXyysd) 19 | - [Patreon](https://www.patreon.com/MlgmXyysd) 20 | 21 | ## ⚠️ 警告 22 | 23 | 解锁 BootLoader 后,你可能会遇到以下情况: 24 | 25 | - 软件或硬件无法正常工作,甚至永久性损坏。 26 | - 设备中存储的数据丢失。 27 | - 信用卡被盗刷,或遭受其他经济损失。 28 | 29 | 如果您遇到上述任何情况,您应该自己承担所有责任,因为这是您在解锁 BootLoader 时可能遇到的风险。这显然不能涵盖所有风险。我们已经警告过您了。 30 | 31 | - 保修丢失。根据小米提供的免责条款,这不仅是基础三包,您购买的一些额外延保(如 Mi Care 或碎屏险)也可能会丢失。 32 | - 像 Samsung Knox 那样的硬件级熔断。TEE 相关功能将永久损坏。除更换主板外,无法恢复。 33 | - 刷入第三方系统后出现功能异常,这可能是因为内核源代码闭源引起。 34 | - 设备或账号因为解锁 BootLoader 被小米封禁。 35 | 36 | 如果您遇到上述任何情况,请您自认倒霉。自从小米限制解锁 BootLoader 后,小米就一直在违背"极客"精神,甚至违背了 GPL。小米对 BootLoader 解锁的限制是无穷尽的,作为开发者,我们对此无能为力。 37 | 38 | ## 📲 前置要求 39 | 40 | - 一个有效的设备: 41 | - 一个未被封禁\*的小米、红米或 POCO 设备。 42 | - 设备正在运行官方版 HyperOS。 43 | - (2023/11/23 更新) 您的设备不会被小米强制验证账户资格。 44 | - 一个有效的 SIM 卡: 45 | - \* 无法使用 SIM 卡的平板电脑除外。 46 | - SIM 卡不得处于停机或无服务状态。 47 | - SIM 卡需要能够连接到互联网。 48 | - 每张有效 SIM 卡在三个月内只能解锁 2 台设备。 49 | - 一个有效的小米账号: 50 | - 一个未被封禁\*的小米账号。 51 | - 每个账号一个月只能解锁一部手机,一年只能解锁三部手机。 52 | - 您已阅读并理解上述 [警告](#%EF%B8%8F-警告)。 53 | 54 | - \* 根据小米提供的解锁说明,某些账号和设备将被禁止使用解锁工具,这被称为"风控"。 55 | 56 | ## ⚙️ 使用教程 57 | 58 | 1. 从 [官方网站](https://www.php.net/downloads) 下载并安装适用于您操作系统的 PHP 8.0+。 59 | 2. 在 `php.ini` 中启用 OpenSSL 和 Curl 扩展。(如果脚本未正常工作,请将 `extension_dir` 设置为 PHP 的 `ext` 文件夹路径。) 60 | 3. 将 [php-adb](https://github.com/MlgmXyysd/php-adb) 中的 `adb.php` 放到目录中。 61 | 4. 下载 [platform-tools](https://developer.android.com/studio/releases/platform-tools),并将其放入 `libraries`。*注意:Mac OS 需要将 `adb` 重命名为 `adb-darwin`。 62 | 5. 打开终端,使用 PHP 解释器执行 [脚本](../bypass.php)。 63 | 64 | - p.s. Releases 已将所需文件和一键脚本打包。 65 | 66 | 6. 多次点击`设置 - 关于手机 - MIUI 版本`启用`开发者选项`。 67 | 7. 在`设置 - 附加设置 - 开发者选项`中启用`OEM 解锁`、`USB 调试`和`USB 调试(安全设置)`。 68 | 8. 登录一个_有效_\*的小米账号。 69 | 9. 通过有线方式将设备连接到电脑。 70 | 10. 选中`始终允许来自此计算机的调试`,然后单击`确定`。 71 | 72 | - \* 请参阅上文的 "[前置要求](#-前置要求)"。 73 | 74 | 11. 等待并按脚本提示操作。 75 | 12. 绑定成功后,您可以使用 [官方解锁工具](https://www.miui.com/unlock/index.html) 查看需要等待的时间。 76 | 13. 在等待期间,请正常使用设备,保持 SIM 卡插入,不要登出小米账号或关闭"查找我的手机",不要重新绑定设备,直到成功解锁。设备将每隔一段时间自动向服务器发送 `HeartBeat` 数据包。 77 | 78 | ## 📖 漏洞分析 79 | 80 | - 维修中... 81 | 82 | ## 🔖 FAQ 83 | 84 | - Q: 为什么解锁工具仍然提醒我等待 168/360(或更长)小时? 85 | - A: 根据原理,该 PoC 只绕过了小米为 HyperOS 额外添加的限制。您仍然需要遵循 MIUI 的限制。 86 | 87 | - Q: 设备显示 "验证失败,请稍后再试"。 88 | - A: 这是正常现象,设备端的绑定请求已被脚本拦截。实际绑定结果以脚本提示为准。 89 | 90 | - Q: 绑定失败,错误代码为 `401`。 91 | - A: 您的小米账号凭据已过期,您需要在设备中登出账号并重新登录。 92 | 93 | - Q: 绑定失败,错误代码为 `20086`。 94 | - A: 您的设备凭据已过期,您可能需要重新启动设备。 95 | 96 | - Q: 绑定失败,错误代码为 `20090` 或 `20091`。 97 | - A: 设备的 `Security Device Credential Manager` 功能已损坏,请联系售后服务寻求支持。 98 | 99 | - Q: 绑定失败,错误代码为 `30001`。 100 | - A: 您的设备已被小米强制验证账户资格。小米早就抛弃了"极客"精神,我们对此无能为力。 101 | 102 | - Q: 绑定失败,错误代码为 `86015`。 103 | - A: 服务器拒绝了本次绑定请求,请重试。 104 | 105 | ## ⚖️ 协议 106 | 107 | 无许可证,您只被允许使用本项目。未经许可,不得删除或更改本软件的所有版权(以及链接等)。本项目所有权利归 [MeowCat Studio](https://github.com/MeowCat-Studio)、[Meow Mobile](https://github.com/Meow-Mobile) 和 [NekoYuzu](https://github.com/MlgmXyysd) 所有。 108 | -------------------------------------------------------------------------------- /docs/README-ja.md: -------------------------------------------------------------------------------- 1 | # Xiaomi HyperOS BootLoader Bypass 2 | 3 | ![Version: 1.0](https://img.shields.io/badge/Version-1.0-brightgreen?style=for-the-badge) [![English](https://img.shields.io/badge/English-brightgreen?style=for-the-badge)](README.md) [![中文文档](https://img.shields.io/badge/中文文档-brightgreen?style=for-the-badge)](README-zh.md) 4 | 5 | 脆弱性を悪用し、コミュニティレベルのアカウントバインド制限をバイパスして、Xiaomi HyperOS の BootLoader のロックを解除できる PoC。 6 | 7 | > [!NOTE] 8 | > Pull reqeust で このプロジェクトの改善を提案できます :) 9 | 10 | ## 💘 php-adb 11 | 12 | このプロジェクトでは [php-adb](https://github.com/MlgmXyysd/php-adb) ライブラリを使用しています。 13 | 14 | ## ☕ コーヒーを奢る 15 | 16 | ✨ このプロジェクトが気に入ったら、以下の方法でコーヒーを奢ってください: 17 | 18 | - [AFDIAN](https://afdian.net/@MlgmXyysd) 19 | - [PayPal](https://paypal.me/MlgmXyysd) 20 | - [Patreon](https://www.patreon.com/MlgmXyysd) 21 | 22 | ## ⚠️ 警告 23 | 24 | BootLoader のロックを解除した後、以下の問題が発生する可能性があります: 25 | 26 | - ソフトウェアの異常動作/ハードウェアの損傷 27 | - デバイスに保存されているデータの損失 28 | - クレジットカードの盗難、またはその他の経済的損失 29 | 30 | > [!CAUTION] 31 | > 上記のいずれかが発生した場合は、BootLoader のロックを解除する際に発生する可能性があるリスクであるため、すべての責任は自分で負う必要があります。 32 | これは明らかにすべてのリスクを保障するものではありません。**警告しましたからね**。 33 | 34 | - 保証適用外 35 | 基本保証だけでなく、購入した追加の延長保証の一部 (Mi Care や画面破損の保証など) も、Xiaomi が提供する除外規定に従って失われる可能性があります。 36 | - TEE 関連の機能は永久に使用不可能です。 37 | Samsung Knox のようにハードウェア レベルで自己破壊するため、マザーボードを交換する以外に復旧方法はありません。 38 | - ソースコード非公開のカーネルが原因で、サードパーティ システムをフラッシュした後の機能異常 39 | - BootLoader のロックを解除すると、デバイスまたはアカウントが BAN されます。 40 | 41 | > [!WARNING] 42 | > 上記のいずれかが発生した場合は、運が悪いと思ってください。 43 | Xiaomi が BootLoader のロック解除を制限して以来、Xiaomi の「オタク」精神、さらには GPL にも違反しています。 44 | > BootLoader のロック解除に対する Xiaomi の制限は無限であり、開発者としてそれに対してできることは何もありません。 45 | 46 | ## 📲 アンロック要件 47 | 48 | - 対象デバイス: 49 | - BAN されていない[^1] Xiaomi、Redmi、または POCO デバイス 50 | - デバイスが HyperOS の公式バージョンを実行している 51 | - (2023/11/23 に追記) デバイスは Xiaomi によってアカウントの資格確認を強制されない 52 | - 有効な SIM カード: 53 | - SIM カードが使用できないタブレットを除く[^1] 54 | - SIM カードのサービスが使用不能になっていない 55 | - SIM カードはモバイルネットワークにアクセスできる 56 | - 有効な SIM カード毎に、3か月以内に 2台のデバイスのロックを解除できます。 57 | - 有効な Xiaomi アカウント 58 | - BAN されていない[^1] Xiaomi アカウント 59 | - 各アカウントでロックを解除できるのは、1ヶ月で1台、1年で3台のみです。 60 | - 上記の [警告](#%EF%B8%8F-警告) を読み、理解したものとします。 61 | 62 | [^1]: Xiaomi が提供するロック解除手順によると、特定のアカウントとデバイスはロック解除ツールの使用を禁止されます。これは「リスク管理」と呼ばれています。 63 | 64 | ## ⚙️ 使用方法 65 | 1. [公式サイト](https://www.php.net/downloads) からシステムに PHP 8.0+ をダウンロードしてインストールします。 66 | 2. `php.ini` で OpenSSL と Curl 拡張機能を有効にします。 67 | (スクリプトが機能しない場合は、`extension_dir` を PHP の `ext` ディレクトリに設定してください。) 68 | 3. [php-adb](https://github.com/MlgmXyysd/php-adb) の `adb.php` をディレクトリに配置します。 69 | 4. [platform-tools](https://developer.android.com/studio/releases/platform-tools?hl=ja#downloads) をダウンロードして`libraries` に展開します。 70 | ※注意: Mac OS では、`adb` の名前を `adb-darwin` に変更する必要があります。 71 | 5. ターミナルを開き、PHP インタープリターを使用して[スクリプト](../bypass.php)を実行します。 72 | 73 | - P.S. [Releases](https://github.com/MlgmXyysd/Xiaomi-HyperOS-BootLoader-Bypass/releases/latest) には、必要なファイルとクイック実行スクリプトが同梱されています。 74 | 75 | 6. `設定`→`デバイス情報`→`MIUIバージョン`を7回以上連続でタッチして`開発者向けオプション`を有効にします。 76 | 7. `設定`→`追加設定`→`開発者向けオプション`で、`OEMロック解除`、`USBデバッグ`、`USBデバッグ (セキュリティ設定)` を有効にします。 77 | 8. **有効な**[^1] Xiaomi アカウントでログインします。 78 | 9. デバイスを優先でPCに接続します。 79 | 10. `このPCからのUSBデバイスを常に許可する` にチェックを入れてから `OK` を押します。 80 | 81 | - ※ 上記の["アンロック要件"](#-アンロック要件)を確認して下さい。 82 | 83 | 11. スクリプトの指示に従い待機します。 84 | 12. バインドが成功したら、[公式のロック解除ツール](https://www.miui.com/unlock/index.html)を使用して、解除が可能になるまでの待機時間を確認できます。 85 | 13. 待機時間中は、デバイスを通常どおり使用し、SIM カードを挿入したままにし、Xiaomi アカウントからログアウトしたり、`デバイスを探す`をオフにしたりせず、ロックが正常に解除されるまでデバイスを再バインドしないでください。 86 | デバイスは定期的に`HeartBeat`パケットをサーバーに自動的に送信します。 87 | 88 | ## 📖 回避策 89 | 90 | - 準備中... 91 | 92 | ## 🔖 FAQ 93 | 94 | - Q: ロック解除ツールが依然として 168/360 (またはそれ以上) 時間待つように要求するのはなぜですか? 95 | - A: 原則として、この PoC は、Xiaomi が HyperOS に対して追加した追加の制限を回避するだけです。 96 | MIUI の制限に従う必要があります。 97 | 98 | - Q: デバイスに `Couldn't verify, wait a minute or two and try again` と表示される。 99 | - A: これは正常であり、デバイス側のバインド要求はスクリプトによってブロックされます。 100 | 実際のバインド結果は、スクリプトプロンプトの影響を受けます。 101 | 102 | - Q: エラーコード `401` でバインドに失敗しました。 103 | - A: Xiaomi アカウントの認証情報の有効期限が切れているため、デバイスからログアウトして再度ログインする必要があります。 104 | 105 | - Q: エラーコード `20086` でバインドに失敗しました。 106 | - A: デバイスの認証情報の有効期限が切れているため、デバイスを再起動する必要があります。 107 | 108 | - Q: エラーコード `20090` または `20091` でバインドに失敗しました。 109 | - A: デバイスの `Security Device Credential Manager` 機能が破損しています。 110 | サポートについてはアフターサービスにお問い合わせください。 111 | 112 | - Q: エラーコード `30001` でバインドに失敗しました。 113 | - A: デバイスは、Xiaomi によってアカウントの資格確認を強制されました。 114 | Xiaomi はずっと前に「オタク」の精神を失っており、それについて私たちにできることは何もありません。 115 | 116 | - Q: エラーコード `86015` でバインドに失敗しました。 117 | - A: サーバーがバインド要求を拒否しました。もう一度試してください。 118 | 119 | ## ⚖️ ライセンス 120 | 121 | ライセンスがない場合、このプロジェクトの使用のみが許可されます。 122 | このソフトウェア(およびリンクなど)のすべての著作権を許可なく削除または変更することはできません。 123 | このプロジェクトのすべての権利は、[MeowCat Studio](https://github.com/MeowCat-Studio)、[Meow Mobile](https://github.com/Meow-Mobile)、[NekoYuzu](https://github.com/MlgmXyysd) に帰属します。 124 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Xiaomi HyperOS BootLoader Bypass 2 | 3 | ![Version: 1.0](https://img.shields.io/badge/Version-1.0-brightgreen?style=for-the-badge) [![中文文档](https://img.shields.io/badge/中文文档-brightgreen?style=for-the-badge)](README-zh.md) [![日本語](https://img.shields.io/badge/日本語-brightgreen?style=for-the-badge)](README-ja.md) 4 | 5 | A PoC that exploits a vulnerability to bypass the Xiaomi HyperOS community restrictions of BootLoader unlocked account bindings. 6 | 7 | Feel free pull request if you want :) 8 | 9 | ## 💘 php-adb 10 | 11 | The project proudly uses the [php-adb](https://github.com/MlgmXyysd/php-adb) library. 12 | 13 | ## ☕ Buy me a Coffee 14 | 15 | ✨ If you like my projects, you can buy me a coffee at: 16 | 17 | - [爱发电](https://afdian.net/@MlgmXyysd) 18 | - [PayPal](https://paypal.me/MlgmXyysd) 19 | - [Patreon](https://www.patreon.com/MlgmXyysd) 20 | 21 | ## ⚠️ Warning 22 | 23 | After unlocking the BootLoader, you may encounter the following situations: 24 | 25 | - Software or hardware not working properly or even damaged. 26 | - Loss of data stored in the device. 27 | - Credit card theft, or other financial loss. 28 | 29 | If you're experiencing any of the above, you should take all the responsibility yourself as this is the risk you may encounter when unlocking BootLoader. This obviously does not cover all risks. You've been warned. 30 | 31 | - Warranty lost. Not only the base warranty, but some of the extra extended warranties (such as Mi Care or broken-screen warranty) that you have purchased may also be lost according to the exclusions provided by Xiaomi. 32 | - Hardware level self-destruct like Samsung Knox. TEE-related features will be permanently damaged. There is no way to restore other than by replacing the motherboard. 33 | - Functional anomalies after flashing a third-party system due to closed-source kernel source code. 34 | - Device or account banned by unlocking BootLoader. 35 | 36 | If you're experiencing any of the above, consider yourself damned. Ever since Xiaomi restricted unlocking BootLoader, it has been against Xiaomi's 'geek' spirit and even the GPL. Xiaomi's restrictions on BootLoader unlocking are endless, and there's nothing we as developers can do about it. 37 | 38 | ## 📲 Unlocking requirements 39 | 40 | - A valid device: 41 | - A unbanned\* Xiaomi, Redmi or POCO device. 42 | - Your device is running the official version of HyperOS. 43 | - (Update 2023/11/23) Your device is not forced to verify account qualification by Xiaomi. 44 | - A valid SIM card: 45 | - \* Except for tablets that cannot use SIM cards. 46 | - SIM card must not be out of service. 47 | - SIM card needs to be able to access the internet. 48 | - Only 2 devices per valid SIM card are allowed to be unlock to a valid SIM card within a three-month period. 49 | - A valid Xiaomi account: 50 | - An unbanned\* Xiaomi account. 51 | - Each account can only unlock 1 phone in a month and 3 phones in a year period. 52 | - You have read and understood the [Warning](#%EF%B8%8F-warning) above. 53 | 54 | - \* According to the unlocking instructions provided by Xiaomi, it will prohibit some accounts and devices from using the unlocking tool, which is called "risk control". 55 | 56 | ## ⚙️ How to use 57 | 58 | 1. Download and install PHP 8.0+ for your system from the [official website](https://www.php.net/downloads). 59 | 2. Enable OpenSSL and Curl extension in `php.ini`. (And/or set `extension_dir` to your PHP's `ext` directory if script not work.) 60 | 3. Place `adb.php` in [php-adb](https://github.com/MlgmXyysd/php-adb) to the directory. 61 | 4. Download [platform-tools](https://developer.android.com/studio/releases/platform-tools) and place them in `libraries`. *Note: Mac OS needs to rename `adb` to `adb-darwin`.* 62 | 5. Open a terminal and use PHP interpreter to execute the [script](../bypass.php). 63 | 64 | - p.s. Releases has packaged the required files and click-to-run scripts. 65 | 66 | 6. Tap repeatedly on the `Settings - About Phone - MIUI Version` to enable `Development Options`. 67 | 7. Enable `OEM Unlocking`, `USB Debugging` and `USB Debugging (Security Settings)` in `Settings - Additional Settings - Development Options`. 68 | 8. Log in a _valid_\* Xiaomi account. 69 | 9. Connect phone to PC via wired interface. 70 | 10. Check `Always allow from this computer` and click `OK`. 71 | 72 | - \* See "[Unlocking Requirements](#-Unlocking-requirements)" above. 73 | 74 | 11. Wait and follow the prompts of script. 75 | 12. After successful binding, you can use the [official unlock tool](https://en.miui.com/unlock/index.html) to check the time you need to wait. 76 | 13. During the waiting period, please use the device normally, keep the SIM card inserted, do not log out of your account or turn off `Find My Phone`, and do not re-bind the device until it is successfully unlocked. The device will automatically send `HeartBeat` packets to the server every once in a while. 77 | 78 | ## 📖 Workaround 79 | 80 | - Undergoing maintenance... 81 | 82 | ## 🔖 FAQs 83 | 84 | - Q: Why does the unlock tool still remind me to wait 168/360 (or more) hours? 85 | - A: By principle, this PoC only bypasses the restrictions added for HyperOS. You still need to comply with the restrictions for MIUI. 86 | 87 | - Q: The device shows `Couldn't verify, wait a minute or two and try again`. 88 | - A: This is normal, the binding request on the device side has been blocked by our script. The actual binding result is subject to the script prompt. 89 | 90 | - Q: Binding failed with error code `401`. 91 | - A: Your Xiaomi account credentials have expired, you need to log out and log in again in your device. 92 | 93 | - Q: Binding failed with error code `20086`. 94 | - A: Your device credentials have expired, you need to reboot your device. 95 | 96 | - Q: Binding failed with error code `20090` or `20091`. 97 | - A: Device's Security Device Credential Manager function failure, contact after-sales. 98 | 99 | - Q: Binding failed with error code `30001`. 100 | - A: Your device has been forced to verify the account qualification by Xiaomi. Xiaomi lost its 'geek' spirit a long time ago, and there's nothing we can do about it. 101 | 102 | - Q: Binding failed with error code `86015`. 103 | - A: The server has rejected this bind request, please try again. 104 | 105 | ## ⚖️ License 106 | 107 | No license, you are only allowed to use this project. All copyright (and link, etc.) in this software is not allowed to be deleted or changed without permission. All rights are reserved by [MeowCat Studio](https://github.com/MeowCat-Studio), [Meow Mobile](https://github.com/Meow-Mobile) and [NekoYuzu](https://github.com/MlgmXyysd). 108 | -------------------------------------------------------------------------------- /status.md: -------------------------------------------------------------------------------- 1 | # Device Status 2 | 3 | - This auto-generated list only included devices with the official Xiaomi HyperOS available. It is designed to track devices capable of bypassing BootLoader unlocking restrictions. 4 | - Since Xiaomi's unlocking restrictions only apply to devices sold in PRC market (excluding Hong Kong, Macau and Taiwan), it focuses on devices sold in China mainland. 5 | 6 | ## Status Description 7 | 8 | - ✔️ Opening: Unlock channel available. Restrictions can be bypassed. 9 | - ❌ Blocked: Xiaomi has enforced verification. Unlocking is only possible with an authorized account. 10 | - ⚠️ Unsupported: Xiaomi prohibits unlocking this device, regardless of permissions. 11 | - ❓ Unknown: The unlock policy for this device could not be found in Xiaomi servers. Please refer to the actual situation. (Feedback required) 12 | 13 | ---- 14 | 15 | | Name | Code | Release Date | Initial OS | Status | 16 | | :- | :-: | :-: | :-: | :- | 17 | | Xiaomi 10 | umi | 2020-02-13 | MIUI | ✔️ Opening | 18 | | Xiaomi 10S | thyme | 2021-03-10 | MIUI | ✔️ Opening | 19 | | Xiaomi 10 Pro | cmi | 2020-02-13 | MIUI | ✔️ Opening | 20 | | Xiaomi 10 Ultra | cas | 2020-08-11 | MIUI | ✔️ Opening | 21 | | Xiaomi 11 Lite | lisa | 2021-12-09 | MIUI | ✔️ Opening | 22 | | Xiaomi 11 | venus | 2020-12-28 | MIUI | ✔️ Opening | 23 | | Xiaomi 11 Pro | star | 2021-03-29 | MIUI | ✔️ Opening | 24 | | Xiaomi 11 Ultra | star | 2021-03-29 | MIUI | ✔️ Opening | 25 | | Xiaomi 12X | psyche | 2021-12-28 | MIUI | ✔️ Opening | 26 | | Xiaomi 12 | cupid | 2021-12-28 | MIUI | ✔️ Opening | 27 | | Xiaomi 12 Pro | zeus | 2021-12-28 | MIUI | ✔️ Opening | 28 | | Xiaomi 12 Pro Dimensity | daumier | 2022-07-04 | MIUI | ✔️ Opening | 29 | | Xiaomi 12S | mayfly | 2022-07-04 | MIUI | ✔️ Opening | 30 | | Xiaomi 12S Pro | unicorn | 2022-07-04 | MIUI | ✔️ Opening | 31 | | Xiaomi 12S Ultra | thor | 2022-07-04 | MIUI | ✔️ Opening | 32 | | Xiaomi 13 | fuxi | 2022-12-11 | MIUI | ✔️ Opening | 33 | | Xiaomi 13 Pro | nuwa | 2022-12-12 | MIUI | ✔️ Opening | 34 | | Xiaomi 13 Ultra | ishtar | 2023-04-18 | MIUI | ✔️ Opening | 35 | | Xiaomi 14 | houji | 2023-10-26 | Xiaomi HyperOS | ❌ Blocked | 36 | | Xiaomi 14 Pro | shennong | 2023-10-26 | Xiaomi HyperOS | ❌ Blocked | 37 | | Xiaomi 14 Pro Ti Satellite | shennong | 2024-02-22 | Xiaomi HyperOS | ❌ Blocked | 38 | | Xiaomi 14 Ultra | aurora | 2024-02-22 | Xiaomi HyperOS | ❓ Unknown | 39 | | Xiaomi MIX 4 | odin | 2021-08-10 | MIUI | ✔️ Opening | 40 | | Xiaomi MIX Fold | cetus | 2021-03-30 | MIUI Fold | ✔️ Opening | 41 | | Xiaomi MIX Fold 2 | zizhan | 2022-08-11 | MIUI Fold | ✔️ Opening | 42 | | Xiaomi MIX Fold 3 | babylon | 2023-08-14 | MIUI Fold | ✔️ Opening | 43 | | Xiaomi MIX Fold 4 | goku | 2024-07-19 | Xiaomi HyperOS | ❌ Blocked | 44 | | Xiaomi MIX Flip | ruyi | 2024-07-19 | Xiaomi HyperOS | ❌ Blocked | 45 | | Xiaomi Civi | mona | 2021-09-27 | MIUI | ✔️ Opening | 46 | | Xiaomi Civi 1S | zijin | 2022-04-21 | MIUI | ✔️ Opening | 47 | | Xiaomi Civi 2 | ziyi | 2022-09-27 | MIUI | ✔️ Opening | 48 | | Xiaomi Civi 3 | yuechu | 2023-05-25 | MIUI | ✔️ Opening | 49 | | Xiaomi Civi 4 Pro | chenfeng | 2024-03-21 | Xiaomi HyperOS | ❌ Blocked | 50 | | Xiaomi Pad 5 | nabu | 2021-08-10 | MIUI Pad | ✔️ Opening | 51 | | Xiaomi Pad 5 Pro | elish | 2021-08-10 | MIUI Pad | ✔️ Opening | 52 | | Xiaomi Pad 5 Pro 5G | enuma | 2021-08-10 | MIUI Pad | ✔️ Opening | 53 | | Xiaomi Pad 5 Pro 12.4 | dagu | 2022-08-11 | MIUI Pad | ✔️ Opening | 54 | | Xiaomi Pad 6 | pipa | 2023-04-18 | MIUI Pad | ✔️ Opening | 55 | | Xiaomi Pad 6 Pro | liuqin | 2023-04-18 | MIUI Pad | ✔️ Opening | 56 | | Xiaomi Pad 6 Max | yudi | 2023-08-14 | MIUI Pad | ✔️ Opening | 57 | | Xiaomi Pad 6S Pro | sheng | 2024-02-22 | Xiaomi HyperOS | ❌ Blocked | 58 | | Redmi 12C | earth | 2022-12-31 | MIUI | ✔️ Opening | 59 | | Redmi 12 | sky | 2023-08-14 | MIUI | ✔️ Opening | 60 | | Redmi 12R | sky | 2023-12-09 | MIUI | ✔️ Opening | 61 | | Redmi Note 12R | sky | 2023-06-28 | MIUI | ✔️ Opening | 62 | | Redmi 13R | air | 2023-12-08 | MIUI | ✔️ Opening | 63 | | Redmi 13C | air | 2023-12-29 | MIUI | ✔️ Opening | 64 | | Redmi 14R | flame | 2024-09-18 | Xiaomi HyperOS | ❓ Unknown | 65 | | Redmi Note 11R | light | 2022-09-29 | MIUI | ✔️ Opening | 66 | | Redmi Note 11E | light | 2022-03-01 | MIUI | ✔️ Opening | 67 | | Redmi Note 11E Pro | veux | 2022-03-01 | MIUI | ✔️ Opening | 68 | | Redmi Note 11 | evergo | 2021-10-28 | MIUI | ✔️ Opening | 69 | | Redmi Note 11 Pro | pissarro | 2021-10-28 | MIUI | ✔️ Opening | 70 | | Redmi Note 11 Pro+ | pissarro | 2021-10-28 | MIUI | ✔️ Opening | 71 | | Redmi Note 11T Pro | xaga | 2022-05-24 | MIUI | ✔️ Opening | 72 | | Redmi Note 11T Pro+ | xaga | 2022-05-24 | MIUI | ✔️ Opening | 73 | | Redmi Note 12 | sunstone | 2022-10-27 | MIUI | ✔️ Opening | 74 | | Redmi Note 12R Pro | sunstone | 2023-04-27 | MIUI | ✔️ Opening | 75 | | Redmi Note 12 Pro | ruby | 2022-10-27 | MIUI | ✔️ Opening | 76 | | Redmi Note 12 Pro+ | ruby | 2022-10-27 | MIUI | ✔️ Opening | 77 | | Redmi Note 12 Pro Speed | redwood | 2022-12-27 | MIUI | ✔️ Opening | 78 | | Redmi Note 12 Turbo | marble | 2023-03-28 | MIUI | ✔️ Opening | 79 | | Redmi Note 12T Pro | pearl | 2023-05-30 | MIUI | ✔️ Opening | 80 | | Redmi Note 13R | breeze | 2024-05-30 | Xiaomi HyperOS | ❌ Blocked | 81 | | Redmi Note 13 | gold | 2023-09-21 | MIUI | ⚠️ Unsupported | 82 | | Redmi Note 13R Pro | gold | 2023-11-20 | MIUI | ⚠️ Unsupported | 83 | | Redmi Note 13 Pro | garnet | 2023-09-21 | MIUI | ⚠️ Unsupported | 84 | | Redmi Note 13 Pro+ | zircon | 2023-09-21 | MIUI | ⚠️ Unsupported | 85 | | Redmi Turbo 3 | peridot | 2024-04-10 | Xiaomi HyperOS | ❌ Blocked | 86 | | Redmi Note 14 | beryl | 2024-09-26 | Xiaomi HyperOS | ❓ Unknown | 87 | | Redmi Note 14 Pro | malachite | 2024-09-26 | Xiaomi HyperOS | ❓ Unknown | 88 | | Redmi Note 14 Pro+ | amethyst | 2024-09-26 | Xiaomi HyperOS | ❌ Blocked | 89 | | Redmi K40 Gaming | ares | 2021-04-27 | MIUI | ✔️ Opening | 90 | | Redmi K40 | alioth | 2021-02-25 | MIUI | ✔️ Opening | 91 | | Redmi K40S | munch | 2022-03-17 | MIUI | ✔️ Opening | 92 | | Redmi K40 Pro | haydn | 2021-02-25 | MIUI | ✔️ Opening | 93 | | Redmi K40 Pro+ | haydn | 2021-02-25 | MIUI | ✔️ Opening | 94 | | Redmi K50 Gaming | ingres | 2022-02-16 | MIUI | ✔️ Opening | 95 | | Redmi K50 | rubens | 2022-03-17 | MIUI | ✔️ Opening | 96 | | Redmi K50 Pro | matisse | 2022-03-17 | MIUI | ✔️ Opening | 97 | | Redmi K50 Ultra | diting | 2022-08-11 | MIUI | ✔️ Opening | 98 | | Redmi K60E | rembrandt | 2022-12-27 | MIUI | ✔️ Opening | 99 | | Redmi K60 | mondrian | 2022-12-27 | MIUI | ✔️ Opening | 100 | | Redmi K60 Pro | socrates | 2022-12-27 | MIUI | ✔️ Opening | 101 | | Redmi K60 Ultra | corot | 2023-08-14 | MIUI | ✔️ Opening | 102 | | Redmi K70E | duchamp | 2023-11-29 | Xiaomi HyperOS | ❌ Blocked | 103 | | Redmi K70 | vermeer | 2023-11-29 | Xiaomi HyperOS | ❌ Blocked | 104 | | Redmi K70 Pro | manet | 2023-11-29 | Xiaomi HyperOS | ❌ Blocked | 105 | | Redmi K70 Ultra | rothko | 2024-07-19 | Xiaomi HyperOS | ❌ Blocked | 106 | | Redmi Pad SE | xun | 2023-09-21 | MIUI Pad | ✔️ Opening | 107 | | Redmi Pad | yunluo | 2022-10-27 | MIUI Pad | ✔️ Opening | 108 | | Redmi Pad Pro | dizi | 2024-04-10 | Xiaomi HyperOS | ❌ Blocked | 109 | | Redmi Pad Pro 5G | ruan | 2024-04-10 | Xiaomi HyperOS | ❌ Blocked | 110 | -------------------------------------------------------------------------------- /bypass.php: -------------------------------------------------------------------------------- 1 | refreshDeviceList(); 93 | $t = array(); 94 | foreach ($s as $d) { 95 | if ($d["status"] === $a::CONNECT_TYPE_DEVICE) { 96 | $t[] = array($d["serial"], $d["transport"]); 97 | } 98 | } 99 | return $t; 100 | } 101 | 102 | /** 103 | * Formatted Log 104 | * @param $m string optional Message 105 | * @param $c string optional Color 106 | * @param $p string optional Indicator 107 | * @param $t string optional Type (Level) 108 | * @author NekoYuzu (MlgmXyysd) 109 | * @date 2022/03/24 14:50:01 110 | */ 111 | 112 | function logf(string $m = "", string $c = "", string $p = "-", string $t = "I"): void 113 | { 114 | switch (strtoupper($c)) { 115 | case "G": 116 | $c = "\033[32m"; 117 | break; 118 | case "R": 119 | $c = "\033[31m"; 120 | break; 121 | case "Y": 122 | $c = "\033[33m"; 123 | break; 124 | default: 125 | $c = ""; 126 | } 127 | switch (strtoupper($t)) { 128 | case "W": 129 | $t = "WARN"; 130 | break; 131 | case "E": 132 | $t = "ERROR"; 133 | break; 134 | case "I": 135 | default: 136 | $t = "INFO"; 137 | } 138 | print(date("[Y-m-d] [H:i:s]") . " [" . $t . "] " . $p . " " . $c . $m . "\033[0m" . PHP_EOL); 139 | } 140 | 141 | /** 142 | * Curl HTTP wrapper function 143 | * @param $url string required Target url 144 | * @param $method string required Request method 145 | * @param $fields array optional Request body 146 | * @param $header array optional Request header 147 | * @param $useForm bool optional Treat request body as urlencoded form 148 | * @return array Curl response 149 | * @author NekoYuzu (MlgmXyysd) 150 | * @date 2023/11/20 23:50:39 151 | */ 152 | 153 | function http(string $url, string $method, array $fields = array(), array $header = array(), bool $useForm = false): array 154 | { 155 | if ($useForm) { 156 | $fields = http_build_query($fields); 157 | } 158 | $curl = curl_init(); 159 | curl_setopt_array($curl, array( 160 | CURLOPT_URL => $url, 161 | CURLOPT_RETURNTRANSFER => true, 162 | CURLOPT_ENCODING => "", 163 | CURLOPT_SSL_VERIFYPEER => false, 164 | CURLOPT_SSL_VERIFYHOST => false, 165 | CURLOPT_MAXREDIRS => 10, 166 | CURLOPT_CONNECTTIMEOUT => 2, 167 | CURLOPT_TIMEOUT => 6, 168 | CURLOPT_CUSTOMREQUEST => $method, 169 | CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, 170 | CURLOPT_POST => $method == "POST", 171 | CURLOPT_POSTFIELDS => $fields, 172 | CURLOPT_HTTPHEADER => $header 173 | )); 174 | 175 | $response = curl_exec($curl); 176 | $info = curl_getinfo($curl); 177 | $info["errno"] = curl_errno($curl); 178 | $info["error"] = curl_error($curl); 179 | $info["request"] = json_encode($fields); 180 | $info["response"] = $response; 181 | curl_close($curl); 182 | return $info; 183 | } 184 | 185 | /** 186 | * HTTP POST wrapper 187 | * @param $_api string required Target endpoint 188 | * @param $data array optional Request body 189 | * @param $header array optional Request header 190 | * @param $useForm bool optional Treat request body as urlencoded form 191 | * @return array Curl response 192 | * @return false Response code is not HTTP 200 OK 193 | * @author NekoYuzu (MlgmXyysd) 194 | * @date 2023/11/20 23:55:41 195 | */ 196 | 197 | function postApi(string $_api, array $data = array(), array $header = array(), bool $useForm = false): array|false 198 | { 199 | $response = http($GLOBALS["api"] . $_api, "POST", $data, $header, $useForm); 200 | if ($response["http_code"] != 200) { 201 | return false; 202 | } 203 | return json_decode($response["response"], true); 204 | } 205 | 206 | /** 207 | * Sign data using HMAC SHA-1 208 | * @param $data string required Data to sign 209 | * @return string Signed hash 210 | * @author NekoYuzu (MlgmXyysd) 211 | * @date 2023/11/21 00:20:56 212 | */ 213 | 214 | function signData(string $data): string 215 | { 216 | return strtolower(bin2hex(hash_hmac("sha1", "POST\n/v1/unlock/applyBind\ndata=" . $data . "&sid=miui_sec_android", $GLOBALS["sign_key"], true))); 217 | } 218 | 219 | /** 220 | * Decrypt data using AES/CBC/PKCS5Padding 221 | * @param $data string required Data to decrypt 222 | * @return string Decrypted data 223 | * @return false Failed to decrypt 224 | * @author NekoYuzu (MlgmXyysd) 225 | * @date 2023/11/21 00:15:30 226 | */ 227 | 228 | function decryptData(string $data): string|false 229 | { 230 | return openssl_decrypt(base64_decode($data), "AES-128-CBC", $GLOBALS["data_pass"], OPENSSL_RAW_DATA, $GLOBALS["data_iv"]); 231 | } 232 | 233 | /*********************** 234 | * Functions End * 235 | ***********************/ 236 | 237 | /********************** 238 | * Banner Start * 239 | **********************/ 240 | 241 | logf("************************************", "g"); 242 | logf("* Xiaomi HyperOS BootLoader Bypass *", "g"); 243 | logf("* By NekoYuzu Version " . $version . " *", "g"); 244 | logf("************************************", "g"); 245 | logf("GitHub: https://github.com/MlgmXyysd"); 246 | logf("XDA: https://xdaforums.com/m/mlgmxyysd.8430637"); 247 | logf("X (Twitter): https://x.com/realMlgmXyysd"); 248 | logf("PayPal: https://paypal.me/MlgmXyysd"); 249 | logf("My Blog: https://www.neko.ink/"); 250 | logf("************************************", "g"); 251 | 252 | /******************** 253 | * Banner End * 254 | ********************/ 255 | 256 | /******************** 257 | * Main Logic * 258 | ********************/ 259 | 260 | logf("Starting ADB server..."); 261 | 262 | $adb = new ADB(__DIR__ . DIRECTORY_SEPARATOR . "libraries"); 263 | 264 | $devices = parseDeviceList($adb); 265 | $devices_count = count($devices); 266 | 267 | while ($devices_count != 1) { 268 | if ($devices_count == 0) { 269 | logf("Waiting for device connection..."); 270 | } else { 271 | logf("Only one device is allowed to connect, disconnect others to continue. Current number of devices: " . $devices_count); 272 | } 273 | sleep(1); 274 | $devices = parseDeviceList($adb); 275 | $devices_count = count($devices); 276 | } 277 | 278 | $device = $devices[0]; 279 | $id = $adb -> getDeviceId($device[1], true); 280 | logf("Processing device " . $device[0] . "(" . $device[1] . ")..."); 281 | 282 | $adb -> clearLogcat($id); 283 | $adb -> runAdb($id . "shell svc data enable"); 284 | 285 | logf("Finding BootLoader unlock bind request..."); 286 | 287 | $focus = $adb -> getCurrentActivity(); 288 | if ($focus[0] != "com.android.settings") { 289 | if ($focus[0] != "NotificationShade") { 290 | $adb -> runAdb($id . "shell am start -a android.settings.APPLICATION_DEVELOPMENT_SETTINGS"); 291 | } 292 | } else { 293 | if ($focus[1] != "com.android.settings.bootloader.BootloaderStatusActivity") { 294 | $adb -> runAdb($id . "shell am start -a android.settings.APPLICATION_DEVELOPMENT_SETTINGS"); 295 | } 296 | } 297 | logf("Now you can bind account in the developer options.", "y", "*"); 298 | 299 | $args = $headers = null; 300 | 301 | $process = proc_open($adb -> bin . " " . $id . "logcat *:S CloudDeviceStatus:V", array( 302 | 1 => ["pipe", "w"] 303 | ), $pipes); 304 | 305 | if (is_resource($process)) { 306 | while (!feof($pipes[1])) { 307 | $output = fgets($pipes[1]); 308 | 309 | if (str_contains($output, "CloudDeviceStatus: args:")) { 310 | if (preg_match("/args:(.*)/", $output, $matches)) { 311 | $args = trim($matches[1]); 312 | } 313 | $adb -> runAdb($id . "shell svc data disable"); 314 | } 315 | 316 | if (str_contains($output, "CloudDeviceStatus: headers:")) { 317 | if (preg_match("/headers:(.*)/", $output, $matches)) { 318 | $headers = trim($matches[1]); 319 | } 320 | logf("Account bind request found! Let's block it."); 321 | break; 322 | } 323 | } 324 | 325 | fclose($pipes[1]); 326 | } 327 | 328 | logf("Refactoring parameters..."); 329 | 330 | $data = json_decode(decryptData($args), true); 331 | 332 | // V816 is the special identity for HyperOS in MIUI version 333 | $data["rom_version"] = str_replace("V816", "V14", $data["rom_version"]); 334 | 335 | $data = json_encode($data); 336 | $sign = signData($data); 337 | 338 | $headers = decryptData($headers); 339 | $cookies = null; 340 | if (preg_match("/Cookie=\[(.*)\]/", $headers, $matches)) { 341 | $cookies = trim($matches[1]); 342 | } 343 | 344 | logf("Sending POST request..."); 345 | $res = postApi("unlock/applyBind", array( 346 | "data" => $data, 347 | "sid" => "miui_sec_android", 348 | "sign" => $sign 349 | ), array( 350 | "Cookie: " . $cookies, 351 | "Content-Type: application/x-www-form-urlencoded" 352 | ), true); 353 | 354 | $adb -> runAdb($id . "shell svc data enable"); 355 | 356 | if (!$res) { 357 | logf("Fail to send request, check your internet connection.", "r", "!"); 358 | exit(); 359 | } 360 | 361 | switch ($res["code"]) { 362 | case 0: 363 | logf("Target account: " . $res["data"]["userId"], "g"); 364 | logf("Account bound successfully, wait time can be viewed in the unlock tool.", "g"); 365 | break; 366 | case 401: 367 | logf("Account credentials have expired, re-login to your account in your phone. (401)", "y"); 368 | break; 369 | case 20086: 370 | logf("Device credentials expired. (20086)", "y"); 371 | break; 372 | case 30001: 373 | logf("Binding failed, this device has been forced to verify the account qualification by Xiaomi. (30001)", "y"); 374 | break; 375 | case 86015: 376 | logf("Fail to bind account, invalid device signature. (86015)", "y"); 377 | break; 378 | default: 379 | logf($res["descEN"] . " (" . $res["code"] . ")", "y"); 380 | } 381 | --------------------------------------------------------------------------------