Thread: Reverse Engineering

  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    46

    Reverse Engineering

    Hey, I'm looking into my old codes and I have what I remember to be my best programming project I coded in C for my C programming class last semester. The fact of the matter is that I seem to have found that my source code is partially there!! I had used CodeBlocks to porgram it and something terrible happened when I opened it, I guess..

    anywho, I did compile it and have the .exe file saved in that same folder... I really want to take a look at my code so I thought maybe I could reverse engineer that executable file?
    How can I do that? Is there tools for that? I know it might be considered illegal to do this? I'm not sure, I just want my source code back!!

    Help?

    TIA

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    I do not know if those license terms against reverse engineering are actually enforceable in practice, but if it is your own program, there should not be a legal problem.

    That said, you will find it much easier to just rewrite the code. Even if you find a tool that is able to convert the machine code to C, the C code may look nothing like what you wrote, and you might not be able to understand it.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    What exactly are they teaching in school these days that would cause a person to think it might be illegal to reverse engineer something they created themselves?

    Civilization seems to be crumbling
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    I believe laserlight was referring to the reverse engineering of his product of the Code::Blocks, compiler, and the EULA it has.

    There are tools that are used for this, but the final product will not be like your program used to be - from what I've heard it's very difficult to decipher what's what, in the final product.

    Despite what you may read to the contrary, reverse engineering has been generally upheld as a legitmate area of investigation. Check your own laws to be sure, since it does vary.

    I believe this would be no problem, especially since it is your own problem. If you get a sudden insight from something you see regarding Code::Blocks compiler, I'd say mum's the word about that.

  5. #5
    Registered User
    Join Date
    Oct 2009
    Posts
    46
    Thanks guys. And yes, I do know that decompiling my own executables isn't illegal, but if I hadn't written something of the like, I was sure to get someone rant to me about the illegality of reverse engineering stuff that isn't mine and then I would not be a productive thread at all.

    All in all, I did some research, the only decompiler I found turns the executable into assembly, then translates it into some type of C-looking file that is horrible, but at least it shows you the function names, calls, and very ragged code chunks that are very generic looking.

    Thus, as unfortunate as it is to admit it, it is indeed much easier, as LaserLight put it, to just write the code all over.

  6. #6
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Yup. The upside is that it's wonderful practice. I do it sometimes just for fun.

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by Adak
    I believe laserlight was referring to the reverse engineering of his product of the Code::Blocks, compiler, and the EULA it has.
    More like to anti-reverse engineering clauses in EULAs in general since Code::Blocks and its default compiler toolchain are open source and thus do not have such clauses in their licenses.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #8
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    People occasionally turn to here or other forums as a last ditch attempt at getting back their source code. What they fail to realise is that it's as futile as squeezing blood from a stone, and umpteen times as hard as rewriting it again from scratch anyway. A far better option would be try an undelete program.

    There is a bright side though, if you've lost it. Code always comes out better the second time around, and takes half the time.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  9. #9
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    I use IDA-PRO, it produces pretty clean assembly and shows the function names (if they are there). It also helps for post compilation obfuscation.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with my reverse function and its output!
    By Matus in forum C Programming
    Replies: 4
    Last Post: 04-29-2008, 08:33 PM
  2. Reverse Engineering on a Download file
    By c_geek in forum C Programming
    Replies: 1
    Last Post: 03-22-2008, 03:15 PM
  3. gethostbyaddr() reverse lookups failing (???)
    By Uncle Rico in forum C Programming
    Replies: 9
    Last Post: 08-19-2005, 09:22 AM
  4. Reverse Engineering Tools
    By Goldie in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 10-26-2004, 11:36 PM
  5. Reverse Engineering and Disasembling
    By jinx in forum Windows Programming
    Replies: 0
    Last Post: 12-08-2001, 06:16 PM