francescotescari / XiaoMiToolV2

XiaomiTool V2 - Modding tool for xiaomi devices
https://www.xiaomitool.com
Apache License 2.0
636 stars 124 forks source link

Fix error during unlocking caused by 'fastboot getvar token' returning 'GetVar Variabe Not found' on newer devices #88

Closed ghost closed 2 months ago

ghost commented 1 year ago

Xiaomi has changed the fastboot behavior on newer devices. Now you need to call "fastboot oem get_token" instead of "fastboot getvar token", and the token also bacame longer.

This fix tries to get the token using the old way, and if the tken is not returned, it uses the new method to retrieve it, ensuring compatibility with both older and newer devices.

Okazakee commented 1 year ago

Fixes #54

Hey can you provide a build with that fix somewhere? i am trying to do it but i am not a java dev. Thanks in advance

Okazakee commented 1 year ago

Fixes #54

Hey can you provide a build with that fix somewhere? i am trying to do it but i am not a java dev. Thanks in advance

Here you go, please report if anything doesn't work as intended, i'll probably try to fix https://github.com/Nik-Kot/XiaoMiToolV2/releases/tag/dev

Omg I will try that tomorrow, a friend of mine has a Xiaomi to unlock, let's see. Thank you very much either way

Okazakee commented 1 year ago

There is something strange on login, it says the JSON response {R S OK}, something like that. Even the old app is giving problems

edisionnano commented 1 year ago

I'm trying to login however I'm never receiving the SMS with the verification code

edisionnano commented 1 year ago

OK so small update, scanning the QR code to login will NOT work due to the aforementioned JSON issue; here's what you need to do: The correct way to login is via phone and password, it must send you an SMS with a token but you can't see the captcha from the tool's login window. Open a Chromium tab instead, navigate to https://account.xiaomi.com/pass/serviceLogin?sid=unlockApi&json=false&passive=true&hidden=false&_snsDefault=facebook&_locale=en_US&checkSafePhone=true Login, input the captcha and once you get the SMS input the code on the tool's login window instead of Chromium. This should let you login. PS:Thanks to #67 if you change the JavaFX version to the latest stable you will get the captcha but I wasn't able to receive the SMS even after changing the URL on LoginController to private static final String LOGIN_URL = "https://account.xiaomi.com/pass/serviceLogin?sid=unlockApi&json=false&passive=true&hidden=false&_snsDefault=facebook&_locale=en_US&checkSafePhone=true";

First problem solved, the second issue was that on Linux it couldn't find any devices and looking at the terminal there seemed to be some permission issue that chmod +x couldn't fix but this was easy to overcome. I cloned OP's branch using https://github.com/Nik-Kot/XiaoMiToolV2.git CDd inside cd XiaoMiToolV2 and built and ran the app using sudo ./gradlew run Now on Arch Linux I had to set java-11-openjdk using sudo archlinux-java set java-11-openjdk

Second problem solved, then I ran into another issue; when booting to fastboot it would stay there for a split second and then black screen and no device on lsusb, this was an easy one. See I used the usb hub my keyboard had, using the usb ports on the back of my PC solved this issue.

And now my fourth problem, while trying to solve issue #3 I ran out of SMS verification attempts and I shall wait 24 hours to receive another one.

edisionnano commented 1 year ago

YES! It worked and I was able to unlock my Mi 8 Lite on Linux, thanks

ajaypaul619 commented 1 year ago

Hey there this build is not working for me. everything worked well but atlast i got a error message like this image

image

Please help me to solve this.Thanks!!

ajaypaul619 commented 1 year ago

I also tried running java application .Please find below the error i got : [16:10:18][INFO ][4fa65672] Unlock request token: [16:10:18][INFO ][4fa65672] Unlock request (/api/v2/nonce) params: r=wcrefgdlhjivxomb&sid=miui_unlocktool_client&sign=7a6fcb796033f0d07460601311f9550e0b2e4472 [16:10:19][INFO ][4fa65672] Unlock request (/api/v2/nonce) response: {"code":0,"nonce":"eyJzIjoiZWUxZTYxNTZhYjRhZGM4YmMyYTgxMzQ3Nzk4NTVjY2U3NzNhMGEzYSIsInQiOjE2NzkxMzYwMTg2MTIsInIiOiJEWkh2WSJ9","description":"??"} [16:10:19][INFO ][4fa65672] Unlock request (/api/v3/ahaUnlock) params: appId=1&data=ewogICAiY2xpZW50SWQiIDogIjIiLAogICAiY2xpZW50VmVyc2lvbiIgOiAiNS41LjIyNC41NSIsCiAgICJkZXZpY2VJbmZvIiA6IHsKICAgICAgImJvYXJkVmVyc2lvbiIgOiAiIiwKICAgICAgImRldmljZU5hbWUiIDogIiIsCiAgICAgICJwcm9kdWN0IiA6ICJyb3N5IiwKICAgICAgInNvY0lkIiA6ICIiCiAgIH0sCiAgICJkZXZpY2VUb2tlbiIgOiAiIiwKICAgImxhbmd1YWdlIiA6ICJlbiIsCiAgICJvcGVyYXRlIiA6ICJ1bmxvY2siLAogICAicGNJZCIgOiAiNTllN2MwMzk4MTY2YWJhZTIwYWYzNThkYTVlNjI1OTgiLAogICAicmVnaW9uIiA6ICIiLAogICAidWlkIiA6ICI1NTgwNzQ0MDYzIgp9Cg==&nonce=eyJzIjoiZWUxZTYxNTZhYjRhZGM4YmMyYTgxMzQ3Nzk4NTVjY2U3NzNhMGEzYSIsInQiOjE2NzkxMzYwMTg2MTIsInIiOiJEWkh2WSJ9&sid=miui_unlocktool_client&sign=7636acf77eda96340771e99287d432aa7d236c05 [16:10:19][INFO ][4fa65672] Unlock request (/api/v3/ahaUnlock) response: {"code":10000,"description":"????","descCN":"????","descEN":"Request parameter error","uid":"5580744063"} [16:10:19][INFO ][4fa65672] Unlock request response: {"code":10000,"description":"????","descCN":"????","descEN":"Request parameter error","uid":"5580744063"} [16:10:19][PROC ][7ec57f6c] Process (67) output: could not read ok from ADB Server

