【发布时间】:2020-05-01 03:30:50
【问题描述】:
在 Visual Basic for Applications (VBA) 中,您可以使用 Attribute 关键字设置模块或变量的属性。比如
' Header
Attribute VB_Name = "ClassOrModuleName"
Attribute VB_GlobalNameSpace = False ' ignored
Attribute VB_Creatable = False ' ignored
Attribute VB_PredeclaredId = False ' a Value of True creates a default global instance
Attribute VB_Exposed = True ' Controls how the class can be instanced.
'Module Scoped Variables
Attribute variableName.VB_VarUserMemId = 0 ' Zero indicates that this is the default member of the class.
Attribute variableName.VB_VarDescription = "some string" ' Adds the text to the Object Browser information for this variable.
'Procedures
Attribute procName.VB_Description = "some string" ' Adds the text to the Object Browser information for the procedure.
Attribute procName.VB_UserMemId = someInteger
' 0: Makes the function the default member of the class.
' -4: Specifies that the function returns an Enumerator.
我在想,有没有办法在代码中获取/读取这些属性?例如像
Sub BarMacroName()
'
' BarMacroName Macro
' Bar Macro Description
'
Dim var
MsgBox VB_Description 'display this module's description
MsgBox VB_Name 'display this module's description
End Sub
不只是描述和名称,一般情况下,我们真的可以读取代码本身内部的属性吗?
编辑:我特别想看看您是否可以在 VBA 脚本本身中提取属性值。我正在研究恶意软件漏洞,我很好奇是否有人可以在 VBA 模块的描述中嵌入恶意代码。
【问题讨论】:
-
我会尝试直接从vbaProject.bin提取它
-
@omegastripes 我特别想看看您是否可以在脚本本身中提取属性值,而不是想提取它们,我编辑了原始问题以反映这一点
-
据我所知不是直接的。您必须导出模块并读取 bas 文件。
-
@hyk 所以如果你正在研究嵌入恶意 VBA 模块属性的能力,那么问题标题不应仅限于获取/读取操作。