If we get our hands on the compiled byte code for web technologies like C# and Java, we can use various tools to recover the original source code that convert the application’s byte code to an intermediate language representation.
C#
For C# applications, we can use the dnSpy
or ILSpy
decompilers and debuggers
for recovering a close representation of a C# application’s original source
code:
Java
For Java applications, we can use JD-GUI
to decompile and review a close
representation of a Java application’s original source code:
Debugging tips
Debugging compiled .NET applications can be difficult due to optimizations taken
by the compiler. To remove these obstacles, we can update an assembly’s
attributes for debugging by adding the following with dnSpy
:
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
After editing these assembly attributes in dnSpy
, we can re-compile the target
application and continue with our debugging adventures.
Some tips from the dnSpy maintainers: