Developer Manual On How To Obfuscate .NET Applications Using Microsoft Visual Studio and Obfuscar

To read the full guide with pictures, click here: Developer Manual On How To Obfuscate .NET Applications Using Microsoft Visual Studio and Obfuscar

NOTE: This manual assumes that you already have a project in a solution ready.

  1. Open your solution.
  1. Navigate to the “Solution Explorer” at the right side of the window. NOTE: If the “Solution Explorer” is not visible at the right side of your window, open the “View” menu from the upper-left area of the window to display a dropdown menu of options, then click “Solution Explorer”.
  1. Right-click your solution, which is named “Solution ‘ProjectName'”.
  1. Click “Manage NuGet Packages for Solution”.
  1. On “Manage Packages for Solution” now visible to your left, go to the “Browse” tab.
  1. In the search bar, type in “Obfuscar”, then click the package simply named “Obfuscar”.
  1. From the projects in the list on the left side of “Manage Packages for Solution”, check the boxes beside all the projects you wish to obfuscate.
  1. Click “OK” on the window that follows.
  1. Click “I Accept” on the window that follows.
  1. After installation, go to the “Installed” tab and confirm that “Obfuscar” is on the list of installed packages.
  1. Navigate back to the “Solution Explorer”.
  1. Right-click your solution. NOTE: Alternatively, you can right click an individual project if you only wish to build one.
  1. Click “Build Solution”. NOTE: Alternatively, you can click “Build” if you right-clicked an individual project.
  1. After the solution is done building, open “Windows Explorer” and navigate to your project’s binary files. NOTE: By default, the path to your solution’s binary files is “C:\Users\[CurrentUser]\source\repos\[SolutionName]\[ProjectName]\bin”.
  1. Depending on what configuration you most recently built your solution or project with, copy the “Debug” or “Release” folder.
  1. Paste it into the folder containing “Obfuscar.Console.exe”. NOTE: By default, the path to “Obfuscar.Console.exe” is “C:\Users\[CurrentUser]\.nuget\packages\obfuscar\[VersionNumber]\tools”.
  1. Create an XML file in the same folder called “config.xml”.
  1. Edit the file and paste the following lines:

<?xml version=’1.0′?>

<Obfuscator>

  <Var name=”InPath” value=”.\[FolderCopied]” />

  <Var name=”OutPath” value=”.\Obfuscator_Output” />

  <Var name=”KeepPublicApi” value=”false” />

  <Var name=”HidePrivateApi” value=”true” />

  <Var name=”RenameProperties” value=”true” />

  <Var name=”RenameEvents” value=”true” />

  <Var name=”RenameFields” value=”true” />

  <Var name=”UseUnicodeNames” value=”true” />

  <Var name=”HideStrings” value=”true” />

  <Var name=”OptimizeMethods” value=”true” />

  <Var name=”SuppressIldasm” value=”true” />

</Obfuscator>

NOTE: Replace [FolderCopied] with the name of the folder you copied into the same directory as “Obfuscar.Console.exe”.

  1. In the file, above “</Obfuscator>”, insert  the following line: “<Module file=”$(InPath)\[ToObfuscate]” />”. NOTE: Replace [ToObfuscate] with the executable/DLL of your built application. If you are obfuscating a .NET Core project, obfuscate the DLLs, otherwise obfuscate the executables. If it is within more folders, replace “($InPath)\[ToObfuscate]” with “($InPath)\[Folder1]\[Folder…]\[FolderN]\[ToObfuscate]”, replace all the [Folder#]s with all the folders leading to the executable/DLL. Duplicate this line with the appropriate file paths if there are more executables/DLLs to obfuscate.
  1. Open the folder within a terminal. NOTE: On Windows Explorer, you can open a folder within a terminal by clicking on the address bar, typing “cmd” then pressing Enter.
  1. In the terminal, type in “Obfuscar.Console.exe config.xml” then press Enter.
  1. Go into the newly created output folder. NOTE: If you have copied the exact lines of XML to “config.xml” as shown in step 18, the output folder should be named “Obfuscator_Output”.
  1. Copy the obfuscated executables/DLLs. NOTE: You do not have to copy the “Mapping.txt” file.
  1. Paste the obfuscated executables/DLLs into the folder with the originals and choose to replace files.
  1. Your application’s core files are now obfuscated.