Archive for 2月, 2013

I made sample php native extension to decrypt ms-office 2007 document.

Source code is here

What php-ole can is to ..

1 . Read ole object stream as php-stream
2 . Compute secret key from EncryptionInfo Stream and password ( you specified )
EncryptionInfo Stream

So php-ole can’t decrypt oox document exactly.
But you can decrypt document to use php mcrypt extension and computed secret key.
Please refer to php sample code if you want to more details.


1 . Unix or linux style os
2 . libgsf , libgsf-devel ( 3rd library )
3. PHP 5.3 or more
4. mcrypt php extension ( to decrypt AES document in sample php code)

Prepared to build
#yum install libgsf libgsf-devel

I just wrote to use pkg-config for libgsf in config.m4.

How to build

1. download zip (src files ) from github

2. build from src

#cd php-ole
#./configure --enable-ole
#make; make install;
How to run the sample PHP code in archives
$cd php-ole
$php -f php/ole.php php/test/password_abc.docx

or ( if you don’t want to install so file )

$cd php-ole
$php -d extension=.libs/ -f php/ole.php php/test/password_abc.docx

You can show the document password ‘abc’ in sample code( php/ole.php).
So when you use your own document file,
Please change the password.

expected console output

------ Class OleInfile method list --------
array(6) {
  string(11) "__construct"
  string(4) "open"
  string(11) "numChildren"
  string(9) "statIndex"
  string(15) "getStreamByName"
  string(17) "getEncryptionInfo"
=== document entries === 
array(2) {
  string(11) "DataSpaces"
array(2) {
  string(14) "EncryptionInfo"
array(2) {
  string(16) "EncryptedPackage"
------ Class OleEncryptionInfo method list --------
array(4) {
  string(14) "verifyPassword"
  string(12) "getSecretKey"
  string(11) "getVerifier"
  string(15) "getVerifierHash"
====== OK ==== 
Add to Google
« 11月