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 IT Industry, Reverse Engineering is quite common word now-a-days. Let’s take a leap into what is 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’snot 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.
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 which I want to take look. Specially, for .NET application there are many reflectors available in market. .net reflector by Red Gat and DotPeek by Jetbrains are two very famous decompiles currently available and in market and used widely.
Here we will be using dotpeek as it’sfree software.
- Download dotpeek from http://www.jetbrains.com/decompiler/
- Install dotpeek. It is very simple and straight forward exercise.
- Now, Open dotpeek. You can see a screen like this.
4. 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 decompiler is displaying two methods main which is a starting point. Let’s look into that. On Double click of method; you can see 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 complete architecture of the system for reverse engineer it. Some time by reverse engineering you can inject new code in 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 till now you are thinking about your software safety. How you can save your products to become victim of any other software engineer’s reverse engineering.
The answer is you can’t. Seriously you can’t!
There is pretty good discussion about this on stackoverflow. Of course there are multiple solutions which can make reverse engineering more difficult for beginner. You can’t fully secure any application. If systems like the PlayStationand 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 engineer.
Below are some options which make your application more secure. It’s about finding every hole and plug 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.