[TOOL][WIN/LIN/MAC] MiUnlockTool - Unlock bootloader of xiaomi devices on mac & linux

Search This thread

franztesca

Member
Apr 23, 2017
9
190
[TOOL][WIN/LIN/MAC] MiUnlockTool - Unlock bootloader of xiaomi devices on mac & linux

Ciao xda users, I'm here to introduce a new tool of mine, MiUnlockTool.
MiUnlockTool is an unofficial tool used to unlock bootloader on Xiaomi devices. This tool is copied from the original windows MiFlashUnlock tool and works the same way. The main feature of this tool is compatibility with linux and mac operating system (and windows too).
If you want more information about the tool and the story behind you can read below, if you just want the download link, here it is:
DOWNLOAD LINK
Requirements: java (javafx for gui if not included in your jdk/jre)

Usage:
- Download and extract the zip file
- If you don't have it, install java
- On windows:
-- open MiFlashUnlock.bat for graphical interface or:
-- open a cmd windows and cd into extracted dir and use "MiUnlockTool.bat username password" command for command-line usage
- On linux:
-- open a terminal window and cd into extracted dir and use "sudo ./MiUnlockTool.sh" command for gui interface or "sudo ./MiUnlockTool.sh username password" for command-line
- On mac:
-- open (double click) MiFlashUnlock.command for graphical interface or
-- open a terminal window and cd into extracted dir and use "./MiFlashUnlock.command username password" for command-line
- Attach your locked device in fastboot mode.
- If you are using gui just follow what you see on your screen
- If you are using command line version remember that there is no confirmation request before unlock and no check if the bootloader is already unlocked.

Possible errors:
- If you get a permission related error on linux or mac when launching the tool, open a terminal and cd into extracted dir and use "chmod 777 MiUnlockTool.sh" (or MiUnlockTool.command on mac) to set the executable permission.
- If your device isn't recognized:
-- On windows: install adb drivers
-- On linux/mac trying launching the tool with sudo (sudo ./MiUnlockTool.sh on linux or sudo ./MiUnlockTool.command on mac)
- Other problems launching the tool: try running "java -jar bin/MiUnlockTool.jar" command
- If you get some errors with javafx class not found stuff when you try to launch the gui, then you are missing javafx library. See openjfx package on linux.
- Any other problem: provide feedback in the comments.


Additional info: original MiFlashUnlock tool is just a bridge between fastboot, you (and your account login credentials) and xiaomi server: the tool gets device info from the device and send them to the server together with the account login token, the server checks wherever you satisfy all their requirements (account authorized, account associated with device in developer settings etc) and if everything is okay the server reply with the unlock key for your device instance (every time you reboot your phone you need a new key). Then the tool send the key to the device with a custom build of fastboot and if the key is right then the device is unlocked, else it reboots. After I discovered all the process behind the original unlock tool (and all the security encryption techniques) I decided to replicate it with a java (cross-platform) tool which embeds a custom fastboot version and replicates what the original tool does. That's a simple explaination of how my tool works (obviously it's more complicated than that).
This tool requires all of what is required by the original tool (an authorized xiaomi account binded to the device through developer options for three days if I remember correctly).

FAQs:
- Is this tool safe to use?
Yes, the main part is communication between tool and server, a safe thing. Also the unlock procedure itself is safe: or the key is correct or it is not. In both cases the device will not be damage.
- How did you find out how to replicate the original tool?
Thank you for your question. It's been a bit difficult since the original tool has been obfuscated and virtualized (protected against reverse engeneering) with a powerful protector: VMProtect. I've spent some time to reverse it (and custom fastboot too) and I finally did it. I will not explain in details how I did it.
- Is this tool more powerful than the original on? why should I use it on Windows?
Absolutely not, my tool is worst than the original one (it will have more bugs and on windows it doesn't manage drivers for example), that's why you should NOT use it on Windows. I made it work even with Windows because it was very simple to do. You can use it one Windows just to test it if you like, but I recommend using the better original tool MiFlashUnlock.
- Wow, you did a tool already done by developers paid by xiaomi, who is paying for the effort you put into this?
No one, I try to help people and getting appreciation for my work is a bit of a reward to me, but if you want to show your gratitude even more and support me as a developer you can make a donation, I will appreciate that even more ;) (donation link below)
- I have to put my xiaomi account credentials, should I trust this?
I'm the developer of XiaoMiTool, I hope that a little bit of my reputation together with the hopefully good early feedback of reckless users on this tool is enough. If you are more a geek you can track the traffic and see that the only server connected are xiaomi and miui.
- I wanted too see the source of this tool but I see it is a bit obfuscated, why?
Xiaomi clearly doesn't wanted people to see how MiFlashUnlock works (since they obfuscated it a lot), I don't want to disrespect xiaomi decision by releasing the source plain, so I decided to obfuscated it a bit just to make it a bit harder to see (even if my tool is 100 times easier to reverse than the original)
- Can I share this tool?
Of course yes, but I would like you to share it using the xiaomitool.com link (not mega.nz one) so that if I release an update new people will get that and not the old version (there is no tool update enginge built in).
- You're english is not wonderful...
I know, hopefully it is understandable enough


