Skip to content

Add "Modules" as keyword for self-modification - #823

Open
DecimalTurn wants to merge 2 commits into
decalage2:masterfrom
DecimalTurn:master
Open

DecimalTurn wants to merge 2 commits into
decalage2:masterfrom
DecimalTurn:master

Conversation

@DecimalTurn

@DecimalTurn DecimalTurn commented Sep 18, 2023 •

Copy link
Copy Markdown
Contributor

I recently found this question on Stack Overflow, it shows how to import a new code module in VBA using the Modules object.

Here's a simplified snippet that illustrates how it works:

    Dim ThisModule As Module
    Set ThisModule = ThisWorkbook.Modules.Add
    ThisModule.InsertFile "C:\Users\(username)\Desktop\..."

I always thought you had to use VBComponents.Import, but turns out there is this undocumented method as well.

@DecimalTurn

Copy link
Copy Markdown
Contributor Author

For the record, the snippet of code above won't be flagged by olevba as malicious, but does manage to import a VBA module even if "trust access to the vba project object model" is disabled!

@decalage2
decalage2 self-requested a review June 10, 2024 10:48
@decalage2 decalage2 self-assigned this Jun 10, 2024
@decalage2 decalage2 added this to the oletools 0.60 milestone Jun 10, 2024
Copilot AI balanced review requested due to automatic review settings November 17, 2026 03:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the addition of Modules to VBA self-modification detection.

No open issues 🎉

What changed in this PR

Extends olevba’s suspicious-keyword detection to recognize Modules as a possible VBA self-modification mechanism.

Changes:

  • Adds Modules to the existing self-modification keyword group, covering the alternative module-import approach described in the PR.
File Description
oletools/​olevba.py Adds Modules to the VBA self-modification detection keywords.

Review effort: Balanced

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants