Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8.2 of iTunes itl not readable #2

Closed
josephw opened this issue Mar 13, 2015 · 6 comments
Closed

8.2 of iTunes itl not readable #2

josephw opened this issue Mar 13, 2015 · 6 comments

Comments

@josephw
Copy link
Owner

josephw commented Mar 13, 2015

Original issue 2 created by josephw on 2009-05-26T15:15:21.000Z:

looks like they changed it again in .itl for iTunes 8.2 beta.
The file no longer will decompress.

@josephw
Copy link
Owner Author

josephw commented Mar 13, 2015

Comment #1 originally posted by josephw on 2009-07-01T04:55:46.000Z:

The existing key still works fine for me in 8.2. As noted above, the data must be zlib deflated after it is
decrypted.

@josephw
Copy link
Owner Author

josephw commented Mar 13, 2015

Comment #2 originally posted by josephw on 2009-07-11T04:22:28.000Z:

If I run the code against an older (before 2009-Mar), I get the decrypted file;
anything later (incl. 8.2) gives me Chinese text.

"deflated" suggests compression; the latest version of the iTunes library should be
compressed after it's decrypted?!

I inserted this code after
decrypted = crypt(restOfFile, Cipher.DECRYPT_MODE);
in Hdfm.read(...):

java.util.zip.DeflaterInputStream is_Deflater = new java.util.zip.DeflaterInputStream
( new java.io.ByteArrayInputStream( decrypted ), new java.util.zip.Deflater() );
java.io.ByteArrayOutputStream os_ByteArray = new java.io.ByteArrayOutputStream(
restOfFile.length );
byte[] by_Compressed = new byte[restOfFile.length];
int i__Compressed;
while( true )
{ i__Compressed = is_Deflater.read( by_Compressed, 0, restOfFile.length );
if( i__Compressed == -1 )
break;
os_ByteArray.write( by_Compressed, 0, i__Compressed );
}
by_Compressed = os_ByteArray.toByteArray();
return new Hdfm( version, unknown, headerRemainder, by_Compressed );

I temporarily modified ParseLibrary.parse(...) to immediately return the Hdfm to
ParseLibrary.main(...) - since ParseLibrary.drain(...) was failing - and write
Hdfm.fileData (aka by_Compressed) to decrypted-file. With pre-8.? ITLs, I get an
obvious database; otherwise I get tons of Chinese characters.

If you have code that works, please post an example. It's agonizing being so close
yet so far (cannot revert database to 7.x). BTW, tried inflating too; got some kind
of header error.

Thanks.

@josephw
Copy link
Owner Author

josephw commented Mar 13, 2015

Comment #3 originally posted by josephw on 2009-07-11T16:42:19.000Z:

Sorry for that first paragraph above - the poor writing reflects my level of
frustration at the time.

I've had two important realizations:

  1. sean.patrick.obrien (2009-Apr-27) was right: you must inflate - not deflate;
  2. The 8.x ITL I was using came from the "Previous iTunes Libraries" folder, where
    damaged libraries (too) are kept - the library I was testing was probably corrupt.

Using inflate code and a copy of my current (working) iTunes Library, I was finally
successful.

Here's the code added to Hdfm.java:

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;

...

// In Hdfm.read(...):
byte[] by_Decompressed; // Moved out of example for clarity
int i__Decompressed;
ByteArrayOutputStream os_Decompressed;
InflaterInputStream is_Inflater;

...

// Comment out the following line:
// return new Hdfm(version, unknown, headerRemainder, decrypted);

// Add these lines instead:
is_Inflater = new InflaterInputStream( new ByteArrayInputStream(
by_Decrypted ), new Inflater() );
os_Decompressed = new ByteArrayOutputStream( restOfFile.length );
by_Decompressed = new byte[restOfFile.length];
while( true )
{ i__Decompressed = is_Inflater.read( by_Decompressed, 0,
restOfFile.length );
if( i__Decompressed == -1 )
break;
os_Decompressed.write( by_Decompressed, 0, i__Decompressed );
}
by_Decompressed = os_Decompressed.toByteArray();
os_Decompressed.close();
is_Inflater.close();

return new Hdfm( version, unknown, headerRemainder, by_Decompressed );

// End modification

I borrowed the core of this code from devdaily.com; Java experts can probably do the
whole thing better (and use accepted formatting conventions). BTW, this fix applies
to the r7 code.

@josephw
Copy link
Owner Author

josephw commented Mar 13, 2015

Comment #4 originally posted by josephw on 2010-01-02T01:02:02.000Z:

Hi everyone,

I recently needed to use the the functionality of the "MoveMusic" tool. I took the
"inflate" code posted by zzz2009... and incorporated it into the Hdfm.java file,
along with a "deflate" function for writing the file back out again. I ran the code
against an ITL file from iTunes 9.0.2, and everything worked perfectly!

The Hdfm.java file I used is attached; it's not perfect, but it worked for me, and
hopefully it can help someone else too. If anyone has questions about it, feel free
to e-mail me.

Also - I'd be willing to contribute more to this project in the future... can the
project owner contact me?

Brian

@josephw
Copy link
Owner Author

josephw commented Mar 13, 2015

Comment #5 originally posted by josephw on 2010-01-02T01:09:36.000Z:

Forgot two things:

  • My e-mail address is my profile name followed by "@gmail.com"
  • A very sincere thank you to everyone who has contributed to this project so far!
    Once the inflate/deflate issue was out of the way, the program did exactly what I
    needed it to do. iTunes is working perfectly on my new computer with the new ITL file.

Brian

@josephw
Copy link
Owner Author

josephw commented Mar 13, 2015

Comment #7 originally posted by josephw on 2010-03-29T14:51:34.000Z:

Applied fix. Thanks!

@josephw josephw closed this as completed Mar 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant