Search code examples
.netsecuritydllcustom-controlsrestrict

Protect assembly?


I have a .NET DLL (C#/VB) with custom controls, extension and other stuff.

I want that it should be available for me only. Is there any way to restrict unauthorized access to a DLL?


Solution

  • Your best option is to pack/encrypt/obfuscate the DLL as Anton pointed out. And then pray that nobody will go through all the hassle of unpacking it.

    The usual term for this is simply "packing".

    This is what game developers do with f.ex Sony's SecuROM.

    But all packing programs have the same drawbacks:

    1. They can be reverse-engineered and the encryption key must be embedded in the binary
    2. They usually cost money, and those that don't (UPX) are easily unpacked.
    3. Platform incompatability issues can be introduced by the unpacking process.
    4. Packed binaries tend to freak Anti-viruses out.

    Companies that use packers usually ship binaries that must be able to run on every thinkable computer. If you really meant it, I guess you could encrypt every single dll shipped with a unique key and then require it be ran with internet access for some challenge-response magic during the decryption phase. Overkill at any rate.

    You could also make your own packer, but believe me when I say it: You don't want to go there ;)

    In short, what you want is not simple to achieve even for the big players. How long does it take for a SecuROM game to show up on piratebay? So the only thing you can do is "raise the bar" and hope to go unnoticed by the good reverse-engineers.

    Lastly, knowing what you're getting yourself into: Will it be worth it for you? Let's say you shipped the DLL unpacked - as it is. People will still need to reverse-engineer it to use it. Who uses undocumented 3rd-party libraries anyway? I've only done that once or twice in moments of insanity.