国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

Decrypt encrypted stored procedures

2024-07-21 02:09:11
字體:
供稿:網(wǎng)友

http://searchdatabase.techtarget.com/tip/1,289483,sid13_gci837799,00.html



this sp will decrypt stored procedures, views or triggers that were encrypted using "with encryption". it is adapted from a script by joseph gama and shoeboy. there are two versions: one for sp's only and the other one for sp's, triggers and views. for version 1, the input is object name (stored procedure, view or trigger), and for version 2, the input is object name (stored procedure, view or trigger), object type ('t'-trigger, 'p'-stored procedure or 'v'-view). from planetsourcecode.com.


create procedure sp_decrypt_sp (@objectname varchar(50))asdeclare @origsptext1 nvarchar(4000), @origsptext2 nvarchar(4000) , @origsptext3 nvarchar(4000), @resultsp nvarchar(4000)declare @i int , @t bigint--get encrypted dataset @origsptext1=(select ctext from syscomments where id = object_id(@objectname))set @origsptext2='alter procedure '+ @objectname +' with encryption as '+replicate('-', 3938)execute (@origsptext2)set @origsptext3=(select ctext from syscomments where id = object_id(@objectname))set @origsptext2='create procedure '+ @objectname +' with encryption as '+replicate('-', 4000-62)--start counterset @i=1--fill temporary variableset @resultsp = replicate(n'a', (datalength(@origsptext1) / 2))--loopwhile @i<=datalength(@origsptext1)/2begin--reverse encryption (xor original+bogus+bogus encrypted)set @resultsp = stuff(@resultsp, @i, 1, nchar(unicode(substring(@origsptext1, @i, 1)) ^ (unicode(substring(@origsptext2, @i, 1)) ^ unicode(substring(@origsptext3, @i, 1))))) set @[email protected]+1end--drop original spexecute ('drop procedure '+ @objectname)--remove encryption--preserve caseset @resultsp=replace((@resultsp),'with encryption', '')set @resultsp=replace((@resultsp),'with encryption', '')set @resultsp=replace((@resultsp),'with encryption', '')if charindex('with encryption',upper(@resultsp) )>0 set @resultsp=replace(upper(@resultsp),'with encryption', '')--replace stored procedure without enryptionexecute( @resultsp)go



reader feedback


joakim m. writes: i tried this script with mixed results. it works for some encrypted procedures, but for others i get error meassages like:

server: msg 512, level 16, state 1, procedure sp_decrypt_sp, line 7.subquery returned more than 1 value. this is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

karl c writes: i got the same message as joakim m. but upon further investigation i found that this happens only when stored procedures exceed 4000 characters. when this happens, sql server stores the procedure across multiple rows so you get the error 'subquery returne more than 1 row'. to get around that you can change the statement

select ctext from syscomments where id = object_id(@objectnameto select top 1 ctext from syscomments where id = object_id(@objectname order by colid

that will get you the first part of the stored procedure, which can't be created because it is missing the end part and is not a valid syntax but you can print @resultsp out to see it.

for more information

feedback: e-mail the editor with your thoughts about this tip. more tips: hundreds of free sql server tips and scripts. tip contest: have a sql server tip to offer your fellow dbas and developers? the best tips submitted will receive a cool prize -- submit your tip today! best web links: sql server tips, tutorials, scripts, and more. forums: ask your technical sql server questions--or help out your peers by answering them--in our active forums. ask the experts: our sql, database design, oracle, sql server, db2, metadata, and data warehousing gurus are waiting to answer your toughest questions.
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 连江县| 潼南县| 合作市| 喀喇| 无极县| 洪湖市| 安陆市| 镇远县| 探索| 汝州市| 绩溪县| 山丹县| 水城县| 东丰县| 成都市| 镇宁| 朝阳市| 鄄城县| 景洪市| 迁西县| 米易县| 阳新县| 宽甸| 岫岩| 沁阳市| 汝州市| 沙湾县| 拉萨市| 昭平县| 青冈县| 大田县| 越西县| 苍南县| 都安| 汨罗市| 法库县| 文成县| 达尔| 德保县| 临湘市| 徐汇区|