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.
- Open your solution.
- 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”.
- Right-click your solution, which is named “Solution ‘ProjectName'”.
- Click “Manage NuGet Packages for Solution”.
- On “Manage Packages for Solution” now visible to your left, go to the “Browse” tab.
- In the search bar, type in “Obfuscar”, then click the package simply named “Obfuscar”.
- 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.
- Click “OK” on the window that follows.
- Click “I Accept” on the window that follows.
- After installation, go to the “Installed” tab and confirm that “Obfuscar” is on the list of installed packages.
- Navigate back to the “Solution Explorer”.
- Right-click your solution. NOTE: Alternatively, you can right click an individual project if you only wish to build one.
- Click “Build Solution”. NOTE: Alternatively, you can click “Build” if you right-clicked an individual project.
- 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”.
- Depending on what configuration you most recently built your solution or project with, copy the “Debug” or “Release” folder.
- 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”.
- Create an XML file in the same folder called “config.xml”.
- 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”.
- 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.
- 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.
- In the terminal, type in “Obfuscar.Console.exe config.xml” then press Enter.
- 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”.
- Copy the obfuscated executables/DLLs. NOTE: You do not have to copy the “Mapping.txt” file.
- Paste the obfuscated executables/DLLs into the folder with the originals and choose to replace files.
- Your application’s core files are now obfuscated.