Connecting Tech Pros Worldwide Forums | Help | Site Map

Please help me to make source code from exe

Michael Dekson
Guest
 
Posts: n/a
#1: Jul 22 '05
Hello,
Can I exe file made in Microsoft Visual C++ decompile into source code.
If it is possibly please tell me how.
Thanks



lilburne
Guest
 
Posts: n/a
#2: Jul 22 '05

re: Please help me to make source code from exe




Michael Dekson wrote:
[color=blue]
> Hello,
> Can I exe file made in Microsoft Visual C++ decompile into source code.
> If it is possibly please tell me how.[/color]

What did MS technical support say?


Nils Petter Vaskinn
Guest
 
Posts: n/a
#3: Jul 22 '05

re: Please help me to make source code from exe


On Wed, 11 Feb 2004 13:13:19 +0100, Michael Dekson wrote:
[color=blue]
> Can I exe file made in Microsoft Visual C++ decompile into source code.
> If it is possibly please tell me how.[/color]

Offtopic here but:

For almost any compiler the answer is no. There could theoretically be a
compiler out there that leaves enough unnessesary data in the executable
to be able to reconstruct the source, but I don't know of any.

What you probably could get out is the assembly. And then maybe that could
be converted to C code that does the same job as the original code, but
I've seen such assembly -> C and it's not pretty, and it doesn't resemble
the original code much.

If it had been possible don't you think a google search would have given
you a ton of utilities to do it. If it had been possible do you think
anyone would even have bothered with copy protection?

--
NPV

"the large print giveth, and the small print taketh away"
Tom Waits - Step right up

Thomas Matthews
Guest
 
Posts: n/a
#4: Jul 22 '05

re: Please help me to make source code from exe


Michael Dekson wrote:
[color=blue]
> Hello,
> Can I exe file made in Microsoft Visual C++ decompile into source code.
> If it is possibly please tell me how.
> Thanks
>
>[/color]

Here is how to do it:
1. Find the format of the executable file.
Try http://www.wotsit.org
2. Parse the header section of the executable file. Extract
and retain important information.
3. Point to the first instruction data.
4. Read in the instruction data and convert into an assembly
language statement. Display all numeric quantities in hex.
Also, keep track of the addresses. You will need this
information for creating labels for all the loops, function
calls.
5. Output the instruction into a text file.
6. Repeat steps 4 & 5 for all executable bytes in the file.
7. Once the assembly language file is created, parse it looking
for patterns, such as for-loops, while and do-while loops.
Also scan for function prologue (i.e. parameter passing,
local variable allocation) and function epilog.
Once a pattern is found, output it to another text file,
which will be your C source file.

Some notes:
1. Devise some scheme for nameing variables and functions.
2. Recognize the difference between char, int, float and
double representations in memory.
3. Research the operating system. Create a table of
operating system call sequences and their function
names. This will come in handy as you improve your
program to list operating system calls.
4. Along the same lines, research the call sequences for
the C and C++ library routines. You'll need this to
translate the calls to offsets into more readable
function names.
5. The resultant code has a high probability of looking
nothing like your original source code; or an readable
source code.
6. Always test your utility by running your assembly language
output through an assembler and compiling your source
program.
7. Some operating systems have dynamic libraries. Learn how
to recognize the activation of dynamic library functions.
8. Let nobody fool you about turning hamburger back into a
cow. That analogy doesn't apply; as one _can_ convert an
executable into a source file.

This is an excellent project. I personally have other projects
to work on, which is why I'm not doing this.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Howard
Guest
 
Posts: n/a
#5: Jul 22 '05

re: Please help me to make source code from exe



"Thomas Matthews" <Thomas_MatthewsSpitsOnSpamBots@sbcglobal.net> wrote in
message > 8. Let nobody fool you about turning hamburger back into a[color=blue]
> cow. That analogy doesn't apply; as one _can_ convert an
> executable into a source file.
>
> This is an excellent project. I personally have other projects
> to work on, which is why I'm not doing this.
>[/color]

Excellent project? It's a fool's project!

The "source code" you produce will in no way resemble the original source
code. You have no way to know how the original objects were distributed
amonst the various compilation units, what any of the objects were named,
what namespaces were defined, what was statically linked against, etc. Any
number of variations of code might produce a given snippet of assembler.
Especially after optimizations have taken place!

It would probably be easier and quicker to write your own program that
imitated the actions and appearance of the one you're trying to hack. Just
look at all the work involved in what you've described.

What possible use would it be to do all that? To get around
copy-protection? Good luck...some of what you'll try to disassemble will be
encoded and you won't even notice it until you analyze every last bit of the
"source" you've supposedly generated, only to realize that, once run, some
of that source itself would have been decoded into something entirely
different!

Do you want to change the behavior of some program to fit your desires?
Write your own program to do what you want. If you're capable of all the
analysis and work needed to make the "source code" as described in this
post, you're quite capable of writing the whole app yourself.

But of course, it's your time. Try doing what was described on a simple
"Hello world" console app. Or better yet, go a step beyond that and try the
same thing on a "Hello world" Windows app using VC++ and MFC objects and a
dialog resource. Then come back and let us know what your re-created source
looks like. See you in six months...

-Howard





Thomas Matthews
Guest
 
Posts: n/a
#6: Jul 22 '05

re: Please help me to make source code from exe