hhacker1999 commented 1 year ago

Hello, Can you please make a mac os build? I am trying to build this branch but always getting java errors.

ghost commented 1 year ago

OK so small update, scanning the QR code to login will NOT work due to the aforementioned JSON issue; here's what you need to do: The correct way to login is via phone and password, it must send you an SMS with a token but you can't see the captcha from the tool's login window. Open a Chromium tab instead, navigate to https://account.xiaomi.com/pass/serviceLogin?sid=unlockApi&json=false&passive=true&hidden=false&_snsDefault=facebook&_locale=en_US&checkSafePhone=true Login, input the captcha and once you get the SMS input the code on the tool's login window instead of Chromium. This should let you login. PS:Thanks to #67 if you change the JavaFX version to the latest stable you will get the captcha but I wasn't able to receive the SMS even after changing the URL on LoginController to private static final String LOGIN_URL = "https://account.xiaomi.com/pass/serviceLogin?sid=unlockApi&json=false&passive=true&hidden=false&_snsDefault=facebook&_locale=en_US&checkSafePhone=true";

First problem solved, the second issue was that on Linux it couldn't find any devices and looking at the terminal there seemed to be some permission issue that chmod +x couldn't fix but this was easy to overcome. I cloned OP's branch using https://github.com/Nik-Kot/XiaoMiToolV2.git CDd inside cd XiaoMiToolV2 and built and ran the app using sudo ./gradlew run Now on Arch Linux I had to set java-11-openjdk using sudo archlinux-java set java-11-openjdk

Second problem solved, then I ran into another issue; when booting to fastboot it would stay there for a split second and then black screen and no device on lsusb, this was an easy one. See I used the usb hub my keyboard had, using the usb ports on the back of my PC solved this issue.

And now my fourth problem, while trying to solve issue #3 I ran out of SMS verification attempts and I shall wait 24 hours to receive another one.

I've done what you said. I changed the LoginController file and the JavaFX version for the captcha to shows up. Then, I built and ran the tool, I also navigated to the site you pointed out and requested and SMS code. After I tried to place the code in the tool I got a verification code error, then, when I tried to use the same code in the browser I got the same error. 2023-08-03_15-08-1691094692 However, if I don't try to use the code in the tool and put it in the browser right away it succeeds and shows the following: 2023-08-03_15-08-1691095092 Do you know how can I avoid the verification code error? I'm trying to unlock a Xiaomi Redmi Note 6 pro using the XiaoMiToolV2 on an ArchLinux machine.

dreit-p commented 11 months ago

Here you go, please report if anything doesn't work as intended, i'll probably try to fix https://github.com/Nik-Kot/XiaoMiToolV2/releases/tag/dev

@Nik-Kot , could you please make a build for macos?

darkcous commented 6 months ago

Xiaomi has changed the fastboot behavior on newer devices. Now you need to call "fastboot oem get_token" instead of "fastboot getvar token", and the token also bacame longer.

This fix tries to get the token using the old way, and if the tken is not returned, it uses the new method to retrieve it, ensuring compatibility with both older and newer devices.

Xiaomi ha cambiado el comportamiento de fastboot en dispositivos más nuevos. Ahora necesita llamar a "fastboot oem get_token" en lugar de "fastboot getvar token", y el token también se hizo más largo.

Esta solución intenta obtener el token de la forma anterior y, si no se devuelve, utiliza el nuevo método para recuperarlo, lo que garantiza la compatibilidad tanto con dispositivos antiguos como nuevos.

Amigo tengo un problema, se que este tema está cerrado y no sé si todavía siga esto o estás activo, pero he bloqueado en bootloader lo que bloqueado con una rom personalizada me puede ayudar a desbloquearlo?