Code Monkey home page Code Monkey logo

msoffice's People

Contributors

didierstevens avatar gaolycn avatar herumi avatar jan2000 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

msoffice's Issues

error decrypt shared workbook

D:\work\msoc\msoffice\bin\64>msoffice-crypt.exe -d -p 123 Book1.xlsx book2.xlsx
inFile=Book1.xlsx, outFile=book2.xlsx, mode=dec, encMode=0
exception:ms:cfb:DirectoryEntryVec:short size:19144:5120

Fails to compile: AtomicAddSub is not a member of cybozu::atomic_local::Tag<8u>

Trying to compile on Fedora. I've tried a few earlier releases of cybozu to see whether this was just a version issue, but no joy.

g++ -c attack.cpp -o release/attack.o -g -D_FILE_OFFSET_BITS=64 -msse2 -fno-operator-names -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith  -Ofast -fomit-frame-pointer -DNDEBUG -march=native -msse4 -I/home/dave/development/msoffice/include -I/home/dave/development/msoffice/../cybozulib/include -I/home/dave/development/msoffice/../mie/include
In file included from /home/dave/development/msoffice/../cybozulib/include/cybozu/thread.hpp:10:0,
                 from /home/dave/development/msoffice/../cybozulib/include/cybozu/parallel.hpp:10,
                 from /home/dave/development/msoffice/include/attack.hpp:16,
                 from attack.cpp:14:
/home/dave/development/msoffice/../cybozulib/include/cybozu/atomic.hpp: In instantiation of ‘T cybozu::AtomicAdd(T*, T) [with T = long long unsigned int]’:
/home/dave/development/msoffice/include/attack.hpp:75:44:   required from here
/home/dave/development/msoffice/../cybozulib/include/cybozu/atomic.hpp:110:56: error: ‘AtomicAddSub’ is not a member of ‘cybozu::atomic_local::Tag<8u>’
  return atomic_local::Tag<sizeof(T)>::AtomicAddSub(p, y);
                                                        ^
