Jump to content


Photo
- - - - -

Decompiler For C++


  • Please log in to reply
5 replies to this topic

#1 alxhotel

alxhotel

    Newbie

  • Active Members
  • 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

    -we're all just neophytes-

  • Active Members
  • PipPipPipPipPipPipPipPipPipPipPipPip
  • 7,655 posts
  • Gender:Male
  • Location:RnVjayBPZmYh 192.168.100.1

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

    Hak5 Zombie

  • Active Members
  • PipPipPipPipPip
  • 158 posts
  • Gender:Male
  • Interests:Internet

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

    Hak5 Fan

  • Active Members
  • 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

    Gray-Hat Specialist

  • Active Members
  • PipPipPipPipPipPipPipPipPipPipPipPip
  • 4,392 posts
  • Gender:Male
  • Location:Over the Atlantic, at a cruising altitude of 70.000 feet.
  • Interests:Wireless and Network Security
    Server Virtualization
    Computer Network Infrastructure
    Server implementation.
    General Aviation
    RC Airplanes and Helicopters
    Scuba Diving
    Sky Diving
    War driving
    Solar battery Systems.
    Pen-Testing
    Command & Conquer

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

    Hak5 Pirate

  • Active Members
  • PipPipPipPipPipPip
  • 393 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.)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users