search
HomeDatabaseMysql Tutorial如何防止Access2000密码被破译的方法

如果你过分信任 Access 2000数据库的 密码 保护,你可能会因此而蒙受损失。这是因为Access 2000的数据库级 密码 并不安全,相反它很脆弱,甚至下面这段非常小的程序就可以攻破它: ' 程序一(VB6):Access 2000 密码 破译 Private Sub Command1_Click() Cons

如果你过分信任 Access 2000数据库的密码保护,你可能会因此而蒙受损失。这是因为Access 2000的数据库级密码并不安全,相反它很脆弱,甚至下面这段非常小的程序就可以攻破它:

' 程序一(VB6):Access 2000密码破译

Private Sub Command1_Click()

Const Offset = &H43 ' 文件偏移地址:Access数据库从此处开始存放加密密码

Dim bEmpty(1 To 2) As Byte, bPass(1 To 2) As Byte

Dim I As Integer, Password As String

' 打开一个空数据库作为参照

Open "D:VB6_TestMDB_PasswordNew_Empty_DB.mdb" For Binary As #1

' 打开被密码保护的数据库

Open "D:VB6_TestMDB_PasswordPass_Protected_DB.mdb" For Binary As #2

Seek #1, Offset

Seek #2, Offset

For I = 1 To 20 ' Access 2000 数据库密码最长允许20位

Get #1, , bEmpty ' 其中每位密码占两个字节

Get #2, , bPass ' 一个汉字也仅是一位密码,占两个字节

If (bEmpty(1) Xor bPass(1)) 0 Then

Password = Password + Chr(bEmpty(1) Xor bPass(1)) ' 将密码解密

End If

Next

Close 1, 2

MsgBox "Password:" + Password ' 显示密码

End Sub

一、深入分析

上述程序成功的关键是使用了一个空数据库(New_Empty_DB.mdb)。该数据库的创建日期必须与被密码保护的数据库(Pass_Protected_DB.mdb)相一致。 换句话说,Access 2000 仅仅是使用“数据库创建日期”来加密用户密码

应注意的是:上面的“创建日期”只是操作系统级的,也就是 Windows记录在文件夹目录里的信息(根据文件名的长短,每个文件在目录里占用至少32个字节,包括:文件名、属性、文件大小、首蔟号、创建时间、修改时间和访问时间等)。

Access 2000 在数据库中也记录了该数据库的“创建日期”。加密数据库密码的正是数据库内部记录的这个“创建日期”。该日期只有在数据库被成功打开后才能看到。但在一般情况下,操作系统级的以及数据库内保存的“创建日期”是完全一样的,因此这为破译者提供了方便。

上述程序中还有一点需要说明:为简明起见,解密密码时仅处理了双字节的首字节,因此它仅对非汉字密码有效。若要解密汉字密码,须对双字节均做处理。

二、防范措施

1、隐藏“创建日期”

从上面的分析可以看出,既然“创建日期”是破译的关键,那么我们应“对症下药”,将真实的“创建日期”隐藏起来。

第一步,创建数据库时,使用一个“不可思议的、别人不易猜测”的日期。做法为:修改 Windows系统日期,例如改为2026年05月15日,创建数据库后再将系统日期改回。这个“不可思议”的日期即为该数据库的真实“创建日期”。

第二步,修改操作系统级的“创建日期”。上述第一步完成后,该数据库在操作系统级的创建日期也是2026年05月15日,必须加以修改,以达到隐藏真实创建日期的目的。修改操作系统级的“创建日期”可以由下面的程序二完成。

' 程序二(VB6):修改文件在操作系统级的“创建日期”

Private Type FILETIME

dwLowDateTime As Long

dwHighDateTime As Long

End Type

Private Type SYSTEMTIME

wYear As Integer

wMonth As Integer

wDayOfWeek As Integer

wDay As Integer

wHour As Integer

wMinute As Integer

wSecond As Integer

wMilliseconds As Integer

End Type

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_TestMDB_PasswordPass_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、使用用户级安全机制

通过设置不同的用户帐号和组帐号对数据库中的各种资源进行权限管理。这种加强了的安全机制虽然给日常使用(尤其是单用户使用)带来了不便,但在有安全隐患的地方依然有设置的必要。