Howard wrote:
[color=blue]
> "Thomas Matthews" <Thomas_MatthewsSpitsOnSpamBots@sbcglobal.net> wrote in
> message > 8. Let nobody fool you about turning hamburger back into a
>[color=green]
>> cow. That analogy doesn't apply; as one _can_ convert an
>> executable into a source file.
>>
>>This is an excellent project. I personally have other projects
>>to work on, which is why I'm not doing this.
>>[/color]
>
>
> Excellent project? It's a fool's project!
>
> The "source code" you produce will in no way resemble the original source
> code. You have no way to know how the original objects were distributed
> amonst the various compilation units, what any of the objects were named,
> what namespaces were defined, what was statically linked against, etc. Any
> number of variations of code might produce a given snippet of assembler.
> Especially after optimizations have taken place!
>
> It would probably be easier and quicker to write your own program that
> imitated the actions and appearance of the one you're trying to hack. Just
> look at all the work involved in what you've described.
>
> What possible use would it be to do all that? To get around
> copy-protection? Good luck...some of what you'll try to disassemble will be
> encoded and you won't even notice it until you analyze every last bit of the
> "source" you've supposedly generated, only to realize that, once run, some
> of that source itself would have been decoded into something entirely
> different!
>
> Do you want to change the behavior of some program to fit your desires?
> Write your own program to do what you want. If you're capable of all the
> analysis and work needed to make the "source code" as described in this
> post, you're quite capable of writing the whole app yourself.
>
> But of course, it's your time. Try doing what was described on a simple
> "Hello world" console app. Or better yet, go a step beyond that and try the
> same thing on a "Hello world" Windows app using VC++ and MFC objects and a
> dialog resource. Then come back and let us know what your re-created source
> looks like. See you in six months...
>
> -Howard[/color]

I agree that this is a huge task, far beyond what the
OP has imagined. I was just answering his/her question.
Perhaps the OP will consider other alternatives, rather
than keep posting the same question.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

rossum
Guest
 
Posts: n/a
#7: Jul 22 '05

re: Please help me to make source code from exe


On Wed, 11 Feb 2004 13:13:19 +0100, "Michael Dekson"
<nospam@nospam.com> wrote:
[color=blue]
>Hello,
>Can I exe file made in Microsoft Visual C++ decompile into source code.
>If it is possibly please tell me how.
>Thanks
>[/color]
See the FAQ:
http://www.fmi.uni-konstanz.de/~kueh....html#faq-37.4

(Look out for line-wrap.)

rossum

--

The Ultimate Truth is that there is no Ultimate Truth
Mike Wahler
Guest
 
Posts: n/a
#8: Jul 22 '05

re: Please help me to make source code from exe


"Howard" <alicebt@hotmail.com> wrote in message
news:c0dnv6$q3e@dispatch.concentric.net...[color=blue]
>
> "Thomas Matthews" <Thomas_MatthewsSpitsOnSpamBots@sbcglobal.net> wrote in
> message > 8. Let nobody fool you about turning hamburger back into a[color=green]
> > cow. That analogy doesn't apply; as one _can_ convert an
> > executable into a source file.
> >
> > This is an excellent project. I personally have other projects
> > to work on, which is why I'm not doing this.
> >[/color]
>
> Excellent project? It's a fool's project![/color]

If attempted by a novice with the objective of reverse engineering,
I agree. But I think it *is* a good intellectual exercise.

-Mike


jeffc
Guest
 
Posts: n/a
#9: Jul 22 '05

re: Please help me to make source code from exe



"Howard" <alicebt@hotmail.com> wrote in message
news:c0dnv6$q3e@dispatch.concentric.net...[color=blue]
>
> "Thomas Matthews" <Thomas_MatthewsSpitsOnSpamBots@sbcglobal.net> wrote in
> message > 8. Let nobody fool you about turning hamburger back into a[color=green]
> > cow. That analogy doesn't apply; as one _can_ convert an
> > executable into a source file.
> >
> > This is an excellent project. I personally have other projects
> > to work on, which is why I'm not doing this.
> >[/color]
>
> Excellent project? It's a fool's project!
>
> The "source code" you produce will in no way resemble the original source
> code.[/color]

Dude, relax. He said the same thing himself. Nonetheless, he's obviously
put a lot of thought into it and it sounds like a very interesting project
to me to.
[color=blue]
>What possible use would it be to do all that? To get around
>copy-protection?[/color]

Who said it has anything to do with getting around copy protection? Some
people just have more active minds than others.


Albert van der Horst
Guest
 
Posts: n/a
#10: Jul 22 '05

re: Please help me to make source code from exe


In article <c0d639$u90$1@ariane.blic.net>,
Michael Dekson <nospam@nospam.com> wrote:[color=blue]
>Hello,
>Can I exe file made in Microsoft Visual C++ decompile into source code.[/color]

It is easy to see that you never can have the original source back.
The most important parts, the comment and the informative names
the programmer gave to local variables, are lost. With inlining,
also the division of the work over modules is lost.

If all you want to do is get rid of the wormholes in Internet Explorer:
1. disassemble to machine code
2. fix wormholes
3. reassemble

The 80i86 assembler is much easier to understand than any extremely
contorted C++ code that results from going one step further.

Aka IE, it is much easier to install an alternative program
without the wormholes.
[color=blue]
>If it is possibly please tell me how.[/color]

It would help if you tell us your perspective on this.
Is it one of climbing the Mount Everest, having a good time,
doing home work or ripping off software vendors?
[color=blue]
>Thanks[/color]

Groetjes Albert
--
Albert van der Horst,Oranjestr 8,3511 RA UTRECHT,THE NETHERLANDS
One man-hour to invent,
One man-week to implement,
One lawyer-year to patent.
Closed Thread