Deobfuscate fonts in an XPS document

10 Juni 2007

XPS is the new portable format from Microsoft. The file structure consists of several parts, which includes the text (the so called „fixed documents“) and, of course, all resources. Images and fonts are embedded in a specific folder but as a general rule fonts are obfuscated to „protect“ the copyrights of the author.

To extract the text (which is by the way a subset of XAML) all resources have to be extracted, too. But obfuscated fonts cannot be read, therefore a decryption is required.
The encryption is rather simple: The first 32 bytes are XOR with the GUID of the file (it is also documented in the MSDN). To reverse all font files repeat the exclusive disjunction with the GUID (the file name implies the GUID, thank you) and you will receive the original source (for a better understanding see: http://en.wikipedia.org/wiki/XOR).

I attached a little example. Pass the obfuscated font path and streamOut will return the deobfuscated stream. To save the stream to disc, call streamOut.Position = 0 first.

Edit 2008-10-26:
Here you can find my solution:
http://www.bremora.com/index.php/xps-font-deobfuscator