Giter Club home page Giter Club logo

miunlocktool's Introduction

MiUnlockTool

Version 1.5.1

developed to retrieve encryptData(token) for Xiaomi devices to unlock bootloader, It is compatible with all platforms.

Telegram Channel

Installation:

For MacOS, Linux, Windows:

  1. Install Python3.
  2. Download MiUnlockTool and run it.

For Android:

  1. Install Termux

  2. Install Termux API

  3. From Termux command line:

termux-setup-storage
curl https://raw.githubusercontent.com/offici5l/MiUnlockTool/main/.install | bash

License

miunlocktool's People

Contributors

nevack avatar offici5l avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

miunlocktool's Issues

(remote: 'Token Verify Failed, Reboot the device')

(remote: 'Token Verify Failed, Reboot the device')

The solution is (if the data has not been automatically refreshed by the device to Xiaomi servers... synchronization):

  • Insert the same SIM card you used previously in the exact same slot(1 or 2) (if your phone supports dual SIM).

  • Reboot the device in normal mode.

  • Wait a few seconds (until the SIM card data is automatically reset).

  • Reboot the device in bootloader mode. Then try again.

Explanation of the reason behind "Token Verify Failed," according to my analysis:

When a request is sent to the Xiaomi server through the "Mi Unlock status" in developer settings, multiple pieces of data, including SIM card data, are sent.

The "Token Verify Failed" issue occurs due to removing the SIM card from the device or replacing it with another card after linking the account in developer options. Consequently, upon restarting the device, the device's data will be updated, meaning it won't contain the SIM card data initially sent to the Xiaomi server. As a result, when attempting to unlock the bootloader via the tool, the server will send an unlock token based on the initial data, leading to conflicting information and resulting in the "Token Verify Failed" error.

notice : 

To avoid this error in the future, please refrain from removing the SIM card from the device until the bootloader is successfully unlocked.

code 10013 = This device is not activated, please activate it and try to unlock it again

code 10013 = This device is not activated, please activate it and try to unlock it again

the issue is due to changing a piece of the phone's hardware, most likely the motherboard

Currently, there is no solution for this issue unfortunately

The only solution currently is to contact the Xiaomi support team.

Explanation of the reason according to my analysis:

When sending a request to Xiaomi's server through developer settings "Mi Unlock status" the following information is sent to Xiaomi's server for verification:

  • userId
  • rom_version
  • heartbeat_mode
  • cloudsp_devId
  • cloudsp_cpuId
  • cloudsp_product
  • cloudsp_userId
  • cloudsp_fid
  • cloudsp_nonce
  • cloudp_sign
  • error_code

I believe the issue is related to cloudsp_fid, which is the security DeviceId.

Therefore, Xiaomi's server, upon analyzing the security DeviceId, returns error code 10013 when attempting to unlock the bootloader.

Device not activated issue

I have been trying to unlock the bootloader of Poco m3. It always give me an error device not activated, activate device and try again. I searched this error and turns out I need to activate my sim in the miui account. But everytime I do that the Xiaomi sim activation service fails. Please make a fix for this, some bypass or anything

failed to start

the tool crashes and failed to start windows 10 pro and latest python installed

pyshorteners Archived

I committed un-lock to the AUR un-lock-git

I found that pyshorteners has been archived, and running it on Arch may be missing the corresponding dependency packages, can I replace them with python packages that already exist on other arch?

code 20035 = Please upgrade your unlock tool

code 20035 = Please upgrade your unlock tool.

If you are using an official tool or other tools Download the latest version of the tool.

If you are using the MiUnlockTool, Just update "clientVersion":"Place a higher version than the previous one"

