国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 數(shù)據(jù)庫(kù) > SQL Server > 正文

SQL Server存儲(chǔ)函數(shù)的加密解密

2024-08-31 00:49:18
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

存儲(chǔ)過(guò)程、存儲(chǔ)函數(shù)的加密:with encryption

  <!--[if !supportlinebreaknewline]-->

  <!--[endif]-->

  create procedure dbo.sp_xml_main

  @table_name nvarchar(260)='',

  @dirname nvarchar(20)=''

  with encryption

  as

  begin

  ....................................................

  end

  go

  存儲(chǔ)過(guò)程、存儲(chǔ)函數(shù)的解密(以下是一位絕世高人編寫(xiě)的代碼)

  if exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[sp_decrypt]') and objectproperty(id, n'isprocedure') = 1)

  drop procedure [dbo].[sp_decrypt]

  go

  /*--破解函數(shù),過(guò)程,觸發(fā)器,視圖.僅限于sqlserver2000

  --作者:j9988--*/

  /*--調(diào)用示例

  --解密指定存儲(chǔ)過(guò)程

  exec sp_decrypt 'appsp_test'

  --對(duì)所有的存儲(chǔ)過(guò)程解密

  declare tb cursor for

  select name from sysobjects where xtype='p' and status>0 and name<>'sp_decrypt'

  declare @name sysname

  open tb

  fetch next from tb into @name

  while @@fetch_status=0

  begin

  print '/*-------存儲(chǔ)過(guò)程 ['[email protected]+'] -----------*/'

  exec sp_decrypt @name

  fetch next from tb into @name

  end

  close tb

  deallocate tb

  --*/

  if exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[sp_decrypt]') and objectproperty(id, n'isprocedure') = 1)

  drop procedure [dbo].[sp_decrypt]

  go

  create procedure sp_decrypt(@objectname varchar(50))

  as

  begin

  set nocount on

  --csdn:j9988 copyright:2004.04.15

  --v3.1

  --破解字節(jié)不受限制,適用于sqlserver2000存儲(chǔ)過(guò)程,函數(shù),視圖,觸發(fā)器

  --修正上一版視圖觸發(fā)器不能正確解密錯(cuò)誤

  --發(fā)現(xiàn)有錯(cuò),請(qǐng)e_mail:[email protected]

  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 varchar(10),@parentid int

  declare @colid int,@n int,@q 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<[email protected]

  begin

  if exists(select 1 from syscomments where id=object_id(@objectname) and [email protected])

  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 [email protected]_obj

  if @tr_parent_xtype='v'

  begin

  set @sql1='alter trigger '[email protected]+' on '+object_name(@parentid)+' with encryption insterd of insert as print 1 '

  end

  else

  begin

  set @sql1='alter trigger '[email protected]+' 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' then

  'alter function '+ @objectname+'(@a char(1)) returns @b table(a varchar(10)) with encryption as begin insert @b select @a return end '

 

  when 'fn' then

  'alter function '+ @objectname+'(@a char(1)) returns char(1) with encryption as begin return @a end'

  when 'if' then

  'alter function '+ @objectname+'(@a char(1)) returns table with encryption as return select @a as a'

  end)

  if @type='v'

  set @sql1='alter view '[email protected]+' with encryption as select 1 as f'

  set @q=len(@sql1)

  set @[email protected]+replicate('-',[email protected])

select @sql2=replicate('-',8000)

  set @sql3='exec(@sql1'

  select @colid=max(colid) from #temp where [email protected]

  set @n=1

  while @n<=ceiling(1.0*(@colid-1)/2) and len(@sql3)<=3996

  begin

  set @[email protected]+'[email protected]'

  set @[email protected]+1

  end

  set @[email protected]+')'

  exec sp_executesql @sql3,n'@sql1 nvarchar(4000),@ varchar(8000)',@[email protected],@[email protected]

  end

  set @[email protected]+1

  end

  set @k=0

  while @k<[email protected]

  begin

  if exists(select 1 from syscomments where id=object_id(@objectname) and [email protected])

  begin

  select @colid=max(colid) from #temp where [email protected]

  set @n=1

  while @n<[email protected]

  begin

  select @origsptext1=ctext,@encrypted=encrypted,@status=status from #temp where [email protected] and [email protected]

  set @origsptext3=(select ctext from syscomments where id=object_id(@objectname) and [email protected] and [email protected])

  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 @origsptext2=(case @type when 'tf' then

  'create 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 as begin return @a end'

  when 'if' then

  'create function '+ @objectname+'(@a char(1)) returns table with encryption as return select @a as a'

  end)

  if @type='tr'

  begin

  if @tr_parent_xtype='v'

  begin

  set @origsptext2='create trigger '[email protected]+' on '+object_name(@parentid)+' with encryption instead of insert as print 1 '

  end

  else

  begin

  set @origsptext2='create trigger '[email protected]+' on '+object_name(@parentid)+' with encryption for insert as print 1 '

  end

  end

  if @type='v'

  set @origsptext2='create view '[email protected]+' with encryption as select 1 as f'

  set @q=4000-len(@origsptext2)

  set @[email protected]+replicate('-',@q)

  end

  else

  begin

  set @origsptext2=replicate('-', 4000)

  end

  set @i=1

  set @resultsp = replicate(n'a', (datalength(@origsptext1) / 2))

  while @i<=datalength(@origsptext1)/2

  begin

  set @resultsp = stuff(@resultsp, @i, 1, nchar(unicode(substring(@origsptext1, @i, 1)) ^

  (unicode(substring(@origsptext2, @i, 1)) ^

  unicode(substring(@origsptext3, @i, 1)))))

  set @[email protected]+1

  end

  set @orgvarbin=cast(@origsptext1 as varbinary(8000))

  set @resultsp=(case when @encrypted=1

  then @resultsp

  else convert(nvarchar(4000),case when @status&2=2 then uncompress(@orgvarbin) else @orgvarbin end)

  end)

  print @resultsp

  set @[email protected]+1

  end

  end

  set @[email protected]+1

  end

  drop table #temp

  rollback tran

  end

 



發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 武胜县| 新泰市| 军事| 桃江县| 洱源县| 水富县| 灵山县| 渑池县| 密云县| 吉木乃县| 杨浦区| 唐河县| 宜春市| 双柏县| 包头市| 什邡市| 赤城县| 黎平县| 山丹县| 鹤壁市| 枣强县| 岳阳县| 巴彦淖尔市| 新丰县| 达孜县| 上饶市| 花莲市| 阿拉善右旗| 巴林右旗| 巴东县| 申扎县| 余庆县| 石景山区| 泌阳县| 广丰县| 闽清县| 庄河市| 获嘉县| 灵武市| 孟州市| 岑溪市|