One of the major file types that I have come across during my development of my Log File analysis tool is the Binary Plist. The Plist file format has many alternatives and is most commonly found in an XML style. Newer versions of the Plist can be found within a Binary format which has been adopted recently due to speed and size.
Their is plenty of tools to open Binary Plist files and convert into different formats but these do not help when you are wanting to read in a file to analyse. The plutil utility that is available via Terminal allows the conversion of Binary Plist files into XML format and vice versa. This facility is extremely useful but is not feasible within a program.
Python has had an installed Plist reader / writer library for sometime and expanded this feature from just Mac based Python installations to all operating systems running Python 2.7 and higher. Unfortunately this library does not handle Binary Plist files which is a disappointment.
Luckily it seems someone has had the same issue as myself and needed a built in library that would handle Binary Plist files. Luckily for me this person had a better knowledge of Python programming and was able to develop a Library that fulfils this issue. The library is called Biplist, a wonderful library that expands the already available Plistlib library allowing for parsing and writing Binary Plist files.
Installation:
Installation with Biplist is hassle free, just goto the directory containing the Biplist folder and run the following command.
sudo easy_install biplist
Using Biplist:
Biplist is used the same way Plistlib is used within Python but allows the library to be extended to allow functionality with Binary Plist files.
plist = readPlist(filename.plist)
The above command is the exact same that can be used with Plistlib but will allow the Binary file to bread into a Dictionary or List to then later be printed or modified.
Download:
https://github.com/wooster/biplist
Examples:
These examples have been taken from the Biplist GitHub page.
Plist generation:
from biplist import *
from datetime import datetime
plist = {'aKey':'aValue',
'0':1.322,
'now':datetime.now(),
'list':[1,2,3],
'tuple':('a','b','c')
}
try:
writePlist(plist, "example.plist")
except (InvalidPlistException, NotBinaryPlistException), e:
print "Something bad happened:", e
Plist parsing:
from biplist import *
try:
plist = readPlist("example.plist")
print plist
except (InvalidPlistException, NotBinaryPlistException), e:
print "Not a plist:", e