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

ReadPlist should use biplist.readPlistFromString instead of biplist.readPlist #16

Closed
hadar0x opened this issue Mar 18, 2019 · 7 comments

Comments

@hadar0x
Copy link

hadar0x commented Mar 18, 2019

It turns out that biplist (which wraps plistlib) fails to parse plist files that have newlines and redundant white-spaces.

If you will replace biplist.readPlist with readPlistFromString, then we would be able to strip the newlines and white-spaces, and then we will not miss any plist file.

@ydkhatri
Copy link
Owner

Do you have a sample of such a plist, can you post it here. Also is this a macOS created one or by some other program?
Your proposed solution assumes that we already know this to be an XML plist, but it could be a binary one.

@hadar0x
Copy link
Author

hadar0x commented Mar 18, 2019

See attached - I had to zip it because GitHub don't support uploading plists.
com.apple.BluetoothService.zip

The file was was created by Empire.

In regards of the solution - correct. We can validate the type before doing so.

@ydkhatri
Copy link
Owner

Hmm, this is not valid XML as xml document must begin with <?xml, but macOS does not seem to care and plutil will read it just fine. Thanks for highlighting this, I will put in a fix.

@ydkhatri
Copy link
Owner

I put in a fix for it. Please check and let me know if there are still issues.

@hadar0x
Copy link
Author

hadar0x commented Mar 19, 2019

I checked and there's a new issue now:

MAIN.LAUNCHDAEMONS-ERROR-Failed to read plist /Library/LaunchDaemons/com.apple.BluetoothService.plist Error was : Exception from ReadPlist, trying to open file. Exception='unicode' does not have the buffer interface

When I wrapped it with str(data) - it worked. Of course there are other ways to handle it, just a quick suggestion.

@ydkhatri
Copy link
Owner

from __future__ import unicode_literals was the problem. Apparently biplist does not like unicode strings. I've added an explicit encode back to utf8 now. This should work now!

@hadar0x
Copy link
Author

hadar0x commented Mar 20, 2019

Works great. Thanks @ydkhatri

@hadar0x hadar0x closed this as completed Mar 20, 2019
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

2 participants