Decompilers that converts a program back to it's original source?

In summary, decompilers are hard to come by and usually don't work well. They can help in certain cases but are not perfect.
  • #1
henry2221
20
0
Earlier this week I had a talk with someone who told me that they've seen a decompiler which is able to convert a program back to it's original source in a language such as C++. From my knowledge I believe this is impossible, but I was wondering if anyone else knows anything about this?
 
Technology news on Phys.org
  • #2
You can't generally convert back to the 'original' source. You can decompile back to source code but it isn't necessarily the same source that you wrote.
Since the compiler (especially a modern optomising compiler for C++) can produce the same output for the different input there isn't a one-one mapping between what you wrote and what the compiler generates.

For languages that compile to a runtime environment like C# and Java it is possible to decompile them back to the original code (or very close to) - there are products called obsfurcators which will rewrite the soruce code to make it confusing but still do the same thing. This helps make it more difficult to decompile.
 
Last edited:
  • #4
Like mgb_phys mentioned, VB6, Java and C# programs are easily decompiled. For C# there's Spices.Net, and Salamander even has a web-based decompiler, they're both pretty good, but for example they don't handle switch statements very well - they tend to generate a mix of goto and if/else which is less readable. From the point of view of the decompiler there's some ambiguity as to what the original source of the code was, which varies from languages that run on a VM, or are interpreted to languages that compile to machine code.

Decompiling a C/C++ program is much harder. In Java you can interpret the Virtual Machine byte code, and in C# or any .NET language you can interpret the IL (intermediate language) that the compiler generates. For example, you can use ildasm.exe (which comes with visual studio) to browse any .NET assembly and actually look at the IL - you can see in ildasm just how much data a decompiler has available (the IL is not very far away from the original source). In C/C++ the compiled code has much less information regarding the original source, so it's much more ambiguous. You're able to get the Assembly level code using programs like ADA or OLLY, but to get any further than that you'll need to be a pro, or have some knowledge of the original code.

For VB6 I've use VB Decompiler with good results.
 
  • #5
Uhh, if that was the case, it would be a dream for the open source world.
 
  • #6
I have tried a few decompilers but haven't been successful with any of them... Few of them never work at all (eg:- boomerang never worked for me till date), few that work for a few attempts and stop (REC Studio)... However, you will not be able to get the exact (or even similar) decompiled code as the original source because we use high level languages.
However there are decent disassemblers available that convert the object code into assembly code (Olly debugger is a very good one). However, analyzing large programs is really difficult in assembly code because there are too many things to be considered at a time...
This has been written with regard to C...
 
Last edited:
  • #7
"IDA Pro" is worth a try...u can search for IDA Pro script to "translate" assembly code to native C code...
 
  • #8
-Job- said:
Like mgb_phys mentioned, VB6, Java and C# programs are easily decompiled. For C# there's Spices.Net, and Salamander even has a web-based decompiler, they're both pretty good, but for example they don't handle switch statements very well - they tend to generate a mix of goto and if/else which is less readable. From the point of view of the decompiler there's some ambiguity as to what the original source of the code was, which varies from languages that run on a VM, or are interpreted to languages that compile to machine code.

Decompiling a C/C++ program is much harder. In Java you can interpret the Virtual Machine byte code, and in C# or any .NET language you can interpret the IL (intermediate language) that the compiler generates. For example, you can use ildasm.exe (which comes with visual studio) to browse any .NET assembly and actually look at the IL - you can see in ildasm just how much data a decompiler has available (the IL is not very far away from the original source). In C/C++ the compiled code has much less information regarding the original source, so it's much more ambiguous. You're able to get the Assembly level code using programs like ADA or OLLY, but to get any further than that you'll need to be a pro, or have some knowledge of the original code.

For VB6 I've use VB Decompiler with good results.

I'm quite agree with you. Throuth I do some coding on ASM, It still difficult to read my disasmbled code in OLLYDBG, sometimes I't hard to read the source code if you don't understand the true workflow and the logic.
 
  • #9
VB6 decompilation raises a point. MS changed the generation of dynamic libraries from VB5 to VB6 so that when developers supplied .vbx or .dll or other libraries to users, the users could not decompile the code into readable VB code and steal intellectual property. This is still true in .NET, I believe.

So, this means that only executable image files can be decompiled with any real success in Windows.
 
  • #10
henry2221 said:
Earlier this week I had a talk with someone who told me that they've seen a decompiler which is able to convert a program back to it's original source in a language such as C++. From my knowledge I believe this is impossible, but I was wondering if anyone else knows anything about this?

I don't know of anything like that. However, for windows I use PE Exp from http://www.heaventools.com/

On linux just disassemble.

This won't get you to C++ but it will give you code.
 
  • #11
I use PE Explorer as well, i recommend it.
 
  • #12
Yes, I second PE Explorer. The best thing about PE Explorer is that it is really easy to use compared with other disassemblers.
 

FAQ: Decompilers that converts a program back to it's original source?

How does a decompiler work?

A decompiler works by analyzing the compiled code of a program and attempting to reverse engineer it back to the original source code. It uses various techniques and algorithms to decipher the machine code and translate it into a high-level programming language that humans can understand.

What types of programs can be decompiled?

Decompilers can be used on a wide range of programs, including executable files, libraries, and even firmware. However, the success of decompiling depends on factors such as the complexity of the program, the compiler used, and the level of optimization applied to the code.

Are decompilers legal?

The legality of decompilers varies depending on the country and jurisdiction. In some cases, decompiling may be considered a violation of copyright or intellectual property laws. However, in other cases, decompiling may be allowed for certain purposes such as interoperability or debugging. It is important to consult with legal experts before using a decompiler.

Can a decompiler retrieve all the original source code?

No, a decompiler may not be able to retrieve the entire original source code. Some information, such as variable names and comments, may be lost during the compilation process. Additionally, if the code has been heavily optimized, the decompiler may not be able to accurately reconstruct the original code.

How can decompilers be used in software development?

Decompilers can be a useful tool for software developers in understanding and debugging compiled code. They can also be used for reverse engineering to gain insights into how a program works or to identify potential vulnerabilities. However, it is important to use decompilers ethically and within the bounds of the law.

Back
Top