Questions tagged [decompiling]

Decompilers analyze binary code outputting source code in a higher level language such as C. The output is generally not any easier to analyze than the original assembler due to loss of information during compilation.

The concept of a decompiler seems simple to most people. A compiled binary was created from source code, so the operation seems like it should be reversible. However, there are some challenges that a decompiler faces:

  • Decomposing assembler to a basic block.
  • Lose of information during compilation.

Decomposing Basic blocks

Hand crafted assembler may confound analysis into a basic block, which will prohibit the creation of a control flow graph. For example, hand crafted assembler is not bound to follow a function prologue and epilogue. Assembler may make use of instructions that do not map to a higher level language. It may use self-modifying code and multiple entry points (even mid-instruction) for legitimate purposes or to foil reverse engineering. Aggressive compiler optimization may produce the same effects under some cases.

Loss of information

Comment and variable names are obviously lost information in the decompilation process. As well, compilers aggressively optimize code; a key part being to keep high level variable in registers. Because of this, a register maybe re-used for many different high level variable. This may result in the decompiled code have a different amount of variables and control structure from the original code. Also, different compilers (or even different optimization levels) generate different code for the same source code. Ie, the source to machine mapping is compiler dependent. Without hints to the decompiler, it cannot generically re-generate the same source. Often the decompiled code will resemble obfuscated code.

Cristina Cifuentes's research paper from Queensland University of Technology give more technical details of a decompiler. The Boomerang project is an example of an Open Source decompiler.

Some general uses of a decompiler:

  • Retargetting code to a different instruction set.
  • Analyzing a binary for security issue.
  • Patching code for an operating system update.

Due to the loss of information, decompiled code may not assist in understanding assembler code. It certainly can not produce the original source code. Examining decompiled code can give an appreciation of good variable naming.

See also:

1005 questions
1350
votes
28 answers

Is there a way to get the source code from an APK file?

The hard drive on my laptop just crashed and I lost all the source code for an app that I have been working on for the past two months. All I have is the APK file that is stored in my email from when I sent it to a friend. Is there any way to…
Frank Bozzo
  • 13,873
  • 6
  • 22
  • 29
272
votes
16 answers

Is it possible to "decompile" a Windows .exe? Or at least view the Assembly?

A friend of mine downloaded some malware from Facebook, and I'm curious to see what it does without infecting myself. I know that you can't really decompile an .exe, but can I at least view it in Assembly or attach a debugger? Edit to say it is not…
swilliams
  • 44,959
  • 24
  • 94
  • 129
267
votes
8 answers

How do I decompile a .NET EXE into readable C# source code?

I wrote a C# application for a client a couple of years ago, but I no longer have the source code. All I have is the EXE that I deployed on the client's PC. Is there a way I can generate C# source code from the EXE?
MusiGenesis
  • 71,592
  • 38
  • 183
  • 324
267
votes
13 answers

Reverse engineering from an APK file to a project

I accidently erased my project from Eclipse, and all I have left is the APK file which I transferred to my phone. Is there a way to reverse the process of exporting an application to the .apk file, so I can get my project back?
Marko Cakic
  • 6,076
  • 9
  • 25
  • 32
196
votes
7 answers

Is it possible to decompile a compiled .pyc file into a .py file?

Is it possible to get some information out of the .pyc file that is generated from a .py file?
Howard
  • 1,961
  • 2
  • 12
  • 3
177
votes
11 answers

Extract source code from .jar file

Is there a way to extract the source code from an executable .jar file (Java ME)?
hiba
  • 1,819
  • 2
  • 12
  • 5
150
votes
8 answers

How to decompile an APK or DEX file on Android platform?

Is it possible to decompile an APK package or DEX file on Android platform? Are there any tools that can decompile an APK file?
user3151261
  • 1,747
  • 2
  • 11
  • 12
124
votes
5 answers

Is there a C++ decompiler?

I have a program in which I've lost the C++ source code. Are there any good C++ decompilers out there? I've already ran across Boomerang.
Bryan Denny
  • 26,451
  • 32
  • 103
  • 124
104
votes
3 answers

The quest for the Excel custom function tooltip

This question has been asked before, but each time the accepted answer is simply a resignation to provide function descriptions using Application.MacroOptions (VBA6) (VBA7), but this information does not actually appear as a tooltip, so it does not…
Alain
  • 24,704
  • 19
  • 103
  • 170
102
votes
9 answers

How to lock compiled Java classes to prevent decompilation?

How do I lock compiled Java classes to prevent decompilation? I know this must be very well discussed topic on the Internet, but I could not come to any conclusion after referring them. Many people do suggest obfuscator, but they just do renaming of…
jatanp
  • 3,736
  • 4
  • 35
  • 42
94
votes
6 answers

How do you decompile a swf file

I am the maintainer of a site that has allegedly 'lost' the source code to a flash swf file. How do I decompile this source? Are there any programs online or offline that I could use?
Nathan Feger
  • 17,890
  • 10
  • 56
  • 69
89
votes
7 answers

Is it possible to decompile an Android .apk file?

Are the users able to convert the apk file of my application back to the actual code? If they do - is there any way to prevent this?
aryaxt
  • 69,636
  • 87
  • 281
  • 421
87
votes
6 answers

How can I protect MySQL username and password from decompiling?

Java .class files can be decompiled fairly easily. How can I protect my database if I have to use the login data in the code?
Jakob Cosoroaba
  • 1,638
  • 3
  • 23
  • 32
79
votes
13 answers

How can I protect my .NET assemblies from decompilation?

One if the first things I learned when I started with C# was the most important one. You can decompile any .NET assembly with Reflector or other tools. Many developers are not aware of this fact and most of them are shocked when I show them their…
TalkingCode
  • 12,759
  • 27
  • 96
  • 141
79
votes
8 answers

Decompile an APK, modify it and then recompile it

I need to modify an existing APK, modify the sources and then recompile it. I can decompile it using dex2jar or apktool, it's working great From the jar file I can obtain the java sources (using jd-gui) Then I can modify the java files But now I…
darkheir
  • 8,317
  • 6
  • 43
  • 64
1
2 3
66 67