[Mono-dev] Obfuscation at compile time
m.j.hutchinson at gmail.com
Sat Oct 1 09:49:15 EDT 2005
> I was wondering if there's a quick way to add a simple obfuscation
> functionality to the compiler. For example, starting with an option to
> rename private methods and locals.
I don't know much about the internals of mcs, so I can't comment on
whether its AST is the ideal place to perform your transformations,
but a better place would seem to me to be to be the CIL assembler.
Then you could use ildasm to disassemble *any* CIL assembly generated
from any CLR-targeting language and obfuscate it with the assembler.
I'm not sure whether attributes are necessary, as you'll pretty much
always want to keep public members untouched and conceal the rest. My
feeling is they'll just clog up your code, unless you apply them at
the assembly or maybe at the class level. If you find yourself wanting
to obfuscate public members they should probably be marked internal.
I doubt anything like this will be absorbed into the core
distribution; firstly, it's not critical for compatibility or
functionality, and secondly, this is an open-source project ;-) The
counter to this is that you will always be free to write and
distribute a patch to add this functionality.
Also, I don't think this belongs in the assembler or compiler, though
a general-purpose architecture for pluggable 'optimisers' might be
nice. I read on the Mono wiki about tentative plans for a tool to
optimise CIL trees using Cecil, the CIL reading/writing library, and
your ideas might fit nicely with that. Again, the advantage is that
the functionality is available to any CIL-targeting language.
Just a few thoughts,
More information about the Mono-devel-list