Decrypt the encrypted store procedure through the T-SQL programming in SQL Server 2005

HI ,
I have a encrypted store procedure in my production server .Right now I do not have the script now I want do some modification.
Please any one can help me to decrypt the store procedure it will be a great help for me.
For any suggestion thanks
 in advance.
" Education is the beginning of transformation. Dedicate yourself to daily learning via Blogs/Forums/books and coaching "
Click here to read my blog

I have modified Jon's post so it also supports functions correctly, jon's version gave a syntax error on functions because the dummy func sql was invalid
1. Connect using "admin:server\instance"  instead of "server\instance" (enable dac if you havent already, its an sp_reconfigure command)
2. create the below proc
3. exec SqlDecryptor 'dbo', 'function_or_stored_proc_name'
ALTER -- CREATE
proc SqlDecryptor (@objschemaname nvarchar(255), @objname nvarchar(255))
AS
DECLARE @objid INT,@objtype NVARCHAR(50),@objtypicalstm NVARCHAR(4000),@objencrypted BIT
SELECT TOP 1 @objid=o,@objname = n,@objtype = t,@objtypicalstm=s,@objencrypted = (SELECT ([encrypted]) FROM syscomments WHERE [id] = x.o and colid = 1)
FROM
SELECT object_id o, name n,
CASE WHEN [type] = 'P' THEN N'PROCEDURE'
WHEN [type] = 'V' THEN 'VIEW'
WHEN [type] IN ('FN','TF','IF') THEN N'FUNCTION'
ELSE [type]
END t,
CASE WHEN [type] = 'P' THEN N'WITH ENCRYPTION AS'
WHEN [type] = 'V' THEN N'WITH ENCRYPTION AS SELECT 123 ABC'
WHEN [type] IN ('FN','TF','IF') THEN N' () RETURNS INT WITH ENCRYPTION AS BEGIN RETURN 1 END'
ELSE [type]
END s
FROM sys.all_objects WHERE [type] NOT IN ('S','U','PK','F','D','SQ','IT','X','PC','FS','AF')
AND name = @objname AND (SCHEMA_NAME([schema_id]) = COALESCE(@objschemaname,'dbo'))
--UNION ALL SELECT object_id,name,'TRIGGER',N'ON ALL SERVER WITH ENCRYPTION FOR DDL_LOGIN_EVENTS AS SELECT 1' FROM sys.server_triggers WHERE name = @objname
--UNION ALL SELECT object_id,name,'TRIGGER',N'ON DATABASE WITH ENCRYPTION FOR CREATE_TABLE AS SELECT 1' FROM sys.triggers WHERE name = @objname
) x
--SELECT @objid,@objname,@objtype,@objtypicalstm,@objencrypted
SET NOCOUNT ON
IF @objencrypted <> 0
BEGIN
IF EXISTS
SELECT * FROM sys.dm_exec_connections ec JOIN sys.endpoints e
on (ec.[endpoint_id]=e.[endpoint_id])
WHERE e.[name]='Dedicated Admin Connection'
AND ec.[session_id] = @@SPID
BEGIN
DECLARE @ChunkNumber INT,@ChunkPiece NVARCHAR(MAX),@CompareChunksAtPosition INT,@DummyChunk NVARCHAR(MAX),@DummyObject VARBINARY(MAX),@EncryptedChunk NVARCHAR(MAX),@EncryptedObject VARBINARY(MAX),@p INT,@p1 NVARCHAR(MAX),@p2 NVARCHAR(MAX),@QueryForDummyObject NVARCHAR(MAX),@ReplacementText NVARCHAR(4000)
SELECT @EncryptedObject = [imageval] FROM [sys].[sysobjvalues] WHERE [objid] = @objid AND [valclass] = 1
BEGIN TRANSACTION
SET @p = 1
SET @p1= N'ALTER'+SPACE(1)+@objtype+SPACE(1)+ISNULL((@objschemaname+'.'),'')+@objname +SPACE(1)+@objtypicalstm;
SET @p1=@p1+REPLICATE('-',4000-LEN(@p1))
SET @p2 = REPLICATE('-',8000)
SET @QueryForDummyObject = N'EXEC(@p1'
WHILE @p <=CEILING(DATALENGTH(@EncryptedObject) / 8000.0)
BEGIN
SET @QueryForDummyObject=@QueryForDummyObject+N'+@f'
SET @p =@p +1
END
SET @QueryForDummyObject=@QueryForDummyObject+')'
EXEC sp_executesql @QueryForDummyObject,N'@p1 NVARCHAR(4000),@f VARCHAR(8000)',@p1=@p1,@f=@p2
SET @DummyObject=(SELECT [imageval] FROM [sys].[sysobjvalues] WHERE [objid] = @objid and [valclass] = 1)
ROLLBACK TRANSACTION
SET @ChunkNumber=1
WHILE @ChunkNumber<=CEILING(DATALENGTH(@EncryptedObject) / 8000.0)
BEGIN
SELECT @EncryptedChunk = SUBSTRING(@EncryptedObject, (@ChunkNumber - 1) * 8000 + 1, 8000)
SELECT @DummyChunk = SUBSTRING(@DummyObject, (@ChunkNumber - 1) * 8000 + 1, 8000)
IF @ChunkNumber=1
BEGIN
SET @ReplacementText=N'CREATE'+SPACE(1)+@objtype+SPACE(1)+ISNULL((@objschemaname+'.'),'')+@objname +SPACE(1)+@objtypicalstm+REPLICATE('-',4000)
END
ELSE
BEGIN
SET @ReplacementText=REPLICATE('-', 4000)
END
SET @ChunkPiece = REPLICATE(N'A', (DATALENGTH(@EncryptedChunk) / 2))
SET @CompareChunksAtPosition=1
WHILE @CompareChunksAtPosition<=DATALENGTH(@EncryptedChunk)/2
BEGIN
SET @ChunkPiece = STUFF(@ChunkPiece, @CompareChunksAtPosition, 1, NCHAR(UNICODE(SUBSTRING(@EncryptedChunk, @CompareChunksAtPosition, 1)) ^ (UNICODE(SUBSTRING(@ReplacementText, @CompareChunksAtPosition, 1)) ^ UNICODE(SUBSTRING(@DummyChunk, @CompareChunksAtPosition, 1)))))
SET @CompareChunksAtPosition=@CompareChunksAtPosition+1
END
PRINT @ChunkPiece
SET @ChunkNumber=@ChunkNumber+1
END
END
ELSE
BEGIN
PRINT 'Use a DAC Connection'
END
END
ELSE
BEGIN
PRINT 'Object not encrypted or not found'
END
SET QUOTED_IDENTIFIER OFF
GO

