sql存储过程解密:Sql存储过程加密和解密方法来源: 发布时间:星期四, 2009年2月12日 浏览:202次 评论:0
可用于加密SQL存储过程或者触发器 (这是SQLServer本身提供也就是说这是微软加密算法) 使用WITHENCRYPTION选项 WITHENCRYPTION子句对用户隐藏存储过程文本下例创建加密过程使用sp_helptext系统存储过程获取有关加密过程信息然后尝试直接从syscomments表中获取有关该过程信息 IFEXISTS(SelectnameFROMsysobjects Wherename=’encrypt_this’ANDtype=’P’) DropPROCEDUREencrypt_this GO USEpubs GO CreatePROCEDUREencrypt_this WITHENCRYPTION AS Select* FROMauthors GO EXECsp_helptextencrypt_this 下面是结果集: Theobject’scommentshavebeenencrypted. 接下来选择加密存储过程内容标识号和文本 Selectc.id,c.text FROMsyscommentscINNERJOINsysobjectso ONc.id=o.id Whereo.name=’encrypt_this’ 下面是结果集: 介绍说明text列输出显示在单独行中执行时该信息将和id列信息出现在同行中 Idtext ---------------------------------------------------------------------- 1413580074?????????????????????????????????e?????????????????????????????????????????????????????????????????????????? (1row(s)affected) 备注: createprocname withencryption as begin --语句 end CreateTRIGGERtrigger_name ON{table|view} WITHENCRYPTION FORUpdate AS begin --语句 end Sql存储过程解密算法破解微软加密算法 网上同样有很多Sql存储过程解密软件Software但大都是收费 下边是网上流传Sql存储过程解密算法虽非官方但绝对可行! 同样可用于解密SQL存储过程或者触发器 代码 createPROCEDUREsp_decrypt(@objectnamevarchar(50)) AS begin nocounton --CSDN:j9988copyright:2004.07.15 --V3.2 --破解字节不受限制适用于SQLSERVER2000存储过程视图触发器 --修正上版\"视图触发器\"不能正确解密 [Page] --发现有错请E_MAIL:[email protected] begran declare@objectname1varchar(100),@orgvarbinvarbinary(8000) declare@sql1nvarchar(4000),@sql2varchar(8000),@sql3nvarchar(4000),@sql4nvarchar(4000) DECLARE@OrigSpText1nvarchar(4000),@OrigSpText2nvarchar(4000),@OrigSpText3nvarchar(4000),@resultspnvarchar(4000) declare@i,@status,@typevarchar(10),@parentid declare@colid,@n,@q,@j,@k,@encrypted,@number select@type=xtype,@parentid=parent_objfromsysobjectswhereid=object_id(@objectname) createtable#temp(number,colid,ctextvarbinary(8000),encrypted,status) insert#tempSelectnumber,colid,ctext,encrypted,statusFROMsyscommentsWhereid=object_id(@objectname) select@number=max(number)from#temp @k=0 while@k<=@number begin exists(select1fromsyscommentswhereid=object_id(@objectname)andnumber=@k) begin @type=’P’ @sql1=(when@number>1then’AlterPROCEDURE’+@objectname+’;’+rtrim(@k)+’WITHENCRYPTIONAS’ ’AlterPROCEDURE’+@objectname+’WITHENCRYPTIONAS’ end) @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 @tr_parent_xtype=’V’ begin @sql1=’AlterTRIGGER’+@objectname+’ON’+OBJECT_NAME(@parentid)+’WITHENCRYPTIONINSTERDOFInsertASPRINT1’ end begin @sql1=’AlterTRIGGER’+@objectname+’ON’+OBJECT_NAME(@parentid)+’WITHENCRYPTIONFORInsertASPRINT1’ end end @type=’FN’or@type=’TF’or@type=’IF’ @sql1=(@typewhen’TF’then ’AlterFUNCTION’+@objectname+’(@achar(1))s@btable(avarchar(10))withencryptionasbegininsert@bselect@aend’ [Page] when’FN’then ’AlterFUNCTION’+@objectname+’(@achar(1))schar(1)withencryptionasbegin@aend’ when’IF’then ’AlterFUNCTION’+@objectname+’(@achar(1))stablewithencryptionasselect@aasa’ end) @type=’V’ @sql1=’AlterVIEW’+@objectname+’WITHENCRYPTIONASSelect1asf’ @q=len(@sql1) @sql1=@sql1+REPLICATE(’-’,4000-@q) select@sql2=REPLICATE(’-’,8000) @sql3=’exec(@sql1’ select@colid=max(colid)from#tempwherenumber=@k @n=1 while@n<=CEILING(1.0*(@colid-1)/2)andlen(@sql3)<=3996 begin @sql3=@sql3+’+@’ @n=@n+1 end @sql3=@sql3+’)’ execsp_executesql@sql3,N’@sql1nvarchar(4000),@varchar(8000)’,@sql1=@sql1,@=@sql2 end @k=@k+1 end @k=0 while@k<=@number begin exists(select1fromsyscommentswhereid=object_id(@objectname)andnumber=@k) begin select@colid=max(colid)from#tempwherenumber=@k @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) @n=1 begin @type=’P’ SET@OrigSpText2=(when@number>1then’CreatePROCEDURE’+@objectname+’;’+rtrim(@k)+’WITHENCRYPTIONAS’ ’CreatePROCEDURE’+@objectname+’WITHENCRYPTIONAS’ end) @type=’FN’or@type=’TF’or@type=’IF’ SET@OrigSpText2=(@typewhen’TF’then ’CreateFUNCTION’+@objectname+’(@achar(1))s@btable(avarchar(10))withencryptionasbegininsert@bselect@aend’ when’FN’then ’CreateFUNCTION’+@objectname+’(@achar(1))schar(1)withencryptionasbegin@aend’ [Page] when’IF’then ’CreateFUNCTION’+@objectname+’(@achar(1))stablewithencryptionasselect@aasa’ end) @type=’TR’ begin @tr_parent_xtype=’V’ begin @OrigSpText2=’CreateTRIGGER’+@objectname+’ON’+OBJECT_NAME(@parentid)+’WITHENCRYPTIONINSTEADOFInsertASPRINT1’ end begin @OrigSpText2=’CreateTRIGGER’+@objectname+’ON’+OBJECT_NAME(@parentid)+’WITHENCRYPTIONFORInsertASPRINT1’ end end @type=’V’ @OrigSpText2=’CreateVIEW’+@objectname+’WITHENCRYPTIONASSelect1asf’ @q=4000-len(@OrigSpText2) @OrigSpText2=@OrigSpText2+REPLICATE(’-’,@q) end 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(sub(@OrigSpText1,@i,1))^ (UNICODE(sub(@OrigSpText2,@i,1))^ UNICODE(sub(@OrigSpText3,@i,1))))) SET@i=@i+1 END @orgvarbin=cast(@OrigSpText1asvarbinary(8000)) @resultsp=(when@encrypted=1 then@resultsp convert(nvarchar(4000),when@status&2=2thenuncompress(@orgvarbin)@orgvarbinend) end) pr@resultsp @n=@n+1 end end @k=@k+1 end droptable#temp rollbacktran end go 0
相关文章读者评论发表评论 |
|