offici5l / MiUnlockTool

MiUnlockTool developed to retrieve encryptData(token) for Xiaomi devices for unlocking bootloader, It is compatible with all platforms.
Apache License 2.0
289 stars 17 forks source link

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

Closed TunnelThruTime closed 9 months ago

TunnelThruTime commented 9 months ago

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.

offici5l commented 9 months ago

thank you for reporting ..

you're right, I forgot to change name on https://github.com/offici5l/un-lock/blob/main/offici5l-un-lock.py#L224 (has been corrected)

( code 10000 means that device token or product is incorrect or you are trying un-lock on an already unlocked device !, and this will not work. you must try the un-lock on a locked bootloader device )

i did not originally intend to make a version that would work on Windows/Linux/Mac

a user was looking for this https://github.com/offici5l/MiTool/issues/10 so I made a quick copy of mitool .. and he successfully unlocked bootloader via MacOs

there will definitely be some shortcomings.. i will try to improve them in the next update ...