您好,登錄后才能下訂單哦!
這篇文章將為大家詳細講解有關SQL SERVER SP的解密過程介紹,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
在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的解密過程大概了解了嗎?如果想了解更多相關文章內容,歡迎關注億速云行業資訊頻道,感謝各位的閱讀!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。