MS Office 2013 - VBA密码安全 [英] MS Office 2013 - VBA password security
问题描述
我在网上搜索过,有一些网站销售软件来做,是否可靠?
我想开发围绕我的办公室文件的一些安全性,这取决于内部的VBA代码,但如果vba代码可以轻松更改/看到这是非常有意义的。
谢谢
使用这个答案如下:是有没有办法在Excel VBA项目中破解密码?
而不是做所有的十六进制的东西。你可以试试这个。它将适用于任何文件(* .xls,* .xlsm,* .xlam ...)。测试并在Excel 2007,Excel 2010和Excel 2013 - 32位版本
上运行。- 打开文件s)包含您锁定的VBA项目
-
创建一个新的xlsm文件并将此代码存储在 Module1
Option Explicit
Private Const PAGE_EXECUTE_READWRITE =& H40
私有声明Sub MoveMemory Libkernel32别名RtlMoveMemory _
(目的地长,源长,ByVal长度)
私有声明函数VirtualProtect Libkernel32(lpAddress As Long,_
ByVal dwSize As Long ,ByVal flNewProtect As Long,lpflOldProtect As Long)As Long
私有声明函数GetModuleHandleA Libkernel32(ByVal lpModuleName As String)As Long
私有声明函数GetProcAddress Lib kernel32(ByVal hModule As Long,_
ByVal lpProcName As String)As Long
私有声明函数DialogBoxPar am Libuser32别名DialogBoxParamA(ByVal hInstance As Long,_
ByVal pTemplateName As Long,ByVal hWndParent As Long,_
ByVal lpDialogFunc As Long,ByVal dwInitParam As Long)As Integer
Dim HookBytes(0到5)As Byte
Dim OriginBytes(0到5)As Byte
Dim pFunc As Long
Dim Flag As Boolean
私有函数GetPtr(ByVal Value As Long)As Long
GetPtr = Value
End Function
Public Sub RecoverBytes()
如果Flag Then MoveMemory ByVal pFunc,ByVal VarPtr(OriginBytes(0)),6
End Sub
公共函数Hook()As Boolean
Dim TmpBytes(0到5)As Byte
Dim p As Long
Dim OriginProtect As Long
Hook = False
pFunc = GetProcAddress(GetModuleHandleA(user32.dll),DialogBoxParamA)
如果VirtualProtect(ByVal pFunc,6,PAGE_EXECUTE_READWRITE,OriginProtect) 0然后
MoveMemory ByVal VarPtr(TmpBytes(0)),ByVal pFunc,6
如果TmpBytes(0) & H68然后
MoveMemory ByVal VarPtr(OriginBytes(0)),ByVal pFunc,6
p = GetPtr(AddressOf MyDialogBoxParam)
HookBytes( 0)=& H68
MoveMemory ByVal VarPtr(HookBytes(1)),ByVal VarPtr(p),4
HookBytes(5)=& HC3
MoveMemory ByVal pFunc ,ByVal VarPtr(HookBytes(0)),6
Flag = True
Hook = True
End If
End If
End Function
私有函数MyDialogBoxParam(ByVal hInstance As Long,_
ByVal pTemplateName As Long,ByVal hWndParent As Long,_
ByVal lpDialogFunc As Long,ByVal dwInitParam As Long)As Integer
如果pTemplateName = 4070然后
MyDialogBoxParam = 1
Else
RecoverBytes
MyDialogBoxParam = DialogBoxParam(hInstance,pTemplateName,_
hWndParent,lpDialogFunc,dwInitParam)
H ook
如果
结束函数
-
将此代码粘贴到 Module2 并运行
Sub unprotected()
如果Hook Then
MsgBox VBA项目不受保护!,vb信息,*****
如果
End Sub
-
回到您的VBA项目,享受。
P / S :这个代码记入了越南开发商Siwtom(昵称)。您可以将此代码转换为Excel插件以供经常使用。
I am wondering about how safe is the VBA password on MS Office 2013.
I've searched online and there are a bunch of websites selling software to do it, is it reliable?
I want to develop some security around my office files that would depend on the VBA code inside, but if the vba code inside can be easily changed/seen it's non sense going that way.
Thanks
Using this answer as reference : Is there a way to crack the password on an Excel VBA Project?
Instead of doing all the Hex stuffs. You can try this. It will work for any files (*.xls, *.xlsm, *.xlam ...). Tested and works on Excel 2007, Excel 2010 and Excel 2013 - 32 bit version.
- Open the file(s) that contain your locked VBA Projects
Create a new xlsm file and store this code in Module1
Option Explicit Private Const PAGE_EXECUTE_READWRITE = &H40 Private Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" _ (Destination As Long, Source As Long, ByVal Length As Long) Private Declare Function VirtualProtect Lib "kernel32" (lpAddress As Long, _ ByVal dwSize As Long, ByVal flNewProtect As Long, lpflOldProtect As Long) As Long Private Declare Function GetModuleHandleA Lib "kernel32" (ByVal lpModuleName As String) As Long Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, _ ByVal lpProcName As String) As Long Private Declare Function DialogBoxParam Lib "user32" Alias "DialogBoxParamA" (ByVal hInstance As Long, _ ByVal pTemplateName As Long, ByVal hWndParent As Long, _ ByVal lpDialogFunc As Long, ByVal dwInitParam As Long) As Integer Dim HookBytes(0 To 5) As Byte Dim OriginBytes(0 To 5) As Byte Dim pFunc As Long Dim Flag As Boolean Private Function GetPtr(ByVal Value As Long) As Long GetPtr = Value End Function Public Sub RecoverBytes() If Flag Then MoveMemory ByVal pFunc, ByVal VarPtr(OriginBytes(0)), 6 End Sub Public Function Hook() As Boolean Dim TmpBytes(0 To 5) As Byte Dim p As Long Dim OriginProtect As Long Hook = False pFunc = GetProcAddress(GetModuleHandleA("user32.dll"), "DialogBoxParamA") If VirtualProtect(ByVal pFunc, 6, PAGE_EXECUTE_READWRITE, OriginProtect) <> 0 Then MoveMemory ByVal VarPtr(TmpBytes(0)), ByVal pFunc, 6 If TmpBytes(0) <> &H68 Then MoveMemory ByVal VarPtr(OriginBytes(0)), ByVal pFunc, 6 p = GetPtr(AddressOf MyDialogBoxParam) HookBytes(0) = &H68 MoveMemory ByVal VarPtr(HookBytes(1)), ByVal VarPtr(p), 4 HookBytes(5) = &HC3 MoveMemory ByVal pFunc, ByVal VarPtr(HookBytes(0)), 6 Flag = True Hook = True End If End If End Function Private Function MyDialogBoxParam(ByVal hInstance As Long, _ ByVal pTemplateName As Long, ByVal hWndParent As Long, _ ByVal lpDialogFunc As Long, ByVal dwInitParam As Long) As Integer If pTemplateName = 4070 Then MyDialogBoxParam = 1 Else RecoverBytes MyDialogBoxParam = DialogBoxParam(hInstance, pTemplateName, _ hWndParent, lpDialogFunc, dwInitParam) Hook End If End Function
Paste this code in Module2 and run it
Sub unprotected() If Hook Then MsgBox "VBA Project is unprotected!", vbInformation, "*****" End If End Sub
Come back to your VBA Projects and enjoy.
P/S: This code is credited to Siwtom (nick name), a vietnamese developer. You could turn this code into an Excel addin for frequently usage.
这篇关于MS Office 2013 - VBA密码安全的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!