Decryptencryptedstoredprocedures
来源:互联网 发布:linux system 头文件 编辑:程序博客网 时间:2024/06/03 19:26
http://searchdatabase.techtarget.com/tip/1,289483,sid13_gci837799,00.html
ThisSPwilldecryptStoredProcedures,ViewsorTriggersthatwereencryptedusing"withencryption".ItisadaptedfromascriptbyJosephGamaandShoeBoy.Therearetwoversions:oneforSP'sonlyandtheotheroneforSP's,triggersandviews.Forversion1,theinputisobjectname(storedprocedure,viewortrigger),andforversion2,theinputisobjectname(storedprocedure,viewortrigger),objecttype('T'-trigger,'P'-storedprocedureor'V'-view).FromPlanetSourceCode.com.
createPROCEDUREsp_decrypt_sp(@objectNamevarchar(50))ASDECLARE@OrigSpText1nvarchar(4000),@OrigSpText2nvarchar(4000),@OrigSpText3nvarchar(4000),@resultspnvarchar(4000)declare@iint,@tbigint--getencrypteddataSET@OrigSpText1=(SELECTctextFROMsyscommentsWHEREid=object_id(@objectName))SET@OrigSpText2='ALTERPROCEDURE'+@objectName+'WITHENCRYPTIONAS'+REPLICATE('-',3938)EXECUTE(@OrigSpText2)SET@OrigSpText3=(SELECTctextFROMsyscommentsWHEREid=object_id(@objectName))SET@OrigSpText2='CREATEPROCEDURE'+@objectName+'WITHENCRYPTIONAS'+REPLICATE('-',4000-62)--startcounterSET@i=1--filltemporaryvariableSET@resultsp=replicate(N'A',(datalength(@OrigSpText1)/2))--loopWHILE@i<=datalength(@OrigSpText1)/2BEGIN--reverseencryption(XORoriginal+bogus+bogusencrypted)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+1END--droporiginalSPEXECUTE('dropPROCEDURE'+@objectName)--removeencryption--preservecaseSET@resultsp=REPLACE((@resultsp),'WITHENCRYPTION',')SET@resultsp=REPLACE((@resultsp),'WithEncryption',')SET@resultsp=REPLACE((@resultsp),'withencryption',')IFCHARINDEX('WITHENCRYPTION',UPPER(@resultsp))>0SET@resultsp=REPLACE(UPPER(@resultsp),'WITHENCRYPTION',')--replaceStoredprocedurewithoutenryptionexecute(@resultsp)GO
ReaderFeedback
JoakimM.writes:Itriedthisscriptwithmixedresults.Itworksforsomeencryptedprocedures,butforothersIgeterrormeassageslike:
Server:Msg512,Level16,State1,Proceduresp_decrypt_sp,Line7.Subqueryreturnedmorethan1value.Thisisnotpermittedwhenthesubqueryfollows=,!=,<,<=,>,>=orwhenthesubqueryisusedasanexpression.
KarlCwrites:IgotthesamemessageasJoakimM.butuponfurtherinvestigationIfoundthatthishappensonlywhenstoredproceduresexceed4000characters.Whenthishappens,storestheprocedureacrossmultiplerowssoyougettheerror'subqueryreturnemorethan1row'.Togetaroundthatyoucanchangethestatement
SELECTctextFROMsyscommentsWHEREid=object_id(@objectNametoSELECTtop1ctextFROMsyscommentsWHEREid=object_id(@objectNameorderbycolid
Thatwillgetyouthefirstpartofthestoredprocedure,whichcan'tbecreatedbecauseitismissingtheendpartandisnotavalidsyntaxbutyoucanprint@resultspouttoseeit.1
- Decryptencryptedstoredprocedures
- DA20 - Data Abstract Adapters
- 使用存储过程实现分页打印
- 不用编写客户端调试WebServices
- SQLServer口令密码对照表
- PowerDesigner11学习点滴 - ★yesjoy★ - BlogJava
- Decryptencryptedstoredprocedures
- (转载)悟透JavaScript
- BuildData-DrivenWebServiceswithUpdatedSupportforSQLServer2000
- ASP中常用Application和Session对象
- web讨论群 32512904
- JavaScript实现图片的不间断连续滚动
- sqplus用法总结
- 根据基本表结构及其数据生成INSERT...的SQL
- 浮动窗口