ByteHide
Posted on July 5, 2022
Decompiling .NET assemblies is an invaluable skill for any software developer or security engineer who wants to reverse engineer or disassemble someone else’s code, and there are several tools available to help you do this, each with its own unique features and quirks. This guide will compare the features of the most popular decompilers to help you figure out which one is right for you.
What is decompilation in .NET?
For everyone for understand what the decompilation process in .NET is, you must first understand the concept of compilation.
Undestanding what is compilation .NET
In software development, C# is a high-level programming language. Compilation in .NET is the process in which C# code written or programmed by a developer (understandable to a human) is converted into machine or computer understandable code. This code is called Intermediate Language code (IL Code). That is, the source code is converted into an executable (which can be a .dll
or .exe
file).
This compilation process is necessary to be able to run the source code on a computer or device by means of an executable file.
Now, understanding the concept of compilation and how it works (without going into too much depth), let’s see what decompilation is and how it works.
Undestanding what is decompilation in .NET
Decompilation is the opposite of compilation. Decompilation is responsible for converting the machine-understandable code (IL code) of an executable (.exe
or .dll
files) into the original human-understandable source code (recovers source code). This makes it possible to analyze, understand and modify the operation of the application or program.
Decompilation is one of the first steps in reverse engineering and cracking of .NET and C# applications.
Is decompilation in .NET illegal?
The legality of decompiling .NET applications is the same as it would be for any other type of application.
The decompilation of applications is generally legal. According to Section 103 of the Digital Millennium Copyright Act (17 U.S.C. § 1201):
“A person in legal possession of a program may reverse-engineer and circumvent its protection if that is necessary to achieve “interoperability,” a term that broadly covers other devices and programs that can interact with it, make use of it, and to use and transfer data to and from it in useful ways.”
For example, in the USA it is legal as long as the software or application has been obtained legally and, as long as the licensing and use agreement of the application itself prohibits it.
In the European Union, decompilation is also legal as long as it is for interoperability purposes. However, reverse engineering and decompilation does not give you permission to publish the findings.
What is a .NET decompiler and how it works?
A .NET decompiler is a third party tool used to decompile all types of .NET binaries and libraries. Since .NET applications and executable files are compiled in IL code, in order to read the code and understand its operation, you have to convert (decompile) the IL code to C# code.
How to decompile .NET applications?
You may wonder why you would want to decompile .NET applications. Maybe you want to delve into the world of decompiling and reverse engineering.
If you are interested in learning how to decompile any .NET application (C#, VB, Xamarin, etc…) in a few steps and in a very easy way, I leave you below this article explaining step by step the different phases of decompiling explaining it with pictures that will teach you how to decompile any .NET application in a very easy way.
Article No Longer Available
So, let’s see which are the best available decompilers and Assembly Browsers for .NET applications.
What are the Best C# and .NET decompilers?
In the jungle of .NET decompilers and disassemblers there are many options, we can find a great variety of tools and options: Free and paid, open-source and private, online and offline, for different operating systems, etc…
In this top you will see the list of the most popular and most used decompilers (both free and paid).
Ildasm.exe IL Disassembler
Ildasm.exe is the first decompiler in this top. This IL disassembler is free and when you install the Visual Studio IDE, Ildasm.exe is automatically installed along with it.
This free .NET decompiler is written in the .NET language itself (C#) by the open source software platform sponsored by Microsoft: Mono-Project.
With Ildasm you can disassemble any type of binaries and .NET files. The options included in this disassembler are many, it supports several types of extensions:
-
.dll
-
.exe
-
.obj
-
.lib
-
.winmd
Its great advantage over other .NET decompilers is, as I explained before, that it installs automatically together with Visual Studio (and we all know that Visual Studio is the preferred IDE for .NET development).
By being automatically installed alongside Visual Studio, Ildasm has the same cross-platform compatibility as the IDE itself: You will have no problem using it on the operating system of your choice (Windows, macOs or Linux).
IlSpy .NET Decompiler with support for PDB generation
ILSpy is the second decompiler in this list. Like the previous one mentioned (Ildasm.exe), it is a free and open source decompiler and assembly browser, a part is based on Avalonia (AvaloniaSpy).
This disassembler also brings many curious features and that is why it is on this list:
- Decompilation of applications developed in C#.
- It allows the decompilation of
BAML
files toXAML
files. - Easy to search for methods, properties or types
- ReadyToRun (RTR) support for .NET Core applications.
It is also strongly supported thanks to its compatibilities with different IDE and operating system versions:
- Visual Studio 2017/2019/2022 compatibility.
- Visual Studio Code support
- Windows/Mac/Linux compatibility
ILSpy can be installed with the extension for Visual Studio extension or via a NuGet package for your own projects. It also has a special module to run the C# disassembler from a PowerShell.
If you wish, you can consult the ILSpy repository on GitHub.
DnSpy .NET debugger and assembly editor
DnSpy, the most popular free and open source .NET decompiler? This decompiler is characterized by its large number of options and tools and above all by its UI design. Using DnSpy (for most .NET developers) is easier and more intuitive than the decompilers mentioned above.
DnSpy is a very versatile disassembler, supporting C#, VB, F# code and more. It also has a debug mode for Unity game assemblies and clearly, .NET Core and .NET Framework. It has a dark theme (apart from the light one, obviously) which is really appreciated, especially for us developers, who could be considered nocturnal creatures ;).
Another feature of this free and open source decompiler is that it is extensible, that is, you can create your own extensions on top of dnSpy.
As a last curious feature, it supports High DPI monitors (maybe someone wants to decompile in 4K 60Hz, who knows).
Thanks to its breakpoints, you can debug by just pressing F9
and F5
. Its PBD generation is fast and implicit.
As a curious fact, this decompiler is known to be used by hackers and security and reverse engineering experts.
You can download it form GitHub
9Rays Spices.Net Decompiler
Spices.NET is another well-known decompiler for C# applications developed by 9Rays Software Company. It features are source code recovery to avoid crashes and convert IL assemblies and executables into readable code.
9Rays categorizes Spices.NET as a flexible and efficient decompiler. Another thing that stands out is that it supports several programming languages: C#, VB.NET (Visual Basic), MSIL (Microsoft Intermediate Language), Delphi.NET and J# among others.
This decompiler is paid but includes a trial.
Its main features are:
- Visual decompiler
- Active hints
- IDE’s integration (Visual Studio)
- Complex Nested statement
It also has the ability to recognize and detect insecure or vulnerable code with pointers in a simple way. You can also extract information from different types of attributes (also supports custom attributes).
Redgate .NET Reflector Decompiler
This next .NET application decompiler is on this list because it has been well known and historically used by many developers and companies working with .NET. Is commercial decompiler and like the previous one (Spices.Net), is paid and has a trial.
This disassembler belongs to the company RedGate, a software company that offers different tools and solutions to improve productivity when developing.
With .NET Reflector you can easily find and fix bugs in the code even without having access to the original source code. You can also analyze APIs and different third-party platforms.
In addition, .NET Reflector features Visual Studio shorcuts, dynamic decompilation, browse assemblies and easy-to-use search filtering. Another of its advantages is that it has several add-ins, which allow you to add more functionality to the decompiler and get the most out of it.
Too good, isn’t it? Well, the big disadvantage is that it is not supported anymore. Its only support is limited to its forums and documentation.
Telerik JustDecompile .NET Assembly Decompiler & Browser
The .NET decompiler JustDecompile was published by Telerik. Telerik is a company that offers different UI products and solutions for developers for testing, reporting and debugging among others. JustDecompile is another free .NET disassembler and as stated on Telerik’s own website, it is “10 times faster than competitors”.
In terms of features it does not fall short at all:
- It is extensible just like Ildasm.exe (it allows you to create your own extensions on the decompiler thanks to its public API and open to everyone).
- Fast and easy navigation thanks to its different views in tabs in just one instance.
- Supports actions via Command prompt.
- Extract and save resources with Windows Explorer.
This open source decompilation engine is also characterized by the support because Telerik has a very active community of developers and also has a good documentation and support resources.
JetBrains dotPeek Free .NET Decompiler & Assembly Browser
dotPeek is another standalone decompiler that also integrates with Visual Studio. This Assembly browser belongs to the JetBrains company that offers tools for developers and development teams.
It is a free and quite complete .NET decompiler and supports different formats:
- executables (
.exe
files) - libraries (
.dll
files) - Windows metadata files (
.winmd
files)
One of the main features is that it allows to export and save the decompiled C# code to a new Visual Studio project (.csproj
). It also allows you to index all assemblies in a list of your own in order to keep them organized and make navigation easier.
You can search and highlight any symbol, method, local variable or property. You can also see the IL code separated from the C# code in a different view. It also has a dark blue theme (although it can also be synchronized with the Visual Studio color scheme in the settings).
Finally, this free .NET decompiler has bookmarks: you can bookmark important parts of the code and come back to them later (like web browser bookmarks), herarchical class navigation and inheritance chains exploration.
Posted on July 5, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
September 9, 2024