You find it in the file MiUnlockTool.py., in the line containing :
r = RetrieveEncryptData("/api/v3/ahaUnlock", {"appId":"1", "data":{"clientId":"2", "clientVersion":"7.6.727.43", .........

What an AMAZING job!

Thank you very much for your work, I need to wait 107 hours before unlocking. Compared with the torture of using ARM Windows to unlock Xiaomi devices under M1 mac, this news is extremely exciting.
image

Permission denied: 'encryptData'

After entering the link, program output is as follows:

wb_id saved successfully
Check if the device is connected in bootloader mode...
product saved successfully
Check if the device is connected in bootloader mode...
Check if the device is connected in bootloader mode...
token saved successfully
DeviceInfo:
product: vili
token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
AccountInfo:
id: xxxxxxxxxx
region: europe
________________________________________________________
Traceback (most recent call last):
File "/home/karl/Downloads/MiUnlockTool.py", line 222, in <module>
with open("encryptData", "wb") as edfile:
^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: 'encryptData'

(Account data and token are obviously different). There seems to be a problem with opening the code file? I can't quite track down the problem.

product: zircon

terminal:

invalid product or deviceToken

Check if device is connected in bootloader mode...

product saved.

and the R S OK page url doesn't return deviceToken

code 20030 = Sorry, couldn't unlock more devices by this account this month

code 20030 = Sorry, couldn't unlock more devices by this account this month

The reason is because you have already unlocked a device recently from one Mi account at once

You must wait for the beginning of next month, meaning the 1st of next month ( according to the time zone of the server region )


Question:
But I haven't unlocked any device before!

Answer:
Yes, but you have used a bootloader unlocking tool before (or reason) with the same account (whether it's official or unofficial doesn't matter).
The Xiaomi server has indeed sent the encryptedData(token) before, to unlock the bootloader. So, whether you have previously unlocked a device or failed to unlock the same device, it doesn't matter. Because new data (with the same account) For some Reason(explained at the end of the answer) was sent to the server that doesn't match the data sent in the initial attempt. Therefore, the Xiaomi server considers that you're attempting to unlock a new device, and it only allows unlocking one device per month.

Reason: after the last encryptedData(token) received from the server(

  • The account has logged out on the device Then are logged in(This generates a mismatched device token)
  • An attempt was made to send the request in developer settings("add account and device")
  • And other reasons

) Conclusion: data no longer matches > So Xiaomi's server considers it a new device

Code 20038 ?!

I am trying to unlock the Redmi 5 Plus (vince). I finished with this:

=========================================================
product saved successfully
token saved successfully

DeviceInfo:
product: vince
token: ******

AccountInfo:
id: ******
region: *******


code: 20038

description: 该手机已被账号 145****753 通过查找手机锁定,无法解锁

What I found strange is that in settings there is information that the device is unlocked. But the output of command "fastboot oem device-info" is different:

(bootloader) Device unlocked: false
(bootloader) Device critical unlocked: false

I would appreciate any idea how to solve it. Thank you.

Attempting unlock from macOS, os error 2 no such file or dirctory

Procedure

I cloned your repo and setup a venv and downloaded and unzipped a fresh darwin androidtools.
after realizing that your setup.py didn't have setuptools module in it, I ran it using the interpretor,
using python setup.py.
Please add that in the README so folks knows.

I copied the 'offici5l-un-lock.py' to my 'platform-tools' dir created from the unzipping of the platformtools zipfile, and after running through the prompts in the script I got this error:

device token:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

device product:
lancelot

code: 10000 descEN: Request parameter error
Invalid device token or product.

Traceback (most recent call last):
  File "/xxxxx/xxxxxx/xxxxxxxxxxxx/mitool/miunlock/platform-tools/offici5l-un-lock.py", line 224, in <module>
    exec("\n".join(line for i, line in enumerate(codecs.open('un-lock.py', 'r', 'utf-8').read().split('\n'), 1) if i not in range(10, 27)))
                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen codecs>", line 906, in open
FileNotFoundError: [Errno 2] No such file or directory: 'un-lock.py'

parts are obfuscated for security, but you can see that 'un-lock.py' is returning a Error no 2, as
I've stated above. Was that because you decided to rename the script from 'un-lock.py' to 'offici5l-un-lock.py'. There isn't any reference to this in the README, and the file doesn't appear in the repo.

When I think about it it doesn't make sense that 'un-lock.py' is a typo, since there won't much need to open another file from a script where all the data is already accessible.
It is very non-plus.

In looking through the MiTool main repo there is the identical layout with one exception being that the open() function is pointing towards an address on the termux filesystem.
It says something like '/data/data/com.termux/files/usr/bin/un-lock.py' or soemthing.
and in the repo there is actually a file called 'un-lock.py' as oppsed to here where there is only a 'offici5l-un-lock.py'. Maybe that is the source of the problem.

I put up a long sprawling post about it where I suggest near the end that you might have a feature here that dumps the token so that a user might use it with a fastboot command.

There should be a warning of erasure before retrieving the code

So I've waited for 300 hours to unlock the bootloader, today did run the app, got the following warning:

user data will be cleared when the device is unlocked.

Press Enter to unlock bootloader

So I had to cancel (via ctrl+c) to back my data up, and after that on the next app run got the following:

code 20030

Sorry, couldn't unlock more devices by this account this month.

Guess there should be a warning for that.

Receiving code 10000 (product: topaz) !

Hi,

Thank you for your work 🙏

In my case the script is failing at line 222 because I'm receiving code 10000 in the response:

elif "code" in r and r["code"] == 10000:
    remove("product", "token")
    sys.exit()

Do you have any idea why? My password contains special characters like ~,>!. Could it be an encoding issue?

Code 20041 MI id is not associated with a phone number, but I can't add any

Probably not a bug of the tool, but I'm stuck and don't know how to proceed.
I got this code when trying to unlock. Unfortunately I can't add a recovery phone to my MI account. The options suggested in https://account.xiaomi.com/helpcenter/faq/en_US/03.account-safety/04.security-phone-and-email/faq-3 aren't there. I even tried creating a new MI account on another phone so it links to it, but it didn't work.
Does anybody have an idea on how to do this? Thanks in advance!

Failed to get passToken !

  • If logged in with any account(Xiaomi) in your default browser, please log out Before running the tool
     This can be checked by opening the following link in the [ default browser ] : https://account.xiaomi.com

  • If you have not linked an email or phone number to your Xiaomi account, please do so

  • If the problem persists, Please go to:
     settings > Mi Account > Devices > select Current device > Find device "enable Find device

Can't get token after logging in

My best regards. I'm stuck with the dreaded "device not activated" error (apart from the fact that activating hasn't ever been a compulsory step while just binding under developer options has always been enough, my device is correctly activated instead) arisen only after waiting for the time asked by Xiaomi and I've tried to install miunlock according to the guidelines.
I log in with Mi account only after launching the script and, just to be on the safe side, I start with a browser with empty cache. Tried three different browsers too (Kiwi, Fennec and Soul) with the same outcome. After logging in, I get no confirmation page with the token in its address but just errors (401 with Kiwi and Fennec, net::ERR_HTTP_RESPONSE_CODE_FAILURE with Soul) at this address.
If I try to paste that address, miunlock says it can't find the token there but I'm not surprised given that I'm leaving the path very well outlined in the documentation.
Considering, I've strictly adehered to the setup and usage guidelines, I tend to exclude errors on my side and so I do with a bug in the script itself so I believe Xiaomi has changed something, again, to prevent users from successfully unlocking bootloaders.
Have a nice day! :)

unlocked: no

image_2024-05-15_025353372
Describe the bug
A clear and concise description of what the bug is.

Screenshots
If applicable, add screenshots to help explain your problem.

Zircon - Device allready unlocked

phone connected

DeviceInfo:
unlocked: None
product: zircon
token: *********

Device is allready unlocked !
fastboot getvar unlocked
unlocked: yes
Finished. Total time: 0.018s

Failes to unlock bootloader of xiaomi 12

code: 20038
description: 该手机已被账号 221****878 通过查找手机锁定,无法解锁

translates to : This phone has been locked by account 221****878 through Find Phone and cannot be unlocked

securityStatus 16 Error

get something wrong
`
securityStatus 16

Please go to: settings > Mi Account > Devices > select Current device > Find device "enable Find device"
`
but, I have finish this. Find device is enabled.
My phone is RedMi K7Pro

MiBypassTool

When I try to unlock my redmi k60 with hyperos I get this error. How do I fix it?

Traceback (most recent call last):
  File "/root/xiaomi/MiBypassTool.py", line 105, in <module>
    headers = {"Cookie": re.search(r"Cookie=\[(.*)\]", AES.new(b'20nr1aobv2xi8ax4', AES.MODE_CBC, b'0102030405060708').decrypt(base64.b64decode(headers)).rstrip(b'\0').decode('utf-8')).group(1).strip(), "Content-Type": "application/x-www-form-urlencoded"}
                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 2: invalid start byte

Download is not allowed on locked devices

After waiting the 168 hours, I was disappointed when the unlocking failed.

Here's the output:

Press Enter to unlock bootloader

Sending 'encryptData' (0 KB)                       FAILED (remote: 'Download is not allowed on locked devices')
fastboot: error: Command failed
FAILED (remote: 'Command not supported in default implementation')
fastboot: error: Command failed

________________________________________________________

(version: 1.5.0) For issues or feedback:
- GitHub: github.com/offici5l/MiUnlockTool/issues
- Telegram: t.me/Offici5l_Group


Press Enter to exit ...MiUnlockTool.py


Why is this happening? How do I fix it?

Thank you

Not connected to the phone !

If you're using Windows, Linux, Mac, ... make sure to delete any previous version of Adb&Fastboot

  1. Reboot the device into bootloader mode.
  2. Connect the device via cable (if it doesn't work, try using a different cable; it's preferable to use the original cable for your device).

If you're using Termux: Make sure to install Termux-API app.

  1. Reboot the device into bootloader mode.
  2. Connect the devices via cable(with otg)
    (Make sure that the device supports OTG, and sometimes in some devices you must activate OTG manually)
    with otg
    (if it doesn't work, try using a different cable; it's preferable to use the original cable for your device).

(termux users only)

issue "Not connected to the phone !"

Sometimes just try reboot device to bootloader mode again solves the problem

Some devices take a long time to recognize the device The default time set is 6 seconds, so this can be changed by increasing the time with the command :

miunlock time12

(Instead of 12, you can use the time you see fit, "in seconds")

therefore, if you encounter problems, you can change the device in which you use the termux because the problem is only in some devices

If you do not have another device, you can use manual mode with command :

miunlock -m

Screenshot_20240510-033651_Termux.jpg

If the fastboot commands do not work for you in termux, you can use other app such as the bugjaeger to obtain information.

command to get product

fastboot getvar product

command to get token

fastboot getvar token

or for mtk

fastboot oem get_token

KeyError: 'passToken'

Traceback (most recent call last):
  File "/home/muqiu/Applications/MiUnlockTool/MiUnlockTool.py", line 194, in <module>
    data = json.loads(requests.get("https://account.xiaomi.com/pass/serviceLogin?sid=unlockApi&_json=true&passive=true&hidden=true", headers=headers, cookies={'passToken': p['passToken'], 'userId': str(p['userId']), 'deviceId': parse_qs(urlparse(p['location']).query)['d'][0]}).text.replace("&&&START&&&", ""))
                                                                                                                                                                            ~^^^^^^^^^^^^^
KeyError: 'passToken'

FAILED (remote: 'Download is not allowed on locked devices')

Sending 'encryptData' (0 KB)                       FAILED (remote: 'Download is not allowed on locked devices')
fastboot: error: Command failed
FAILED (remote: 'Command not supported in default implementation')
fastboot: error: Command failed

Device: Redmi K50
product: rubens

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.