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

Extract macros only from some office formats #610

Merged
merged 2 commits into from
Aug 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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