三、结论

所谓“道高一尺魔高一丈”,因为这世上并没有绝对的安全。上述方法一的目的是提高破译的成本以达到常人难以接受的程度;而方法二的初衷是增加密码的数量。两种方法的结合足以使破译者望而却步。不过这并不意味着百分之百的安全。但从思想上提高安全意识,防患于未然,这毕竟是正确的选择。
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How does MySQL index cardinality affect query performance?How does MySQL index cardinality affect query performance?Apr 14, 2025 am 12:18 AM

MySQL index cardinality has a significant impact on query performance: 1. High cardinality index can more effectively narrow the data range and improve query efficiency; 2. Low cardinality index may lead to full table scanning and reduce query performance; 3. In joint index, high cardinality sequences should be placed in front to optimize query.

MySQL: Resources and Tutorials for New UsersMySQL: Resources and Tutorials for New UsersApr 14, 2025 am 12:16 AM

The MySQL learning path includes basic knowledge, core concepts, usage examples, and optimization techniques. 1) Understand basic concepts such as tables, rows, columns, and SQL queries. 2) Learn the definition, working principles and advantages of MySQL. 3) Master basic CRUD operations and advanced usage, such as indexes and stored procedures. 4) Familiar with common error debugging and performance optimization suggestions, such as rational use of indexes and optimization queries. Through these steps, you will have a full grasp of the use and optimization of MySQL.

Real-World MySQL: Examples and Use CasesReal-World MySQL: Examples and Use CasesApr 14, 2025 am 12:15 AM

MySQL's real-world applications include basic database design and complex query optimization. 1) Basic usage: used to store and manage user data, such as inserting, querying, updating and deleting user information. 2) Advanced usage: Handle complex business logic, such as order and inventory management of e-commerce platforms. 3) Performance optimization: Improve performance by rationally using indexes, partition tables and query caches.

SQL Commands in MySQL: Practical ExamplesSQL Commands in MySQL: Practical ExamplesApr 14, 2025 am 12:09 AM

SQL commands in MySQL can be divided into categories such as DDL, DML, DQL, DCL, etc., and are used to create, modify, delete databases and tables, insert, update, delete data, and perform complex query operations. 1. Basic usage includes CREATETABLE creation table, INSERTINTO insert data, and SELECT query data. 2. Advanced usage involves JOIN for table joins, subqueries and GROUPBY for data aggregation. 3. Common errors such as syntax errors, data type mismatch and permission problems can be debugged through syntax checking, data type conversion and permission management. 4. Performance optimization suggestions include using indexes, avoiding full table scanning, optimizing JOIN operations and using transactions to ensure data consistency.

How does InnoDB handle ACID compliance?How does InnoDB handle ACID compliance?Apr 14, 2025 am 12:03 AM

InnoDB achieves atomicity through undolog, consistency and isolation through locking mechanism and MVCC, and persistence through redolog. 1) Atomicity: Use undolog to record the original data to ensure that the transaction can be rolled back. 2) Consistency: Ensure the data consistency through row-level locking and MVCC. 3) Isolation: Supports multiple isolation levels, and REPEATABLEREAD is used by default. 4) Persistence: Use redolog to record modifications to ensure that data is saved for a long time.

MySQL's Place: Databases and ProgrammingMySQL's Place: Databases and ProgrammingApr 13, 2025 am 12:18 AM

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

MySQL: From Small Businesses to Large EnterprisesMySQL: From Small Businesses to Large EnterprisesApr 13, 2025 am 12:17 AM

MySQL is suitable for small and large enterprises. 1) Small businesses can use MySQL for basic data management, such as storing customer information. 2) Large enterprises can use MySQL to process massive data and complex business logic to optimize query performance and transaction processing.

What are phantom reads and how does InnoDB prevent them (Next-Key Locking)?What are phantom reads and how does InnoDB prevent them (Next-Key Locking)?Apr 13, 2025 am 12:16 AM

InnoDB effectively prevents phantom reading through Next-KeyLocking mechanism. 1) Next-KeyLocking combines row lock and gap lock to lock records and their gaps to prevent new records from being inserted. 2) In practical applications, by optimizing query and adjusting isolation levels, lock competition can be reduced and concurrency performance can be improved.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)