Showing posts with label encrypted. Show all posts
Showing posts with label encrypted. Show all posts

Wednesday, March 21, 2012

Open stored in Hexadecimal

How I can to open a encrypted stored procedure in Hexadecimal mode
with Query Analyzer?

ThanksYachi <yachi@.pointel.it> wrote in message news:<bpujh0himbt42fv9obbj477tnnqeu9162b@.4ax.com>...
> How I can to open a encrypted stored procedure in Hexadecimal mode
> with Query Analyzer?
> Thanks

In general, you won't get an answer to questions like this in a
newsgroup, because it's not always clear what the motive behind the
question is. However, if you really need to know, then Google should
be able to help...

Simon

Monday, March 12, 2012

Open Encrypted Stored Procedure

Hi, i has another problem i think you can help me on,
I need to open a encrypted stored procedure, how can i do it??
Thanks.Ohhhh.. Microsoft and his security realy sucks...
here you have how.

Create Procedure Decryptsp2K (@.objName varchar(50))
AS
-- INPUT: object name (stored procedure, view or trigger)
DECLARE @.a nvarchar(4000), @.b nvarchar(4000), @.c nvarchar(4000), @.d nvarchar(4000), @.i int, @.t bigint
--get encrypted data
SET @.a=(SELECT ctext FROM syscomments WHERE id = object_id(@.objName))
SET @.b='ALTER PROCEDURE '+ @.objName +' WITH ENCRYPTION AS '+REPLICATE('-', 4000-62)
EXECUTE (@.b)
--get encrypted bogus SP
SET @.c=(SELECT ctext FROM syscomments WHERE id = object_id(@.objName))
SET @.b='CREATE PROCEDURE '+ @.objName +' WITH ENCRYPTION AS '+REPLICATE('-', 4000-62)
--start counter
SET @.i=1
--fill temporary variable
SET @.d = replicate(N'A', (datalength(@.a) / 2))
--loop
WHILE @.i<=datalength(@.a)/2
BEGIN
--xor original+bogus+bogus encrypted
SET @.d = stuff(@.d, @.i, 1,
NCHAR(UNICODE(substring(@.a, @.i, 1)) ^
(UNICODE(substring(@.b, @.i, 1)) ^
UNICODE(substring(@.c, @.i, 1)))))
SET @.i=@.i+1
END
--drop original SP
EXECUTE ('drop PROCEDURE '+ @.objName)
--remove encryption
--try to preserve case
SET @.d=REPLACE((@.d),'WITH ENCRYPTION', '')
SET @.d=REPLACE((@.d),'With Encryption', '')
SET @.d=REPLACE((@.d),'with encryption', '')
IF CHARINDEX('WITH ENCRYPTION',UPPER(@.d) )>0
SET @.d=REPLACE(UPPER(@.d),'WITH ENCRYPTION', '')
--replace SP
execute( @.d)

GO|||Thank you for you code, is exactly what i need and works perfect!