<

What to do when you want to apply a strong sign to a DLL without a source code.

Published on
8,061 Points
2,061 Views
Last Modified:
Approved
This article is neither here to teach you how to crack a DLL nor to encourage you to do so.  However, this is a situation that can occur often with legacy applications.
 
It is not uncommon in mature systems that iterate through many generations of versions to end up with DLL's that are either missing some or all source or it might be difficult to easily replicate the build environment.  When security wasn't as important is it is now, signing DLL's wasn't an important portion of the workflow.

Therefore, we need this little tip to be able to sign a DLL without a source code.

In order to execute the task you need the following linking tools; Ildasm and Ilasm

Both are in the .NET SDK. The path will usually be something like this depending on which version of the SDK is installed: C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin or they can be found in the .NET runtime installation path.  Here is the path for .NET 2.0: C:\Windows\Microsoft.NET\Framework\v2.0.50727

1) You will need to use .NET SDK to create a new key. you can do this by either within the Visual Studio IDE or using the command prompt by typing "sn -k example.snk". Be sure to record the path where you keep this key.

2) Using the command prompt, go to the folder with your DLL. Copy ilasm.exe and ildasm.exe to the same directory and also the previously created key file. (In this case example.snk)
Note: if you have your environment variables set up to .NET SDK then you don't have to copy these programs or you can reference the path explicitly.

3) Type “ildasm example.dll /out=example.il” to decompile the DLL into IL format with the resource file that we will use later to be attached with the key file

4) Type “ilasm example.il /dll/resource=example.res /key=example.snk /optimize”. This command recompiles the DLL with the il file, resource file and the new key file together.

5) Validate the strong name by using "sn -v example.dll" from the command prompt.

You now have a strongly typed DLL that can be safely signed in any application without source code or recreating a build environment.
0
Comment
Author:yu0307
0 Comments

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Join & Write a Comment

Check How effective MS Exchange Expert thinks Exchange Mailbox Recovery by SysTools IS. Visit the Official site to get detailed information:- https://www.systoolsgroup.com/exchange-recovery.html (https://www.systoolsgroup.com/exchange-recovery.h…
Watch this online video tutorial and learn the best way to reduce Outlook mailbox size using Compact Now feature of Outlook. It removes the deletes item's space from Microsoft Outlook 2016, 2013, and 2010 and compresses the PST file size. This will …

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month