Advanced Deserialization Attacks
Decompiling .NET Applications
Introduction
As input for this penetration test, we have been provided with the deployment files of the web application, which were written using C#/.NET (see the file attached to the question at the bottom of this page). This is fine for us, since .NET applications are compiled into intermediate code, known as Common Intermediate Language (also referred to as Microsoft intermediate language (MSIL) or Intermediate Language (IL)), which, unless obfuscated, typically decompiles very nicely, resulting in code very similar to the original.
There is a large selection of tools that can be used to decompile .NET applications; popular ones include:
- Jet Brains dotPeek (Free, Windows-only)
- ILSpy (Open-source, Cross-platform)
Note: This and the upcoming two sections provide a pre-customized Windows VM with all the required tools and customizations; utilize it to your advantage throughout the module. However, it is also recommended that you know how to set up these required tools yourself.
dotPeek
Installing dotPeek
Let's install dotPeek so that we can decompile the target application. We can download the installer for free from Jet Brain's Website and start the installation process. During installation, we can skip all products except for dotPeek.

Alternatively, we can simply select the portable version from the same download page to skip any installation process.
Decompiling with dotPeek
Once we have dotPeek open, we can select File > Open and then select bin\TeeTrove.dll in the file explorer. At this point, dotPeek will add the assembly and class list to the Assembly Explorer on the left side of the window.

From this pane, we can expand namespaces and double-click on classes to view the decompiled source code in the main window pane. Since decompilation is not a perfect process, there will be some code snippets that will look strange, like the line highlighted with the red rectangle in the image below.

By right-clicking on the TeeTrove assembly in the Assembly Explorer window, we can select Export to Project to save the decompiled source files to disk (as a Visual Studio solution in this case). This can be useful later, in case you want to use another tool to analyze/search through the source code.

ILSpy
Installing ILSpy
We can download the latest ILSpy release by heading to the project's GitHub repository's release page. If you would prefer a portable version, select the selfcontained ZIP file. If you would prefer to install ILSpy, then select the first -x64.msi file. Your browser may issue a warning about downloading a MSI file, but this can be ignored. Once downloaded, we can click through the installation process, keeping all default values.
Decompilng with ILSpy
Once installed, the decompilation process with ILSpy is very similar to dotPeek; hit File > Open and then select the DLL file bin\TeeTrove.dll in the file explorer window. The .NET assembly will be added to the Assemblies window on the left-hand side of the screen, and some assembly information will be displayed in the main window.

Using the Assemblies window, similar to dotPeek, we can navigate the namespaces and classes, and we can select individual ones to view the decompiled source code in the main window. You may notice that the output varies from dotPeek in certain places, for example, the Index function below compared to the Index function according to dotPeek above. In this case, ILSpy gave us output that is closer to the original code.

By right-clicking on the TeeTrove assembly in the Assemblies window, we can select Save Code to save the decompiled source files so that they can be opened with other tools.

Note: Opting for TCP instead of UDP for the VPN connection to the Windows VM enhances connectivity and prevents (potential) network issues.
VPN Servers
Warning: Each time you "Switch", your connection keys are regenerated and you must re-download your VPN connection file.
All VM instances associated with the old VPN Server will be terminated when switching to
a new VPN server.
Existing PwnBox instances will automatically switch to the new VPN server.
PROTOCOL
/ 1 spawns left
Questions
Answer the question(s) below to complete this Section and earn cubes!
Click here to spawn the target system!
Target:
Click here to spawn the target system!
Table of Contents
Introduction
IntroductionIdentifying Deserialization Vulnerabilities
Decompiling .NET Applications Identifying Vulnerable Functions Debugging .NET ApplicationsExploiting Deserialization Vulnerabilities
The ObjectDataProvider Gadget Example 1: JSON Example 2: XML The TypeConfuseDelegate Gadget Example 3: Binary Automating Exploitation with YSoSerial.NETDefending against Deserialization Vulnerabilities
Preventing Deserialization Vulnerabilities Patching Deserialization VulnerabilitiesSkills Assessment
Skills AssessmentMy Workstation
OFFLINE
/ 1 spawns left