/home/dave/development/msoffice/../cybozulib/include/cybozu/atomic.hpp: In function ‘T cybozu::AtomicAdd(T*, T) [with T = long long unsigned int]’:
/home/dave/development/msoffice/../cybozulib/include/cybozu/atomic.hpp:111:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
make[1]: *** [release/attack.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory `/home/dave/development/msoffice/src'
make: *** [all] Error 2

Run on Linux (CentOS 8 Stream)

I build and run this project, it worked really really great on Windows 10 and VS2019 !!!
@herumi -san, I have a question, can we make it for Linux? Example my environment is CentOS 8 Stream.

Fails with exception:bad allocation for large excel files

Hi,

I am trying to encrypt excel files on Windows.
Managed to clone msoffice, cybozulib_ext, cybozulib repos and successfully build using mk.bat

No issues with encoding smaller files.
I was testing with larger excel files 250 000 rows x 150 cols, all values are random generated strings saved in shared string table.
The xlsx file size is approx 770 Mb and 3.5Gb after unpacking

When run I get the exception:bad allocation.

D:\projects\msoffice\bin>msoffice-crypt.exe -p "password" -e -vv c:\test\test_002.xlsx c:\test\test_002_encrypted.xlsx
inFile=c:\test\test_002.xlsx, outFile=c:\test\test_002_encrypted.xlsx, mode=enc, encMode=0
exception:bad allocation

Read-Only Password

Bit of a long shot... do you know if it's possible to protect the file with an edit password? and could this be added?

Example: someone opening the file gets prompted to open it as read-only or supply a password to open for editing.

exception:randomgenerator

I am seeing this exception when trying to encode XLSX files in an Azure WebJob, I think the issue is environmental because this code has been working great in an Azure cloud service for over a year. We recently moved from cloud service to app service and this error occurs every time the EXE is invoked with the -e option

If anyone has ideas about that is wrong in the case I would like to know your thoughts

can not remove a password of xlsx file

Hi @herumi, thanks for this project, I just want to use this tool to remove a password of a xlsx file, I do not remember the password of this file, so I run:

~/work/msoffice/bin/msoffice-crypt.exe -p test test.xlsx test1.xlsx

but I get:

inFile=test.xlsx, outFile=test1.xlsx, mode=view, encMode=0
flags = 00000024
sizeExtra = 0
algId = 0000660e
algIdHash = 00008004
keySize = 128
providerType = 00000018
cspName = Microsoft Enhanced RSA and AES Cryptographic Provider (Prototype)
dataSize=72
saltSize = 16
salt = F4:D3:15:A4:29:74:ED:92:BD:01:A8:9F:07:27:B1:C3:
encryptedVerifier = E4:34:D2:71:10:F5:55:9E:CB:C7:EE:F8:01:15:FC:26:
verifierHashSize = 20
encryptedVerifierHash = 88:DA:7B:04:0F:02:11:89:F0:F7:02:1A:EC:6B:99:94:55:A1:E8:4F:C3:86:E9:CC:2A:66:A8:62:4D:3D:E8:34:
bad password

Error cloning new version msoffice

I've been using this package for the last 3 years.
I used it in August 2023, no issues whatsoever.
I used it today (October 3, 2023) and I got the following error

make[1]: Entering directory '/content/msoffice/src' g++ -c msoffice-crypt.cpp -o release/msoffice-crypt.o -g -D_FILE_OFFSET_BITS=64 -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith -O2 -DNDEBUG -I/content/msoffice/include -I/content/msoffice/../cybozulib/include g++ -c attack.cpp -o release/attack.o -g -D_FILE_OFFSET_BITS=64 -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith -O2 -DNDEBUG -I/content/msoffice/include -I/content/msoffice/../cybozulib/include g++ release/attack.o -o /content/msoffice/bin/attack.exe -lcrypto -L/content/msoffice/lib -lcrypto -lpthread -lrt /usr/bin/ld: cannot open output file /content/msoffice/bin/attack.exe: No such file or directory collect2: error: ld returned 1 exit status make[1]: *** [../common.mk:68: /content/msoffice/bin/attack.exe] Error 1 make[1]: *** Waiting for unfinished jobs.... make[1]: Leaving directory '/content/msoffice/src' make: *** [Makefile:7: all] Error 2

I used it in Colab which runs on Linux.

I don't understand what it means, so my solution was to make a fork and go back to version 89dbedf add OLD_OPENSSL option. This commit was made back in March 2023. Ran the script again and everything worked.

AES256 / sha512 with manually installed OpenSSL3

On Redhat 7, I manually installed OpenSSL3, and edited CFLAGS and LDFLAGS in common.mk, so can compile and run this msoffice package with no problem. But when trying "-encMode 1", it complains "exception:hassPassword:not support:sha512". How can I resolve this?

libcrypto.so.3

On Debian GNU/Linux 10 (buster) ,
I received this error :
while loading shared libraries: libcrypto.so.3: cannot open shared object file: No such file or directory
But i found that's unstable on my debian
image

fatal error: openssl/hmac.h: No such file or directory

system specification

Ubuntu 20.04.2 LTS 64-bit
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
clang version 10.0.0-4ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix

installed successfully

mkdir work
git clone https://github.com/herumi/cybozulib
git clone https://github.com/herumi/msoffice
make -j RELEASE=1

error messages

In file included from /home/uendelrocha/Software/msoffice-crypt/msoffice/include/decode.hpp:14,
from msoffice-crypt.cpp:16:
/home/uendelrocha/Software/msoffice-crypt/msoffice/../cybozulib/include/cybozu/crypto.hpp:23:10: fatal error: openssl/hmac.h: No such file or directory
23 | #include <openssl/hmac.h>
| ^~~~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [../common.mk:57: release/msoffice-crypt.o] Error 1
make[1]: *** Waiting for unfinished jobs....
In file included from /home/uendelrocha/Software/msoffice-crypt/msoffice/include/attack.hpp:14,
from attack.cpp:14:
/home/uendelrocha/Software/msoffice-crypt/msoffice/../cybozulib/include/cybozu/crypto.hpp:23:10: fatal error: openssl/hmac.h: No such file or directory
23 | #include <openssl/hmac.h>
| ^~~~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [../common.mk:57: release/attack.o] Error 1
make: *** [Makefile:7: all] Error 2

output messages file

error.txt

Add support for libssl3

I've tried to run the tool on Ubuntu 22.04 but I wasn't able run it. It requires libssl1.1 which isn't available anymore on this Ubuntu version.

Exception when attempting decrypt

Attempting to decrypt and getting the following message:

$ bin/msoffice-crypt.exe -p 5558 247.docx 247-decrypt.docx
inFile=247.docx, outFile=247-decrypt.docx, mode=view, encMode=0
exception:ms:cfb:validate:minorVersion == 0x3eu || minorVersion == 0x3bu:/home/user/work/msoffice/include/cfb.hpp:186

Exception DirectoryEntryVec:short size

Hi,

Unfortunately the tool gives me exception similar to #7.

exception:ms:cfb:DirectoryEntryVec:short size:4096:256

Output of -v:

msoffice-crypt -d -p 1234 invoice.doc decrypted.doc -v
inFile=../Downloads/invoice.doc, outFile=../Downloads/decrypted.doc, mode=dec, encMode=0
version : major = 3, minor = 0x003e
sectorShift = 9
numDirectorySectors = 0
numFatSectors = 1
firstDirectorySectorLocation = 9
transactionSignatureNumber = 0
firstMiniFatSectorLocation = 10
numMiniFatSectors = 1
firstDifatSectorLocation = END
numDifatSectors = 0
difat size=1
 8
dataSize=38872(0x97d8)
sectorSize=512
# of mini fat sectors = 1
analyze dirs
load contents
dataSize=832, content.size()=1024
dataSize=4096, content.size()=256
exception:ms:cfb:DirectoryEntryVec:short size:4096:256

Could you please provide any help? If you need any more info, please feel free to ask. I cannot provide the doc in question publicly though. Thanks!

Problem with miniFAT sectors when numMiniFatSectors > 1

Hello,
I noticed an issue when parsing documents with more then one MiniFAT sectors.

version : major = 3, minor = 0x003e
sectorShift = 9
numDirectorySectors = 0
numFatSectors = 1
firstDirectorySectorLocation = 52
transactionSignatureNumber = 0
firstMiniFatSectorLocation = 55
numMiniFatSectors = 2
firstDifatSectorLocation = END
numDifatSectors = 0
difat size=1
 51
dataSize=45056(0xb000)
sectorSize=512
# of mini fat sectors = 2
exception:ms:cfb:FatSectors:bad idx:128
00000000: d0cf 11e0 a1b1 1ae1 0000 0000 0000 0000  ................
00000010: 0000 0000 0000 0000 3e00 0300 feff 0900  ........>.......
00000020: 0600 0000 0000 0000 0000 0000 0100 0000  ................
00000030: 3400 0000 0000 0000 0010 0000 3700 0000  4...........7...
00000040: 0200 0000 feff ffff 0000 0000 3300 0000  ............3...
00000050: ffff ffff ffff ffff ffff ffff ffff ffff  ................
...
000001f0: ffff ffff ffff ffff ffff ffff ffff ffff  ................

I have added a check to avoid this exception but it doesn't seem to be enough, probably because the additional MiniFAT sectors are not consecutive? I can share the sample document via email if it helps.

adepasquale@7f5c00e

I haven't been able to find documentation about the location of additional MiniFAT sectors in case there's more than one (for this sample there are two). Anyway I have identified the locations below:

  • 0x00007000 from the 0x00000037 in the header;
  • 0x00009400 by manually analysing the rest of the file.
00007000: 0100 0000 0200 0000 0300 0000 0400 0000  ................
00007010: feff ffff 0600 0000 0700 0000 0800 0000  ................
00007020: 0900 0000 0a00 0000 feff ffff 0c00 0000  ................
00007030: 0d00 0000 0e00 0000 0f00 0000 1000 0000  ................
00007040: 1100 0000 1200 0000 1300 0000 1400 0000  ................
00007050: 1500 0000 1600 0000 1700 0000 1800 0000  ................
00007060: feff ffff 1a00 0000 1b00 0000 1c00 0000  ................
00007070: 1d00 0000 1e00 0000 1f00 0000 2000 0000  ............ ...
00007080: 2100 0000 2200 0000 2300 0000 2400 0000  !..."...#...$...
00007090: 2500 0000 2600 0000 2700 0000 2800 0000  %...&...'...(...
000070a0: 2900 0000 2a00 0000 2b00 0000 2c00 0000  )...*...+...,...
000070b0: 2d00 0000 2e00 0000 2f00 0000 3000 0000  -......./...0...
000070c0: 3100 0000 3200 0000 3300 0000 3400 0000  1...2...3...4...
000070d0: 3500 0000 3600 0000 3700 0000 3800 0000  5...6...7...8...
000070e0: 3900 0000 3a00 0000 3b00 0000 3c00 0000  9...:...;...<...
000070f0: 3d00 0000 3e00 0000 3f00 0000 4000 0000  =...>...?...@...
00007100: 4100 0000 4200 0000 4300 0000 4400 0000  A...B...C...D...
00007110: feff ffff 4600 0000 4700 0000 4800 0000  ....F...G...H...
00007120: 4900 0000 4a00 0000 4b00 0000 4c00 0000  I...J...K...L...
00007130: 4d00 0000 4e00 0000 4f00 0000 5000 0000  M...N...O...P...
00007140: 5100 0000 5200 0000 5300 0000 5400 0000  Q...R...S...T...
00007150: 5500 0000 5600 0000 5700 0000 5800 0000  U...V...W...X...
00007160: 5900 0000 5a00 0000 5b00 0000 5c00 0000  Y...Z...[...\...
00007170: 5d00 0000 5e00 0000 5f00 0000 6000 0000  ]...^..._...`...
00007180: feff ffff 6200 0000 6300 0000 6400 0000  ....b...c...d...
00007190: 6500 0000 6600 0000 6700 0000 6800 0000  e...f...g...h...
000071a0: 6900 0000 6a00 0000 6b00 0000 6c00 0000  i...j...k...l...
000071b0: 6d00 0000 6e00 0000 6f00 0000 7000 0000  m...n...o...p...
000071c0: 7100 0000 feff ffff 7300 0000 7400 0000  q.......s...t...
000071d0: 7500 0000 7600 0000 7700 0000 7800 0000  u...v...w...x...
000071e0: 7900 0000 7a00 0000 7b00 0000 7c00 0000  y...z...{...|...
000071f0: 7d00 0000 7e00 0000 7f00 0000 8000 0000  }...~...........
00009400: 8100 0000 8200 0000 8300 0000 8400 0000  ................
00009410: 8500 0000 8600 0000 8700 0000 8800 0000  ................
00009420: 8900 0000 8a00 0000 8b00 0000 8c00 0000  ................
00009430: 8d00 0000 8e00 0000 8f00 0000 9000 0000  ................
00009440: 9100 0000 9200 0000 9300 0000 9400 0000  ................
00009450: 9500 0000 9600 0000 9700 0000 9800 0000  ................
00009460: 9900 0000 9a00 0000 9b00 0000 9c00 0000  ................
00009470: 9d00 0000 9e00 0000 9f00 0000 a000 0000  ................
00009480: a100 0000 a200 0000 a300 0000 a400 0000  ................
00009490: a500 0000 a600 0000 a700 0000 a800 0000  ................
000094a0: feff ffff aa00 0000 ab00 0000 ac00 0000  ................
000094b0: ad00 0000 ae00 0000 af00 0000 b000 0000  ................
000094c0: b100 0000 b200 0000 feff ffff b400 0000  ................
000094d0: feff ffff b600 0000 b700 0000 b800 0000  ................
000094e0: b900 0000 feff ffff bb00 0000 bc00 0000  ................
000094f0: bd00 0000 be00 0000 bf00 0000 c000 0000  ................
00009500: c100 0000 c200 0000 feff ffff c400 0000  ................
00009510: feff ffff c600 0000 c700 0000 c800 0000  ................
00009520: c900 0000 feff ffff cb00 0000 feff ffff  ................
00009530: ffff ffff ffff ffff ffff ffff ffff ffff  ................
...
000095f0: ffff ffff ffff ffff ffff ffff ffff ffff  ................

git clone command in readme

Hello, when I run the commands listed in the readme to build the library on Linux, I get this error:

git clone https://github.dev.cybozu.co.jp/herumi/msoffice
Cloning into 'msoffice'...
fatal: unable to access 'https://github.dev.cybozu.co.jp/herumi/msoffice/': SSL: certificate subject name (*.cybozu.co.jp) does not match target host name 'github.dev.cybozu.co.jp'

I managed to clone the repo with this command instead:

git clone https://github.com/herumi/msoffice.git

Trouble compiling

I am having trouble compiling the latest git pulldown of msoffice, getting the following error each time that I attempt it:
/root/Downloads/msoffice/msoffice/../cybozulib/include/cybozu/file.hpp:300:32: error: ‘std::ios::seek_dir’ has not been declared
300 | void seek(int64_t pos, std::ios::seek_dir dir)
| ^~~
In file included from attack.cpp:10:
/root/Downloads/msoffice/msoffice/../cybozulib/include/cybozu/file.hpp:300:32: error: ‘std::ios::seek_dir’ has not been declared
300 | void seek(int64_t pos, std::ios::seek_dir dir)

Fortunately, I already have compiled this excellent program from an earlier pulldown, but it would still be nice to be able to continue to build new revisions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.