Similar Messages

  • While opening the iTune Store i receive the following error, "The procedure entry point ADAdPolicyEngine_DidEnterSation could not be located in the dynamic link library iAdCore.dll" Please help me to clear this error.

    While opening the iTune Store i receive the following error, "The procedure entry point ADAdPolicyEngine_DidEnterSation could not be located in the dynamic link library iAdCore.dll" Please help me to clear this error.

    I faced the same issue. This solved it for me: Troubleshooting issues with iTunes for Windows updates
    Hope this helps.

  • My App Store is connected to another account. I've tried to alter all my settings through iTunes, The App Store on both the phone and my Mac but it is still connected to the original owner's apple ID. Is there something I can do?

    My App Store is connected to another account. I've tried to alter all my settings through iTunes, The App Store on both the phone and my Mac but it is still connected to the original owner's apple ID. Is there something I can do?

    Turn off Find My iPhone in iCloud on the iDevice.
    Log out of iMessage, Facetime, remove Apple ID from iTunes & App Store.
    Use Settings > Reset > Erase All Content and Settings.
    Then set it up as a new iPhone with your own Apple ID.

  • I have installed Itunes on my laptop. However, the apple store opens in German language. I need it in English. How can i change the language for istore through the itunes?

    I have installed Itunes on my laptop. However, the apple store opens in German language. I need it in English. How can i change the language for istore through the itunes?

    Go to the bottom of the page, click the flag, then select your country.

  • I purchased Adobe Acrobat Pro XI via email download via the Dell Store yesterday. The product key doesn't work/fit into any of the "Registration" templates I've look through on the Adobe website. Manufacturer Part # 65195473.

    I purchased Adobe Acrobat Pro XI via email download code via the Dell Store yesterday. The product key given doesn't work/fit into the boxes on any of the "Register" pages on the Adobe website. Therefore, although I paid for the product and it is downloaded, it is not "installed" and will not work to print documents from emails, etc.

    Hi williamc48321229,
    You must have received redemption code via email from the reseller.
    Please ensure that you are entering the right code as that would be needed to obtain the serial number for activating the product.
    For more details on this, please refer:
    Find your serial number quickly
    Hope this helps.
    regards,
    Anubha

  • I bought an iphone 4s from the apple store in HK, the model of the phone is A1387. Would it work if I use a sim-card using CDMA EV-DO Rev. A technique?

    I bought an iphone 4s from the apple store in HK, the model of the phone is A1387. Would it work if I use a sim-card using CDMA EV-DO Rev. A technique?

    Based on this issue, I have contacted Rogers. The procedure was very time consuming as I spent over 4 hours on the phone with multiple service reps, supervisors, and managers. This has cost me over $40 in long distance charges just for this phone call. In addition, they made me aware that I was sold an iPhone 4s that was locked to Rogers. Rogers charged me $57 for this unlock, and they said they could not waive this fee because it goes through apple. The typical procedure when apple sells locked phones, is that a replacement phone would be given to me free of charge by apple. I just do not understand why the service rep told me that the phone was unlocked, when actually the supervisor at Rogers confirmed that this device was originally locked to Rogers (traced from imei). I deserve compensation, and would like to hear a prompt response from apple with regards to this matter. 

  • Ok. So my iTunes started acting up a few months ago. ALL of the songs I purchased from the iTunes store stop in the middle of the song and then go back to the begining (I keep it on repeat one song by the way). Please help!!! (Windows 7)

    Ok. So my iTunes started acting up a few months ago. ALL of the songs I purchased from the iTunes store stop in the middle of the song and then go back to the begining (I keep it on repeat one song by the way). Please help!!! (Windows 7) I would really like to hear my songs all the way through, but I can't . I tried the "Convert Protected ACC files to Purchased ACC files fix" but it DIDN'T work. I don't know what to do. It does it when I transfer the music onto my Classic too.

    What do you mean "doesn't recognize"?

  • I re-installed Mountain Lion from a USB stick, and now my Apps can't be downloaded.  The App store indicates that the Apps are already installed, but that is not the case. Now what :)

    I re-installed Mountain Lion from scratch of a USB stick, and now my Apps in the App store ca not be installed, the App store indicates that they are already installed, but that is not the case.  Now what?

    Ok, this is somewhat of a better work around I've found:
    Starting in the Australian iTunes store, I go through the process of signing into the UK iTunes store up until the point it asks for my credit card information.
    I then click the 'X' in the top left of iTunes to exit the store.
    Now when I click on my Apps Updates button it shows me what UK Apps I have that are available to update.
    You can't download these as at this point I've changed the store I'm viewing, but haven't officially switched accounts. Not to worry.
    I write down the names of the UK Apps to update.
    Then, use the 'search store' field in the top right of iTunes to search for one of the Apps.
    Once you've found it, click to buy it / download it.
    iTunes recognises that the App is already in your account and downloads it again for free….
    … now I'm HOPING that that App is now fully within my Australian account… unfortunately only time will tell once there is a new update for it.
    I'll let you know.

  • Hi! The cable for my ipod broke(6mos after purchase from the states). Is the warranty still applicable in the apple stores here in the Philippines?

    So my cousin bought me an ipod 5th gen and sent it here in the Philippines. 6 months later, the cable became unusable. It doesn't charge my ipod anymore. I'm wondering, since it wasn't bought at the apple store here in the Philippines, is the warranty still applicable? Can I still exchang my cable for a new one through the apple stores here in the country? Help!

    It is hardly Apple's fault that Epson can't/won't update their driver, but at least Epson suggest that you use the Gutenprint driver, which in any case is far better that what Epson offer.
    You can get it here:
    http://gimp-print.sourceforge.net/
    You can download the latest version from here:
    http://sourceforge.net/projects/gimp-print/
    Have you downloaded the recent Apple update to Epson drivers?
    http://support.apple.com/kb/DL1398

  • When trying to log on to the iTunes store I get the message 'We could not complete your iTunes store request. The network connection was reset'.

    When trying to log on to the iTunes store I get the message 'We could not complete your iTunes store request. The network connection was reset'.  I can access my account on a different PC but not my own.  Can you advise me as to what I should do please?

    Hello donnafromwakefield,
    The article linked below details steps that can help restore your computer's ability to connect to the iTunes Store.
    Can't connect to the iTunes Store
    http://support.apple.com/en-us/TS1368
    Cheers,
    Allen

  • Backing Up and Restoring the Message Store v.s. the queue

    Hello,
    We are running iPlanet 5.2 Messaging Server and need to migrate to another (duplicate) 5.2 Messaging Server. We have all the software installed and the LDAP user accounts created. Now we just need to move the existing mail from one server to the other.
    I found the Backing Up and Restoring the Message Store section in the Admin Guide says to back up and restore your data, Messaging Server provides the imsbackup and imsrestore utilities.
    However I am wondering about the Queue?
    Under <instance>/imta/queue
    What is the difference between the Message Store
    and the Queue? Can I just backup and restore the Queue using tar or cpio?
    Thanks in advance for any advice.
    Regards,
    Tim

    Hello,
    We are running iPlanet 5.2 Messaging Server and need
    to migrate to another (duplicate) 5.2 Messaging
    Server. We have all the software installed and the
    LDAP user accounts created. Now we just need to move
    the existing mail from one server to the other.
    I found the Backing Up and Restoring the Message
    Store section in the Admin Guide says to back up and
    restore your data, Messaging Server provides the
    imsbackup and imsrestore utilities.
    However I am wondering about the Queue?
    Under <instance>/imta/queue
    What is the difference between the Message Store
    and the Queue? The Message Store is where messages get delivered to, so you can read them.'
    The queue is where messages are temporarily stored, pending delivery to wherever they go.
    You can use tar, cpio, or what have you for the queue. Stop the server first. . .
    You then just restore the files to the new server. No need to restart or anything like that. Just dump the files in, and run
    imsimta cache -sync
    to tell the MTA to re-read the queue.
    Can I just backup and restore the
    Queue using tar or cpio?
    Thanks in advance for any advice.
    Regards,
    Tim

  • Sign in to download from the App Store screen has the wrong Apple ID- grayed out. How can I change it?

    When I have a software update notification and I go to the 'Updates" tab of the App Store and click 'update',  the flash screen 'Sign in to download from the App Store comes up the the Apple ID is wrong and grayed out so I can't change it.  Where is the bogus Apple ID stored? How can I 'ungray' it to make it editable?
    I'm running Mavericks 10.9.4 on an IMAC 2.5 GHz Intel Core i5.

    You installed a hacked app, originally from the Mac App Store. It contains the receipt for a different app, downloaded using an account that you don't control. You need to identify and remove the hacked app.
    Important: The app you need to remove is not necessarily the one named in the App Store alert. For example, the App Store may prompt you to update "Angry Birds" or "Twitter," but the hacked app may be something else entirely. Don't make any assumptions about which app you're looking for. To find it, you must carry out a systematic search with Spotlight.
    1. Triple-click anywhere in the line of text below on this page to select it:
    kMDItemAppStoreHasReceipt=1
    Copy the selected text to the Clipboard by pressing the key combination command-C.
    2. In the Finder, press command-F to open a search window, or select
              File ▹ Find
    from the menu bar. In the search window, select
              Search: This Mac
    from the row of tokens below the toolbar. Below that is a popup menu of search criteria, initially showing Kind. From that menu, select
              Other...
    A sheet will drop down. In that sheet, select
              Raw Query
    as the criterion, then click OK or press return.
    Now there will be a text box to the right of the menu of search criteria. That's where you enter the raw search query. Click in that box and paste the text you copied earlier by pressing command-V.
    4. The search window will now show all the App Store products that are installed. Compare those search results with the list of your purchases from the App Store. To see the complete list, you may need to unhide hidden purchases. If any apps were download from the App Store using other Apple ID accounts that you control, sign in to the store under each of those ID's and check the purchases.
    At least one of the apps in the Spotlight search results is not among your purchases in the App Store. Move each such item to the Trash, after quitting it if it's running. You may be prompted for your administrator password. Empty the Trash.
    Quit and relaunch the App Store. Test.
    If you find these instructions confusing, ask for an alternative method.

  • TS3297 Every time I open iTunes to listen to music, not access the iTunes Store, I get the password sign in box, over and over again. When I try to access the iTunes Store it does not except my password. This has happened since the last update.

    Everytime I open iTunes to play music, NOT to access the iTunes Store, I get the password sign in box for the iTunes Store. If I click cansel the box pops up a second time.
    When I try to sign in to the iTunes Store it does not except the password and pops up the sign in box afain,and again endlessly.
    This started happening about two weeks ago.

    if itunes will not run, you probably have mangled windows badly
    one feature of windows 8 is the refresh that saves libraries,
    because you are using windows 7, you will need to backup all files to another storage device

  • TS1702 Does anyone know how to resolve the problem of apps not being able to download in the App Store? After the IOS 6 update I haven't been able to download any apps.

    Does anyone know how to resolve the problem of apps not being able to download in the App Store? After the IOS 6 update I haven't been able to download any apps.

    Maybe here:
    IOS 6 App store crash: Apple Support Communities

  • HT204476 I cannot open iPhoto now that I upgraded to Yosemite.When I click iPhoto it says I have to download older version of iPhoto.The app store, it says "The item you've requested is not currently available in the U.S. HELP!

    I upgraded my Macbook Pro (early 2011) to OS X Yosemite 10.10.3.  Now, I cannot open iPhoto. It says I have to download older version of iPhoto. When I go to the app store, it says: The version of iPhoto installed on this Mac is not compatible with OS X Yosemite. Download the latest version for free from the Mac App Store. the it says: "The item you've requested is not currently available in the U.S.Do I need to find my original Macbook disk and install it back and go from there? Did I loose all my pics?  Do I really ned it if they are all visible from the new "Photos" App? HELP!

    Try Terence's instructions here  Is Iphoto gone ? i want it back!
    Pete

