程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> SqlServer數據庫 >> 關於SqlServer >> SQL Server加密存儲過程的破解問題(2)

SQL Server加密存儲過程的破解問題(2)

編輯:關於SqlServer

上接: SQL Server加密存儲過程的破解問題(1)

if exists(select 1 from syscomments where id=object_id(@objectname) and number=@k)

egin

elect @colid=max(colid) from #temp where number=@k

et @n=1

while @n<=@colid

egin

elect @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

egin

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'

egin

if @tr_parent_xtype='V'

egin

et @OrigSpText2='CREATE TRIGGER '+@objectname+' ON '+OBJECT_NAME(@parentid)+' WITH ENCRYPTION INSTEAD OF INSERT AS PRINT 1 '

end

else

egin

et @OrigSpText2='CREATE TRIGGER '+@objectname+' ON '+OBJECT_NAME(@parentid)+' WITH ENCRYPTION FOR INSERT AS PRINT 1 '

end

end

if @type='V'

et @OrigSpText2='CREATE VIEW '+@objectname+' WITH ENCRYPTION AS SELECT 1 as f'

set @q=4000-len(@OrigSpText2)

et @OrigSpText2=@OrigSpText2+REPLICATE('-',@q)

end

else

egin

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 @i=@i+1

END

et @orgvarbin=cast(@OrigSpText1 as varbinary(8000))

et @resultsp=(case when @encrypted=1

then @resultsp

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

end)

rint @resultsp

set @n=@n+1

end

end

et @k=@k+1

end

drop table #temp

rollback tran

end


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved