Danh mục

Tài liệu SQL Server 2005 – Hack dữ liệu đã mã hoá bởi mật khẩu

Số trang: 12      Loại file: pdf      Dung lượng: 171.09 KB      Lượt xem: 21      Lượt tải: 0    
Thư viện của tui

Phí tải xuống: 2,000 VND Tải xuống file đầy đủ (12 trang) 0
Xem trước 2 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Như bạn đã biết, mã hoá bằng mật khẩu là một phương pháp mã hoá dữ liệu cơ bản chỉ sử dụng đến mật khẩu và có thể giải mã với cùng mật khẩu đó. Giờ hãy giả dụ chúng ta quên mất mật khẩu đã đặt và cần phải khôi phục lại dữ liệu như ban đầu. Bước 1 Mã hoá dữ liệu theo phương pháp mã hoá bằng mật khẩu select EncryptedData = EncryptByPassPhrase('MAK', '123456789' ) Kết quả EncryptedData ------------------------------------------------------------------------0x01000000F75D553409C74570F6DDBCADA53FD489DDD52D9277010050565ADF 30F244F8CC Bước 2 Tạo thủ tục sử dụng để khôi phục lại dữ liệu đã má hoá. Thủ...
Nội dung trích xuất từ tài liệu:
Tài liệu SQL Server 2005 – Hack dữ liệu đã mã hoá bởi mật khẩu SQL Server 2005 – Hack dữ liệu đã mã hoá bởi mật khẩu Như bạn đã biết, mã hoá bằng mật khẩu là một phương pháp mã hoá dữ liệu cơ bản chỉ sử dụng đến mật khẩu và có thể giải mã với cùng mật khẩu đó. Giờ hãy giả dụ chúng ta quên mất mật khẩu đã đặt và cần phải khôi phục lại dữ liệu như ban đầu. Bước 1 Mã hoá dữ liệu theo phương pháp mã hoá bằng mật khẩu select EncryptedData = EncryptByPassPhrase('MAK', '123456789' ) Kết quả EncryptedData ---------------------------------------------------------------- ---------- 0x01000000F75D553409C74570F6DDBCADA53FD489DDD52D9277010050565ADF 30F244F8CC Bước 2 Tạo thủ tục sử dụng để khôi phục lại dữ liệu đã má hoá. Thủ tục này sẽ sử dụng hàm DecryptByPassPhrase để giải mã dữ liệu và hiển thị lên mật khẩu. USE [Master] GO /****** Object: StoredProcedure [dbo].[hack_encryption] Script Date: 12/18/2007 18:18:36 ******/ IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[hack_encryption]') AND type in (N'P', N'PC')) DROP PROCEDURE [dbo].[hack_encryption] GO set nocount on SET CONCAT_NULL_YIELDS_NULL OFF go USE [Master] GO /****** Object: StoredProcedure [dbo].[hack_encryption] Script Date: 12/18/2007 18:18:55 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE procedure [dbo].[hack_encryption] @encryptedtext varbinary(max) as declare @password varchar(6) declare @i int declare @j int declare @k int declare @l int declare @m int declare @n int set @i=-1 set @j=-1 set @k=-1 set @l=-1 set @m=-1 set @n=-1 set @password ='' while @i print 'This is the Encrypted text:' +@password set @i=256;set @j=256;set @k=256;set @l=256;set @m=256;set @n=256; print 'The actual data is :' +convert(varchar(100), DecryptByPassPhrase(ltrim(rtrim(@password)), @encryptedtext)) end --print 'A'+ltrim(rtrim(@password))+'B' --print convert(varchar(100), DecryptByPassPhrase(ltrim(rtrim(@password)),@encryptedtext)) set @n=@n+1 end set @n=0 set @m=@m+1 end set @m=0 set @l=@l+1 end set @l=0 set @k=@k+1 end set @k=0 set @j=@j+1 end set @j=0 set @i=@i+1 end GO Bước 3 Giả sử rằng bạn đã quên mật khẩu dùng để mã hoá dữ liệu thành “0x01000000F75D553409C74570F6DDBCADA53FD489DDD52D9277010050565ADF30F244 F8CC”. Chúng ta có thể truy tìm lại được mật khẩu và dữ liệu đã bị mã hoá bằng thủ tục sau use master go select getdate() as StartingTime go declare @myencryptedtext varbinary(max) set @myencryptedtext=0x01000000F75D553409C74570F6DDBCADA53FD489DDD52 D9277010050565ADF30F244F8CC print @myencryptedtext exec hack_encryption @encryptedtext=@myencryptedtext go select getdate() as EndingTime go Kết quả StartingTime ----------------------- 2007-12-18 18:24:10.843 0x01000000F75D553409C74570F6DDBCADA53FD489DDD52D9277010050565ADF 30F244F8CC This is the Encrypted text: MAK The actual data is :123456789 EndingTime ----------------------- 2007-12-18 18:26:36.080 Hình 1 Như bạn thấy trong kết quả (hình 1), nó chỉ cần đển 2 phút để t ìm lại được dữ liệu và mật khẩu. Về cơ bản, thủ tục này lặp lại tất cả khả năng hợp lý có thể xảy ra của các ký tự ASCII có độ dài trên 6 ký tự để tìm ra mật khẩu và sử dụng nó để giải mã dữ liệu. Tạo ra một thủ tục sẽ không giúp g ì nhiều khi dữ liệu đã được mã hoá nằm trong một bảng. Vì vậy chúng ta phải thay đổi thủ t hục này thành một hàm vô hướng như hướng dẫn dưới đây Bước 1 Tạo thủ tục như sau USE [master] GO /****** Object: UserDefinedFunction [dbo].[hack_encryption_password] Script Date: 12/18/2007 18:36:29 ******/ IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[hack_encryption_password]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT')) DROP FUNCTION [dbo].[hack_encryption_password] GO use [Master] go CREATE function [dbo].[hack_encryption_password] (@encryptedtext varbinary(max)) returns varchar(6) with execute as caller as begin declare @password varchar(6) declare @i int declare @j int declare @k int declare @l int declare @m int declare @n int set @i=-1 set @j=-1 set @k=-1 set @l=-1 set @m=-1 set @n=-1 set @password ='' while @i begin while @lend return @password END Bước 2 Tạo một bảng với dữ liệu được mã hoá USE [tempdb] GO /****** Object: Table [dbo].[MyTable] Script Date: 12/18/2007 18:44:40 ******/ IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[MyTable]') AND type in (N'U')) DROP TABLE [dbo].[MyTable] GO create table MyTable(id int, encrypteddata va ...

Tài liệu được xem nhiều: