Jump to content


Photo
- - - - -

Decompiler For C++


This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1 alxhotel

alxhotel
  • Active Members
  • Newbie

  • 6 posts

Posted 20 March 2012 - 02:48 PM

Well, I just started in the world of coding. I started with C++ because lots of you told me that C++ was the mother of al languages. So I start programming simple stuff, and then I ask me: Exist a decompiler to get the source code of a program in .exe ?

I dont know if it's just my imagination but, could exist?

Please Help, (sorry for my english, is terrible)

#2 digip

digip
  • Active Members
  • -we're all just neophytes-

  • PipPipPipPipPipPipPipPipPipPipPipPip
  • 8,167 posts

Posted 20 March 2012 - 08:07 PM

Well, nothing that will show the original source code in plain text, but you could use a debugger to see what it does.
@xxdigipxx http://www.attack-scanner.com/ | I'm the resident dick around here, or so I am told. Don't take it personally, I just give a shit too much sometimes. respect to all, its the Internet, don't take it to heart.
"Staying quiet doesn't mean I have nothing to say, it means I don't think you're ready to hear my thoughts..."

#3 int0x80

int0x80
  • Active Members
  • Hak5 Zombie

  • PipPipPipPipPip
  • 160 posts

Posted 21 March 2012 - 03:29 PM

Check out the Hex-Rays plugin for IDA Pro.
6a 25 58 6a ff 5b 6a 09 59 cd 80

http://dualcoremusic.com

#4 Tox1k

Tox1k
  • Active Members
  • Hak5 Fan

  • PipPip
  • 16 posts

Posted 22 March 2012 - 12:01 AM

There's nothing really that exists that will output in c/c++, the only good way requires two prerequisites: knowing assembly and being able to use ollybdg/some other debugger (but ollydbg shows APIs). Then, use w32dasm to save the file in assembly, and use ollydbg to translate it. It's kinda wierd to explain, but it makes sense when you do it. The few decompilers out there will produce rubbish code, which you will need to know assembly to translate into c++ anyways.

However, since you will probably learn assembly best after you already know a higher level language, you might want to stick to textbooks/open source stuff. There are equivalent programs if you are using linux.

Edited by Tox1k, 22 March 2012 - 12:03 AM.


#5 Infiltrator

Infiltrator
  • Active Members
  • Gray-Hat Specialist

  • PipPipPipPipPipPipPipPipPipPipPipPip
  • 4,392 posts

Posted 25 March 2012 - 05:58 AM

No such thing as Decompiler, I wish that existed, I have lots of C programs that I wish I could decompile them.

You could try reserve engineering it, but it would take some time and lots of efforts.
Regards,
Infiltrator


Posted Image

Currently studying for my CCE.

#6 Sitwon

Sitwon
  • Active Members
  • Hak5 Pirate

  • PipPipPipPipPipPip
  • 470 posts

Posted 26 March 2012 - 11:10 AM

Well, I just started in the world of coding. I started with C++ because lots of you told me that C++ was the mother of al languages. So I start programming simple stuff, and then I ask me: Exist a decompiler to get the source code of a program in .exe ?

I dont know if it's just my imagination but, could exist?

Please Help, (sorry for my english, is terrible)

In general, no. A true decompiler simply can't exist for most high level languages. The process of compiling source code into a native binary is a very lossy conversion. Unless you explicitly tell the compiler to include debugging information in the binary, the compiler will "forget" all your variable names. All the comments will be lost because they are ignored by the compiler. For the purpose of optimization, it will re-arrange the order or pattern of your instructions. Certain control structures are provided as a convenience for the programmer, but don't really exist at the machine level. For example, in the machine code there is no difference between a for-loop and a while-loop, both are just conditional jumps.

Think of it this way, there are a lot of different ways you could describe the quadratic equation in English, but there is one canonical way to write the equation in mathematical notation. Can you look at a mathematical equation and determine the exact words (and the exact order) that another person might use to describe that equation?

Let's use a simple case for demonstration.
The equation: 1 + 1 = 2
Could be translated into any of these English sentences:
1. One plus one equals two.
2. One and one equals two.
3. The addition of one and one results in two.
4. Two is the sum of one and one.
5. When summed together, one and one produce two.

This is why a decompiler can't translate from compiled code back into the high-level language that was used to generate it.

In the case of Java, you can get much better results from a decompiler for a number of reasons.
1. Java bytecode is closer to the Java language than machine language is to C++. (Optimization is done at run-time by the just-in-time compiler.)
2. Java often encodes debugging information such as line numbers and variable names into the class files for use in error messages.
3. Java was designed with disassembly in mind, the official JDK even includes a tool to do it (javap).

This is one reason why Java is frequently used by companies for internal software development or for server-side code, but rarely used for developing products which will be sold to end-users. (Although tools do exist to obfuscate source code and make it harder to reverse. Notch uses such a tool on the Minecraft JARs he distributes.)