Search code examples
c#dlldotfuscator

Referencing an Obfuscated DLL


I've obfuscated a .Net DLL using DotfuscatorCLI with Visual Studio 2015 Update 3 Post Build events commands. It seems to be successfully obfuscated as no error appeared after that command.

Here is the Command:

dotfuscatorcli.exe /q /p=SourceDirectory="$(TargetDir)\",SourceFile=$(TargetFileNa‌​me) "$(ProjectDir)Dotfuscator.xml"

And here is the Obfuscator.xml

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE dotfuscator SYSTEM "http://www.preemptive.com/dotfuscator/dtd/dotfuscator_v1.1.dtd">
<dotfuscator version="1.1">
   <propertylist>
      <property name="SourceDirectory" value="This Path Will Be Replaced By Visual Studio" />
      <property name="SourceFile" value="This Filename Will Be Replaced By Visual Studio" />
   </propertylist>
   <trigger>
      <filelist>
         <file dir="${SourceDirectory}\" name="${SourceFile}" />
      </filelist>
   </trigger>
   <output>
      <file dir="${SourceDirectory}\Dotfuscator\" />
   </output>
</dotfuscator>

Now, when I reference that DLL in another project and try to access its public members; I can no longer access them. It is as if they are not defined/public in that DLL, and they are not available in intellisense too.

If I view that DLL in Object Browser, it shows classes with some weird names e.g. h, I, m, n etc.

Am I missing something here, in order to consume that DLL?

Any response, hint or solution will be appreciated.


Solution

  • With the help from @Nathan, I'm able to resolve the problem I had. Here is the content from updated Obfuscator.xml file.

    <?xml version="1.0" encoding="utf-8" standalone="no"?>
        <!DOCTYPE dotfuscator SYSTEM "http://www.preemptive.com/dotfuscator/dtd/dotfuscator_v2.3.dtd">
        <dotfuscator version="2.3">
           <propertylist>
              <property name="SourceDirectory" value="This Path Will Be Replaced By Visual Studio" />
              <property name="SourceFile" value="This Filename Will Be Replaced By Visual Studio" />
           </propertylist>
            <input>
            <asmlist>
              <inputassembly>
               <option>library</option>
                 <file dir="${SourceDirectory}\" name="${SourceFile}" />
              </inputassembly>
           </asmlist>
          </input>
           <output>
              <file dir="${SourceDirectory}\Dotfuscator\" />
           </output>
        </dotfuscator>
    

    I know that If I use dotfuscator UI, it automatically enables library mode but I choose CLI approach on purpose. I want to automate and give generic solution to my 35+ DLLs which are referenced in one project. So now with this approach, I hope this will not only automate my obfuscation process but also speed things up since it's a post build event command approach. In short, all I need to do is Press Build solution button, and its done.

    Hope this would help others. Let me know in case of any ambiguity or concerns, or if you have any other suggestions.