查看: 12217|回复: 8

SQL Server 2000下如何查看已加密的存储过程?

[复制链接]
论坛徽章:
40
奥运会纪念徽章:柔道
日期:2008-05-09 15:54:34保时捷
日期:2013-10-30 15:22:28日产
日期:2013-11-07 15:56:26奔驰
日期:2013-11-07 16:18:18三菱
日期:2013-12-03 14:23:08奔驰
日期:2014-01-07 16:30:15雪佛兰
日期:2014-01-16 13:00:54问答徽章
日期:2014-01-24 14:14:042014年新春福章
日期:2014-02-18 16:41:11马上有车
日期:2014-02-18 16:41:11
跳转到指定楼层
1#
发表于 2004-5-12 23:51 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
SQL Server 2000下如何查看已加密的存储过程呢?
如果在创建了存储过程中运用了 with encryption 这一项,现在想恢复不加密的状态或者查看已加密的存储过程,有什么办法吗?谢谢大家了。
论坛徽章:
28
授权会员
日期:2005-10-30 17:05:332011新春纪念徽章
日期:2011-01-25 15:42:332011新春纪念徽章
日期:2011-01-25 15:42:56管理团队成员
日期:2011-05-07 01:45:082012新春纪念徽章
日期:2012-02-13 15:11:362012新春纪念徽章
日期:2012-02-13 15:11:362012新春纪念徽章
日期:2012-02-13 15:11:362012新春纪念徽章
日期:2012-02-13 15:11:362012新春纪念徽章
日期:2012-02-13 15:11:36马上有车
日期:2014-02-19 11:55:14
2#
发表于 2004-5-13 08:05 | 只看该作者
--解密存储过程
CREATE  PROCEDURE sp_decrypt(@objectName varchar(50))
AS
begin
set nocount on
--CSDN:j9988 copyright:2004.04.15
--V3.1
--破解字节不受限制,适用于SQLSERVER2000存储过程,函数,视图,触发器
--修正上一版视图触发器不能正确解密错误
--发现有错,请E_MAIL:CSDNj9988@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 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<=@number
begin
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' 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 '+@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=@k
set @n=1
while @n<=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),@ varchar(8000)',@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 @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 '+@objectname+' ON '+OBJECT_NAME(@parentid)+' WITH ENCRYPTION INSTEAD OF INSERT AS PRINT 1 '
end
else
begin
set @OrigSpText2='CREATE TRIGGER '+@objectname+' ON '+OBJECT_NAME(@parentid)+' WITH ENCRYPTION FOR INSERT AS PRINT 1 '
end

end

if @type='V'
set @OrigSpText2='CREATE VIEW '+@objectname+' WITH ENCRYPTION AS SELECT 1 as f'

set @q=4000-len(@OrigSpText2)
set @OrigSpText2=@OrigSpText2+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 @i=@i+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 @n=@n+1

end

end
set @k=@k+1
end

drop table #temp
rollback tran
end

使用道具 举报

回复
论坛徽章:
40
奥运会纪念徽章:柔道
日期:2008-05-09 15:54:34保时捷
日期:2013-10-30 15:22:28日产
日期:2013-11-07 15:56:26奔驰
日期:2013-11-07 16:18:18三菱
日期:2013-12-03 14:23:08奔驰
日期:2014-01-07 16:30:15雪佛兰
日期:2014-01-16 13:00:54问答徽章
日期:2014-01-24 14:14:042014年新春福章
日期:2014-02-18 16:41:11马上有车
日期:2014-02-18 16:41:11
3#
 楼主| 发表于 2004-5-14 15:22 | 只看该作者
谢谢楼上的兄弟。觉得这种方法比较繁,不知道微软有没有方法可以去除加密功能的

使用道具 举报

回复
论坛徽章:
0
4#
发表于 2007-8-31 10:59 | 只看该作者
多谢陈永仁楼主,你给的该解密过程,是我用到的最好的解密程序,多谢了。
应该说,该解密程序可解密7.0, 2005等,因为可将7.0,2005的数据库备份后恢复到2000下,其加密的存储过程内容不变(我试过)。
我想给你加分,但我不知如何加

使用道具 举报

回复
论坛徽章:
53
IT宝贝
日期:2010-11-09 10:49:442013年新春福章
日期:2013-04-11 16:50:352013年新春福章
日期:2013-04-11 16:50:352013年新春福章
日期:2013-04-11 16:50:352013年新春福章
日期:2013-04-11 16:50:352013年新春福章
日期:2013-04-11 16:50:352013年新春福章
日期:2013-04-11 16:50:352013年新春福章
日期:2013-04-11 16:50:352013年新春福章
日期:2013-04-11 16:50:352013年新春福章
日期:2013-04-11 16:50:35
5#
发表于 2007-8-31 14:08 | 只看该作者
不错 学习了..

使用道具 举报

回复
论坛徽章:
5
授权会员
日期:2007-09-04 12:51:04ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44开发板块每日发贴之星
日期:2007-12-07 01:05:35生肖徽章2007版:鸡
日期:2008-01-02 17:35:532008新春纪念徽章
日期:2008-02-13 12:43:03
6#
发表于 2007-8-31 21:26 | 只看该作者
很不错,谢谢.

使用道具 举报

回复
论坛徽章:
19
授权会员
日期:2007-08-25 20:02:41会员2007贡献徽章
日期:2007-09-26 18:42:10BLOG每日发帖之星
日期:2008-11-13 01:01:05
7#
发表于 2007-8-31 23:36 | 只看该作者
先收藏了,以后研究。

使用道具 举报

回复
论坛徽章:
273
生肖徽章2007版:猪
日期:2008-09-27 09:35:45明尼苏达森林狼
日期:2009-01-12 14:15:09生肖徽章2007版:猪
日期:2009-01-21 16:30:59布鲁克林篮网
日期:2009-03-03 14:42:32圣安东尼奥马刺
日期:2009-03-03 14:44:41生肖徽章2007版:鸡
日期:2009-03-03 21:45:52生肖徽章2007版:牛
日期:2009-03-09 14:03:42生肖徽章2007版:猪
日期:2009-03-10 21:37:00生肖徽章2007版:羊
日期:2009-03-16 10:17:11生肖徽章2007版:虎
日期:2009-03-24 21:26:52
8#
发表于 2007-9-1 08:01 | 只看该作者
学习一下下

使用道具 举报

回复
论坛徽章:
7
紫蛋头
日期:2012-12-18 17:17:41复活蛋
日期:2013-03-06 17:02:31奥运纪念徽章
日期:2013-07-18 13:55:12ITPUB社区12周年站庆徽章
日期:2013-10-08 15:00:34灰彻蛋
日期:2019-02-25 15:28:37复活蛋
日期:2019-02-25 15:29:12弗兰奇
日期:2019-03-30 10:02:45
9#
发表于 2013-1-17 16:04 | 只看该作者
学习学习

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表