大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
这篇文章将为大家详细讲解有关SQL SERVER SP的解密过程介绍,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
成都创新互联主要从事网站设计、成都网站制作、网页设计、企业做网站、公司建网站等业务。立足成都服务乳山,10余年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:028-86922220
在SQL SERVER里,已知微软在加密和解密存储过程时用的是RC4算法。下面是解密存储过程的解题思路,读者可以据此自己写个解密小程序。
想解密SP,其实就是解答下列一道证明题。
已知条件:
证明过程:
/**Object: StoredProcedure [dbo].[dbtwin_sp_decrypt] Script Date: 01/01/2020 21:09:31 **/
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[dbtwin_sp_decrypt]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[dbtwin_sp_decrypt]
GO
/**Object: StoredProcedure [dbo].[dbtwin_sp_decrypt] Script Date: 01/01/2020 21:09:31 **/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dbtwin_sp_decrypt](@procname sysname = NULL)
AS
DECLARE @encrypted NVARCHAR(MAX)
DECLARE @encryptedLength INT
DECLARE @tempStr NVARCHAR(MAX)
DECLARE @tempHead NVARCHAR(MAX)
DECLARE @tempBody NVARCHAR(MAX)
DECLARE @dummySp NVARCHAR(MAX)
DECLARE @dummyEncrypted NVARCHAR(MAX)
DECLARE @decryptedMessage NVARCHAR(MAX)
DECLARE @cnt INT
DECLARE @decryptedChar NCHAR(1)
SET NOCOUNT ON
SET @encrypted = (SELECT imageval FROM sys.sysobjvalues WHERE object_name(objid)=@procname)
SET @encryptedLength=DATALENGTH(@encrypted) / 2
SET @tempStr = N'PROCEDURE ' + @procname + N' WITH ENCRYPTION AS'
BEGIN TRAN
SET @tempHead = N'ALTER ' + @tempStr
SET @tempBody = REPLICATE(N' ',(@encryptedLength - LEN(@tempHead)))
EXEC(@tempHead + @tempBody)
SET @dummyEncrypted = (SELECT imageval FROM sys.sysobjvalues WHERE object_name(objid)=@procname)
ROLLBACK TRAN
SET @dummySp =N'CREATE ' + @tempStr + @tempBody
SET @decryptedMessage =''
SET @cnt = 1
WHILE @cnt <> @encryptedLength
BEGIN
SET @decryptedChar =NCHAR(UNICODE(SUBSTRING(@encrypted, @cnt, 1)) ^
UNICODE(SUBSTRING(@dummySp, @cnt, 1)) ^
UNICODE(SUBSTRING(@dummyEncrypted, @cnt, 1)))
SET @decryptedChar=ISNULL(@decryptedChar,N' ')
SET @decryptedMessage = @decryptedMessage + @decryptedChar
SET @cnt = @cnt + 1
END
SELECT @decryptedMessage
GO
看完上述内容,你们对SQL SERVER SP的解密过程大概了解了吗?如果想了解更多相关文章内容,欢迎关注创新互联行业资讯频道,感谢各位的阅读!