/************* 解密儲存過程 **********
------------------------sql2000大於40000的------
*/alter procedure sp_decrypt (@objectname varchar(50))
asbegin
begin transaction --add by playyuer
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), @resultsp nvarchar(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)
vset @sql1='alter procedure '+ @objectname +' with encryption as '
--set @sql1='alter procedure '+ @objectname +' with encryption as '
set @q=len(@sql1)
set @sql1=@sql1+replicate('-',4000-@q)
select @sql2=replicate('-',4000),@sql3=replicate('-',4000),@sql4=replicatev('-',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 vencryption as '--
set @q=4000-len(@origsptext2)
set @origsptext2=@origsptext2+replicate('-',@q)
endelse
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+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 procedure '+ @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
enddrop table #temp
endrollback transaction --add by playyuer
go/*
適合40000字元。
每次4000 print出來,自已貼。
切記:我見過的解過程都是對原過程進行破壞。破解前一定要備份!!!!
超過40000的,自已加sql(我上面用sql.sql2--sql10)
超長的可加sql11--sql20........*/
SQLserver儲存過程加密 解密
sqlserver儲存過程加密 解密 加密儲存過程 判斷表是否存在,如果存在就刪除 if object id n dbo.test n u is not null drop table dbo.pwdtable go 建立表 varbinary是乙個可以改變長度的二進位制資料。default 如果某...
sql資料庫函式,儲存過程的加密解密
use fms 建立加密函式 fn x ifobject id fn x is not null drop function fn x 首先判斷函式是否為空,不為空刪除 gocreate function fn x x nchar 1 returns nchar 1 asbegin return n...
Linux下的加密儲存
手頭有個專利涉及linux系統下的加密儲存。提交前先得了解一下背景,所以就用了大半天看了相關的知識。linux下的加密儲存方式主要用兩種 ecryptfs和dm crypt。ecryptfs是一種檔案系統,其特殊之處在它堆疊於其它檔案系統之上,對檔案做加密處理。加密所用的元資料儲存在加密後的檔案的頭...