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

About password protected numbers files #93

Open
Deng-yongbiao opened this issue Nov 4, 2024 · 5 comments
Open

About password protected numbers files #93

Deng-yongbiao opened this issue Nov 4, 2024 · 5 comments

Comments

@Deng-yongbiao
Copy link

According to some information on the Internet, encrypted documents are encrypted using ASE-128. So is there a simpler way to determine whether a numbers document is encrypted? I do not need to parse the content of the encrypted document.

@masaccio
Copy link
Owner

masaccio commented Nov 4, 2024

See also #88. The challenge will be that AES-encrypted data is indistinguishable from random noise. It's possible for numbers-parser to unpack the top-level document and spot that it has what looks like Numbers metadata, but no readable IWA files, and infer from this the document might be encrypted. But the only option would be to raise an exception on the Document() class.

@Deng-yongbiao
Copy link
Author

I noticed that if a numbers file is encrypted, then almost all iwa files in it are unreadable, that is, the iwa binary stream does not start with 0x00

@masaccio
Copy link
Owner

The most recent commits on the GitHub main branch include a test for the existence of .iwph in the document, which is an indication it's encrypted. Opening such a document will raise a UnsupportedError.

@daddytigerflying
Copy link

is there a simpler way to determine whether a numbers document is encrypted?

Back to you original question, the answer is Yes. Numbers app can be manipulated by AppleScript, and consequent several Python libraries.

For AppleScript, you can check the password_protected property of document:

tell application "Numbers"
        tell front document\n
              return password protected\n
        end tell\n
end tell

Or you can use appscript package:

import appscript
app = appscript.app('numbers')
doc = app.documents[0]
return doc.password_protected()

Hope this helps.

@masaccio
Copy link
Owner

masaccio commented Nov 21, 2024

The Zip that wraps the document contains some files that are indicative of a password-protected file. There is code in place to check for this (see https://github.com/masaccio/numbers-parser/blob/main/src/numbers_parser/iwork.py#L201) but it's not published yet in a release as I just need to tidy up some code elsewhere to return to 100% coverage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants