I have a stored procedure which is encrypted using the WITH ENCRYPTION option. Now I want to decrypt that procedure. I have already tried a stored procedure called "Decryptsp2K" which is given for SQL 2000 in this forum: http://forums.asp.net/t/1516587.aspx/1
我有一个使用WITH ENCRYPTION选项加密的存储过程。现在我想解密这个过程。我已经尝试过一个名为“Decryptsp2K”的存储过程,它是在本论坛中为SQL 2000提供的:http://forums.asp.net/t/1516587.aspx/1
But it deletes my stored procedure, rather than decrypting it.
但是它会删除我的存储过程,而不是解密它。
Is there a way to decrypt a stored procedure in SQL Server 2008?
SQL Server 2008中的存储过程是否有解密方法?
4 个解决方案
#1
22
The SQL Server Pro article "Decrypt SQL Server Objects" still works in SQL Server 2008.
SQL Server Pro文章“解密SQL Server对象”仍然适用于SQL Server 2008。
You need to connect via the DAC. See the file "Decrypt SQL 2005 stored procedures, functions, triggers, views.sql" in the download.
您需要通过DAC连接。参见“解密SQL 2005存储过程、函数、触发器、视图”文件。sql”下载。
Just to summarise the steps that it performs for the following stored procedure definition
下面总结一下它为以下存储过程定义执行的步骤
CREATE PROC dbo.myproc
WITH ENCRYPTION
AS
SELECT 'FOO'
- Retrieves the encrypted object text from the
imageval
column insys.sysobjvalues
and stores it in a variable@ContentOfEncryptedObject
- 从sys中的imageval列检索加密的对象文本。sysobjvalues并将其存储在变量@ContentOfEncryptedObject
- Calculates
@ObjectDataLength
fromDATALENGTH(@ContentOfEncryptedObject)/2
. - 计算从DATALENGTH @ObjectDataLength(@ContentOfEncryptedObject)/ 2。
- Generates an
ALTER PROCEDURE
statement padded out to the correct length with the-
character (so in this caseALTER PROCEDURE [dbo].[myproc] WITH ENCRYPTION AS------------
) - 生成一个用-字符填充的ALTER PROCEDURE语句(在这种情况下,ALTER PROCEDURE [dbo])。与加密(myproc)- - - - - - - - - - - -)
- Executes the
ALTER
statement, retrieves the encrypted version fromsys.sysobjvalues
and stores that in the variable@ContentOfFakeEncryptedObject
then rolls back the change. - 执行ALTER语句,从sys检索加密版本。sysobjvalues并将其存储在变量@ contentoffencryptedobject中,然后回滚更改。
- Generates a
CREATE PROCEDURE
statement padded out to the correct length with the-
character (so in this caseCREATE PROCEDURE [dbo].[myproc] WITH ENCRYPTION AS-----------
). This gets stored in the variable@ContentOfFakeObject
- 生成一个用-字符填充的CREATE PROCEDURE语句(因此在本例中创建过程[dbo])。与加密(myproc)- - - - - - - - - - - -)。它存储在变量@ContentOfFakeObject中
It then loops through for @i = 1 to @ObjectDataLength
and decrypts the definition a character at a time using the following XOR
calculation.
然后循环@i = 1到@ObjectDataLength,每次使用以下XOR计算解密一个字符。
NCHAR(
UNICODE(SUBSTRING(@ContentOfEncryptedObject, @i, 1)) ^
(
UNICODE(SUBSTRING(@ContentOfFakeObject, @i, 1)) ^
UNICODE(SUBSTRING(@ContentOfFakeEncryptedObject, @i, 1))
)
)
UPDATE
更新
Paul White has written a very nice article that goes into details on why the above works, and that gives an alternate method that doesn't rely on altering the object: The Internals of
WITH ENCRYPTION
Paul White写了一篇非常好的文章,详细介绍了上述方法的工作原理,并给出了一种不依赖于修改对象的替代方法:加密的内部原理
#2
6
If you want to decrypt procedure or any other encrypted object, check out ApexSQL Decrypt.
如果您想要解密过程或任何其他加密对象,请检查ApexSQL解密。
It’s a free standalone tool, with an option to integrate it into SSMS, preview original DDL script, and create Alter or Create decryption scripts.
它是一个免费的独立工具,可以将其集成到ssm中,预览原始DDL脚本,并创建Alter或create解密脚本。
From a standalone tool you can connect to multiple servers and decrypt multiple objects at once.
从一个独立的工具,您可以连接到多个服务器并同时解密多个对象。
dbForge SQL Decryptor is the other tool that can help you out in this case as well.
dbForge SQL解密器是另一个在这种情况下也可以帮助您的工具。
#3
3
Many older tools stopped working with SQL Server 2005+. Note you must be using the Dedicated Admin Connection
许多较老的工具停止使用SQL Server 2005+。注意,您必须使用专用的管理连接。
A quick search shows several options.
快速搜索显示了几个选项。
- http://www.sql-shield.com/decrypt-stored-procedure.html
- http://www.sql-shield.com/decrypt-stored-procedure.html
#4
1
Decrypt Stored procedure of SQL SERVER
对SQL SERVER的存储过程进行解密
You can use third party tool for decrypting your encrypted stored procedure.
您可以使用第三方工具解密您的加密存储过程。
Download that tool-: It's freeware
下载工具-:这是免费软件
https://www.devart.com/dbforge/sql/sqldecryptor/download.html
https://www.devart.com/dbforge/sql/sqldecryptor/download.html
#1
22
The SQL Server Pro article "Decrypt SQL Server Objects" still works in SQL Server 2008.
SQL Server Pro文章“解密SQL Server对象”仍然适用于SQL Server 2008。
You need to connect via the DAC. See the file "Decrypt SQL 2005 stored procedures, functions, triggers, views.sql" in the download.
您需要通过DAC连接。参见“解密SQL 2005存储过程、函数、触发器、视图”文件。sql”下载。
Just to summarise the steps that it performs for the following stored procedure definition
下面总结一下它为以下存储过程定义执行的步骤
CREATE PROC dbo.myproc
WITH ENCRYPTION
AS
SELECT 'FOO'
- Retrieves the encrypted object text from the
imageval
column insys.sysobjvalues
and stores it in a variable@ContentOfEncryptedObject
- 从sys中的imageval列检索加密的对象文本。sysobjvalues并将其存储在变量@ContentOfEncryptedObject
- Calculates
@ObjectDataLength
fromDATALENGTH(@ContentOfEncryptedObject)/2
. - 计算从DATALENGTH @ObjectDataLength(@ContentOfEncryptedObject)/ 2。
- Generates an
ALTER PROCEDURE
statement padded out to the correct length with the-
character (so in this caseALTER PROCEDURE [dbo].[myproc] WITH ENCRYPTION AS------------
) - 生成一个用-字符填充的ALTER PROCEDURE语句(在这种情况下,ALTER PROCEDURE [dbo])。与加密(myproc)- - - - - - - - - - - -)
- Executes the
ALTER
statement, retrieves the encrypted version fromsys.sysobjvalues
and stores that in the variable@ContentOfFakeEncryptedObject
then rolls back the change. - 执行ALTER语句,从sys检索加密版本。sysobjvalues并将其存储在变量@ contentoffencryptedobject中,然后回滚更改。
- Generates a
CREATE PROCEDURE
statement padded out to the correct length with the-
character (so in this caseCREATE PROCEDURE [dbo].[myproc] WITH ENCRYPTION AS-----------
). This gets stored in the variable@ContentOfFakeObject
- 生成一个用-字符填充的CREATE PROCEDURE语句(因此在本例中创建过程[dbo])。与加密(myproc)- - - - - - - - - - - -)。它存储在变量@ContentOfFakeObject中
It then loops through for @i = 1 to @ObjectDataLength
and decrypts the definition a character at a time using the following XOR
calculation.
然后循环@i = 1到@ObjectDataLength,每次使用以下XOR计算解密一个字符。
NCHAR(
UNICODE(SUBSTRING(@ContentOfEncryptedObject, @i, 1)) ^
(
UNICODE(SUBSTRING(@ContentOfFakeObject, @i, 1)) ^
UNICODE(SUBSTRING(@ContentOfFakeEncryptedObject, @i, 1))
)
)
UPDATE
更新
Paul White has written a very nice article that goes into details on why the above works, and that gives an alternate method that doesn't rely on altering the object: The Internals of
WITH ENCRYPTION
Paul White写了一篇非常好的文章,详细介绍了上述方法的工作原理,并给出了一种不依赖于修改对象的替代方法:加密的内部原理
#2
6
If you want to decrypt procedure or any other encrypted object, check out ApexSQL Decrypt.
如果您想要解密过程或任何其他加密对象,请检查ApexSQL解密。
It’s a free standalone tool, with an option to integrate it into SSMS, preview original DDL script, and create Alter or Create decryption scripts.
它是一个免费的独立工具,可以将其集成到ssm中,预览原始DDL脚本,并创建Alter或create解密脚本。
From a standalone tool you can connect to multiple servers and decrypt multiple objects at once.
从一个独立的工具,您可以连接到多个服务器并同时解密多个对象。
dbForge SQL Decryptor is the other tool that can help you out in this case as well.
dbForge SQL解密器是另一个在这种情况下也可以帮助您的工具。
#3
3
Many older tools stopped working with SQL Server 2005+. Note you must be using the Dedicated Admin Connection
许多较老的工具停止使用SQL Server 2005+。注意,您必须使用专用的管理连接。
A quick search shows several options.
快速搜索显示了几个选项。
- http://www.sql-shield.com/decrypt-stored-procedure.html
- http://www.sql-shield.com/decrypt-stored-procedure.html
#4
1
Decrypt Stored procedure of SQL SERVER
对SQL SERVER的存储过程进行解密
You can use third party tool for decrypting your encrypted stored procedure.
您可以使用第三方工具解密您的加密存储过程。
Download that tool-: It's freeware
下载工具-:这是免费软件
https://www.devart.com/dbforge/sql/sqldecryptor/download.html
https://www.devart.com/dbforge/sql/sqldecryptor/download.html