检查MS office文件(word,excel,ppt,access等)是否启用宏(嵌入式恶意代码)或不使用C#/ JAVA SCRIPT [英] Check the MS office files(word, excel,ppt, access etc.) are macro enabled (embedded malicious codes) or not using C#/JAVA SCRIPT

查看:289
本文介绍了检查MS office文件(word,excel,ppt,access等)是否启用宏(嵌入式恶意代码)或不使用C#/ JAVA SCRIPT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 

我有一些Office文件...
我想将这些文件上传到数据库...
上传之前我想查看文件是否启用宏...
期待java脚本中的解决方案...

我尝试使用以下文件扩展名..

`" .docm"," .dotm"," .xlm"," .xltm"," .xlsm"," .xla"," .xlam"," .pptm","。 potm"," .ppsm"," .sldm"," .ppam"," .accde"`

但我需要知道在JS中找到解决方案的任何其他方式或C#,

处理文件内容并检查其中的任何编程内容..


这些是我试过的代码...

var extnsnArray = [" .docm"," .dotm"," .xlm"," .xltm"," .xlsm"," .xla"," .xlam"," ; .PPTM"," .POTM"," .ppsm"," .sldm"," .ppam&现状t;," .accde"]

var extnsn = $(file).attr('extension');

if(extnsnArray.indexOf(extnsn)> -1)
{
//文件已启用宏
}
其他
{
//文件未启用宏
}


此外,我想知道在非宏启用的office文件中嵌入恶意代码的可能性

(。doc,.ppt,.xlsx等)



解决方案

< blockquote>

你好,


Office JS API 现在不提供访问文件中宏的任何功能。


使用C#,您可以自动执行Office应用程序以打开这些文件,然后访问VBE进行检查如果有宏。您还可以使用Open XML SDK&n bsp;要检查是否有宏,但Open XML SDK适用于Open XML格式文件,它不支持
旧文件格式,如.xls .doc。


在我看来,我建议你使用Open XML。要使用XML访问VBProject,我建议您从
下载Open XML SDK工具  https://www.microsoft.com/en-us/download/details.aspx?id=30425


你可以创建两个文件。一个有宏,另一个没有宏。然后,您可以使用Open XML SDK Tool比较这两个文件并生成c#代码。


如果要使用Office对象模型自动执行Office检查文件,则需要添加引用"Microsoft"应用程序可扩展性5.3"的Visual Basic,然后您可以访问其VBE和VBProject。请访问
Visual Basic可扩展性参考
 了解有关对象的更多信息。


问候,


Celeste


I have some Office files... I want to upload these files into Data Base... Before uploading i want to check the files are macro enabled or not... Expecting the solution in java script... I have tried with the following file extensions.. `".docm",".dotm",".xlm ",".xltm",".xlsm",".xla",".xlam",".pptm",".potm",".ppsm",".sldm",".ppam",".accde"` but i need to know any other way to find the solution in JS or C#, by processing the file content and check any programming contents inside it.. these are the codes i tried... var extnsnArray=[".docm",".dotm",".xlm",".xltm",".xlsm",".xla",".xlam",".pptm",".potm",".ppsm",".sldm",".ppam",".accde"] var extnsn = $(file).attr('extension'); if (extnsnArray.indexOf(extnsn) > -1) { // file is macro enabled } else { // file is not macro enabled } Also i want to know the chance of embedding malicious codes inside a non macro enabled office files

(.doc,.ppt,.xlsx etc.)


解决方案

Hello,

Office JS API now doesn't provide any feature to access the macro in the file.

Using C#, you could automate Office application to open these file and then access the VBE to check if there is macro. You could also use Open XML SDK to check if there is macro, but Open XML SDK works for Open XML format files, it doesnt support old file format like .xls .doc.

In my opinion, I would suggest you use Open XML. To access the VBProject using XML, I suggest you download the Open XML SDK Tool from  https://www.microsoft.com/en-us/download/details.aspx?id=30425

You could create two files. One has macro and the other doesn't have macro in it. Then you could use Open XML SDK Tool compares the two files and generate c# code.

If you want to automate Office to check file using Office object model, you need to add reference "Microsoft Visual Basics for Applications Extensibility 5.3", then you could access its VBE and VBProject. Please visit Visual Basic Extensibility Reference for more information about the objects.

Regards,

Celeste


这篇关于检查MS office文件(word,excel,ppt,access等)是否启用宏(嵌入式恶意代码)或不使用C#/ JAVA SCRIPT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