Feedback.
I love feedback, feedback is the best you can do to help me improving this tool. I have not time to answer everybody's questions but I generally read feedback and do my best to make the tool work. If the tool worked or if the tool didn't worked you can write it in the comments, adding additional information like what error you get, what screen you see when the tool get stuck or even what you tried to solve the problem are precious to me. I have not all of xiaomi devices, I fully ested my tool only with two devices (a redmi 4x and a mi note 2) and only on two operating systems (linux and windows), so any new combination could lead to new errors or problems. Please include also your operating system when leaving feedback. Sometimes there are problems on gui which are not on command-line version, so if the tools fails launching or when using gui I suggest trying the command-line version.

Donation: free software is great from users prospective, but developers who spend hours of their time and don't get money for it are more unhappy to develop further free tools, so if you liked the tools and it saved you from the need to do 5000 kilometers to get a windows pc, or from the need to download a virtual machine image with your 32kB internet connection, you can show your gratitude by offering me a tasty, cold beer by clicking the link below ;)
DONATION LINK

Download: you missed the download link at the top? Here it is again:
DOWNLOAD LINK
 

dpvalverde

New member
Jul 27, 2018
1
1
Problems with mi unlock on ubuntu system

Dear,

I tried to run this miunlock on my linux pc and it did not work. I installed the javafx using "sudo apt install openjfx" . After I ran "sudo ./*.sh". The program open, but when I put my email and password, it does not connect with the xiaomi server. I tried to access using facebook login and I have the same problem. How can I solve this problem? Do you have any idea?

Thanks
Danillo
 
  • Like
Reactions: diannn39

NoMath

New member
Mar 1, 2018
1
0
The program does not find the phone connected. But "sudo fastboot reboot" work

---------- Post added at 12:03 PM ---------- Previous post was at 11:51 AM ----------

Dear,

I tried to run this miunlock on my linux pc and it did not work. I installed the javafx using "sudo apt install openjfx" . After I ran "sudo ./*.sh". The program open, but when I put my email and password, it does not connect with the xiaomi server. I tried to access using facebook login and I have the same problem. How can I solve this problem? Do you have any idea?

Thanks
Danillo
Reinstall certs
 

gabamarul

New member
Jul 28, 2018
1
0
disconnects phone on checking bootloader status with an error message on top left corner of phone "press any key to shutdown"
and stays stuck after reconnecting in fastboot mode when reading device info.
 

bobbygege

Member
Mar 13, 2018
5
1
Status : Success unlock bootloader
Device : Redmi 4X
Waiting Time : 72hours

Thx for the tool . love3 ??????
 

Attachments

  • IMG_20180812_205056.jpg
    IMG_20180812_205056.jpg
    265 KB · Views: 8,347
  • Screenshot_2018-08-12-20-46-57-197_com.android.settings.png
    Screenshot_2018-08-12-20-46-57-197_com.android.settings.png
    25.6 KB · Views: 8,346
  • Screenshot_2018-08-12-03-10-55-732_com.android.settings.png
    Screenshot_2018-08-12-03-10-55-732_com.android.settings.png
    77.5 KB · Views: 8,298

YetAnotherForumUser

Senior Member
Oct 31, 2008
471
1,666
Waiting for a fastboot device...

