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

detect_vba_macros() false positives? #856

Open
xme opened this issue May 18, 2024 · 2 comments
Open

detect_vba_macros() false positives? #856

xme opened this issue May 18, 2024 · 2 comments
Assignees
Milestone

Comments

@xme
Copy link

xme commented May 18, 2024

Affected tool:
olevba

Describe the bug
I'm using the olevba Python module to process files from multiple source. I'm using the following code to detect interesting files (with macros):

if vbaparser.detect_vba_macros():
   do_more_stuff()

Many files are detected as containing macros even if they don't contain valid OLE streams.

Is there another way to properly detect the presence of VBA macros?

@decalage2 decalage2 self-assigned this May 20, 2024
@decalage2 decalage2 added this to the oletools 0.60 milestone May 20, 2024
@decalage2
Copy link
Owner

Hi @xme, indeed the method detect_vba_macros only checks for the presence of specific storages (folders) in the structure of OLE files, or streams with specific bytes that are found in VBA projects. So it will return True if a file contains those storages or streams, even if the VBA project streams are corrupt. (this may happen when a document is "cleaned" by some antivirus, for example)

Maybe you can try get_vba_code_all_modules or extract_all_macros? It will attempt to parse and decompress all VBA modules. If there is some output and no error then there's a good chance that there is a valid VBA project in the file.
But it looks like exceptions are caught, so not sure you will actually get errors... 🤔

@xme
Copy link
Author

xme commented May 21, 2024

Tx! I'll investigate this way!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants