Storage process decryption

xiaoxiao2021-03-05  26

Create Procedure USP_Decrypt (@Objectname VARCHAR (50)) with Encryption As Begin Set NoCount on --9CBS: J9988 Copyright: 2004.04.15 --v3.1 - Crack bytes are unrestricted, suitable for SQLServer2000 stored procedures, functions, View, trigger - Correct the previous version of the view trigger does not decrypt the error correctly - Discover a wrong, please e_mail: 9cbsj9988@tom.com Begin Tran Declare @ Objectname1 varchar (100), @ orgvarbin varbinary (8000) Declare @ SQL1 nvarchar (4000), @ sql2 varchar (8000), @ sql3 nvarchar (4000), @ sql4 nvarchar (4000) DECLARE @ OrigSpText1 nvarchar (4000), @ OrigSpText2 nvarchar (4000), @ OrigSpText3 nvarchar (4000), @resultsp nvarchar (4000) Declare @i int, @ status int, @ Type var, @parecture int declare @colid int, @ n int, @ @ @ @ j int, @ K int, @ encrypted int, @ Number Int select @ type = xtype, @ parentid = parent_obj from sysobjects where id = object_id (@ObjectName) create table #temp (number int, colid int, ctext varbinary (8000), encrypted int, status int) insert #temp SELECT number, colid , ctext, encrypted, status from syscomments where id = object_id (@Objectname) select @ number = max (number) from #temp set @ k = 0 while @K <= @ Number Begi n if exists (select 1 from syscomments where id = object_id (@objectname) and number = @ k) begin if @ type = 'P' set @ sql1 = (case when @number> 1 then 'ALTER PROCEDURE' @objectName ';' rtrim (@k) 'WITH ENCRYPTION AS' else 'ALTER PROCEDURE' @ objectName 'WITH ENCRYPTION AS' end) if @ type = 'TR' begin declare @parent_obj varchar (255), @ tr_parent_xtype varchar ( 10) SELECT @ parent_obj =

parent_obj from sysobjects where id = object_id (@objectName) select @ tr_parent_xtype = xtype from sysobjects where id = @ parent_obj if @ tr_parent_xtype = 'V' begin set @ sql1 = 'ALTER TRIGGER' @ objectname 'ON' OBJECT_NAME (@parentid ) 'WITH ENCRYPTION INSTERD OF INSERT AS PRINT 1' end else begin set @ sql1 = 'ALTER TRIGGER' @ objectname 'ON' OBJECT_NAME (@parentid) 'WITH ENCRYPTION FOR INSERT AS PRINT 1' end end if @type = 'Fn' or @ type = 'tf' or @ Type = 'IF' set @ SQL1 = (Case @Type when 'TF' TEN 'ALTER FUNCTION' @Objectname '(@ a char (1)) Returns @B Table (a varchar (10)) with encryption as begin insert @B select @a return end 'when' fn 'TEN' ALTER FUNCTION ' @Objectname ' (@ a char (1)) Returns char (1) with encryption as Begin Return @a end 'when' ip 'TEN' ALTER FUNCTION ' @objectname ' (@ a char (1)) Returns Table with Encryption As Return SELECT @a as a 'end) f @ type =' v 'set @ SQL1 = 'Alter View' @ Objectname 'with Encryption As SELECT 1 AS F' Set @ q = len (@ SQL1) Set @ SQL1 = @ SQL1 Replicate ('-', 4000 - @ q) Select @ SQL2 = Replicate ('-', 8000) set @ SQL3 = 'Exec (@ SQL1' SELECT @ Colid = Max (Colid) from #temp where number = @n <= ceiling (= CEILING) 1.0 * (@ colid-1) / 2) And len (@ SQL3) <= 3996 begin set @ SQL3 = @ SQL3 '

@ 'set @ n = @ n 1 end set @ SQL3 = @ SQL3 ') 'EXEC SP_EXECUTESQL @ SQL3, N' @ SQL1 NVARCHAR (4000), @ sql1 = @ SQL1, @ = @ SQL2 End Set @ K = @ K 1 End Set @ K = 0 while @K <= @ Number Begin if EXISTS (SELECT 1 from syscomments where id = Object_id (@Objectname) and number = @ K) Begin Select @colid = max (colid) from #temp where number = @ k set @ n = 1 while @n <= @ colid begin select @ OrigSpText1 = ctext, @ encrypted = encrypted, @ status = status fROM #temp WHERE colid = @ n and number = @ k SET @ OrigSpText3 = (SELECT ctext FROM syscomments WHERE id = object_id (@objectName) and colid = @ n and number = @ k) if @ n = 1 begin if @ type = 'P' SET @ OrigSpText2 = ( case when @number> 1 then 'CREATE PROCEDURE' @objectName ';' rtrim (@k) 'WITH ENCRYPTION AS' else 'CREATE PROCEDURE' @objectName 'WITH ENCRYPTION AS' end) if @ type = 'Fn' or @ type = 'tf' or @ type = 'IF' set @ igsptext2 = (case @Type when 'Tf' Then 'crete function' @objectname '(@ a char (1)) Returns @B TABLE (a varchar (10)) with encryption as begin insert @B select @a return end 'WHEN' FN ' THEN 'CREATE FUNCTION' @Objectname '(@ a char (1)) Returns Char (1) with Encryption a s Begin Return @a end' when 'ing' TEN 'CREATE FUNCTION' @Objectname '(@

转载请注明原文地址:https://www.9cbs.com/read-35724.html

New Post(0)