I have a fairly detailed description about this problem here.
In short, the object is not really encrypted, but rather obfuscated. Therefore we can retrieve the original back. The method is a little involved but it consists of these steps:
- Connect to the instance using the Dedicated Admin Connection
Select the obfuscated code like this:
SELECT @secret = imageval
WHERE objid = OBJECT_ID(@object_name);
Replace the object with another one that has the same name same object_id and the same length in bytes (e.g. using
- Get the newly obfuscated code the same way as above
- XOR the three values together (obfuscated original, replacement and obfuscated replacement)
That will give you the original code. However, as Kin mentioned, there might be support and even legal implications with doing this so be sure to consult your lawyer first.