[Tutor] help!!!

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Mon Oct 18 05:51:11 CEST 2004



On Fri, 17 Oct 2003, Cody wrote:

> how can i decompile a .exe file.

This is difficult to do in general.


.EXE "executable" files are intended for machines.  .EXE files are
produced by compilers, and these compilers will often strip off
information that a human would need to understand a program.


As a concrete example, we can take a Python function, and ask the system
what the "bytecodes" --- the primitive instructions --- will look like:

###
>>> def square(x):
...     return x * x
...
>>> import dis
>>> dis.dis(square)
  2           0 LOAD_FAST                0 (x)
              3 LOAD_FAST                0 (x)
              6 BINARY_MULTIPLY
              7 RETURN_VALUE
              8 LOAD_CONST               0 (None)
             11 RETURN_VALUE
###

What you are asking is something equivalent to going the other way around:
that is, to take the binary instructions and try to infer the original
source code.


Python doesn't do heavy postprocessing on bytecode, so there are
decompilers for Python bytecode:

    http://www.crazy-compilers.com/decompyle/

But for the general case, given an .EXE, I don't think there's a good way
to get back comprehensible source code.


Hope this helps!



More information about the Tutor mailing list