前事不忘,后事之师,不忘国耻!

 立即注册  找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1631|回复: 0

[转帖]SQLSERVER2000存储过程解密

[复制链接]

[转帖]SQLSERVER2000存储过程解密

[复制链接]
ehxz

主题

0

回帖

3万

积分

管理员

积分
37090
2004-4-30 23:04:51 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
<p>CREATE&nbsp;&nbspROCEDURE sp_decrypt(@objectName varchar(50))<br/>AS<br/>begin<br/>set nocount on<br/>--CSDN:j9988 copyright:2004.04.15 <br/>--V3.1 <br/>--破解字节不受限制,适用于SQLSERVER2000存储过程,函数,视图,触发器<br/>--修正上一版视图触发器不能正确解密错误<br/>--发现有错,请E_MAIL:CSDNj9988@tom.com<br/>begin tran<br/>declare @objectname1 varchar(100),@orgvarbin varbinary(8000)<br/>declare @sql1 nvarchar(4000),@sql2 varchar(8000),@sql3 nvarchar(4000),@sql4 nvarchar(4000)<br/>DECLARE&nbsp;&nbsp;@OrigSpText1 nvarchar(4000),&nbsp;&nbsp;@OrigSpText2 nvarchar(4000) , @OrigSpText3 nvarchar(4000), @resultsp nvarchar(4000)<br/>declare&nbsp;&nbsp;@i int,@status int,@type varchar(10),@parentid int<br/>declare @colid int,@n int,@q int,@j int,@k int,@encrypted int,@number int<br/>select @type=xtype,@parentid=parent_obj from sysobjects where id=object_id(@ObjectName)</p><p>create table&nbsp;&nbsp;#temp(number int,colid int,ctext varbinary(8000),encrypted int,status int)<br/>insert #temp SELECT number,colid,ctext,encrypted,status FROM syscomments&nbsp;&nbsp;WHERE id = object_id(@objectName)<br/>select @number=max(number) from #temp<br/>set @k=0</p><p>while @k&lt;=@number <br/>begin<br/>if exists(select 1 from syscomments where id=object_id(@objectname) and number=@k)<br/>begin<br/>if @type='P'<br/>set @sql1=(case when @number&gt;1 then 'ALTER PROCEDURE '+ @objectName +';'+rtrim(@k)+' WITH ENCRYPTION AS '<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else 'ALTER PROCEDURE '+ @objectName+' WITH ENCRYPTION AS '<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end)</p><p>if @type='TR'<br/>begin<br/>declare @parent_obj varchar(255),@tr_parent_xtype varchar(10)<br/>select @parent_obj=parent_obj from sysobjects where id=object_id(@objectName)<br/>select @tr_parent_xtype=xtype from sysobjects where id=@parent_obj<br/>if @tr_parent_xtype='V'<br/>begin<br/>set @sql1='ALTER TRIGGER '+@objectname+' ON '+OBJECT_NAME(@parentid)+' WITH ENCRYPTION INSTERD OF INSERT AS PRINT 1 '<br/>end<br/>else<br/>begin<br/>set @sql1='ALTER TRIGGER '+@objectname+' ON '+OBJECT_NAME(@parentid)+' WITH ENCRYPTION FOR INSERT AS PRINT 1 '<br/>end</p><p>end<br/>if @type='FN' or @type='TF' or @type='IF'<br/>set @sql1=(case @type when 'TF' then <br/>'ALTER FUNCTION '+ @objectName+'(@a char(1)) returns @b table(a varchar(10)) with encryption as begin insert @b select @a return end '<br/>when 'FN' then<br/>'ALTER FUNCTION '+ @objectName+'(@a char(1)) returns char(1) with encryption as begin return @a end'<br/>when 'IF' then<br/>'ALTER FUNCTION '+ @objectName+'(@a char(1)) returns table with encryption as return select @a as a'<br/>end)</p><p>if @type='V'<br/>set @sql1='ALTER VIEW '+@objectname+' WITH ENCRYPTION AS SELECT 1 as f'</p><p>set @q=len(@sql1)<br/>set @sql1=@sql1+REPLICATE('-',4000-@q)<br/>select @sql2=REPLICATE('-',8000)<br/>set @sql3='exec(@sql1'<br/>select @colid=max(colid) from #temp where number=@k <br/>set @n=1<br/>while @n&lt;=CEILING(1.0*(@colid-1)/2) and len(@sQL3)&lt;=3996<br/>begin <br/>set @sql3=@sql3+'+@'<br/>set @n=@n+1<br/>end<br/>set @sql3=@sql3+')'<br/>exec sp_executesql @sql3,N'@Sql1 nvarchar(4000),@ varchar(8000)',@sql1=@sql1,@=@sql2</p><p>end<br/>set @k=@k+1<br/>end</p><p>set @k=0<br/>while @k&lt;=@number <br/>begin</p><p>if exists(select 1 from syscomments where id=object_id(@objectname) and number=@k)<br/>begin<br/>select @colid=max(colid) from #temp where number=@k <br/>set @n=1</p><p>while @n&lt;=@colid<br/>begin<br/>select @OrigSpText1=ctext,@encrypted=encrypted,@status=status FROM #temp&nbsp;&nbsp;WHERE colid=@n and number=@k</p><p>SET @OrigSpText3=(SELECT ctext FROM syscomments WHERE id=object_id(@objectName) and colid=@n and number=@k)<br/>if @n=1<br/>begin<br/>if @type='P'<br/>SET @OrigSpText2=(case when @number&gt;1 then 'CREATE PROCEDURE '+ @objectName +';'+rtrim(@k)+' WITH ENCRYPTION AS '<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else 'CREATE PROCEDURE '+ @objectName +' WITH ENCRYPTION AS '<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end)</p><p><br/>if @type='FN' or @type='TF' or @type='IF'<br/>SET @OrigSpText2=(case @type when 'TF' then <br/>'CREATE FUNCTION '+ @objectName+'(@a char(1)) returns @b table(a varchar(10)) with encryption as begin insert @b select @a return end '<br/>when 'FN' then<br/>'CREATE FUNCTION '+ @objectName+'(@a char(1)) returns char(1) with encryption as begin return @a end'<br/>when 'IF' then<br/>'CREATE FUNCTION '+ @objectName+'(@a char(1)) returns table with encryption as return select @a as a'<br/>end)</p><p>if @type='TR' <br/>begin</p><p>if @tr_parent_xtype='V'<br/>begin<br/>set @OrigSpText2='CREATE TRIGGER '+@objectname+' ON '+OBJECT_NAME(@parentid)+' WITH ENCRYPTION INSTEAD OF INSERT AS PRINT 1 '<br/>end<br/>else<br/>begin<br/>set @OrigSpText2='CREATE TRIGGER '+@objectname+' ON '+OBJECT_NAME(@parentid)+' WITH ENCRYPTION FOR INSERT AS PRINT 1 '<br/>end</p><p>end</p><p>if @type='V'<br/>set @OrigSpText2='CREATE VIEW '+@objectname+' WITH ENCRYPTION AS SELECT 1 as f'</p><p>set @q=4000-len(@OrigSpText2)<br/>set @OrigSpText2=@OrigSpText2+REPLICATE('-',@q)<br/>end<br/>else<br/>begin<br/>SET @OrigSpText2=REPLICATE('-', 4000)<br/>end<br/>SET @i=1</p><p>SET @resultsp = replicate(N'A', (datalength(@OrigSpText1) / 2))</p><p>WHILE @i&lt;=datalength(@OrigSpText1)/2<br/>BEGIN</p><p>SET @resultsp = stuff(@resultsp, @i, 1, NCHAR(UNICODE(substring(@OrigSpText1, @i, 1)) ^<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(UNICODE(substring(@OrigSpText2, @i, 1)) ^<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UNICODE(substring(@OrigSpText3, @i, 1)))))<br/>SET @i=@i+1<br/>END<br/>set @orgvarbin=cast(@OrigSpText1 as varbinary(8000))<br/>set @resultsp=(case when @encrypted=1 <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;then @resultsp <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else convert(nvarchar(4000),case when @status&amp;2=2 then uncompress(@orgvarbin) else @orgvarbin end)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end)<br/>print @resultsp</p><p>set @n=@n+1</p><p>end</p><p>end<br/>set @k=@k+1<br/>end</p><p>drop table #temp<br/>rollback tran<br/>end</p>
[此贴子已经被作者于2007-7-11 16:17:03编辑过]

免责申明1、欢迎访问本站,本文内容及相关资源来源于网络,版权归版权方所有!本站原创内容版权归本站所有,请勿转载!
2、本文内容仅代表作者观点,不代表本站立场,作者自负,本站资源仅供学习研究,请勿非法使用,否则后果自负!请下载后24小时内删除!
3、本文内容,包括但不限于源码、文字、图片等,仅供参考。本站不对其安全性,正确性等作出保证。但本站会尽量审核会员发表的内容。
4、如本帖侵犯到任何版权问题,请立即告知本站 ,本站将及时删除并致以最深的歉意!客服邮箱:admin@fmlist.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|小黑屋|爱谁谁社区 ( 鲁ICP备14013101号-3 )

GMT+8, 2024-12-4 01:00 , Processed in 0.040034 second(s), 9 queries , MemCached On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表