Maybe you are looking for

  • Opening pdf documents in SOLAR01

    Hello All, Is there a way to open pdf documents in SOLAR01. If I try this now, an internet browser is opened which after a while will show: <i>The page you are looking for is currently unavailable</i> 1) is it so that the solmandocumentation service

  • Displaying the process id

    I'm having some problems getting the process id to display for the current process. I'm using netbeans 4.0 with JDK 5.0 as my interface. I'm working on a simple program for a class and this is the only portion that I can't seem to figure out how to c

  • Disabling single Screen field

    Hi Friends, Plz help me how to disable single Screen field in Module pool. I have a scenario where One of the field is drop down box,in that options if i select 1 option the next Input/outputfield and Group of radio buttons(2buttons) should be disabl

  • [Solved] lm-sensors fan speeds and voltage.

    After installing lm-sensors and running sensors-detect I have the following readings from sensors; ~$ sensors acpitz-virtual-0 Adapter: Virtual device temp1: +42.0°C (crit = +80.0°C) coretemp-isa-0000 Adapter: ISA adapter Core 0: +47.0°C (high = +78.

  • Mac Mail drafts don't appear in Gmail and vice-versa. HELP??

    When I start writing a message in Mountain Lion's Mac Mail and save it as a draft, it appears locally, but not on Gmail or iOS Mail. It does however appear in imap/[draft] on Gmail and I cannot edit it. Messages that are drafted in Gmail or iOS Mail