Can I digitally sign JScript (.js) or VBScript (.vbs) files?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-23 12:54:16

问题


I know that one can sign a Windows binary executable file using signtool. So all this time I was under assumption that one cannot sign any of the files interpreted by Windows Script Host, such as JScript (.js) or VBScript (.vbs) because those are mere text files.

But today, while opening a .js file that I downloaded off my web site, I was greeted by this warning:

So does this mean that there's a way to sign those .js/.vbs files? If so, then how?


回答1:


Just to finalize my original question. The answer is yes. To the best of my knowledge, one can sign the following files using Microsoft's SignTool:

  • Obviously Windows executables: .exe, .dll, .com (for old DOS format), .scr (for screensaver), .ocx (for ActiveX control), .cpl (for Control Panel executable.)

  • Windows installer files: .msi, .msp

  • Text-based scripts: .js (for JScript), .vbs (for VBScript), .jse (for encoded JScript), .vbe (for encoded VBScript)

  • PowerShell scripts: .ps1 , .psm1, .ps1xml

  • Windows Script Files: .wsf (with mixed content)




回答2:


The Scripting.Signer Object can sign a script with a digital signature.

Dim filespec : Set filespec = "my_script.vbs"
Dim cert : Set cert = "my" ' the default private certificate
Dim oSign : Set oSign = CreateObject("Scripting.Signer")
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
Dim file : Set file = fso.GetFile(filespec)

oSign.SignFile file.Path, cert


来源:https://stackoverflow.com/questions/34238913/can-i-digitally-sign-jscript-js-or-vbscript-vbs-files

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