Commit 7c34036c8a896675ae023f52376524e1213a4004
Committed by
GitHub
Merge pull request #194 from samiraguiar/oleid-openxml-encryption
oleid: detect OpenXML encryption
Showing
4 changed files
with
30 additions
and
0 deletions
oletools/oleid.py
| ... | ... | @@ -54,6 +54,7 @@ from __future__ import print_function |
| 54 | 54 | # 2016-10-25 v0.50 PL: - fixed print and bytes strings for Python 3 |
| 55 | 55 | # 2016-12-12 v0.51 PL: - fixed relative imports for Python 3 (issue #115) |
| 56 | 56 | # 2017-04-26 PL: - fixed absolute imports (issue #141) |
| 57 | +# 2017-09-01 SA: - detect OpenXML encryption | |
| 57 | 58 | |
| 58 | 59 | __version__ = '0.51' |
| 59 | 60 | |
| ... | ... | @@ -211,6 +212,9 @@ class OleID: |
| 211 | 212 | if 0x13 in self.suminfo: |
| 212 | 213 | if self.suminfo[0x13] & 1: |
| 213 | 214 | self.encrypted.value = True |
| 215 | + # check if this is an OpenXML encrypted file | |
| 216 | + elif self.ole.exists('EncryptionInfo'): | |
| 217 | + self.encrypted.value = True | |
| 214 | 218 | |
| 215 | 219 | def check_word (self): |
| 216 | 220 | word = Indicator('word', False, name='Word Document', | ... | ... |
tests/oleid/__init__.py
0 โ 100644
tests/oleid/test_issue_166.py
0 โ 100644
| 1 | +""" | |
| 2 | +Test if oleid detects encrypted documents | |
| 3 | +""" | |
| 4 | + | |
| 5 | +import unittest, sys, os | |
| 6 | + | |
| 7 | +from tests.test_utils import DATA_BASE_DIR | |
| 8 | +from os.path import join | |
| 9 | + | |
| 10 | +from oletools import oleid | |
| 11 | + | |
| 12 | +class TestEncryptedDocumentDetection(unittest.TestCase): | |
| 13 | + def test_encrypted_document_detection(self): | |
| 14 | + """ Run oleid and check if the document is flagged as encrypted """ | |
| 15 | + filename = join(DATA_BASE_DIR, 'basic/encrypted.docx') | |
| 16 | + | |
| 17 | + oleid_instance = oleid.OleID(filename) | |
| 18 | + indicators = oleid_instance.check() | |
| 19 | + | |
| 20 | + is_encrypted = next(i.value for i in indicators if i.id == 'encrypted') | |
| 21 | + | |
| 22 | + self.assertEqual(is_encrypted, True) | |
| 23 | + | |
| 24 | +# just in case somebody calls this file as a script | |
| 25 | +if __name__ == '__main__': | |
| 26 | + unittest.main() | |
| 0 | 27 | \ No newline at end of file | ... | ... |
tests/test-data/basic/encrypted.docx
0 โ 100644
No preview for this file type