r/vba • u/decimalturn • 18h ago
Show & Tell VBA Scan: Analyze Macro-Enabled files for suspicious content before opening them
vba-scan.decimalturn.devSummary
As a regular member of the VBA subreddit, I'm always happy to play around with the latest project that gets shared around here. However, I try to be careful when opening files and enabling macros, just like I would do for any .exe file.
To help with this, I made a webpage that allows to scan a file for suspicious content and display results in an interactive UI that makes it more easily reviewable. The tool is based on the python project oletools (3.5k⭐) directly in the browser using Pyodide.
Obvisouly, even if the tools doesn't detect anything doesn't mean the file is totally safe, but it remains a good sanity check when deciding if you should open the file.
Code is available on GitHub: https://github.com/DecimalTurn/vba-scan
Some Extra Details
Reducing erroneous detection of VBA Stomping
While working on the tool, I tried to fix the thing that annoyed me the most with oletools: VBA stomping false positives. For those who don't know, VBA stomping is a technique used to hide the true VBA content of a file. This is a technique used to make malware. If it is present in a file, you should be highly worried, but having false detection is a cause of unnecessary panic.
To fix the majority of false detection, I implemented a fix directly to a dependency of oletools: pcodedmp. This means that the version of oletools used by VBA-Scan is a fork of the original with the pcodedmp package replaced by this custom version.
A few months ago, u/ConnectionApart675 posted their ski game on the sub. I tried to use oletools to dectect anything suspicious and it detected VBA stomping by mistake. With the new version, this is no longer the case.
Inspecting suspicious lines
In the original oletools package, you don't get the exact VBA line where the issue occurs. I this custom version the tools tells you the exact line of the match and the UI allows to display it for easier review.
Other removal of false positives
Some of the detections done with regex in the original oletools was causing false alarms. Some of the fix implemented for VBA-Scan are:
- No longer detect comments as suspicious
- Avoid detection of keyword inside quoted strings
- Avoid detection of Excel ranges string (eg.
Range("A1")) as suspcicious
AI use
The tool itself doesn't use AI. It's mainly powered by regex rules design to detect suspicious patterns. During the improvements made to oletools and pcodedmp, I did use AI agents to help with the implementation, but I did review (or at least skim) the code and steered it in specific directions since I knew what was needed in most cases since I've already worked manually on the oletools codebase before. Most of the front end code is written by LLMs without much review except manual testing of the user interface. I've left the commit history intact, so the progress and steering can be reviewed as well.
EDIT: The file selection tool doesn't seem to work on the Modbile Reddit Browser, so make sure to open the page on your default mobile broswer instead.