DotNet Modifying Assemblies
Post

DotNet Modifying Assemblies

Assemblies Modification

We can arbitrarily modify assemblies, by using this technique to add debugging statements to a log file or alter an assembly’s attributes in order to better debug our target application.

In order to demonstrate this technique, we will need to first Decompile our custom executable file and edit it using dnSpy. Let’s right-click Program and choose Edit Class.

Edit-Class-C

Then we’ll change “Your answer was: “ to “You said: “ (Figure 40).

Editing-Code

And finally, we’ll click Compile, then File > Save All to overwrite the original version of the executable file.

Save-All-File

Overwrite-File

If we return to our command prompt and re-run test.exe, the second print statement is now “You said: “

Modified Code