您好,登錄后才能下訂單哦!
這篇文章將為大家詳細(xì)講解有關(guān)SQL SERVER SP的解密過程介紹,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。
在SQL SERVER里,已知微軟在加密和解密存儲過程時(shí)用的是RC4算法。下面是解密存儲過程的解題思路,讀者可以據(jù)此自己寫個(gè)解密小程序。
想解密SP,其實(shí)就是解答下列一道證明題。
已知條件:
證明過程:
/** 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
看完上述內(nèi)容,你們對SQL SERVER SP的解密過程大概了解了嗎?如果想了解更多相關(guān)文章內(nèi)容,歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。