如何防止Access 2000密码被破(2)_Access数据库教程
推荐:如何用Access 轻松打造花店订单系统任务名称:打造花店订单系统 任务描述:小特的MM开了一家花店,生意特别火,招了三个小工还有点忙不过来。每天都有不少人通过电话或直接到花店订购鲜花,大多数客户还希望能在指定时间将所购鲜花送到指定地点。小特便用Access帮MM定制了一个花店订单系统:通过这
Private Const GENERIC_WRITE = &H40000000
Private Const OPEN_EXISTING = 3
Private Const FILE_SHARE_READ = &H1
Private Const FILE_SHARE_WRITE = &H2
Private Declare Function SetFileTimeWrite Lib "kernel32" Alias _
"SetFileTime" (ByVal hFile As Long, lpCreateTime As FILETIME, _
ByVal NullP As Long, ByVal NullP2 As Long) As Long
Private Declare Function SystemTimeToFileTime Lib "kernel32" _
(lpSystemTime As SYSTEMTIME, lpFileTime As FILETIME) As Long
Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" _
(ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal _
dwShareMode As Long, ByVal lpSecurityAttributes As Long, ByVal _
dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, _
ByVal hTemplateFile As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) _
As Long
Private Declare Function LocalFileTimeToFileTime Lib "kernel32" _
(lpLocalFileTime As FILETIME, lpFileTime As FILETIME) As Long
Private Sub Command1_Click()
Dim Year As Integer, Month As Integer, Day As Integer
Dim Hour As Integer, Minute As Integer, Second As Integer
Dim TimeStamp As Variant, Filename As String, X As Integer
Year = 2001: Month = 3: Day = 13 ' 准备设定的“创建日期”
Hour = 12: Minute = 0: Second = 26
TimeStamp = DateSerial(Year, Month, Day) + TimeSerial(Hour, Minute, Second)
Filename = "D:\VB6_Test\MDB_Password\Pass_Protected_DB.mdb" ' 目标文件名
X = ModifyFileStamp(Filename, TimeStamp)
End Sub
Function ModifyFileStamp(Filename As String, TimeStamp As Variant) As Integer
Dim X As Long, Handle As Long, System_Time As SYSTEMTIME
Dim File_Time As FILETIME, Local_Time As FILETIME
System_Time.wYear = Year(TimeStamp): System_Time.wMonth = Month(TimeStamp)
System_Time.wDay = Day(TimeStamp)
System_Time.wDayOfWeek = Weekday(TimeStamp) - 1
System_Time.wHour = Hour(TimeStamp): System_Time.wSecond = Second(TimeStamp)
System_Time.wMilliseconds = 0
X = SystemTimeToFileTime(System_Time, Local_Time)
X = LocalFileTimeToFileTime(Local_Time, File_Time) ' 转换成可用的类型
Handle = CreateFile(Filename, GENERIC_WRITE, FILE_SHARE_READ Or _
FILE_SHARE_WRITE, ByVal 0&, OPEN_EXISTING, 0, 0) ' 打开文件
X = SetFileTimeWrite(Handle, File_Time, ByVal 0&, ByVal 0&) ' 设置日期
CloseHandle Handle ' 关闭文件
End Function
图三显示的是数据库的真实“创建日期”以及经程序二伪装的操作系统级的“假象”日期。
可以看出,隐藏“创建日期”的方法对破译者来说只是增大了破译的工作量,增加了破解试验的次数。只有将该方法与下述的“方法二”相结合,才能达到“既治标又治本”的效果。不过在一般的情况下“方法一”已够用,因为如果破译者起始使用的测试日期与最终的真实日期相差百年,他需要付出数万次的努力!
2、使用用户级安全机制
通过设置不同的用户帐号和组帐号对数据库中的各种资源进行权限管理。这种加强了的安全机制虽然给日常使用(尤其是单用户使用)带来了不便,但在有安全隐患的地方依然有设置的必要。
设置各种帐号及相应权限的简单方法是使用“设置安全机制向导”(见图四)。图四还显示了安全机制启动后要求用户登录的画面。
三、结论
所谓“道高一尺魔高一丈”,因为这世上并没有绝对的安全。上述方法一的目的是提高破译的成本以达到常人难以接受的程度;而方法二的初衷是增加密码的数量。两种方法的结合足以使破译者望而却步。不过这并不意味着百分之百的安全。但从思想上提高安全意识,防患于未然,这毕竟是正确的选择。
分享:如何判断一个字段是否在表中'判断一个字段是否在表中 Function BlnField(sTblName As String, sFldName As String) As Boolean 'sTblName 源表名 '要查找的字段名 Dim fld As Field Dim rs As DAO.Recordset BlnField = False Set rs = CurrentDb.OpenRecordset(sTblName) rs.Fields.Re
- 相关链接:
- 教程说明:
Access数据库教程-如何防止Access 2000密码被破(2)。