6 ms·
The cynical part of me wants to respond with one word: badly! But I've spent enough time hand-reversing code to know that that doesn't do justice to the work d
by demallien 15y ago
The cynical part of me wants to respond with one word: badly!
But I've spent enough time hand-reversing code to know that that doesn't do justice to the work done by decompiler writers, it's just that it's a problem that requires strong AI to do it properly.
- ma2rten 15y agowhy do you think that ? I actually would think that just statistics would also work.
- demallien 15y agoBecause for two years it was my job to make sure that decompilers didn't work on code generated by my company... It's so easy to throw automatic analysis tools of the track. It's easy to throw humans, and we're way better at this game than automated tools, at least for the time being. To give you an idea of how easy it is, if you want the decompiler to drop the ball on a for-loop, all you need to do is something simple like increment by two and then decrement by one at the start of the loop body... The tool might be looking for the use of an INC instruction, but because you increment by two, the compiler generates an ADD... and now your tool doesn't know how to recognise the loop.
- verroq 15y agoI don't think anyone uses decompilers to analyse machine code.
- demallien 15y agoErr, what do you think decompilers are for then?
- verroq 15y agoWell in reversing applications, most people use disassemblers and debuggers to step/trace/analyse the machine code. Just because they exist doesn't mean what they provide is of any practical value, as you said it yourself they decompile badly.
- swolchok 15y agoThe Hex-Rays decompiler is very good, and I've used it for reversing several times. In particular, it was extremely useful for our analysis of the Green Dam censorware system (http://www.cse.umich.edu/~jhalderm/pub/gd/ http://www.cse.umich.edu/~jhalderm/pub/gd/).
- Luyt 15y agoThanks for exposing that shipwreck of government-mandated Horrorware. From the Wikipedia article: "As of 30 June 2009, the mandatory pre-installation of the Green Dam software on new computers has been delayed to an undetermined date." Source: http://en.wikipedia.org/wiki/Green_Dam http://en.wikipedia.org/wiki/Green_Dam
- DCoder 15y agoThe decompilation quality really depends on how obfuscated the original code was, and how much time you care to invest. For example, I'm using Hex-Rays to decompile Command & Conquer: Red Alert 2 and extend it, and now its output looks like [1] , which is a lot better than raw assembly menemonics. Though I've been digging into this game since late 2008, which is a long time. [1] http://img824.imageshack.us/img824/1188/hexrayscpp.png http://img824.imageshack.us/img824/1188/hexrayscpp.png
- zeugma 15y agoWhat was the reason to do that ? Apart from rendering your own code completely unreadable ?
- ma2rten 15y agoThat is exactly what I though. I don't know enough about decompilation to argue with OP, but it is my impression that people are too focused on making something that is always guaranteed to work. If you would use some kind of statistical machine learning instead and learn from data (like machine translation for human languages), I would think that you can come a long way, or am I mistaken?
- mjb 15y agoI don't thing strong AI would solve the problem, because one crucial piece of data is lost when the code is compiled: the intention of the programmer. Good code clearly indicates its intended function through structure, most of which does not translate into assembly. When decompiled, this structure needs to be inferred from the assembly, which contains an incomplete view of the required information. This missing information includes, but is not limited to, the extra information that the programmer put in deliberately: class names, variable names, comments, etc. They also encoded a large number of assumptions about typical program inputs, the execution environment, expected and unexpected branches, chunks of logic (classes, functions, etc) into the code. With all this lost, even a strong AI would not be able to piece together the original program. Instead, I think, the best that could be hoped for is a sort of uncanny-valley zombie of the original code. Certainly better than nothing, but totally not a replacement for your dead wife.
- demallien 15y agoNo, strong AI will solve the problem - just ask geohots... The system that is uncrackable has not yet been invented, the best we've been able to do is to make the process slower.
- mjb 15y agoI think it comes down to which problem you are trying to solve: 1) Recover enough to understand the program and make small changes (this is the cracking case). 2) Recover the original code of the program or something close to it, that can be 'stolen' and maintained without much more overhead than if you had the original code. (1) is not easy, but is becoming easier. (2) is still a long way off, and isn't solvable without a good understanding of the domain the original code was written for.
- spc476 15y agoThere are legitimate cases for (2). I've worked in companies that have lost the source code to programs developed. If you're wondering how source code can be lost---think of no revision control, a poor backup policy, and a program that goes a long time between modifications.
- drx 15y ago> The cynical part of me wants to respond with one word: badly! You are right. Decompiling seems hopeless when you look at the problem. Which is one of the reasons why I wrote my decompiler -- to see what can be done. That also depends on what problem you think decompilers are to solve. Decompilers are somewhat good at telling you additional information about the original structure of the program. They suck at recovering the original source code (which, with enough optimization and mangling, is impossible).
- JoeAltmaier 15y agoDecompiled code can end up looking like high-level assembly code. Like a programmer just learning a new language, using all the habits of their old one. You have to call decompiling a success if the result executes the same algorithm. Much more than that is very hard. I wrote a similar conversion tool - PL/M to C - years ago. It did quite a good job, because it had semantic clues (not to mention the original variable names). And even that can be done badly - the 1st pass result folks called "CL/M" because it was obviously not written by a C programmer.
- leon_ 15y agoAfter playing around with the Hexrays C decompiler we got I decided to stay with analyzing disassemblies.
- grav1tas 15y agoApplying AI to a decompilation problem is just like applying AI to a compilation problem. You're taking a potentially nondeterministic approach to a problem that should be formalized and deterministic. I think AI applied to compilers is something to avoid, in general.
- hackinthebochs 15y ago>Applying AI to a decompilation problem is just like applying AI to a compilation problem I think they're very different. Compilation strips semantic information from code. Decompilation attempts to recover semantic information from program structure and, in the AI case, domain knowledge. They are fundamentally different processes.
- grav1tas 15y agoThat's fine that they're different. My point is that they're both formal processes. Adding AI to the mix will not help you arrive at formal conclusions. The conclusions will be probabilistic, instead. If an AI could use formal routines to show you formal conclusions, then you wouldn't need an AI, you'd just need your routines.
- jerf 15y agoAnd those formal processes will tell you, in the most formal of manners, that when information is actually removed from a system that by definition of information you are incapable of formally reconstructing it. If you can reconstruct it, by definition it was not removed in the first place. Intent is gone from compiled code. You can not formally reconstruct it. All you could formally get are reasonable guesses, and actually that's what the decompiler is giving you; it is not hard to interpret its output as very precisely vague on exactly the points it does not know about.