Skip to content

Commit

Permalink
Extract macros only from some office formats (#610)
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstanty Cieśliński authored and chivay committed Aug 10, 2021
1 parent 43e42c9 commit 9592397
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions drakrun/drakrun/sample_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ def get_office_file_startup_command(extension, file_path):
return None
start_command.extend(["/t", "%f"])

vbaparser = VBA_Parser(file_path)
if vbaparser.detect_vba_macros():
outer_macros = get_outer_nodes_from_vba_file(file_path)
if not outer_macros:
outer_macros = []
for outer_macro in outer_macros:
start_command.append(f"/m{outer_macro}")
if file_type_allows_macros(extension):
vbaparser = VBA_Parser(file_path)
if vbaparser.detect_vba_macros():
outer_macros = get_outer_nodes_from_vba_file(file_path)
if not outer_macros:
outer_macros = []
for outer_macro in outer_macros:
start_command.append(f"/m{outer_macro}")

return subprocess.list2cmdline(start_command)

Expand Down Expand Up @@ -84,6 +85,10 @@ def get_dll_startup_command(pe_data):
return "regsvr32 /s %f"


def file_type_allows_macros(extension):
return extension in ["docm", "dotm", "xls", "xlsm", "xltm", "pptx"]


def is_office_word_file(extension):
return extension in ["doc", "docm", "docx", "dotm", "rtf"]

Expand Down

0 comments on commit 9592397

Please sign in to comment.