Because I got my own Q & A app www.sosoask.com in the past two days, I found that the developer encrypted my stored procedure and was depressed. I am glad to find a solution. Now I share it with you:
Open the query analyzer, locate your database, and execute the following SQL statement:
Create procedure sp_decrypt (@ objectName varchar (50 )) AS Begin Begin transaction Declare @ objectname1 varchar (100) Declare @ sql1 nvarchar (4000), @ sql2 nvarchar (4000), @ sql3 nvarchar (4000), @ sql4 nvarchar (4000), @ sql5 nvarchar (4000 ), @ sql6 nvarchar (4000), @ sql7 nvarchar (4000), @ sql8 nvarchar (4000), @ sql9 nvarchar (4000), @ sql10 nvarchar (4000) DECLARE @ OrigSpText1 nvarchar (4000), @ OrigSpText2 nvarchar (4000), @ OrigSpText3 nvarchar (4000), @ resulnvtsp archar (4000) Declare @ I int, @ t bigint Declare @ m int, @ n int, @ q int Set @ m = (SELECT max (colid) FROM syscomments WHERE id = object_id (@ objectName )) Set @ n = 1 -- Get encrypted data Create table # temp (colid int, ctext varbinary (8000 )) Insert # temp SELECT colid, ctext FROM syscomments WHERE id = object_id (@ objectName) Set @ sql1 = 'alter PROCEDURE '+ @ objectName +' with encryption' -- Set @ sql1 = 'alter PROCEDURE '+ @ objectName +' with encryption' Set @ q = len (@ sql1) Set @ sql1 = @ sql1 + REPLICATE ('-', 4000-@ q) Select @ sql2 = REPLICATE ('-', 4000), @ sql3 = REPLICATE ('-', 4000), @ sql4 = REPLICATE ('-', 4000 ), @ sql5 = REPLICATE ('-', 4000), @ sql6 = REPLICATE ('-', 4000), @ sql7 = REPLICATE ('-', 4000 ), @ sql8 = REPLICATE ('-', 4000), @ sql9 = REPLICATE ('-', 4000), @ sql10 = REPLICATE ('-', 4000) Exec (@ sql1 + @ sql2 + @ sql3 + @ sql4 + @ sql5 + @ sql6 + @ sql7 + @ sql8 + @ sql9 + @ sql10) While @ n <= @ m Begin SET @ OrigSpText1 = (SELECT ctext FROM # temp WHERE colid = @ n) Set @ objectname1 = @ objectname + '_ t' SET @ OrigSpText3 = (SELECT ctext FROM syscomments WHERE id = object_id (@ objectName) and colid = @ n) If @ n = 1 Begin SET @ OrigSpText2 = 'create PROCEDURE '+ @ objectName +' with encryption '-- Set @ q = 4000-len (@ OrigSpText2) Set @ OrigSpText2 = @ OrigSpText2 + REPLICATE ('-', @ q) End Else Begin SET @ OrigSpText2 = REPLICATE ('-', 4000) End -- Start counter SET @ I = 1 -- Fill temporary variable SET @ resultsp = replicate (N 'A', (datalength (@ OrigSpText1)/2 )) -- Loop WHILE @ I <= datalength (@ OrigSpText1)/2 BEGIN -- Reverse encryption (XOR original + bogus encrypted) SET @ resultsp = stuff (@ resultsp, @ I, 1, NCHAR (UNICODE (substring (@ OrigSpText1, @ I, 1) ^ (UNICODE (substring (@ OrigSpText2, @ I, 1) ^ UNICODE (substring (@ OrigSpText3, @ I, 1 ))))) SET @ I = @ I + 1 END -- Drop original SP -- EXECUTE ('drop processure '+ @ objectName) -- Remove encryption -- Preserve case SET @ resultsp = REPLACE (@ resultsp), 'with encryption ','') SET @ resultsp = REPLACE (@ resultsp), 'With Encryption ','') SET @ resultsp = REPLACE (@ resultsp), 'with encryption ','') If charindex ('with encryption', UPPER (@ resultsp)> 0 SET @ resultsp = REPLACE (UPPER (@ resultsp), 'WITH encryption ','') -- Replace Stored procedure without enryption Print @ resultsp -- Execute (@ resultsp) Set @ n = @ n + 1 End Drop table # temp Rollback transaction End GO |
Note: replace @ objectName with the name of the stored procedure you want to crack (for example, replace @ www. ***. com ).
In this way, you create a stored procedure called sp_decrypt in your database,
Call sp_decrypt in the query analyzer to decrypt the stored procedure to be cracked. The statement is as follows:
Exec sp_decrypt 'stored procedure name'
Here is an example of a specific statement: exec sp_decrypt 'www. ***. com '(note that the name contains "single quotes ").
After the decryption is completed, copy the SQL script to your server and restore it.