iphone-dataprotection
iphone-dataprotection copied to clipboard
emf_decrypter.py (emf.py) breaks at file names containing non-ASCII/ISO-8859-1 characters
What steps will reproduce the problem?
1. Send mail to an account registered on the phone with an attachments named
"@宋体 7 (ansi).uft" (python u'@\u5b8b\u4f53 7 (ansi).uft').
2. Dump the image using the provided tools
3. Execute emf_decrypter.py --nowrite
What is the expected output? What do you see instead?
The utility is expected to complete without errors.
However, when the above mentioned file is encountered, the following dump is
written:
Traceback (most recent call last):
File "python_scripts/emf_decrypter.py", line 24, in <module>
main()
File "python_scripts/emf_decrypter.py", line 21, in main
v.decryptAllFiles()
File "/tmp/noindex/iphone-dataprotection/python_scripts/hfs/emf.py", line 170, in decryptAllFiles
self.catalogTree.traverseLeafNodes(callback=self.decryptFile)
File "/tmp/noindex/iphone-dataprotection/python_scripts/hfs/btree.py", line 142, in traverseLeafNodes
callback(k,v)
File "/tmp/noindex/iphone-dataprotection/python_scripts/hfs/emf.py", line 187, in decryptFile
print "Decrypting", filename
UnicodeEncodeError: 'ascii' codec can't encode characters in position 1-2:
ordinal not in range(128)
What version of the product are you using? On what operating system?
iphone-dataprotection cloned 2012/3/6 01:53:00 UTC (revision 842f8593e743)
Python 2.6.5
Windows XP SP3
Cygwin
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 7 Mar 2012 at 4:27
Thanks for the detailed report. Can you try replacing
print "Decrypting", filename
with
print "Decrypting", filename.encode("utf-8")
in python_scripts/hfs/emf.py", line 187
Let me know if other errors appear, i'm not quite sure if this is the correct
way to fix this. Thanks.
Original comment by [email protected]
on 7 Mar 2012 at 10:19
- Changed state: Started
Unfortunately, I deleted the image and the keys after it became apparent that
the data I was looking for could not be recovered from the image. In addition,
I no longer have access to a device I can image in order to test the fix.
I continued the process described in the README by replacing filename in the
line you mention with repr(filename). Not a good solution, but it allowed me to
continue.
Thanks again.
Original comment by [email protected]
on 9 Mar 2012 at 5:30
Jean, I have noticed the same behavior on an app with a (c) copyright symbol in
the .ipa filename. I was getting around to investigating this further, I will
test out your recommendation when I have a chance.
Original comment by [email protected]
on 9 Mar 2012 at 7:23
It looks like the str.encode("utf-8") method fixes this issue. I placed this on
line 178 or emf.py instead, changing:
filename = getString(k)
to
filename = getString(k).encode("utf-8")
That way, the print statement on line 173 should succeed as well in all cases.
I don't personally have a dataset that allows me to test this, so I have only
been able to test through feedback from others that have encountered this
problem. This fix doesn't adversely affect a decryption that does not cause
this encoding issue. I just want to be forthcoming that the fix has not been
thoroughly validated by me against the original problem.
Original comment by [email protected]
on 11 Apr 2012 at 7:51
This issue was updated by revision 76d7d636dbb8.
Pushed the change, looks ok for now
Original comment by [email protected]
on 28 Apr 2012 at 9:33