Well, the communication with the 'net seems to work as intended but that is where it stops:

Code:
[18:01:15][INFO  ] Starting login procedure
[18:01:24][INFO  ] Login procedure succeeded
[18:01:25][INFO  ] Checking account unlock permission
[18:01:27][INFO  ] Unlock permission confirmed
[18:01:27][INFO  ] Waiting for a fastboot device

Using the fastboot command line works for the same user account so this won't be solved by running the tool as root. The device reports itself as 18d1:d00d Google Inc. and shows up clearly when using the fastboot command line tool:

Code:
$ fastboot devices
deadbeef	fastboot

(no, my device ID is not deadbeef)

Tried OpenJDK 10 and 9, Oracle JRE 8, no difference.

Digging deeper using strace shows the problem: the 'special' fastboot command you include (in bin/MiUnlockTool_res) is a 64-bit executable while I'm running the tool on a 32-bit machine. Substituting the provided tool for a link to the version already present on this machine makes the command progress to the error:

Code:
$ java -jar bin/MiUnlockTool.jar 'myusername@mydomain.com' 'mysupersecretpassword'
[18:19:25][INFO  ] Starting login procedure
[18:19:36][INFO  ] Login procedure succeeded
[18:19:36][INFO  ] Checking account unlock permission
[18:19:39][INFO  ] Unlock permission confirmed
[18:19:39][INFO  ] Waiting for a fastboot device
[18:19:39][INFO  ] Device connected: deadbeef
[18:19:39][INFO  ] Obtaining device info...
[18:19:40][INFO  ] Device info obtained
[18:19:40][INFO  ] Checking if unlock will erase data and server message
[18:19:42][INFO  ] Unlock procedure will erase userdata
[18:19:42][INFO  ] Server message: An unlocked device is an easy target for malware which may damage your device or cause financial loss.
[18:19:42][INFO  ] Querying unlock server for unlock key
[18:19:48][ERROR ] Unlock request replied with error code 20036
[18:19:48][ERROR ] Error meaning: After %d hours of trying to unlock the device

I guess I have to wait, how long I do not know as this is not shown in either mode (command line or GUI).

Anyway, you might want to add a 32-bit fastboot command or just tell users to install a native version and use that.
 

nadrolinux

New member
Aug 23, 2018
3
0
@YetAnotherForumUser
I see the same error message when I tried to unlock MI 8 (global version bought yesterday in official Xiaomi store in Poland). I tried official Xiaomi tools on Windows 10, but without any success (verify failed at 50%).
 

laharl_22

Senior Member
Jan 23, 2011
247
19
i have this 2 errors on linux tring to unlocking my redmi note 5 [20:59:38][ERROR ] Unlock request replied with error code 20036
[20:59:38][ERROR ] Error meaning: After %d hours of trying to unlock the device
 

nadrolinux

New member
Aug 23, 2018
3
0
After waiting 360 hours I was able to unlock my Mi 8 with this tool on my Ubuntu! With official MiFlashUnlock tool I wasn't able to unlock this device on Windows 10. Thanks a lot!
 

YetAnotherForumUser

Senior Member
Oct 31, 2008
471
1,666
Code:
...
[18:19:48][ERROR ] Unlock request replied with error code 20036
[18:19:48][ERROR ] Error meaning: After %d hours of trying to unlock the device

I guess I have to wait, how long I do not know as this is not shown in either mode (command line or GUI).

After about 13 days - I only tried twice in between - the thing is now unlocked. I needed to run the tool on a 64-bit machine as the 32-bit fastboot crashed (with a message in the lines of "* buffer overflow detected *"), possibly due to the longish argument used in the unlocking procedure.
 

nadrolinux

New member
Aug 23, 2018
3
0
After about 13 days - I only tried twice in between - the thing is now unlocked. I needed to run the tool on a 64-bit machine as the 32-bit fastboot crashed (with a message in the lines of "* buffer overflow detected *"), possibly due to the longish argument used in the unlocking procedure.
I also used 64-bit OS -> Ubuntu 18.04 x64. It would be nice to see amount hours instead of %d, however it's just a minor bug. This tool is the best choice for Linux, MacOS and event Windows 10 users.
 

drewcaddy

