Skip to content

Quick Start Guide to .NET Reverse Engineering

Featured Image

Disclaimer: A reverse-engineering 3rd party product is illegal, subject to their licensing. To learn how to protect your own software, it is advised that you write your own source code, compile it and then try to break it, so that you know how to make your own code stronger.

Reverse Engineering is an art, at least that’s what they say. In the IT Industry, Reverse Engineering is quite a common word nowadays. Let’s take a leap into the real meaning of reverse engineering.

According to Wikipedia,

Reverse engineering is the process of discovering the technological principles of a device, object, or system through analysis of its structure, function, and operation.

For scope of this article, we will only focus on reverse engineering of software, hardware or device is altogether with different practice. If you are software engineer and you found any very good software which is extremely good, you want to implement the same kind of functionality or you need inspiration (I won’t say copy!) then how you can access source code of that software? Of course unless it’s open source, it’s not possible to ask author or company who built the software for permission to look into the source code.

There are several benefits of Reverse engineering. You can solve any bug of software, you can improve its functionality, and you can see how program operates. At the same time, there are some complications of reverse engineering. There can be legal complication if software is proprietor of any company, or if you reverse engineer any application to solve some bugs or improve its functionality without understanding the complete flow of application, then you can introduce new bugs which will be very hard to track.

Why Reverse Engineering?

Today’s technology is tomorrow’s legacy system. In the phase of the Y2K problem, where software industry is having vast shortages of programmers who are capable of dealing with legacy code, only through reverse engineering automated processes can presents itself as one viable tool that could help to get necessary work done. If software is not properly documented then there is no way how to make compatible legacy system into new technologies. Before doing reverse engineering, it is always recommended to obtain written permission from the copyright holder to reverse engineer the software.

At first glance, reverse engineering looks pretty straight forward problem which can be solved by proper documentation but obviously it’s not always the case. In reality, you have to deal with problems such as you have bought software from a company but company vendor is no longer in business. The vendor of company stops their supportor even designers and programmers of software left the company.

–> Check our software product development services

How to Reverse Engineer?

For the scope of this article, we will look into reverse engineering into .NET application.

We made very simple application who takes two integer values as inputs and do some complex calculation in program and return some values.

In this console application, there is some complex calculation that I want to take a look. Specially, for .NET application, there are many reflectors available in the market. .net reflector by Red Gat and DotPeek by Jetbrains are two very famous decompiles currently available and in the market and used widely.

Here we will be using dotpeek as it is free software.

  • Download dot-peek from http://www.jetbrains.com/decompiler/
  • Install dotpeek. It is a very simple and straightforward exercise.
  • Now, Open dotpeek. You can see a screen like this.
  • Go into File -> Open and Locate EXE or DLL you want to decompile.

 

Here, we have located our reverse engineering example, into dotpeekdecompiler. Here you see that the decompiler is displaying two methods which is a starting point. Let’s look into that. On Double click of method; you can see the complete code of complex calculation.

Above is a very simple example of Reverse Engineering, Reverse Engineering is not about seeing code always, you need to understand the complete architecture of the system to reverse engineer it. Sometimes by reverse engineering you can inject new code in the same example as well. That will be real reverse engineering.

How can I Protect My Application?

If you have gone through the complete article then now you are thinking about your software safety. How you can save your products to become a victim of any other software engineer’s reverse engineering.

The answer is you can’t. Seriously you can’t!

There is a pretty good discussion about this on Stackoverflow. Of course, there are multiple solutions that can make reverse engineering more difficult for beginners. You can’t fully secure any application. If systems like the PlayStation and iPad can get cracked – where the vendor even controls the hardware – what hope does your app have? But don’t worry; it’s not as easy as you are thinking about reverse engineering.

Below are some options which make your application more secure. It’s about finding every hole and plugging into it.

  • First and simplest one is obfuscating your code. You can obfuscate your code which will convert your code into machine readable not only human readable. Dotfuscator has a free edition and comes with Visual Studio.
  • To make sure that only you can generate license codes, use public/private key or asymmetric encryption to generate your product licenses. Because it is impossible to reverse the key generating algorithm.
  • Do some over engineering in your code with the help of this article.

As in white collar series, they quote “Perfect Security is myth. A good thief can circumvent any security system the building in place (in this case in software we have) so never outlook for potential entrance or exit.”

Share your views about .NET reverse engineering.

Related Insights