Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

msodde: Fix detecting DDE in the nested field. #807

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions oletools/msodde.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,12 @@ def process_args(cmd_line_args=None):
# separator is present. The field begin character, field end character, and
# field separator are collectively referred to as field characters.

# Begin = 0x13
# Sep = 0x14
# End = 0x15
# Field = <Begin> *<Field> [Sep] *<Field> <End>
# FieldList = *<Field>


def process_doc_field(data):
""" check if field instructions start with DDE
Expand Down Expand Up @@ -350,8 +356,12 @@ def process_doc_stream(stream):
char = ord(char)

if char == OLE_FIELD_START:
if have_start and max_size_exceeded:
logger.debug('big field was not a field after all')
if have_start:
if max_size_exceeded:
logger.debug('big field was not a field after all')
else:
logger.debug('It has multiple starts!')
continue
have_start = True
have_sep = False
max_size_exceeded = False
Expand Down
10 changes: 10 additions & 0 deletions tests/msodde/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def test_valid_doc(self):
'dde-test-from-office2003.doc.zip',
'dde-test-from-office2016.doc.zip',
'dde-test-from-office2013-utf_16le-korean.doc.zip',
'dde-test-from-office365-nested-field.doc.zip',
):
with decrypt_sample(join('msodde', filename)) as temp_name:
self.do_test_validity(temp_name)
Expand Down Expand Up @@ -167,6 +168,15 @@ def test_with_dde_utf16le(self):
self.assertNotEqual(len(self.get_dde_from_output(output)), 0,
msg='Found no dde links in output of ' + filename)

def test_with_dde_nested_field(self):
""" check that ddeauto appear on stdout """
filename = 'dde-test-from-office365-nested-field.doc.zip'
with decrypt_sample(join('msodde', filename)) as temp_file:
output = msodde.process_maybe_encrypted(temp_file,
field_filter_mode=msodde.FIELD_FILTER_BLACKLIST)
self.assertNotEqual(len(self.get_dde_from_output(output)), 0,
msg='Found no dde links in output of ' + filename)

def test_excel(self):
""" check that dde links are found in excel 2007+ files """
expect = ['cmd /c calc.exe', ]
Expand Down
Binary file not shown.