Member
Oct 18, 2014
5
0
Hey guys,

Although I've unlocked & rooted other Android's in the past, this is my first time with a Xiaomi device. I've tried running the tool, and appear to get the "Error meaning: After %d hours of trying to unlock the device" error. Am I right in thinking this is just a bug in terms of the hours displayed, and that I will just need to wait the 15 or so days before I can unlock the device? At what point does that 15 days begin?

Also, once unlocked, what is the best way to flash a ROM? ADB via Terminal?

Looking to flash the Global MIUI over the Chinese one I currrently have.

Thanks!
 

huynhkhoa

New member
Oct 13, 2012
2
0
Help. Can not connect to my phone in fastboot when using this tool. But the MiUnlock is still connected
 

Top Liked Posts

  • There are no posts matching your filters.
  • 53
    [TOOL][WIN/LIN/MAC] MiUnlockTool - Unlock bootloader of xiaomi devices on mac & linux

    Ciao xda users, I'm here to introduce a new tool of mine, MiUnlockTool.
    MiUnlockTool is an unofficial tool used to unlock bootloader on Xiaomi devices. This tool is copied from the original windows MiFlashUnlock tool and works the same way. The main feature of this tool is compatibility with linux and mac operating system (and windows too).
    If you want more information about the tool and the story behind you can read below, if you just want the download link, here it is:
    DOWNLOAD LINK
    Requirements: java (javafx for gui if not included in your jdk/jre)

    Usage:
    - Download and extract the zip file
    - If you don't have it, install java
    - On windows:
    -- open MiFlashUnlock.bat for graphical interface or:
    -- open a cmd windows and cd into extracted dir and use "MiUnlockTool.bat username password" command for command-line usage
    - On linux:
    -- open a terminal window and cd into extracted dir and use "sudo ./MiUnlockTool.sh" command for gui interface or "sudo ./MiUnlockTool.sh username password" for command-line
    - On mac:
    -- open (double click) MiFlashUnlock.command for graphical interface or
    -- open a terminal window and cd into extracted dir and use "./MiFlashUnlock.command username password" for command-line
    - Attach your locked device in fastboot mode.
    - If you are using gui just follow what you see on your screen
    - If you are using command line version remember that there is no confirmation request before unlock and no check if the bootloader is already unlocked.

    Possible errors:
    - If you get a permission related error on linux or mac when launching the tool, open a terminal and cd into extracted dir and use "chmod 777 MiUnlockTool.sh" (or MiUnlockTool.command on mac) to set the executable permission.
    - If your device isn't recognized:
    -- On windows: install adb drivers
    -- On linux/mac trying launching the tool with sudo (sudo ./MiUnlockTool.sh on linux or sudo ./MiUnlockTool.command on mac)
    - Other problems launching the tool: try running "java -jar bin/MiUnlockTool.jar" command
    - If you get some errors with javafx class not found stuff when you try to launch the gui, then you are missing javafx library. See openjfx package on linux.
    - Any other problem: provide feedback in the comments.


    Additional info: original MiFlashUnlock tool is just a bridge between fastboot, you (and your account login credentials) and xiaomi server: the tool gets device info from the device and send them to the server together with the account login token, the server checks wherever you satisfy all their requirements (account authorized, account associated with device in developer settings etc) and if everything is okay the server reply with the unlock key for your device instance (every time you reboot your phone you need a new key). Then the tool send the key to the device with a custom build of fastboot and if the key is right then the device is unlocked, else it reboots. After I discovered all the process behind the original unlock tool (and all the security encryption techniques) I decided to replicate it with a java (cross-platform) tool which embeds a custom fastboot version and replicates what the original tool does. That's a simple explaination of how my tool works (obviously it's more complicated than that).
    This tool requires all of what is required by the original tool (an authorized xiaomi account binded to the device through developer options for three days if I remember correctly).

    FAQs:
    - Is this tool safe to use?
    Yes, the main part is communication between tool and server, a safe thing. Also the unlock procedure itself is safe: or the key is correct or it is not. In both cases the device will not be damage.
    - How did you find out how to replicate the original tool?
    Thank you for your question. It's been a bit difficult since the original tool has been obfuscated and virtualized (protected against reverse engeneering) with a powerful protector: VMProtect. I've spent some time to reverse it (and custom fastboot too) and I finally did it. I will not explain in details how I did it.
    - Is this tool more powerful than the original on? why should I use it on Windows?
    Absolutely not, my tool is worst than the original one (it will have more bugs and on windows it doesn't manage drivers for example), that's why you should NOT use it on Windows. I made it work even with Windows because it was very simple to do. You can use it one Windows just to test it if you like, but I recommend using the better original tool MiFlashUnlock.
    - Wow, you did a tool already done by developers paid by xiaomi, who is paying for the effort you put into this?
    No one, I try to help people and getting appreciation for my work is a bit of a reward to me, but if you want to show your gratitude even more and support me as a developer you can make a donation, I will appreciate that even more ;) (donation link below)
    - I have to put my xiaomi account credentials, should I trust this?
    I'm the developer of XiaoMiTool, I hope that a little bit of my reputation together with the hopefully good early feedback of reckless users on this tool is enough. If you are more a geek you can track the traffic and see that the only server connected are xiaomi and miui.
    - I wanted too see the source of this tool but I see it is a bit obfuscated, why?
    Xiaomi clearly doesn't wanted people to see how MiFlashUnlock works (since they obfuscated it a lot), I don't want to disrespect xiaomi decision by releasing the source plain, so I decided to obfuscated it a bit just to make it a bit harder to see (even if my tool is 100 times easier to reverse than the original)
    - Can I share this tool?
    Of course yes, but I would like you to share it using the xiaomitool.com link (not mega.nz one) so that if I release an update new people will get that and not the old version (there is no tool update enginge built in).
    - You're english is not wonderful...
    I know, hopefully it is understandable enough


    Feedback.
    I love feedback, feedback is the best you can do to help me improving this tool. I have not time to answer everybody's questions but I generally read feedback and do my best to make the tool work. If the tool worked or if the tool didn't worked you can write it in the comments, adding additional information like what error you get, what screen you see when the tool get stuck or even what you tried to solve the problem are precious to me. I have not all of xiaomi devices, I fully ested my tool only with two devices (a redmi 4x and a mi note 2) and only on two operating systems (linux and windows), so any new combination could lead to new errors or problems. Please include also your operating system when leaving feedback. Sometimes there are problems on gui which are not on command-line version, so if the tools fails launching or when using gui I suggest trying the command-line version.

    Donation: free software is great from users prospective, but developers who spend hours of their time and don't get money for it are more unhappy to develop further free tools, so if you liked the tools and it saved you from the need to do 5000 kilometers to get a windows pc, or from the need to download a virtual machine image with your 32kB internet connection, you can show your gratitude by offering me a tasty, cold beer by clicking the link below ;)
    DONATION LINK

    Download: you missed the download link at the top? Here it is again:
    DOWNLOAD LINK
    8
    Fully obfuscated tool. Maybe bloatware or password hijacker
    4
    I'm using the latest Linux Mint but the MiUnlockTool don't work, do you know if there is another tool to unlock the bootloader using GNU/Linux?
    Unfortunately no. The only way that I found to unlock the bootloader was to install Windows and then use Xiaomi's unlock tool.
    I wrote a whole blog post about my experience doing it, but this forum won't let me post a link.
    To read it, search in Google for: "amosbbatto Why we don't own our mobile phones"

    Couldn't get Mi Unlock working on my Windows 10 for the life of me (Unlock button would stay grey even if I had plugged in my phone), but this seemed to work fine until it requested the unlock key.
    You either have to install the USB drivers from xiaomigeek.com or you have to register your phone at the Xiaomi web site. See my blog post about it.
    3
    So, uhh, is the author aware of the bug with %d displaying instead of something meaningful like hours until unlock?
    3

    Lol...using linux and dont know about sudo. We start with sudo for some actions if we want to run comand with admin rights.

    R u using terminal right?

    Then u need sudo command sometime.

    If u want to install app then u say
    sudo apt-get install nameofapp
    Or just go to ubuntu store and search android tools fasboot


    Then open terminal and run fastboot commands
    Connect phone to pc.

    fastboot devices

    fastboot oem device-info

    If its hangs use

    sudo fastboot oem device-info
    Enter password