Programmatically Determine If An Excel File (.xls) Contains Macros

只谈情不闲聊 提交于 2019-11-30 04:38:56

问题


Is there any way to programmatically determine if an .xls contains macros, without actually opening it in Excel?

Also are there any methods to examine which certificate (including timestamp cert) these macros are signed with? Again without using Excel.

I'm wondering in particular if there are any strings that always show up in the raw data of an Excel file when macros are present.


回答1:


Yes, you can open the .xls file as a compound document file and check whether is contains a VBA folder and streams containing VBA code.

Sample code is available in this CodeProject article:

Another OLE Doc Viewer but with editing facility

The certificate information is stored in the DocumentSummaryInformation stream. If you want to read out the information from there you should dig into the file format specifications available from Microsoft:

[MS-OSHARED]: Office Common Data Types and Objects Structure Specification

[MS-OFFCRYPTO]: Office Document Cryptography Structure Specification




回答2:


An xls file containing a macro should contain a string looking something like

Keyboard Shortcut:

Don't know if this is a surefire solution though



来源:https://stackoverflow.com/questions/3006328/programmatically-determine-if-an-excel-file-xls-contains-macros

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!