libimobiledevice / libideviceactivation

A library to handle the activation process of iOS devices
https://libimobiledevice.org
GNU Lesser General Public License v2.1
276 stars 129 forks source link

Fails to activate an iPad Air A1474 #34

Closed EdelMaks closed 5 years ago

EdelMaks commented 6 years ago

My iPad Air (WiFi, no mobile) just refuses to activate. In iTunes it says that it failed to retrieve device info and asks to check the sim card (which does not exist in this model), on iPad it says failed to connect to activation server.. Apple, as usual.. Can you check this out please? Spend whole evening compiling the stuff for Windows and such a frustration. https://pastebin.com/9MuyVPxn

EdelMaks commented 6 years ago

Sorry to bump again, but can please someone help me?

nikias commented 6 years ago

The weird thing is that the server returns HTTP/1.1 500, see line 810. It should usually return 200 here and some data (an xml plist). Now the question is if this is a general issue or if it just didn't like your data...

EdelMaks commented 6 years ago

And the line 806 - is it fine to be like this?

cf303fa69e7...................
nikias commented 6 years ago

Oh. I thought you masked it. If it comes from the device like that it is definitely NOT fine.

EdelMaks commented 6 years ago

So this comes from the device itself like this.. I think this is the reason why so many iPad AIR (WiFi) gone breaks after update. And no way to downgrade.. Can we check if other devices give masked output as well?

nikias commented 6 years ago

I never saw this happening. Weird though is that in the actual base64 IngestBody data inside the CollectionBlob base64 data the full udid is present. What does ideviceinfo -k UniqueDeviceID give you?

EdelMaks commented 6 years ago

It's odd, but it's fine: λ ideviceinfo -k UniqueDeviceID cf303fa69e71779c6e1924f84e9723c64bf67ccd here is the full ideviceinfo output https://pastebin.com/U8yuNi9s

nikias commented 6 years ago

Yes that looks normal. However in the debug output in lockdownd_client_new it shows the dotted one too. Does is also happen if you run ideviceinfo -d ?

EdelMaks commented 6 years ago

Here is the command output, does not look like there is any mask on UDID.. What a weird case.. https://pastebin.com/eicCkMq8

nikias commented 6 years ago

But it repeatedly happens with ideviceactivation? Like every time?

EdelMaks commented 6 years ago

Yes, i don't know what else to do, even Apple Support is useless. Spent whole evening, but all they could advise is to change internet connection or PC which i did many times before them and all other phones do activate without any problem. Even their own system does not know what the error is, because iTunes say "Coudn't retrieve important information from the device" and the device reads "Failed to connect to activation server" LOL. Apple is so Apple..

nikias commented 6 years ago

Ok so let's try something. Add this line

plist_dict_set_item(blob, "UniqueDeviceID", plist_new_string("cf303fa69e71779c6e1924f84e9723c64bf67ccd"));

to line 251 of ideviceactivation.c: https://github.com/libimobiledevice/libideviceactivation/blob/master/tools/ideviceactivation.c#L251

and then recompile and run again with debug (-d) and see what the server responds.

nikias commented 6 years ago

Also, please check what idevice_id -l is showing

EdelMaks commented 6 years ago

Added the line, not much changed and the error looks like this: 20:31:25 src\property_list_service.c:239 internal_plist_receive_timeout(): printing 1379 bytes plist: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

Error Failed to retrieve activation info. ({ FunctionName = "init_lockdown_server_block_invoke"; NSLocalizedDescription = "Failed to retrieve activation info."; NSUnderlyingError = "Error Domain=com.apple.MobileActivation.ErrorDomain Code=-2 \"Failed to establish session.\" UserInfo={NSUnderlyingError=0x100b13ca0 {Error Domain=com.apple.MobileActivation.ErrorDomain Code=-3 \"Failed to decode session data.\" UserInfo={NSUnderlyingError=0x100b17a50 {Error Domain=NSCocoaErrorDomain Code=3840 \"Encountered empty plist tag\" UserInfo={NSDebugDescription=Encountered empty plist tag, kCFPropertyListOldStyleParsingError=Error Domain=NSCocoaErrorDomain Code=3840 \"Malformed data byte group at line 1; invalid hex\" UserInfo={NSDebugDescription=Malformed data byte group at line 1; invalid hex}}}, SourceLine=322, FunctionName=-[MobileActivationDaemon handleSessionResponse:withError:], NSLocalizedDescription=Failed to decode session data.}}, SourceLine=524, FunctionName=-[MobileActivationDaemon createTunnel1ActivationInfo:options:withCompletionBlock:]_block_invoke, NSLocalizedDescription=Failed to establish session.}"; SourceLine = 150; })

and here is the full output: https://pastebin.com/ERGMPKNc

Note the Code=3840 \"Encountered empty plist tag\" message please, maybe this is the problem?

EdelMaks commented 6 years ago

The output looks also fine: λ idevice_id -l cf303fa69e71779c6e1924f84e9723c64bf67ccd

nikias commented 6 years ago

I wanted to see the libcurl output showing the request and response to/from the server like in your initial post

EdelMaks commented 6 years ago

Sorry i have added this in edit, here is the paste: https://pastebin.com/ERGMPKNc

nikias commented 6 years ago

Heh weird. This time the udid is not masked in the lockdownd_client_new function. Still the activation server doesn't like it... this is really strange; the data sent to the server looks fine from what I can tell. Can't say about the signature it has but all this data is coming from the device. Maybe the device is somehow producing invalid (crypto) output and this causes the issues. No idea actually :( I will see what response I get from the server if I flip a bit in the data.

EdelMaks commented 6 years ago

Thanks Nikias, if you get any update I will be glad. Apple Support is literally useless, I don't know what they pay millions for.

nikias commented 6 years ago

So if I modify a byte in the CollectionBlob I can provoke a HTTP 500 error, either in the IngestBody or the X-Apple-* data. It really seems something is broken on the device. Weird. I don't see any misbehavior from iTunes (or ideviceactivation) here. Sorry 😞

EdelMaks commented 6 years ago

Ok thank you a lot. If this is device's fault - nothing we can do. I wonder what kind of data iTunes fails to read if all the data we know we can read.. Over-complicating is what Apple loves more than it's users.. I would have a working iPad instead i have a break.

nikias commented 6 years ago

Have you tried to restore it again?

EdelMaks commented 6 years ago

Sorry, i was on vacation, will let you know asap. Thanks for still trying to help!

EdelMaks commented 6 years ago

Hi Nikias, so what actually happened was a bad exe that i have compiled on windows. After finiding a normal working one i still have the problem with this iPad. Here is the new output from tested and working on other phones software (btw ihave updated it as well and restored) Link

nikias commented 5 years ago

Ok, closing the issue.