|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
先说DDL的分类。有一类DDL,是不需要重建表的,比如加非聚簇索引。这类操作其实不会丢数据,也是在原表上直接操作,对于我们“以恢复数据为目的”的闪回,是可以先忽略的。另外一类,则是会影响到表数据的操作。server|sqlserver|存储历程|函数|加密|解密存储历程、存储函数的加密:WITHENCRYPTION
<!--[if!supportLineBreakNewLine]-->
<!--[endif]-->
CREATEproceduredbo.sp_XML_main
@table_namenvarchar(260)=’’,
@dirnamenvarchar(20)=’’
WITHENCRYPTION
as
begin
....................................................
end
go
存储历程、存储函数的解密(以下是一名尽世高人编写的代码)
ifexists(select*fromdbo.sysobjectswhereid=object_id(N’[dbo].[sp_decrypt]’)andOBJECTPROPERTY(id,N’IsProcedure’)=1)
dropprocedure[dbo].[sp_decrypt]
GO
/*--破解函数,历程,触发器,视图.仅限于SQLSERVER2000
--作者:J9988--*/
/*--挪用示例
--解密指定存储历程
execsp_decrypt’AppSP_test’
--对一切的存储历程解密
declaretbcursorfor
selectnamefromsysobjectswherextype=’P’andstatus>0andname’sp_decrypt’
declare@namesysname
opentb
fetchnextfromtbinto@name
while@@fetch_status=0
begin
print’/*-------存储历程[’+@name+’]-----------*/’
execsp_decrypt@name
fetchnextfromtbinto@name
end
closetb
deallocatetb
--*/
ifexists(select*fromdbo.sysobjectswhereid=object_id(N’[dbo].[SP_DECRYPT]’)andOBJECTPROPERTY(id,N’IsProcedure’)=1)
dropprocedure[dbo].[SP_DECRYPT]
GO
CREATEPROCEDUREsp_decrypt(@objectNamevarchar(50))
AS
begin
setnocounton
--CSDN:j9988copyright:2004.04.15
--V3.1
--破解字节不受限定,合用于SQLSERVER2000存储历程,函数,视图,触发器
--修改上一版视图触发器不克不及准确解密毛病
--发明有错,请E_MAIL:CSDNj9988@tom.com
begintran
declare@objectname1varchar(100),@orgvarbinvarbinary(8000)
declare@sql1nvarchar(4000),@sql2varchar(8000),@sql3nvarchar(4000),@sql4nvarchar(4000)
DECLARE@OrigSpText1nvarchar(4000),@OrigSpText2nvarchar(4000),@OrigSpText3nvarchar(4000),@resultspnvarchar(4000)
declare@iint,@statusint,@typevarchar(10),@parentidint
declare@colidint,@nint,@qint,@jint,@kint,@encryptedint,@numberint
select@type=xtype,@parentid=parent_objfromsysobjectswhereid=object_id(@ObjectName)
createtable#temp(numberint,colidint,ctextvarbinary(8000),encryptedint,statusint)
insert#tempSELECTnumber,colid,ctext,encrypted,statusFROMsyscommentsWHEREid=object_id(@objectName)
select@number=max(number)from#temp
set@k=0
while@k<=@number
begin
ifexists(select1fromsyscommentswhereid=object_id(@objectname)andnumber=@k)
begin
if@type=’P’
set@sql1=(casewhen@number>1then’ALTERPROCEDURE’+@objectName+’;’+rtrim(@k)+’WITHENCRYPTIONAS’
else’ALTERPROCEDURE’+@objectName+’WITHENCRYPTIONAS’
end)
if@type=’TR’
begin
declare@parent_objvarchar(255),@tr_parent_xtypevarchar(10)
select@parent_obj=parent_objfromsysobjectswhereid=object_id(@objectName)
select@tr_parent_xtype=xtypefromsysobjectswhereid=@parent_obj
if@tr_parent_xtype=’V’
begin
set@sql1=’ALTERTRIGGER’+@objectname+’ON’+OBJECT_NAME(@parentid)+’WITHENCRYPTIONINSTERDOFINSERTASPRINT1’
end
else
begin
set@sql1=’ALTERTRIGGER’+@objectname+’ON’+OBJECT_NAME(@parentid)+’WITHENCRYPTIONFORINSERTASPRINT1’
end
end
if@type=’FN’or@type=’TF’or@type=’IF’
set@sql1=(case@typewhen’TF’then
’ALTERFUNCTION’+@objectName+’(@achar(1))returns@btable(avarchar(10))withencryptionasbegininsert@bselect@areturnend’
when’FN’then
’ALTERFUNCTION’+@objectName+’(@achar(1))returnschar(1)withencryptionasbeginreturn@aend’
when’IF’then
’ALTERFUNCTION’+@objectName+’(@achar(1))returnstablewithencryptionasreturnselect@aasa’
end)
if@type=’V’
set@sql1=’ALTERVIEW’+@objectname+’WITHENCRYPTIONASSELECT1asf’
set@q=len(@sql1)
set@sql1=@sql1+REPLICATE(’-’,4000-@q)
select@sql2=REPLICATE(’-’,8000)
set@sql3=’exec(@sql1’
select@colid=max(colid)from#tempwherenumber=@k
set@n=1
while@n<=CEILING(1.0*(@colid-1)/2)andlen(@sQL3)<=3996
begin
set@sql3=@sql3+’+@’
set@n=@n+1
end
set@sql3=@sql3+’)’
execsp_executesql@sql3,N’@sql1nvarchar(4000),@varchar(8000)’,@sql1=@sql1,@=@sql2
end
set@k=@k+1
end
set@k=0
while@k<=@number
begin
ifexists(select1fromsyscommentswhereid=object_id(@objectname)andnumber=@k)
begin
select@colid=max(colid)from#tempwherenumber=@k
set@n=1
while@n<=@colid
begin
select@OrigSpText1=ctext,@encrypted=encrypted,@status=statusFROM#tempWHEREcolid=@nandnumber=@k
SET@OrigSpText3=(SELECTctextFROMsyscommentsWHEREid=object_id(@objectName)andcolid=@nandnumber=@k)
if@n=1
begin
if@type=’P’
SET@OrigSpText2=(casewhen@number>1then’CREATEPROCEDURE’+@objectName+’;’+rtrim(@k)+’WITHENCRYPTIONAS’
else’CREATEPROCEDURE’+@objectName+’WITHENCRYPTIONAS’
end)
if@type=’FN’or@type=’TF’or@type=’IF’
SET@OrigSpText2=(case@typewhen’TF’then
’CREATEFUNCTION’+@objectName+’(@achar(1))returns@btable(avarchar(10))withencryptionasbegininsert@bselect@areturnend’
when’FN’then
’CREATEFUNCTION’+@objectName+’(@achar(1))returnschar(1)withencryptionasbeginreturn@aend’
when’IF’then
’CREATEFUNCTION’+@objectName+’(@achar(1))returnstablewithencryptionasreturnselect@aasa’
end)
if@type=’TR’
begin
if@tr_parent_xtype=’V’
begin
set@OrigSpText2=’CREATETRIGGER’+@objectname+’ON’+OBJECT_NAME(@parentid)+’WITHENCRYPTIONINSTEADOFINSERTASPRINT1’
end
else
begin
set@OrigSpText2=’CREATETRIGGER’+@objectname+’ON’+OBJECT_NAME(@parentid)+’WITHENCRYPTIONFORINSERTASPRINT1’
end
end
if@type=’V’
set@OrigSpText2=’CREATEVIEW’+@objectname+’WITHENCRYPTIONASSELECT1asf’
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(@OrigSpText1asvarbinary(8000))
set@resultsp=(casewhen@encrypted=1
then@resultsp
elseconvert(nvarchar(4000),casewhen@status&2=2thenuncompress(@orgvarbin)else@orgvarbinend)
end)
print@resultsp
set@n=@n+1
end
end
set@k=@k+1
end
droptable#temp
rollbacktran
end
为多种编程语言提供了API。这些编程语言包括C、C++、Python、Java、Perl、PHP、Eiffel、Ruby和Tcl等。 |
|