In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Stored procedure for encryption test
IF EXISTS (SELECT 1 FROM SYSOBJECTS WHERE TYPE='P' AND NAME='P_TEST') DROP PROCEDURE P_TESTGOCREATE PROCEDURE P_TEST (@ USERNAME VARCHAR (20), @ MSG VARCHAR (20) OUTPUT) WITH ENCRYPTIONASBEGIN IF (SELECT COUNT (1) FROM Custs WHERE NAME=@USERNAME) > 0 SET @ MSG=' this user name exists' ELSE SET @ MSG=' this user name does not exist 'END
Decrypted stored procedure
Create PROCEDURE Decryption (@ procedure sysname = NULL) ASSET NOCOUNT ONDECLARE @ intProcSpace bigint, @ t bigint, @ maxColID smallint,@procNameLength intselect @ maxColID = max (subobjid) FROMsys.sysobjvalues WHERE objid = object_id (@ procedure)-- select @ maxColID as' Rows in sys.sysobjvalues'select @ procNameLength = datalength (@ procedure) + 29DECLARE @ real_01 nvarchar (max) DECLARE @ fake_01 nvarchar (max) DECLARE @ fake_encrypt_01 nvarchar (max) DECLARE @ real_decrypt_01 nvarchar (max), @ real_decrypt_01a nvarchar (max) declare @ objtype varchar (2) @ ParentName nvarchar (max) select @ real_decrypt_01a =''--whether the type of the extracted object is a stored procedure or a function If it's a trigger, Also get the name of its parent object select @ objtype=type,@parentname=object_name (parent_object_id) from sys.objects where [object_id] = object_id (@ procedure)-the encrypted imageval record SET @ real_01= (SELECT top 1 imageval FROM sys.sysobjvalues WHERE objid = object_id (@ procedure) and valclass = 1 order by subobjid) from sys.sysobjvalues-create a temporary table create table # output ([ident] [int] IDENTITY (1,1) NOT NULL) [real_decrypt] NVARCHAR (MAX)-- start a transaction Roll back BEGIN TRAN-- to change the original stored procedure later Replace if @ objtype='P' SET @ fake_01='ALTER PROCEDURE'+ @ procedure + 'WITH ENCRYPTION AS select 1 / * * / / *' + REPLICATE (cast ('*'as nvarchar (max)), datalength (@ real_01) / 2-@ procNameLength) +'* / 'else if @ objtype='FN' SET @ fake_01='ALTER FUNCTION' + @ procedure +'() RETURNS INT WITH ENCRYPTION AS BEGIN RETURN 1 / * / / + REPLICATE (cast ('*'as nvarchar (max)) Datalength (@ real_01) / 2-@ procNameLength) +'* / END'else if @ objtype='V' SET @ fake_01='ALTER view'+ @ procedure + 'WITH ENCRYPTION AS select 1 as col / * / / *' + REPLICATE (cast ('*'as nvarchar (max)), datalength (@ real_01) / 2-@ procNameLength) +'* / 'else if @ objtype='TR' SET @ fake_01='ALTER trigger' + @ procedure +'ON'+ @ parentname+'WITH ENCRYPTION AFTER INSERT AS RAISERROR ('Nice') 16 as nvarchar 10) / * / / *'+ REPLICATE (cast ('*'as nvarchar (max)) Datalength (@ real_01) / 2-@ procNameLength) +'* / 'EXECUTE (@ fake_01)-an encrypted fake SET @ fake_encrypt_01= (SELECT top 1 imageval FROM sys.sysobjvalues WHERE objid = object_id (@ procedure) and valclass = 1 order by subobjid) if @ objtype='P' SET @ fake_01='Create PROCEDURE' + @ procedure + 'WITH ENCRYPTION AS select 1 / * / / *' + REPLICATE (cast ('* as nvarchar (max)) Datalength (@ real_01) / 2-@ procNameLength) +'* / 'else if @ objtype='FN' SET @ fake_01='CREATE FUNCTION' + @ procedure +'() RETURNS INT WITH ENCRYPTION AS BEGIN RETURN 1 / * / / + REPLICATE (cast ('*'as nvarchar (max)) Datalength (@ real_01) / 2-@ procNameLength) +'* / END'else if @ objtype='V' SET @ fake_01='Create view'+ @ procedure + 'WITH ENCRYPTION AS select 1 as col / * / / *' + REPLICATE (cast ('*'as nvarchar (max)), datalength (@ real_01) / 2-@ procNameLength) +'* / 'else if @ objtype='TR' SET @ fake_01='Create trigger' + @ procedure +'ON'+ @ parentname+'WITH ENCRYPTION AFTER INSERT AS RAISERROR ('Nice') 16 intProcSpace=1-- 10) / * / / *'+ REPLICATE (cast ('*'as nvarchar (max)), datalength (@ real_01) / 2-@ procNameLength) +'* /'--start counting SET @ intProcSpace=1-- using character padding temporary variable SET @ real_decrypt_01 = replicate (cast ('A'as nvarchar (max)), (datalength (@ real_01) / 2))-- Loop each variable Create a real variable-- one byte at a time SET @ intProcSpace=1-- if necessary Iterate through each @ real_xx variable and decrypt WHILE @ intProcSpace= 0BEGINSELECT @ BasePos = 1SELECT @ CurrentPos = 1SELECT @ TextLength = LEN (@ SyscomText) WHILE @ CurrentPos! = 0BEGINmuri-find the end of the line by entering the enter SELECT @ CurrentPos = CHARINDEX (char (13) + char (10), @ SyscomText,@BasePos)-if you find the carriage return IF @ CurrentPos! = 0BEGINML-if the new value of @ Lines's length is larger than the set length, insert the current content of @ Lines and continue While (isnull (LEN (@ Line)) 0) + @ BlankSpaceAdded + @ CurrentPos-@BasePos + @ LFCR) > @ DefinedLengthBEGINSELECT @ AddOnLen = @ DefinedLength- (isnull (LEN (@ Line), 0) + @ BlankSpaceAdded) INSERT # CommentText VALUES (@ LineId,isnull (@ Line, nasty') + isnull (SUBSTRING (@ SyscomText,@BasePos, @ AddOnLen), nasty') SELECT @ Line = NULL, @ LineId = @ LineId + 1GI BaseBasePos = @ BasePos + @ AddOnLen, @ BlankSpaceAdded = 0ENDSELECT @ Line = isnull (@ Line, nasty') + isnull (SUBSTRING (@ SyscomText,@BasePos) @ CurrentPos-@BasePos + @ LFCR) SELECT @ BasePos = @ CurrentPos+2INSERT # CommentText VALUES (@ LineId, @ Line) SELECT @ LineId = @ LineId + 1SELECT @ Line = NULLENDELSE-- if the enter does not find BEGINIF @ BasePos @ DefinedLengthBEGINSELECT @ AddOnLen = @ DefinedLength-(isnull (LEN (@ Line), 0) + @ BlankSpaceAdded) INSERT # CommentText VALUES (@ LineId,isnull (@ Line, Line') + isnull (SUBSTRING (@ SyscomText,@BasePos, @ AddOnLen)) SELECT @ Line = NULL @ LineId = @ BasePos+ @ AddOnLen, @ BlankSpaceAdded = 0ENDSELECT @ Line = isnull (@ Line, nasty') + isnull (SUBSTRING (@ SyscomText, @ BasePos, @ TextLength-@BasePos+1), nasty') if LEN (@ Line)
< @DefinedLength and charindex(' ',@SyscomText, @TextLength+1 ) >0BEGINSELECT @ Line = @ Line +', @ BlankSpaceAdded = 1ENDENDENDENDFETCH NEXT FROM ms_crs_syscom into @ SyscomTextENDIF @ Line is NOT NULLINSERT # CommentText VALUES (@ LineId @ Line) select Text from # CommentText order by LineIdCLOSE ms_crs_syscomDEALLOCATE ms_crs_syscomDROP TABLE # CommentText-- end the extraction from sp_helptext-delete the The stored procedure created by the dash and rebuilt the original stored procedure ROLLBACK TRANDROP TABLE # outputGO enable DACSP_CONFIGURE 'remote admin connections' GO----0: only allow local connections to use DAC,1: allow remote connections to use DACSP_CONFIGURE 'remote admin connections', 0 host GORECONFIGURE WITH OVERRIDE;GO
File-- > New-- > Database engine query
Server name: admin:. Or admin: server name
Log in to perform the decryption operation
USE TESTEXEC Decryption P_TESTGO
For security reasons, do not decrypt in the formal environment to avoid damaging the original stored procedure during the decryption process!
Summary
The above is the SQLSERVER introduced by the editor to decrypt the encrypted stored procedures, views and triggers. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to the website!
If you think this article is helpful to you, you are welcome to reprint it, please indicate the source, thank you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.